diff --git a/sdk/security/azure-mgmt-security/_meta.json b/sdk/security/azure-mgmt-security/_meta.json index 4fcd76c66d92..a7ec27ff76c2 100644 --- a/sdk/security/azure-mgmt-security/_meta.json +++ b/sdk/security/azure-mgmt-security/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.8.4", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@6.1.5", + "@autorest/modelerfour@4.23.5" ], - "commit": "a8719243647b7c6d06ed287483d788808de7ecab", + "commit": "3bffe148db995d5af5bbb150a9716d4dff360342", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/security/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/security/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.1.5 --use=@autorest/modelerfour@4.23.5 --version=3.8.4 --version-tolerant=False", "readme": "specification/security/resource-manager/readme.md" } \ 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 48195ae40f80..aaec1eb751b8 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/__init__.py @@ -7,9 +7,6 @@ # -------------------------------------------------------------------------- from ._security_center import SecurityCenter -from ._version import VERSION - -__version__ = VERSION __all__ = ['SecurityCenter'] try: @@ -17,3 +14,7 @@ patch_sdk() except ImportError: pass + +from ._version import VERSION + +__version__ = VERSION 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 9e9ac18611d0..065a74405620 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/_configuration.py @@ -1,45 +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. +# Licensed under the MIT License. See License.txt in the project root for +# 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 TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential - class SecurityCenterConfiguration(Configuration): """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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. + :param subscription_id: Azure subscription ID. Required. :type subscription_id: str - :param asc_location: The location where ASC stores the data of the subscription. can be retrieved from Get locations. - :type asc_location: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - asc_location, # type: str + credential: "TokenCredential", + subscription_id: str, **kwargs # type: Any ): # type: (...) -> None @@ -47,15 +43,12 @@ def __init__( raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - if asc_location is None: - raise ValueError("Parameter 'asc_location' must not be None.") super(SecurityCenterConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.asc_location = asc_location self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-security/{}'.format(VERSION)) + kwargs.setdefault('sdk_moniker', 'azure-mgmt-security/{}'.format(VERSION)) self._configure(**kwargs) def _configure( @@ -73,4 +66,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(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/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/_metadata.json deleted file mode 100644 index 57c07b73f3a8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/_metadata.json +++ /dev/null @@ -1,159 +0,0 @@ -{ - "chosen_version": "", - "total_api_version_list": ["2015-06-01-preview", "2017-08-01", "2017-08-01-preview", "2018-06-01", "2019-01-01", "2019-01-01-preview", "2019-08-01", "2020-01-01", "2020-01-01-preview", "2020-07-01-preview", "2021-01-01", "2021-01-15-preview", "2021-05-01-preview", "2021-07-01"], - "client": { - "name": "SecurityCenter", - "filename": "_security_center", - "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Azure subscription ID.", - "docstring_type": "str", - "required": true - }, - "asc_location": { - "signature": "asc_location, # type: str", - "description": "The location where ASC stores the data of the subscription. can be retrieved from Get locations.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Azure subscription ID.", - "docstring_type": "str", - "required": true - }, - "asc_location": { - "signature": "asc_location: str,", - "description": "The location where ASC stores the data of the subscription. can be retrieved from Get locations.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id, asc_location", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=None, # type: Optional[str]", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "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 - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "compliance_results": "ComplianceResultsOperations", - "pricings": "PricingsOperations", - "advanced_threat_protection": "AdvancedThreatProtectionOperations", - "device_security_groups": "DeviceSecurityGroupsOperations", - "iot_security_solution": "IotSecuritySolutionOperations", - "iot_security_solution_analytics": "IotSecuritySolutionAnalyticsOperations", - "iot_security_solutions_analytics_aggregated_alert": "IotSecuritySolutionsAnalyticsAggregatedAlertOperations", - "iot_security_solutions_analytics_recommendation": "IotSecuritySolutionsAnalyticsRecommendationOperations", - "locations": "LocationsOperations", - "operations": "Operations", - "tasks": "TasksOperations", - "auto_provisioning_settings": "AutoProvisioningSettingsOperations", - "compliances": "CompliancesOperations", - "information_protection_policies": "InformationProtectionPoliciesOperations", - "security_contacts": "SecurityContactsOperations", - "workspace_settings": "WorkspaceSettingsOperations", - "regulatory_compliance_standards": "RegulatoryComplianceStandardsOperations", - "regulatory_compliance_controls": "RegulatoryComplianceControlsOperations", - "regulatory_compliance_assessments": "RegulatoryComplianceAssessmentsOperations", - "sub_assessments": "SubAssessmentsOperations", - "automations": "AutomationsOperations", - "alerts_suppression_rules": "AlertsSuppressionRulesOperations", - "server_vulnerability_assessment": "ServerVulnerabilityAssessmentOperations", - "assessments_metadata": "AssessmentsMetadataOperations", - "assessments": "AssessmentsOperations", - "adaptive_application_controls": "AdaptiveApplicationControlsOperations", - "adaptive_network_hardenings": "AdaptiveNetworkHardeningsOperations", - "allowed_connections": "AllowedConnectionsOperations", - "topology": "TopologyOperations", - "jit_network_access_policies": "JitNetworkAccessPoliciesOperations", - "discovered_security_solutions": "DiscoveredSecuritySolutionsOperations", - "security_solutions_reference_data": "SecuritySolutionsReferenceDataOperations", - "external_security_solutions": "ExternalSecuritySolutionsOperations", - "secure_scores": "SecureScoresOperations", - "secure_score_controls": "SecureScoreControlsOperations", - "secure_score_control_definitions": "SecureScoreControlDefinitionsOperations", - "security_solutions": "SecuritySolutionsOperations", - "connectors": "ConnectorsOperations", - "sql_vulnerability_assessment_scans": "SqlVulnerabilityAssessmentScansOperations", - "sql_vulnerability_assessment_scan_results": "SqlVulnerabilityAssessmentScanResultsOperations", - "sql_vulnerability_assessment_baseline_rules": "SqlVulnerabilityAssessmentBaselineRulesOperations", - "alerts": "AlertsOperations", - "settings": "SettingsOperations", - "ingestion_settings": "IngestionSettingsOperations", - "software_inventories": "SoftwareInventoriesOperations" - } -} \ No newline at end of file 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 0c411e391bbb..d26cd035425a 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,313 +1,796 @@ # coding=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 TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer +from azure.profiles import KnownProfiles, ProfileDefinition +from azure.profiles.multiapiclient import MultiApiClientMixin + +from ._configuration import SecurityCenterConfiguration +from ._serialization import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse -from ._configuration import SecurityCenterConfiguration -from .operations import ComplianceResultsOperations -from .operations import PricingsOperations -from .operations import AdvancedThreatProtectionOperations -from .operations import DeviceSecurityGroupsOperations -from .operations import IotSecuritySolutionOperations -from .operations import IotSecuritySolutionAnalyticsOperations -from .operations import IotSecuritySolutionsAnalyticsAggregatedAlertOperations -from .operations import IotSecuritySolutionsAnalyticsRecommendationOperations -from .operations import LocationsOperations -from .operations import Operations -from .operations import TasksOperations -from .operations import AutoProvisioningSettingsOperations -from .operations import CompliancesOperations -from .operations import InformationProtectionPoliciesOperations -from .operations import SecurityContactsOperations -from .operations import WorkspaceSettingsOperations -from .operations import RegulatoryComplianceStandardsOperations -from .operations import RegulatoryComplianceControlsOperations -from .operations import RegulatoryComplianceAssessmentsOperations -from .operations import SubAssessmentsOperations -from .operations import AutomationsOperations -from .operations import AlertsSuppressionRulesOperations -from .operations import ServerVulnerabilityAssessmentOperations -from .operations import AssessmentsMetadataOperations -from .operations import AssessmentsOperations -from .operations import AdaptiveApplicationControlsOperations -from .operations import AdaptiveNetworkHardeningsOperations -from .operations import AllowedConnectionsOperations -from .operations import TopologyOperations -from .operations import JitNetworkAccessPoliciesOperations -from .operations import DiscoveredSecuritySolutionsOperations -from .operations import SecuritySolutionsReferenceDataOperations -from .operations import ExternalSecuritySolutionsOperations -from .operations import SecureScoresOperations -from .operations import SecureScoreControlsOperations -from .operations import SecureScoreControlDefinitionsOperations -from .operations import SecuritySolutionsOperations -from .operations import ConnectorsOperations -from .operations import SqlVulnerabilityAssessmentScansOperations -from .operations import SqlVulnerabilityAssessmentScanResultsOperations -from .operations import SqlVulnerabilityAssessmentBaselineRulesOperations -from .operations import AlertsOperations -from .operations import SettingsOperations -from .operations import IngestionSettingsOperations -from .operations import SoftwareInventoriesOperations -from . import models - - -class SecurityCenter(object): +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): """API spec for Microsoft.Security (Azure Security Center) resource provider. - :ivar compliance_results: ComplianceResultsOperations operations - :vartype compliance_results: azure.mgmt.security.operations.ComplianceResultsOperations - :ivar pricings: PricingsOperations operations - :vartype pricings: azure.mgmt.security.operations.PricingsOperations - :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: IotSecuritySolutionOperations operations - :vartype iot_security_solution: azure.mgmt.security.operations.IotSecuritySolutionOperations - :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 locations: LocationsOperations operations - :vartype locations: azure.mgmt.security.operations.LocationsOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.security.operations.Operations - :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 security_contacts: SecurityContactsOperations operations - :vartype security_contacts: azure.mgmt.security.operations.SecurityContactsOperations - :ivar workspace_settings: WorkspaceSettingsOperations operations - :vartype workspace_settings: azure.mgmt.security.operations.WorkspaceSettingsOperations - :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 automations: AutomationsOperations operations - :vartype automations: azure.mgmt.security.operations.AutomationsOperations - :ivar alerts_suppression_rules: AlertsSuppressionRulesOperations operations - :vartype alerts_suppression_rules: azure.mgmt.security.operations.AlertsSuppressionRulesOperations - :ivar server_vulnerability_assessment: ServerVulnerabilityAssessmentOperations operations - :vartype server_vulnerability_assessment: azure.mgmt.security.operations.ServerVulnerabilityAssessmentOperations - :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 adaptive_application_controls: AdaptiveApplicationControlsOperations operations - :vartype adaptive_application_controls: azure.mgmt.security.operations.AdaptiveApplicationControlsOperations - :ivar adaptive_network_hardenings: AdaptiveNetworkHardeningsOperations operations - :vartype adaptive_network_hardenings: azure.mgmt.security.operations.AdaptiveNetworkHardeningsOperations - :ivar allowed_connections: AllowedConnectionsOperations operations - :vartype allowed_connections: azure.mgmt.security.operations.AllowedConnectionsOperations - :ivar topology: TopologyOperations operations - :vartype topology: azure.mgmt.security.operations.TopologyOperations - :ivar jit_network_access_policies: JitNetworkAccessPoliciesOperations operations - :vartype jit_network_access_policies: azure.mgmt.security.operations.JitNetworkAccessPoliciesOperations - :ivar discovered_security_solutions: DiscoveredSecuritySolutionsOperations operations - :vartype discovered_security_solutions: azure.mgmt.security.operations.DiscoveredSecuritySolutionsOperations - :ivar security_solutions_reference_data: SecuritySolutionsReferenceDataOperations operations - :vartype security_solutions_reference_data: azure.mgmt.security.operations.SecuritySolutionsReferenceDataOperations - :ivar external_security_solutions: ExternalSecuritySolutionsOperations operations - :vartype external_security_solutions: azure.mgmt.security.operations.ExternalSecuritySolutionsOperations - :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 connectors: ConnectorsOperations operations - :vartype connectors: azure.mgmt.security.operations.ConnectorsOperations - :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 sql_vulnerability_assessment_baseline_rules: SqlVulnerabilityAssessmentBaselineRulesOperations operations - :vartype sql_vulnerability_assessment_baseline_rules: azure.mgmt.security.operations.SqlVulnerabilityAssessmentBaselineRulesOperations - :ivar alerts: AlertsOperations operations - :vartype alerts: azure.mgmt.security.operations.AlertsOperations - :ivar settings: SettingsOperations operations - :vartype settings: azure.mgmt.security.operations.SettingsOperations - :ivar ingestion_settings: IngestionSettingsOperations operations - :vartype ingestion_settings: azure.mgmt.security.operations.IngestionSettingsOperations - :ivar software_inventories: SoftwareInventoriesOperations operations - :vartype software_inventories: azure.mgmt.security.operations.SoftwareInventoriesOperations - :param credential: Credential needed for the client to connect to Azure. + 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. + + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Azure subscription ID. + :param subscription_id: Azure subscription ID. Required. :type subscription_id: str - :param asc_location: The location where ASC stores the data of the subscription. can be retrieved from Get locations. - :type asc_location: str - :param str base_url: Service URL + :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 + :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. """ + DEFAULT_API_VERSION = '2021-07-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': '2021-01-01', + 'alerts_suppression_rules': '2019-01-01-preview', + 'allowed_connections': '2020-01-01', + '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', + 'device_security_groups': '2019-08-01', + 'discovered_security_solutions': '2020-01-01', + 'external_security_solutions': '2020-01-01', + 'information_protection_policies': '2017-08-01-preview', + 'ingestion_settings': '2021-01-15-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', + 'operations': '2015-06-01-preview', + 'pricings': '2018-06-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_contacts': '2017-08-01-preview', + 'security_solutions': '2020-01-01', + 'security_solutions_reference_data': '2020-01-01', + 'server_vulnerability_assessment': '2020-01-01', + 'software_inventories': '2021-05-01-preview', + 'sql_vulnerability_assessment_baseline_rules': '2020-07-01-preview', + 'sql_vulnerability_assessment_scan_results': '2020-07-01-preview', + 'sql_vulnerability_assessment_scans': '2020-07-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, # type: "TokenCredential" - subscription_id, # type: str - asc_location, # type: str - base_url=None, # type: Optional[str] + credential: "TokenCredential", + subscription_id: str, + api_version=None, # type: Optional[str] + base_url: str = "https://management.azure.com", + profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = SecurityCenterConfiguration(credential, subscription_id, asc_location, **kwargs) + self._config = SecurityCenterConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + super(SecurityCenter, self).__init__( + api_version=api_version, + profile=profile + ) + + @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-01-15-preview: :mod:`v2021_01_15_preview.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` + """ + 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-01-15-preview': + from .v2021_01_15_preview 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 + 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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def alerts(self): + """Instance depends on the API version: + + * 2021-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 + else: + raise ValueError("API version {} does not have operation group 'alerts'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def ingestion_settings(self): + """Instance depends on the API version: + + * 2021-01-15-preview: :class:`IngestionSettingsOperations` + """ + api_version = self._get_api_version('ingestion_settings') + if api_version == '2021-01-15-preview': + from .v2021_01_15_preview.operations import IngestionSettingsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'ingestion_settings'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def pricings(self): + """Instance depends on the API version: + + * 2018-06-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 + else: + raise ValueError("API version {} does not have operation group 'pricings'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def security_contacts(self): + """Instance depends on the API version: + + * 2017-08-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 + else: + raise ValueError("API version {} does not have operation group 'security_contacts'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.compliance_results = ComplianceResultsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.pricings = PricingsOperations( - 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 = IotSecuritySolutionOperations( - 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.locations = LocationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - 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.security_contacts = SecurityContactsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.workspace_settings = WorkspaceSettingsOperations( - 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.automations = AutomationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts_suppression_rules = AlertsSuppressionRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_vulnerability_assessment = ServerVulnerabilityAssessmentOperations( - 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.adaptive_application_controls = AdaptiveApplicationControlsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.adaptive_network_hardenings = AdaptiveNetworkHardeningsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.allowed_connections = AllowedConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.topology = TopologyOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jit_network_access_policies = JitNetworkAccessPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.discovered_security_solutions = DiscoveredSecuritySolutionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.security_solutions_reference_data = SecuritySolutionsReferenceDataOperations( - self._client, self._config, self._serialize, self._deserialize) - self.external_security_solutions = ExternalSecuritySolutionsOperations( - 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.connectors = ConnectorsOperations( - 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.sql_vulnerability_assessment_baseline_rules = SqlVulnerabilityAssessmentBaselineRulesOperations( - 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.ingestion_settings = IngestionSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.software_inventories = SoftwareInventoriesOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + @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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def settings(self): + """Instance depends on the API version: + + * 2021-06-01: :class:`SettingsOperations` + * 2021-07-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 + else: + raise ValueError("API version {} does not have operation group 'settings'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def sql_vulnerability_assessment_baseline_rules(self): + """Instance depends on the API version: + + * 2020-07-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 + else: + raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_baseline_rules'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def sql_vulnerability_assessment_scan_results(self): + """Instance depends on the API version: + + * 2020-07-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 + else: + raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_scan_results'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def sql_vulnerability_assessment_scans(self): + """Instance depends on the API version: + + * 2020-07-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 + else: + raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_scans'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def tasks(self): + """Instance depends on the API version: + + * 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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def topology(self): + """Instance depends on the API version: + + * 2020-01-01: :class:`TopologyOperations` + """ + 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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def workspace_settings(self): + """Instance depends on the API version: + + * 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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) def close(self): - # type: () -> None self._client.close() - def __enter__(self): - # type: () -> SecurityCenter self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (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 new file mode 100644 index 000000000000..240df16c57f3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/_serialization.py @@ -0,0 +1,2006 @@ +# -------------------------------------------------------------------------- +# +# 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 + +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 +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding='utf-8') + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + +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, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> 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: + # 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_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes, headers): + # type: (Optional[Union[AnyStr, IO]], 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 + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_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 +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 # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? 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=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(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) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + 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) + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node( + xml_name, + xml_prefix, + xml_ns + ) + local_node.text = unicode_str(new_attr) + serialized.append(local_node) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format( + attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + 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 = data_type.strip('[]{}') + internal_data_type = self.dependencies.get(internal_data_type, 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 = [ + 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_with_traceback( + SerializationError, "Unable to build a model: "+str(err), 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) + 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. + :rtype: str + :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] + data = [ + self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" + for d + in data + ] + if not kwargs.get('skip_quote', False): + data = [ + quote(str(d), safe='') + for d + in data + ] + return str(self.serialize_iter(data, internal_data_type, **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_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_with_traceback( + SerializationError, msg.format(data, data_type), 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): + # 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'. + :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: + serialized.append(None) + + 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: + 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 unicode_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) + return result + except ValueError: + for enum_value in enum_obj: + 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_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, 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: + 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 = 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 + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = '.'.join(dict_keys[1:]) + + return working_data.get(key) + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + 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 + # https://github.com/Azure/msrest-for-python/issues/197 + 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=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(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, basestring): + 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 + 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 + raise_with_traceback(DeserializationError, msg, 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 deseralize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + 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 deseralize. + :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, (basestring, bytes)) or hasattr(raw_data, 'read'): + return RawDeserializer.deserialize_from_text(raw_data, content_type) + 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) + 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_with_traceback(DeserializationError, msg, 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, basestring): + 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, basestring): + 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): + 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. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + 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)) + + @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) + attr = attr + padding + 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(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, 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) + + @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_with_traceback(DeserializationError, msg, 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): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + + @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): + 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) + 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_with_traceback(DeserializationError, msg, 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() + 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_with_traceback(DeserializationError, msg, 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) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj 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 133510e3bace..1e7bb939778c 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,16 +1,18 @@ # coding=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.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -18,41 +20,34 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential - class SecurityCenterConfiguration(Configuration): """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. + :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. + :param subscription_id: Azure subscription ID. Required. :type subscription_id: str - :param asc_location: The location where ASC stores the data of the subscription. can be retrieved from Get locations. - :type asc_location: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - asc_location: str, - **kwargs: Any + **kwargs # type: Any ) -> None: 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.") - if asc_location is None: - raise ValueError("Parameter 'asc_location' must not be None.") super(SecurityCenterConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.asc_location = asc_location self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-security/{}'.format(VERSION)) + kwargs.setdefault('sdk_moniker', 'azure-mgmt-security/{}'.format(VERSION)) self._configure(**kwargs) def _configure( @@ -69,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(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/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/_security_center.py index b238b910a8bb..15c51ae26bf4 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,306 +1,796 @@ # coding=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 azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer +from azure.profiles import KnownProfiles, ProfileDefinition +from azure.profiles.multiapiclient import MultiApiClientMixin + +from .._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import SecurityCenterConfiguration -from .operations import ComplianceResultsOperations -from .operations import PricingsOperations -from .operations import AdvancedThreatProtectionOperations -from .operations import DeviceSecurityGroupsOperations -from .operations import IotSecuritySolutionOperations -from .operations import IotSecuritySolutionAnalyticsOperations -from .operations import IotSecuritySolutionsAnalyticsAggregatedAlertOperations -from .operations import IotSecuritySolutionsAnalyticsRecommendationOperations -from .operations import LocationsOperations -from .operations import Operations -from .operations import TasksOperations -from .operations import AutoProvisioningSettingsOperations -from .operations import CompliancesOperations -from .operations import InformationProtectionPoliciesOperations -from .operations import SecurityContactsOperations -from .operations import WorkspaceSettingsOperations -from .operations import RegulatoryComplianceStandardsOperations -from .operations import RegulatoryComplianceControlsOperations -from .operations import RegulatoryComplianceAssessmentsOperations -from .operations import SubAssessmentsOperations -from .operations import AutomationsOperations -from .operations import AlertsSuppressionRulesOperations -from .operations import ServerVulnerabilityAssessmentOperations -from .operations import AssessmentsMetadataOperations -from .operations import AssessmentsOperations -from .operations import AdaptiveApplicationControlsOperations -from .operations import AdaptiveNetworkHardeningsOperations -from .operations import AllowedConnectionsOperations -from .operations import TopologyOperations -from .operations import JitNetworkAccessPoliciesOperations -from .operations import DiscoveredSecuritySolutionsOperations -from .operations import SecuritySolutionsReferenceDataOperations -from .operations import ExternalSecuritySolutionsOperations -from .operations import SecureScoresOperations -from .operations import SecureScoreControlsOperations -from .operations import SecureScoreControlDefinitionsOperations -from .operations import SecuritySolutionsOperations -from .operations import ConnectorsOperations -from .operations import SqlVulnerabilityAssessmentScansOperations -from .operations import SqlVulnerabilityAssessmentScanResultsOperations -from .operations import SqlVulnerabilityAssessmentBaselineRulesOperations -from .operations import AlertsOperations -from .operations import SettingsOperations -from .operations import IngestionSettingsOperations -from .operations import SoftwareInventoriesOperations -from .. import models - - -class SecurityCenter(object): +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): """API spec for Microsoft.Security (Azure Security Center) resource provider. - :ivar compliance_results: ComplianceResultsOperations operations - :vartype compliance_results: azure.mgmt.security.aio.operations.ComplianceResultsOperations - :ivar pricings: PricingsOperations operations - :vartype pricings: azure.mgmt.security.aio.operations.PricingsOperations - :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: IotSecuritySolutionOperations operations - :vartype iot_security_solution: azure.mgmt.security.aio.operations.IotSecuritySolutionOperations - :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 locations: LocationsOperations operations - :vartype locations: azure.mgmt.security.aio.operations.LocationsOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.security.aio.operations.Operations - :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 security_contacts: SecurityContactsOperations operations - :vartype security_contacts: azure.mgmt.security.aio.operations.SecurityContactsOperations - :ivar workspace_settings: WorkspaceSettingsOperations operations - :vartype workspace_settings: azure.mgmt.security.aio.operations.WorkspaceSettingsOperations - :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 automations: AutomationsOperations operations - :vartype automations: azure.mgmt.security.aio.operations.AutomationsOperations - :ivar alerts_suppression_rules: AlertsSuppressionRulesOperations operations - :vartype alerts_suppression_rules: azure.mgmt.security.aio.operations.AlertsSuppressionRulesOperations - :ivar server_vulnerability_assessment: ServerVulnerabilityAssessmentOperations operations - :vartype server_vulnerability_assessment: azure.mgmt.security.aio.operations.ServerVulnerabilityAssessmentOperations - :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 adaptive_application_controls: AdaptiveApplicationControlsOperations operations - :vartype adaptive_application_controls: azure.mgmt.security.aio.operations.AdaptiveApplicationControlsOperations - :ivar adaptive_network_hardenings: AdaptiveNetworkHardeningsOperations operations - :vartype adaptive_network_hardenings: azure.mgmt.security.aio.operations.AdaptiveNetworkHardeningsOperations - :ivar allowed_connections: AllowedConnectionsOperations operations - :vartype allowed_connections: azure.mgmt.security.aio.operations.AllowedConnectionsOperations - :ivar topology: TopologyOperations operations - :vartype topology: azure.mgmt.security.aio.operations.TopologyOperations - :ivar jit_network_access_policies: JitNetworkAccessPoliciesOperations operations - :vartype jit_network_access_policies: azure.mgmt.security.aio.operations.JitNetworkAccessPoliciesOperations - :ivar discovered_security_solutions: DiscoveredSecuritySolutionsOperations operations - :vartype discovered_security_solutions: azure.mgmt.security.aio.operations.DiscoveredSecuritySolutionsOperations - :ivar security_solutions_reference_data: SecuritySolutionsReferenceDataOperations operations - :vartype security_solutions_reference_data: azure.mgmt.security.aio.operations.SecuritySolutionsReferenceDataOperations - :ivar external_security_solutions: ExternalSecuritySolutionsOperations operations - :vartype external_security_solutions: azure.mgmt.security.aio.operations.ExternalSecuritySolutionsOperations - :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 connectors: ConnectorsOperations operations - :vartype connectors: azure.mgmt.security.aio.operations.ConnectorsOperations - :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 sql_vulnerability_assessment_baseline_rules: SqlVulnerabilityAssessmentBaselineRulesOperations operations - :vartype sql_vulnerability_assessment_baseline_rules: azure.mgmt.security.aio.operations.SqlVulnerabilityAssessmentBaselineRulesOperations - :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 ingestion_settings: IngestionSettingsOperations operations - :vartype ingestion_settings: azure.mgmt.security.aio.operations.IngestionSettingsOperations - :ivar software_inventories: SoftwareInventoriesOperations operations - :vartype software_inventories: azure.mgmt.security.aio.operations.SoftwareInventoriesOperations - :param credential: Credential needed for the client to connect to Azure. + 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. + + :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. + :param subscription_id: Azure subscription ID. Required. :type subscription_id: str - :param asc_location: The location where ASC stores the data of the subscription. can be retrieved from Get locations. - :type asc_location: str - :param str base_url: Service URL + :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 + :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. """ + DEFAULT_API_VERSION = '2021-07-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': '2021-01-01', + 'alerts_suppression_rules': '2019-01-01-preview', + 'allowed_connections': '2020-01-01', + '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', + 'device_security_groups': '2019-08-01', + 'discovered_security_solutions': '2020-01-01', + 'external_security_solutions': '2020-01-01', + 'information_protection_policies': '2017-08-01-preview', + 'ingestion_settings': '2021-01-15-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', + 'operations': '2015-06-01-preview', + 'pricings': '2018-06-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_contacts': '2017-08-01-preview', + 'security_solutions': '2020-01-01', + 'security_solutions_reference_data': '2020-01-01', + 'server_vulnerability_assessment': '2020-01-01', + 'software_inventories': '2021-05-01-preview', + 'sql_vulnerability_assessment_baseline_rules': '2020-07-01-preview', + 'sql_vulnerability_assessment_scan_results': '2020-07-01-preview', + 'sql_vulnerability_assessment_scans': '2020-07-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, - asc_location: str, - base_url: Optional[str] = None, - **kwargs: Any + api_version: Optional[str] = None, + base_url: str = "https://management.azure.com", + profile: KnownProfiles = KnownProfiles.default, + **kwargs # type: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = SecurityCenterConfiguration(credential, subscription_id, asc_location, **kwargs) + self._config = SecurityCenterConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + super(SecurityCenter, self).__init__( + api_version=api_version, + profile=profile + ) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - self.compliance_results = ComplianceResultsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.pricings = PricingsOperations( - 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 = IotSecuritySolutionOperations( - 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.locations = LocationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - 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.security_contacts = SecurityContactsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.workspace_settings = WorkspaceSettingsOperations( - 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.automations = AutomationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts_suppression_rules = AlertsSuppressionRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.server_vulnerability_assessment = ServerVulnerabilityAssessmentOperations( - 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.adaptive_application_controls = AdaptiveApplicationControlsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.adaptive_network_hardenings = AdaptiveNetworkHardeningsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.allowed_connections = AllowedConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.topology = TopologyOperations( - self._client, self._config, self._serialize, self._deserialize) - self.jit_network_access_policies = JitNetworkAccessPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.discovered_security_solutions = DiscoveredSecuritySolutionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.security_solutions_reference_data = SecuritySolutionsReferenceDataOperations( - self._client, self._config, self._serialize, self._deserialize) - self.external_security_solutions = ExternalSecuritySolutionsOperations( - 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.connectors = ConnectorsOperations( - 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.sql_vulnerability_assessment_baseline_rules = SqlVulnerabilityAssessmentBaselineRulesOperations( - 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.ingestion_settings = IngestionSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.software_inventories = SoftwareInventoriesOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() + @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-01-15-preview: :mod:`v2021_01_15_preview.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` + """ + 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-01-15-preview': + from ..v2021_01_15_preview 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 + 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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def alerts(self): + """Instance depends on the API version: + + * 2021-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 + else: + raise ValueError("API version {} does not have operation group 'alerts'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def ingestion_settings(self): + """Instance depends on the API version: + + * 2021-01-15-preview: :class:`IngestionSettingsOperations` + """ + api_version = self._get_api_version('ingestion_settings') + if api_version == '2021-01-15-preview': + from ..v2021_01_15_preview.aio.operations import IngestionSettingsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'ingestion_settings'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) - async def __aenter__(self) -> "SecurityCenter": + @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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def pricings(self): + """Instance depends on the API version: + + * 2018-06-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 + else: + raise ValueError("API version {} does not have operation group 'pricings'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def security_contacts(self): + """Instance depends on the API version: + + * 2017-08-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 + else: + raise ValueError("API version {} does not have operation group 'security_contacts'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def settings(self): + """Instance depends on the API version: + + * 2021-06-01: :class:`SettingsOperations` + * 2021-07-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 + else: + raise ValueError("API version {} does not have operation group 'settings'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def sql_vulnerability_assessment_baseline_rules(self): + """Instance depends on the API version: + + * 2020-07-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 + else: + raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_baseline_rules'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def sql_vulnerability_assessment_scan_results(self): + """Instance depends on the API version: + + * 2020-07-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 + else: + raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_scan_results'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def sql_vulnerability_assessment_scans(self): + """Instance depends on the API version: + + * 2020-07-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 + else: + raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_scans'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def tasks(self): + """Instance depends on the API version: + + * 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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def topology(self): + """Instance depends on the API version: + + * 2020-01-01: :class:`TopologyOperations` + """ + 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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + @property + def workspace_settings(self): + """Instance depends on the API version: + + * 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)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + + async def close(self): + await self._client.close() + async def __aenter__(self): await self._client.__aenter__() return self - - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details): 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 deleted file mode 100644 index 65df4fa5ef35..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/__init__.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 ._compliance_results_operations import ComplianceResultsOperations -from ._pricings_operations import PricingsOperations -from ._advanced_threat_protection_operations import AdvancedThreatProtectionOperations -from ._device_security_groups_operations import DeviceSecurityGroupsOperations -from ._iot_security_solution_operations import IotSecuritySolutionOperations -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 ._locations_operations import LocationsOperations -from ._operations import Operations -from ._tasks_operations import TasksOperations -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 ._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 ._automations_operations import AutomationsOperations -from ._alerts_suppression_rules_operations import AlertsSuppressionRulesOperations -from ._server_vulnerability_assessment_operations import ServerVulnerabilityAssessmentOperations -from ._assessments_metadata_operations import AssessmentsMetadataOperations -from ._assessments_operations import AssessmentsOperations -from ._adaptive_application_controls_operations import AdaptiveApplicationControlsOperations -from ._adaptive_network_hardenings_operations import AdaptiveNetworkHardeningsOperations -from ._allowed_connections_operations import AllowedConnectionsOperations -from ._topology_operations import TopologyOperations -from ._jit_network_access_policies_operations import JitNetworkAccessPoliciesOperations -from ._discovered_security_solutions_operations import DiscoveredSecuritySolutionsOperations -from ._security_solutions_reference_data_operations import SecuritySolutionsReferenceDataOperations -from ._external_security_solutions_operations import ExternalSecuritySolutionsOperations -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 ._connectors_operations import ConnectorsOperations -from ._sql_vulnerability_assessment_scans_operations import SqlVulnerabilityAssessmentScansOperations -from ._sql_vulnerability_assessment_scan_results_operations import SqlVulnerabilityAssessmentScanResultsOperations -from ._sql_vulnerability_assessment_baseline_rules_operations import SqlVulnerabilityAssessmentBaselineRulesOperations -from ._alerts_operations import AlertsOperations -from ._settings_operations import SettingsOperations -from ._ingestion_settings_operations import IngestionSettingsOperations -from ._software_inventories_operations import SoftwareInventoriesOperations - -__all__ = [ - 'ComplianceResultsOperations', - 'PricingsOperations', - 'AdvancedThreatProtectionOperations', - 'DeviceSecurityGroupsOperations', - 'IotSecuritySolutionOperations', - 'IotSecuritySolutionAnalyticsOperations', - 'IotSecuritySolutionsAnalyticsAggregatedAlertOperations', - 'IotSecuritySolutionsAnalyticsRecommendationOperations', - 'LocationsOperations', - 'Operations', - 'TasksOperations', - 'AutoProvisioningSettingsOperations', - 'CompliancesOperations', - 'InformationProtectionPoliciesOperations', - 'SecurityContactsOperations', - 'WorkspaceSettingsOperations', - 'RegulatoryComplianceStandardsOperations', - 'RegulatoryComplianceControlsOperations', - 'RegulatoryComplianceAssessmentsOperations', - 'SubAssessmentsOperations', - 'AutomationsOperations', - 'AlertsSuppressionRulesOperations', - 'ServerVulnerabilityAssessmentOperations', - 'AssessmentsMetadataOperations', - 'AssessmentsOperations', - 'AdaptiveApplicationControlsOperations', - 'AdaptiveNetworkHardeningsOperations', - 'AllowedConnectionsOperations', - 'TopologyOperations', - 'JitNetworkAccessPoliciesOperations', - 'DiscoveredSecuritySolutionsOperations', - 'SecuritySolutionsReferenceDataOperations', - 'ExternalSecuritySolutionsOperations', - 'SecureScoresOperations', - 'SecureScoreControlsOperations', - 'SecureScoreControlDefinitionsOperations', - 'SecuritySolutionsOperations', - 'ConnectorsOperations', - 'SqlVulnerabilityAssessmentScansOperations', - 'SqlVulnerabilityAssessmentScanResultsOperations', - 'SqlVulnerabilityAssessmentBaselineRulesOperations', - 'AlertsOperations', - 'SettingsOperations', - 'IngestionSettingsOperations', - 'SoftwareInventoriesOperations', -] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_adaptive_application_controls_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_adaptive_application_controls_operations.py deleted file mode 100644 index 14db3cdfd414..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_adaptive_application_controls_operations.py +++ /dev/null @@ -1,271 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class AdaptiveApplicationControlsOperations: - """AdaptiveApplicationControlsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - 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. - :type include_path_recommendations: bool - :param summary: Return output in a summarized form. - :type summary: bool - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AdaptiveApplicationControlGroups, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AdaptiveApplicationControlGroups - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AdaptiveApplicationControlGroups"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if include_path_recommendations is not None: - query_parameters['includePathRecommendations'] = self._serialize.query("include_path_recommendations", include_path_recommendations, 'bool') - if summary is not None: - query_parameters['summary'] = self._serialize.query("summary", summary, 'bool') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/applicationWhitelistings'} # type: ignore - - async def get( - self, - group_name: str, - **kwargs: Any - ) -> "_models.AdaptiveApplicationControlGroup": - """Gets an application control VM/server group. - - :param group_name: Name of an application control machine group. - :type group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AdaptiveApplicationControlGroup, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AdaptiveApplicationControlGroup - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AdaptiveApplicationControlGroup"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'groupName': self._serialize.url("group_name", group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}'} # type: ignore - - async def put( - self, - group_name: str, - body: "_models.AdaptiveApplicationControlGroup", - **kwargs: Any - ) -> "_models.AdaptiveApplicationControlGroup": - """Update an application control machine group. - - :param group_name: Name of an application control machine group. - :type group_name: str - :param body: - :type body: ~azure.mgmt.security.models.AdaptiveApplicationControlGroup - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AdaptiveApplicationControlGroup, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AdaptiveApplicationControlGroup - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AdaptiveApplicationControlGroup"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'groupName': self._serialize.url("group_name", group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'AdaptiveApplicationControlGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}'} # type: ignore - - async def delete( - self, - group_name: str, - **kwargs: Any - ) -> None: - """Delete an application control machine group. - - :param group_name: Name of an application control machine group. - :type group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'groupName': self._serialize.url("group_name", group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}'} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_adaptive_network_hardenings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_adaptive_network_hardenings_operations.py deleted file mode 100644 index 3a66706140ae..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_adaptive_network_hardenings_operations.py +++ /dev/null @@ -1,344 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class AdaptiveNetworkHardeningsOperations: - """AdaptiveNetworkHardeningsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_by_extended_resource( - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.AdaptiveNetworkHardeningsList"]: - """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. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. - :type resource_namespace: str - :param resource_type: The type of the resource. - :type resource_type: str - :param resource_name: Name of the resource. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AdaptiveNetworkHardeningsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AdaptiveNetworkHardeningsList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AdaptiveNetworkHardeningsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_extended_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_extended_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings'} # type: ignore - - 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. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. - :type resource_namespace: str - :param resource_type: The type of the resource. - :type resource_type: str - :param resource_name: Name of the resource. - :type resource_name: str - :param adaptive_network_hardening_resource_name: The name of the Adaptive Network Hardening - resource. - :type adaptive_network_hardening_resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AdaptiveNetworkHardening, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AdaptiveNetworkHardening - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AdaptiveNetworkHardening"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'adaptiveNetworkHardeningResourceName': self._serialize.url("adaptive_network_hardening_resource_name", adaptive_network_hardening_resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}'} # type: ignore - - async def _enforce_initial( - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - adaptive_network_hardening_resource_name: str, - body: "_models.AdaptiveNetworkHardeningEnforceRequest", - **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - adaptive_network_hardening_enforce_action = "enforce" - api_version = "2020-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._enforce_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'adaptiveNetworkHardeningResourceName': self._serialize.url("adaptive_network_hardening_resource_name", adaptive_network_hardening_resource_name, 'str'), - 'adaptiveNetworkHardeningEnforceAction': self._serialize.url("adaptive_network_hardening_enforce_action", adaptive_network_hardening_enforce_action, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'AdaptiveNetworkHardeningEnforceRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - _enforce_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}/{adaptiveNetworkHardeningEnforceAction}'} # type: ignore - - 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", - **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. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. - :type resource_namespace: str - :param resource_type: The type of the resource. - :type resource_type: str - :param resource_name: Name of the resource. - :type resource_name: str - :param adaptive_network_hardening_resource_name: The name of the Adaptive Network Hardening - resource. - :type adaptive_network_hardening_resource_name: str - :param body: - :type body: ~azure.mgmt.security.models.AdaptiveNetworkHardeningEnforceRequest - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._enforce_initial( - 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, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - adaptive_network_hardening_enforce_action = "enforce" - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'adaptiveNetworkHardeningResourceName': self._serialize.url("adaptive_network_hardening_resource_name", adaptive_network_hardening_resource_name, 'str'), - 'adaptiveNetworkHardeningEnforceAction': self._serialize.url("adaptive_network_hardening_enforce_action", adaptive_network_hardening_enforce_action, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_enforce.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}/{adaptiveNetworkHardeningEnforceAction}'} # type: ignore 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 deleted file mode 100644 index 9e1c93fc00a1..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_advanced_threat_protection_operations.py +++ /dev/null @@ -1,159 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class AdvancedThreatProtectionOperations: - """AdvancedThreatProtectionOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - 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. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AdvancedThreatProtectionSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AdvancedThreatProtectionSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AdvancedThreatProtectionSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - setting_name = "current" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - 'settingName': self._serialize.url("setting_name", setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/advancedThreatProtectionSettings/{settingName}'} # type: ignore - - async def create( - self, - resource_id: str, - advanced_threat_protection_setting: "_models.AdvancedThreatProtectionSetting", - **kwargs: Any - ) -> "_models.AdvancedThreatProtectionSetting": - """Creates or updates the Advanced Threat Protection settings on a specified resource. - - :param resource_id: The identifier of the resource. - :type resource_id: str - :param advanced_threat_protection_setting: Advanced Threat Protection Settings. - :type advanced_threat_protection_setting: ~azure.mgmt.security.models.AdvancedThreatProtectionSetting - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AdvancedThreatProtectionSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AdvancedThreatProtectionSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AdvancedThreatProtectionSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - setting_name = "current" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - 'settingName': self._serialize.url("setting_name", setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(advanced_threat_protection_setting, 'AdvancedThreatProtectionSetting') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - create.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/advancedThreatProtectionSettings/{settingName}'} # 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 deleted file mode 100644 index 4374722f99e7..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_alerts_operations.py +++ /dev/null @@ -1,870 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class AlertsOperations: - """AlertsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.AlertList"]: - """List all the alerts that are associated with the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/alerts'} # type: ignore - - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.AlertList"]: - """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. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/alerts'} # type: ignore - - def list_subscription_level_by_region( - self, - **kwargs: Any - ) -> AsyncIterable["_models.AlertList"]: - """List all the alerts that are associated with the subscription that are stored in a specific - location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_subscription_level_by_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_subscription_level_by_region.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts'} # type: ignore - - def list_resource_group_level_by_region( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.AlertList"]: - """List all the alerts that are associated with the resource group that are stored in a specific - location. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_resource_group_level_by_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_resource_group_level_by_region.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts'} # type: ignore - - async def get_subscription_level( - self, - alert_name: str, - **kwargs: Any - ) -> "_models.Alert": - """Get an alert that is associated with a subscription. - - :param alert_name: Name of the alert object. - :type alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_subscription_level.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'alertName': self._serialize.url("alert_name", alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}'} # type: ignore - - async def get_resource_group_level( - self, - 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 alert_name: Name of the alert object. - :type alert_name: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_resource_group_level.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'alertName': self._serialize.url("alert_name", alert_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}'} # type: ignore - - async def update_subscription_level_state_to_dismiss( - self, - alert_name: str, - **kwargs: Any - ) -> None: - """Update the alert's state. - - :param alert_name: Name of the alert object. - :type alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.update_subscription_level_state_to_dismiss.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'alertName': self._serialize.url("alert_name", alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - update_subscription_level_state_to_dismiss.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss'} # type: ignore - - async def update_subscription_level_state_to_resolve( - self, - alert_name: str, - **kwargs: Any - ) -> None: - """Update the alert's state. - - :param alert_name: Name of the alert object. - :type alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.update_subscription_level_state_to_resolve.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'alertName': self._serialize.url("alert_name", alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - update_subscription_level_state_to_resolve.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/resolve'} # type: ignore - - async def update_subscription_level_state_to_activate( - self, - alert_name: str, - **kwargs: Any - ) -> None: - """Update the alert's state. - - :param alert_name: Name of the alert object. - :type alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.update_subscription_level_state_to_activate.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'alertName': self._serialize.url("alert_name", alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - update_subscription_level_state_to_activate.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/activate'} # type: ignore - - async def update_resource_group_level_state_to_resolve( - self, - alert_name: str, - resource_group_name: str, - **kwargs: Any - ) -> None: - """Update the alert's state. - - :param alert_name: Name of the alert object. - :type alert_name: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.update_resource_group_level_state_to_resolve.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'alertName': self._serialize.url("alert_name", alert_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - update_resource_group_level_state_to_resolve.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/resolve'} # type: ignore - - async def update_resource_group_level_state_to_dismiss( - self, - alert_name: str, - resource_group_name: str, - **kwargs: Any - ) -> None: - """Update the alert's state. - - :param alert_name: Name of the alert object. - :type alert_name: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.update_resource_group_level_state_to_dismiss.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'alertName': self._serialize.url("alert_name", alert_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - update_resource_group_level_state_to_dismiss.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss'} # type: ignore - - async def update_resource_group_level_state_to_activate( - self, - alert_name: str, - resource_group_name: str, - **kwargs: Any - ) -> None: - """Update the alert's state. - - :param alert_name: Name of the alert object. - :type alert_name: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.update_resource_group_level_state_to_activate.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'alertName': self._serialize.url("alert_name", alert_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - update_resource_group_level_state_to_activate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/activate'} # type: ignore - - async def _simulate_initial( - self, - alert_simulator_request_body: "_models.AlertSimulatorRequestBody", - **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._simulate_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(alert_simulator_request_body, 'AlertSimulatorRequestBody') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - _simulate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/default/simulate'} # type: ignore - - async def begin_simulate( - self, - alert_simulator_request_body: "_models.AlertSimulatorRequestBody", - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Simulate security alerts. - - :param alert_simulator_request_body: Alert Simulator Request Properties. - :type alert_simulator_request_body: ~azure.mgmt.security.models.AlertSimulatorRequestBody - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._simulate_initial( - alert_simulator_request_body=alert_simulator_request_body, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_simulate.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/default/simulate'} # 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 deleted file mode 100644 index 24ad78f67198..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_alerts_suppression_rules_operations.py +++ /dev/null @@ -1,280 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class AlertsSuppressionRulesOperations: - """AlertsSuppressionRulesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - alert_type: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.AlertsSuppressionRulesList"]: - """List of all the dismiss rules for the given subscription. - - :param alert_type: Type of the alert to get rules for. - :type alert_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertsSuppressionRulesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AlertsSuppressionRulesList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertsSuppressionRulesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if alert_type is not None: - query_parameters['AlertType'] = self._serialize.query("alert_type", alert_type, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules'} # type: ignore - - 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. - :type alerts_suppression_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertsSuppressionRule, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AlertsSuppressionRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertsSuppressionRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'alertsSuppressionRuleName': self._serialize.url("alerts_suppression_rule_name", alerts_suppression_rule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}'} # type: ignore - - async def update( - self, - alerts_suppression_rule_name: str, - alerts_suppression_rule: "_models.AlertsSuppressionRule", - **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. - :type alerts_suppression_rule_name: str - :param alerts_suppression_rule: Suppression rule object. - :type alerts_suppression_rule: ~azure.mgmt.security.models.AlertsSuppressionRule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertsSuppressionRule, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AlertsSuppressionRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertsSuppressionRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'alertsSuppressionRuleName': self._serialize.url("alerts_suppression_rule_name", alerts_suppression_rule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(alerts_suppression_rule, 'AlertsSuppressionRule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}'} # type: ignore - - 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. - :type alerts_suppression_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'alertsSuppressionRuleName': self._serialize.url("alerts_suppression_rule_name", alerts_suppression_rule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}'} # 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 deleted file mode 100644 index 86f634a6af27..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_allowed_connections_operations.py +++ /dev/null @@ -1,236 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class AllowedConnectionsOperations: - """AllowedConnectionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.AllowedConnectionsList"]: - """Gets the list of all possible traffic between resources for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AllowedConnectionsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AllowedConnectionsList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AllowedConnectionsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/allowedConnections'} # type: ignore - - def list_by_home_region( - self, - **kwargs: Any - ) -> AsyncIterable["_models.AllowedConnectionsList"]: - """Gets the list of all possible traffic between resources for the subscription and location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AllowedConnectionsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AllowedConnectionsList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AllowedConnectionsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_home_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_home_region.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections'} # type: ignore - - async def get( - self, - resource_group_name: 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. - :type resource_group_name: str - :param connection_type: The type of allowed connections (Internal, External). - :type connection_type: str or ~azure.mgmt.security.models.ConnectionType - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AllowedConnectionsResource, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AllowedConnectionsResource - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AllowedConnectionsResource"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'connectionType': self._serialize.url("connection_type", connection_type, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections/{connectionType}'} # type: ignore 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 deleted file mode 100644 index df9555e68ef3..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_assessments_metadata_operations.py +++ /dev/null @@ -1,391 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class AssessmentsMetadataOperations: - """AssessmentsMetadataOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SecurityAssessmentMetadataList"]: - """Get metadata information on all assessment types. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecurityAssessmentMetadataList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecurityAssessmentMetadataList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityAssessmentMetadataList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/providers/Microsoft.Security/assessmentMetadata'} # type: ignore - - 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. - :type assessment_metadata_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityAssessmentMetadata, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityAssessmentMetadata - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityAssessmentMetadata"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'assessmentMetadataName': self._serialize.url("assessment_metadata_name", assessment_metadata_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}'} # type: ignore - - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SecurityAssessmentMetadataList"]: - """Get metadata information on all assessment types in a specific subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecurityAssessmentMetadataList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecurityAssessmentMetadataList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityAssessmentMetadataList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata'} # type: ignore - - 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. - :type assessment_metadata_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityAssessmentMetadata, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityAssessmentMetadata - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityAssessmentMetadata"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get_in_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'assessmentMetadataName': self._serialize.url("assessment_metadata_name", assessment_metadata_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get_in_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}'} # type: ignore - - async def create_in_subscription( - self, - assessment_metadata_name: str, - assessment_metadata: "_models.SecurityAssessmentMetadata", - **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. - :type assessment_metadata_name: str - :param assessment_metadata: AssessmentMetadata object. - :type assessment_metadata: ~azure.mgmt.security.models.SecurityAssessmentMetadata - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityAssessmentMetadata, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityAssessmentMetadata - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityAssessmentMetadata"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_in_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'assessmentMetadataName': self._serialize.url("assessment_metadata_name", assessment_metadata_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(assessment_metadata, 'SecurityAssessmentMetadata') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - create_in_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}'} # type: ignore - - 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. - :type assessment_metadata_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.delete_in_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'assessmentMetadataName': self._serialize.url("assessment_metadata_name", assessment_metadata_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_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, {}) - - delete_in_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}'} # 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 deleted file mode 100644 index 306648b7d29e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_assessments_operations.py +++ /dev/null @@ -1,300 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class AssessmentsOperations: - """AssessmentsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - scope: str, - **kwargs: Any - ) -> AsyncIterable["_models.SecurityAssessmentList"]: - """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). - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecurityAssessmentList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecurityAssessmentList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityAssessmentList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Security/assessments'} # type: ignore - - 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. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. - :type assessment_name: str - :param expand: OData expand. Optional. - :type expand: str or ~azure.mgmt.security.models.ExpandEnum - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityAssessment, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityAssessment - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityAssessment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - 'assessmentName': self._serialize.url("assessment_name", assessment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}'} # type: ignore - - async def create_or_update( - self, - resource_id: str, - assessment_name: str, - assessment: "_models.SecurityAssessment", - **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. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. - :type assessment_name: str - :param assessment: Calculated assessment on a pre-defined assessment metadata. - :type assessment: ~azure.mgmt.security.models.SecurityAssessment - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityAssessment, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityAssessment - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityAssessment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - 'assessmentName': self._serialize.url("assessment_name", assessment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(assessment, 'SecurityAssessment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - return deserialized - create_or_update.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}'} # type: ignore - - 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. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. - :type assessment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - 'assessmentName': self._serialize.url("assessment_name", assessment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}'} # 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 deleted file mode 100644 index ab252d8978e6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_auto_provisioning_settings_operations.py +++ /dev/null @@ -1,224 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class AutoProvisioningSettingsOperations: - """AutoProvisioningSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.AutoProvisioningSettingList"]: - """Exposes the auto provisioning settings of the subscriptions. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoProvisioningSettingList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AutoProvisioningSettingList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoProvisioningSettingList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings'} # type: ignore - - async def get( - self, - setting_name: str, - **kwargs: Any - ) -> "_models.AutoProvisioningSetting": - """Details of a specific setting. - - :param setting_name: Auto provisioning setting key. - :type setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoProvisioningSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AutoProvisioningSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoProvisioningSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'settingName': self._serialize.url("setting_name", setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings/{settingName}'} # type: ignore - - async def create( - self, - setting_name: str, - setting: "_models.AutoProvisioningSetting", - **kwargs: Any - ) -> "_models.AutoProvisioningSetting": - """Details of a specific setting. - - :param setting_name: Auto provisioning setting key. - :type setting_name: str - :param setting: Auto provisioning setting key. - :type setting: ~azure.mgmt.security.models.AutoProvisioningSetting - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoProvisioningSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AutoProvisioningSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoProvisioningSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'settingName': self._serialize.url("setting_name", setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(setting, 'AutoProvisioningSetting') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings/{settingName}'} # 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 deleted file mode 100644 index b2f197c45478..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_automations_operations.py +++ /dev/null @@ -1,436 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class AutomationsOperations: - """AutomationsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.AutomationList"]: - """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. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutomationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AutomationList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/automations'} # type: ignore - - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.AutomationList"]: - """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. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutomationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AutomationList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations'} # type: ignore - - 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. - :type resource_group_name: str - :param automation_name: The security automation name. - :type automation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Automation, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Automation - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Automation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'automationName': self._serialize.url("automation_name", automation_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}'} # type: ignore - - async def create_or_update( - self, - resource_group_name: str, - automation_name: str, - automation: "_models.Automation", - **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. - :type resource_group_name: str - :param automation_name: The security automation name. - :type automation_name: str - :param automation: The security automation resource. - :type automation: ~azure.mgmt.security.models.Automation - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Automation, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Automation - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Automation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'automationName': self._serialize.url("automation_name", automation_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(automation, 'Automation') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}'} # type: ignore - - 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. - :type resource_group_name: str - :param automation_name: The security automation name. - :type automation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'automationName': self._serialize.url("automation_name", automation_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}'} # type: ignore - - async def validate( - self, - resource_group_name: str, - automation_name: str, - automation: "_models.Automation", - **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. - :type resource_group_name: str - :param automation_name: The security automation name. - :type automation_name: str - :param automation: The security automation resource. - :type automation: ~azure.mgmt.security.models.Automation - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutomationValidationStatus, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AutomationValidationStatus - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationValidationStatus"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'automationName': self._serialize.url("automation_name", automation_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(automation, 'Automation') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}/validate'} # 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 deleted file mode 100644 index 791a6cba3736..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_compliance_results_operations.py +++ /dev/null @@ -1,170 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class ComplianceResultsOperations: - """ComplianceResultsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - scope: str, - **kwargs: Any - ) -> AsyncIterable["_models.ComplianceResultList"]: - """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). - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ComplianceResultList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.ComplianceResultList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComplianceResultList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Security/complianceResults'} # type: ignore - - 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. - :type resource_id: str - :param compliance_result_name: name of the desired assessment compliance result. - :type compliance_result_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ComplianceResult, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ComplianceResult - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComplianceResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - 'complianceResultName': self._serialize.url("compliance_result_name", compliance_result_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/complianceResults/{complianceResultName}'} # 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 deleted file mode 100644 index 6e8444354d24..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_compliances_operations.py +++ /dev/null @@ -1,172 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class CompliancesOperations: - """CompliancesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - scope: str, - **kwargs: Any - ) -> AsyncIterable["_models.ComplianceList"]: - """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). - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ComplianceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.ComplianceList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComplianceList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Security/compliances'} # type: ignore - - 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). - :type scope: str - :param compliance_name: name of the Compliance. - :type compliance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Compliance, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Compliance - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Compliance"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'complianceName': self._serialize.url("compliance_name", compliance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Security/compliances/{complianceName}'} # 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 deleted file mode 100644 index 5df7e742ad66..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_connectors_operations.py +++ /dev/null @@ -1,277 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class ConnectorsOperations: - """ConnectorsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ConnectorSettingList"]: - """Cloud accounts connectors of a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectorSettingList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.ConnectorSettingList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectorSettingList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors'} # type: ignore - - 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. - :type connector_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConnectorSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ConnectorSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectorSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'connectorName': self._serialize.url("connector_name", connector_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}'} # type: ignore - - async def create_or_update( - self, - connector_name: str, - connector_setting: "_models.ConnectorSetting", - **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. - :type connector_name: str - :param connector_setting: Settings for the cloud account connector. - :type connector_setting: ~azure.mgmt.security.models.ConnectorSetting - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConnectorSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ConnectorSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectorSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'connectorName': self._serialize.url("connector_name", connector_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(connector_setting, 'ConnectorSetting') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}'} # type: ignore - - 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. - :type connector_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'connectorName': self._serialize.url("connector_name", connector_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}'} # 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 deleted file mode 100644 index 25828e3acbb7..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_device_security_groups_operations.py +++ /dev/null @@ -1,295 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class DeviceSecurityGroupsOperations: - """DeviceSecurityGroupsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - resource_id: str, - **kwargs: Any - ) -> AsyncIterable["_models.DeviceSecurityGroupList"]: - """Use this method get the list of device security groups for the specified IoT Hub resource. - - :param resource_id: The identifier of the resource. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeviceSecurityGroupList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.DeviceSecurityGroupList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceSecurityGroupList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups'} # type: ignore - - 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. - :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. - :type device_security_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeviceSecurityGroup, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.DeviceSecurityGroup - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceSecurityGroup"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - 'deviceSecurityGroupName': self._serialize.url("device_security_group_name", device_security_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}'} # type: ignore - - async def create_or_update( - self, - resource_id: str, - device_security_group_name: str, - device_security_group: "_models.DeviceSecurityGroup", - **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. - :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. - :type device_security_group_name: str - :param device_security_group: Security group object. - :type device_security_group: ~azure.mgmt.security.models.DeviceSecurityGroup - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeviceSecurityGroup, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.DeviceSecurityGroup - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceSecurityGroup"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - 'deviceSecurityGroupName': self._serialize.url("device_security_group_name", device_security_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(device_security_group, 'DeviceSecurityGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - return deserialized - create_or_update.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}'} # type: ignore - - 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. - :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. - :type device_security_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - 'deviceSecurityGroupName': self._serialize.url("device_security_group_name", device_security_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}'} # 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 deleted file mode 100644 index 7fac89302664..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_discovered_security_solutions_operations.py +++ /dev/null @@ -1,235 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class DiscoveredSecuritySolutionsOperations: - """DiscoveredSecuritySolutionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.DiscoveredSecuritySolutionList"]: - """Gets a list of discovered Security Solutions for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiscoveredSecuritySolutionList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.DiscoveredSecuritySolutionList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiscoveredSecuritySolutionList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/discoveredSecuritySolutions'} # type: ignore - - def list_by_home_region( - self, - **kwargs: Any - ) -> AsyncIterable["_models.DiscoveredSecuritySolutionList"]: - """Gets a list of discovered Security Solutions for the subscription and location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiscoveredSecuritySolutionList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.DiscoveredSecuritySolutionList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiscoveredSecuritySolutionList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_home_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_home_region.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/discoveredSecuritySolutions'} # type: ignore - - async def get( - self, - resource_group_name: 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. - :type resource_group_name: str - :param discovered_security_solution_name: Name of a discovered security solution. - :type discovered_security_solution_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiscoveredSecuritySolution, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.DiscoveredSecuritySolution - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiscoveredSecuritySolution"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'discoveredSecuritySolutionName': self._serialize.url("discovered_security_solution_name", discovered_security_solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/discoveredSecuritySolutions/{discoveredSecuritySolutionName}'} # 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 deleted file mode 100644 index 5734e6ff6fce..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_external_security_solutions_operations.py +++ /dev/null @@ -1,235 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class ExternalSecuritySolutionsOperations: - """ExternalSecuritySolutionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ExternalSecuritySolutionList"]: - """Gets a list of external security solutions for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExternalSecuritySolutionList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.ExternalSecuritySolutionList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExternalSecuritySolutionList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/externalSecuritySolutions'} # type: ignore - - def list_by_home_region( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ExternalSecuritySolutionList"]: - """Gets a list of external Security Solutions for the subscription and location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExternalSecuritySolutionList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.ExternalSecuritySolutionList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExternalSecuritySolutionList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_home_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_home_region.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/ExternalSecuritySolutions'} # type: ignore - - async def get( - self, - resource_group_name: 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. - :type resource_group_name: str - :param external_security_solutions_name: Name of an external security solution. - :type external_security_solutions_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExternalSecuritySolution, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ExternalSecuritySolution - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExternalSecuritySolution"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'externalSecuritySolutionsName': self._serialize.url("external_security_solutions_name", external_security_solutions_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/ExternalSecuritySolutions/{externalSecuritySolutionsName}'} # 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 deleted file mode 100644 index 821084dba221..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_information_protection_policies_operations.py +++ /dev/null @@ -1,243 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class InformationProtectionPoliciesOperations: - """InformationProtectionPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def get( - self, - scope: str, - information_protection_policy_name: Union[str, "_models.Enum15"], - **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). - :type scope: str - :param information_protection_policy_name: Name of the information protection policy. - :type information_protection_policy_name: str or ~azure.mgmt.security.models.Enum15 - :keyword callable cls: A custom type or function that will be passed the direct response - :return: InformationProtectionPolicy, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.InformationProtectionPolicy - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.InformationProtectionPolicy"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'informationProtectionPolicyName': self._serialize.url("information_protection_policy_name", information_protection_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Security/informationProtectionPolicies/{informationProtectionPolicyName}'} # type: ignore - - async def create_or_update( - self, - scope: str, - information_protection_policy_name: Union[str, "_models.Enum15"], - information_protection_policy: "_models.InformationProtectionPolicy", - **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). - :type scope: str - :param information_protection_policy_name: Name of the information protection policy. - :type information_protection_policy_name: str or ~azure.mgmt.security.models.Enum15 - :param information_protection_policy: Information protection policy. - :type information_protection_policy: ~azure.mgmt.security.models.InformationProtectionPolicy - :keyword callable cls: A custom type or function that will be passed the direct response - :return: InformationProtectionPolicy, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.InformationProtectionPolicy - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.InformationProtectionPolicy"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'informationProtectionPolicyName': self._serialize.url("information_protection_policy_name", information_protection_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(information_protection_policy, 'InformationProtectionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - return deserialized - create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Security/informationProtectionPolicies/{informationProtectionPolicyName}'} # type: ignore - - def list( - self, - scope: str, - **kwargs: Any - ) -> AsyncIterable["_models.InformationProtectionPolicyList"]: - """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). - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either InformationProtectionPolicyList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.InformationProtectionPolicyList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.InformationProtectionPolicyList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Security/informationProtectionPolicies'} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_ingestion_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_ingestion_settings_operations.py deleted file mode 100644 index d601b6ff1714..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_ingestion_settings_operations.py +++ /dev/null @@ -1,387 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class IngestionSettingsOperations: - """IngestionSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.IngestionSettingList"]: - """Settings for ingesting security data and logs to correlate with resources associated with the - subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IngestionSettingList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.IngestionSettingList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IngestionSettingList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-15-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('IngestionSettingList', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings'} # type: ignore - - async def get( - self, - ingestion_setting_name: str, - **kwargs: Any - ) -> "_models.IngestionSetting": - """Settings for ingesting security data and logs to correlate with resources associated with the - subscription. - - :param ingestion_setting_name: Name of the ingestion setting. - :type ingestion_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IngestionSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IngestionSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IngestionSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-15-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ingestionSettingName': self._serialize.url("ingestion_setting_name", ingestion_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('IngestionSetting', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}'} # type: ignore - - async def create( - self, - ingestion_setting_name: str, - ingestion_setting: "_models.IngestionSetting", - **kwargs: Any - ) -> "_models.IngestionSetting": - """Create setting for ingesting security data and logs to correlate with resources associated with - the subscription. - - :param ingestion_setting_name: Name of the ingestion setting. - :type ingestion_setting_name: str - :param ingestion_setting: Ingestion setting object. - :type ingestion_setting: ~azure.mgmt.security.models.IngestionSetting - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IngestionSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IngestionSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IngestionSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-15-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ingestionSettingName': self._serialize.url("ingestion_setting_name", ingestion_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(ingestion_setting, 'IngestionSetting') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('IngestionSetting', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}'} # type: ignore - - async def delete( - self, - ingestion_setting_name: str, - **kwargs: Any - ) -> None: - """Deletes the ingestion settings for this subscription. - - :param ingestion_setting_name: Name of the ingestion setting. - :type ingestion_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-15-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ingestionSettingName': self._serialize.url("ingestion_setting_name", ingestion_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}'} # type: ignore - - async def list_tokens( - self, - ingestion_setting_name: str, - **kwargs: Any - ) -> "_models.IngestionSettingToken": - """Returns the token that is used for correlating ingested telemetry with the resources in the - subscription. - - :param ingestion_setting_name: Name of the ingestion setting. - :type ingestion_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IngestionSettingToken, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IngestionSettingToken - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IngestionSettingToken"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-15-preview" - accept = "application/json" - - # Construct URL - url = self.list_tokens.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ingestionSettingName': self._serialize.url("ingestion_setting_name", ingestion_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('IngestionSettingToken', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - list_tokens.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}/listTokens'} # type: ignore - - async def list_connection_strings( - self, - ingestion_setting_name: str, - **kwargs: Any - ) -> "_models.ConnectionStrings": - """Connection strings for ingesting security scan logs and data. - - :param ingestion_setting_name: Name of the ingestion setting. - :type ingestion_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConnectionStrings, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ConnectionStrings - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionStrings"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-15-preview" - accept = "application/json" - - # Construct URL - url = self.list_connection_strings.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ingestionSettingName': self._serialize.url("ingestion_setting_name", ingestion_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('ConnectionStrings', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - list_connection_strings.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}/listConnectionStrings'} # type: ignore 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 deleted file mode 100644 index ec6b2c993fde..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_iot_security_solution_analytics_operations.py +++ /dev/null @@ -1,159 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class IotSecuritySolutionAnalyticsOperations: - """IotSecuritySolutionAnalyticsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - 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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IoTSecuritySolutionAnalyticsModelList, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionAnalyticsModelList - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecuritySolutionAnalyticsModelList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels'} # type: ignore - - 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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IoTSecuritySolutionAnalyticsModel, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionAnalyticsModel - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecuritySolutionAnalyticsModel"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default'} # 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 deleted file mode 100644 index 0caa63196f55..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_iot_security_solution_operations.py +++ /dev/null @@ -1,445 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class IotSecuritySolutionOperations: - """IotSecuritySolutionOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_by_subscription( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.IoTSecuritySolutionsList"]: - """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. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IoTSecuritySolutionsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.IoTSecuritySolutionsList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecuritySolutionsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/iotSecuritySolutions'} # type: ignore - - def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.IoTSecuritySolutionsList"]: - """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. - :type resource_group_name: str - :param filter: Filter the IoT Security solution with OData syntax. Supports filtering by - iotHubs. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IoTSecuritySolutionsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.IoTSecuritySolutionsList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecuritySolutionsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions'} # type: ignore - - 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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IoTSecuritySolutionModel, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecuritySolutionModel"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}'} # type: ignore - - async def create_or_update( - self, - resource_group_name: str, - solution_name: str, - iot_security_solution_data: "_models.IoTSecuritySolutionModel", - **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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :param iot_security_solution_data: The security solution data. - :type iot_security_solution_data: ~azure.mgmt.security.models.IoTSecuritySolutionModel - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IoTSecuritySolutionModel, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecuritySolutionModel"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_security_solution_data, 'IoTSecuritySolutionModel') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}'} # type: ignore - - async def update( - self, - resource_group_name: str, - solution_name: str, - update_iot_security_solution_data: "_models.UpdateIotSecuritySolutionData", - **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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :param update_iot_security_solution_data: The security solution data. - :type update_iot_security_solution_data: ~azure.mgmt.security.models.UpdateIotSecuritySolutionData - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IoTSecuritySolutionModel, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecuritySolutionModel"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_iot_security_solution_data, 'UpdateIotSecuritySolutionData') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}'} # type: ignore - - 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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}'} # 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 deleted file mode 100644 index 80c3c47f7db1..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py +++ /dev/null @@ -1,246 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class IotSecuritySolutionsAnalyticsAggregatedAlertOperations: - """IotSecuritySolutionsAnalyticsAggregatedAlertOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - resource_group_name: str, - solution_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.IoTSecurityAggregatedAlertList"]: - """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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :param top: Number of results to retrieve. - :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IoTSecurityAggregatedAlertList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.IoTSecurityAggregatedAlertList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecurityAggregatedAlertList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts'} # type: ignore - - 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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :param aggregated_alert_name: Identifier of the aggregated alert. - :type aggregated_alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IoTSecurityAggregatedAlert, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IoTSecurityAggregatedAlert - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecurityAggregatedAlert"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - 'aggregatedAlertName': self._serialize.url("aggregated_alert_name", aggregated_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts/{aggregatedAlertName}'} # type: ignore - - 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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :param aggregated_alert_name: Identifier of the aggregated alert. - :type aggregated_alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.dismiss.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - 'aggregatedAlertName': self._serialize.url("aggregated_alert_name", aggregated_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_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, {}) - - dismiss.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts/{aggregatedAlertName}/dismiss'} # 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 deleted file mode 100644 index 771b12ab1ca2..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_iot_security_solutions_analytics_recommendation_operations.py +++ /dev/null @@ -1,187 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class IotSecuritySolutionsAnalyticsRecommendationOperations: - """IotSecuritySolutionsAnalyticsRecommendationOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - 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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :param aggregated_recommendation_name: Name of the recommendation aggregated for this query. - :type aggregated_recommendation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IoTSecurityAggregatedRecommendation, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IoTSecurityAggregatedRecommendation - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecurityAggregatedRecommendation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - 'aggregatedRecommendationName': self._serialize.url("aggregated_recommendation_name", aggregated_recommendation_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedRecommendations/{aggregatedRecommendationName}'} # type: ignore - - def list( - self, - resource_group_name: str, - solution_name: str, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.IoTSecurityAggregatedRecommendationList"]: - """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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :param top: Number of results to retrieve. - :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IoTSecurityAggregatedRecommendationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.IoTSecurityAggregatedRecommendationList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecurityAggregatedRecommendationList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedRecommendations'} # type: ignore 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 deleted file mode 100644 index bda90ec34063..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_jit_network_access_policies_operations.py +++ /dev/null @@ -1,577 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class JitNetworkAccessPoliciesOperations: - """JitNetworkAccessPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.JitNetworkAccessPoliciesList"]: - """Policies for protecting resources using Just-in-Time access control. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JitNetworkAccessPoliciesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.JitNetworkAccessPoliciesList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JitNetworkAccessPoliciesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/jitNetworkAccessPolicies'} # type: ignore - - def list_by_region( - self, - **kwargs: Any - ) -> AsyncIterable["_models.JitNetworkAccessPoliciesList"]: - """Policies for protecting resources using Just-in-Time access control for the subscription, - location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JitNetworkAccessPoliciesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.JitNetworkAccessPoliciesList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JitNetworkAccessPoliciesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_region.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies'} # type: ignore - - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.JitNetworkAccessPoliciesList"]: - """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. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JitNetworkAccessPoliciesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.JitNetworkAccessPoliciesList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JitNetworkAccessPoliciesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/jitNetworkAccessPolicies'} # type: ignore - - def list_by_resource_group_and_region( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.JitNetworkAccessPoliciesList"]: - """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. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JitNetworkAccessPoliciesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.JitNetworkAccessPoliciesList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JitNetworkAccessPoliciesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_resource_group_and_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_resource_group_and_region.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies'} # type: ignore - - async def get( - self, - resource_group_name: 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. - :type resource_group_name: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - :type jit_network_access_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JitNetworkAccessPolicy, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.JitNetworkAccessPolicy - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JitNetworkAccessPolicy"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'jitNetworkAccessPolicyName': self._serialize.url("jit_network_access_policy_name", jit_network_access_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}'} # type: ignore - - async def create_or_update( - self, - resource_group_name: str, - jit_network_access_policy_name: str, - body: "_models.JitNetworkAccessPolicy", - **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. - :type resource_group_name: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - :type jit_network_access_policy_name: str - :param body: - :type body: ~azure.mgmt.security.models.JitNetworkAccessPolicy - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JitNetworkAccessPolicy, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.JitNetworkAccessPolicy - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JitNetworkAccessPolicy"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'jitNetworkAccessPolicyName': self._serialize.url("jit_network_access_policy_name", jit_network_access_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'JitNetworkAccessPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}'} # type: ignore - - async def delete( - self, - resource_group_name: 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. - :type resource_group_name: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - :type jit_network_access_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'jitNetworkAccessPolicyName': self._serialize.url("jit_network_access_policy_name", jit_network_access_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}'} # type: ignore - - async def initiate( - self, - resource_group_name: str, - jit_network_access_policy_name: str, - body: "_models.JitNetworkAccessPolicyInitiateRequest", - **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. - :type resource_group_name: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - :type jit_network_access_policy_name: str - :param body: - :type body: ~azure.mgmt.security.models.JitNetworkAccessPolicyInitiateRequest - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JitNetworkAccessRequest, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.JitNetworkAccessRequest - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JitNetworkAccessRequest"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - jit_network_access_policy_initiate_type = "initiate" - api_version = "2020-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.initiate.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'jitNetworkAccessPolicyName': self._serialize.url("jit_network_access_policy_name", jit_network_access_policy_name, 'str'), - 'jitNetworkAccessPolicyInitiateType': self._serialize.url("jit_network_access_policy_initiate_type", jit_network_access_policy_initiate_type, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'JitNetworkAccessPolicyInitiateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - return deserialized - initiate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}/{jitNetworkAccessPolicyInitiateType}'} # 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 deleted file mode 100644 index 0597ef7bfed6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_locations_operations.py +++ /dev/null @@ -1,161 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class LocationsOperations: - """LocationsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.AscLocationList"]: - """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. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AscLocationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.AscLocationList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AscLocationList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations'} # type: ignore - - async def get( - self, - **kwargs: Any - ) -> "_models.AscLocation": - """Details of a specific location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AscLocation, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AscLocation - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AscLocation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}'} # 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 deleted file mode 100644 index 81c86cb0e66b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_operations.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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationList"]: - """Exposes all available operations for discovery purposes. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.OperationList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/providers/Microsoft.Security/operations'} # type: ignore 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 deleted file mode 100644 index 2f5c1427124a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_pricings_operations.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 typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class PricingsOperations: - """PricingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def list( - self, - **kwargs: Any - ) -> "_models.PricingList": - """Lists Security Center pricing configurations in the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PricingList, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.PricingList - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PricingList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings'} # type: ignore - - async def get( - self, - pricing_name: str, - **kwargs: Any - ) -> "_models.Pricing": - """Gets a provided Security Center pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. - :type pricing_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Pricing, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Pricing - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Pricing"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'pricingName': self._serialize.url("pricing_name", pricing_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}'} # type: ignore - - async def update( - self, - pricing_name: str, - pricing: "_models.Pricing", - **kwargs: Any - ) -> "_models.Pricing": - """Updates a provided Security Center pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. - :type pricing_name: str - :param pricing: Pricing object. - :type pricing: ~azure.mgmt.security.models.Pricing - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Pricing, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Pricing - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Pricing"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'pricingName': self._serialize.url("pricing_name", pricing_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(pricing, 'Pricing') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}'} # 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 deleted file mode 100644 index 32614aec3d99..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_regulatory_compliance_assessments_operations.py +++ /dev/null @@ -1,184 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class RegulatoryComplianceAssessmentsOperations: - """RegulatoryComplianceAssessmentsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - regulatory_compliance_standard_name: str, - regulatory_compliance_control_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.RegulatoryComplianceAssessmentList"]: - """Details and state of assessments mapped to selected regulatory compliance control. - - :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. - :type regulatory_compliance_standard_name: str - :param regulatory_compliance_control_name: Name of the regulatory compliance control object. - :type regulatory_compliance_control_name: str - :param filter: OData filter. Optional. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegulatoryComplianceAssessmentList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.RegulatoryComplianceAssessmentList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegulatoryComplianceAssessmentList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'regulatoryComplianceStandardName': self._serialize.url("regulatory_compliance_standard_name", regulatory_compliance_standard_name, 'str'), - 'regulatoryComplianceControlName': self._serialize.url("regulatory_compliance_control_name", regulatory_compliance_control_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}/regulatoryComplianceAssessments'} # type: ignore - - 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. - :type regulatory_compliance_standard_name: str - :param regulatory_compliance_control_name: Name of the regulatory compliance control object. - :type regulatory_compliance_control_name: str - :param regulatory_compliance_assessment_name: Name of the regulatory compliance assessment - object. - :type regulatory_compliance_assessment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegulatoryComplianceAssessment, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.RegulatoryComplianceAssessment - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegulatoryComplianceAssessment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'regulatoryComplianceStandardName': self._serialize.url("regulatory_compliance_standard_name", regulatory_compliance_standard_name, 'str'), - 'regulatoryComplianceControlName': self._serialize.url("regulatory_compliance_control_name", regulatory_compliance_control_name, 'str'), - 'regulatoryComplianceAssessmentName': self._serialize.url("regulatory_compliance_assessment_name", regulatory_compliance_assessment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}/regulatoryComplianceAssessments/{regulatoryComplianceAssessmentName}'} # 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 deleted file mode 100644 index 2c64a381af9c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_regulatory_compliance_controls_operations.py +++ /dev/null @@ -1,175 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class RegulatoryComplianceControlsOperations: - """RegulatoryComplianceControlsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - regulatory_compliance_standard_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.RegulatoryComplianceControlList"]: - """All supported regulatory compliance controls details and state for selected standard. - - :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. - :type regulatory_compliance_standard_name: str - :param filter: OData filter. Optional. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegulatoryComplianceControlList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.RegulatoryComplianceControlList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegulatoryComplianceControlList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'regulatoryComplianceStandardName': self._serialize.url("regulatory_compliance_standard_name", regulatory_compliance_standard_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls'} # type: ignore - - 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. - :type regulatory_compliance_standard_name: str - :param regulatory_compliance_control_name: Name of the regulatory compliance control object. - :type regulatory_compliance_control_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegulatoryComplianceControl, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.RegulatoryComplianceControl - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegulatoryComplianceControl"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'regulatoryComplianceStandardName': self._serialize.url("regulatory_compliance_standard_name", regulatory_compliance_standard_name, 'str'), - 'regulatoryComplianceControlName': self._serialize.url("regulatory_compliance_control_name", regulatory_compliance_control_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}'} # 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 deleted file mode 100644 index 5dbcd284f0d0..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_regulatory_compliance_standards_operations.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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class RegulatoryComplianceStandardsOperations: - """RegulatoryComplianceStandardsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.RegulatoryComplianceStandardList"]: - """Supported regulatory compliance standards details and state. - - :param filter: OData filter. Optional. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegulatoryComplianceStandardList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.RegulatoryComplianceStandardList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegulatoryComplianceStandardList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards'} # type: ignore - - 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. - :type regulatory_compliance_standard_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegulatoryComplianceStandard, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.RegulatoryComplianceStandard - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegulatoryComplianceStandard"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'regulatoryComplianceStandardName': self._serialize.url("regulatory_compliance_standard_name", regulatory_compliance_standard_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}'} # 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 deleted file mode 100644 index e5df37ba2e9b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_secure_score_control_definitions_operations.py +++ /dev/null @@ -1,171 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SecureScoreControlDefinitionsOperations: - """SecureScoreControlDefinitionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SecureScoreControlDefinitionList"]: - """List the available security controls, their assessments, and the max score. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecureScoreControlDefinitionList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecureScoreControlDefinitionList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecureScoreControlDefinitionList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/providers/Microsoft.Security/secureScoreControlDefinitions'} # type: ignore - - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SecureScoreControlDefinitionList"]: - """For a specified subscription, list the available security controls, their assessments, and the - max score. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecureScoreControlDefinitionList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecureScoreControlDefinitionList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecureScoreControlDefinitionList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScoreControlDefinitions'} # type: ignore 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 deleted file mode 100644 index 07f3d874ea7e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_secure_score_controls_operations.py +++ /dev/null @@ -1,189 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SecureScoreControlsOperations: - """SecureScoreControlsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_by_secure_score( - self, - secure_score_name: str, - expand: Optional[Union[str, "_models.ExpandControlsEnum"]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.SecureScoreControlList"]: - """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. - :type secure_score_name: str - :param expand: OData expand. Optional. - :type expand: str or ~azure.mgmt.security.models.ExpandControlsEnum - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecureScoreControlList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecureScoreControlList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecureScoreControlList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_secure_score.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'secureScoreName': self._serialize.url("secure_score_name", secure_score_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_secure_score.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores/{secureScoreName}/secureScoreControls'} # type: ignore - - def list( - self, - expand: Optional[Union[str, "_models.ExpandControlsEnum"]] = None, - **kwargs: Any - ) -> AsyncIterable["_models.SecureScoreControlList"]: - """Get all security controls within a scope. - - :param expand: OData expand. Optional. - :type expand: str or ~azure.mgmt.security.models.ExpandControlsEnum - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecureScoreControlList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecureScoreControlList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecureScoreControlList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScoreControls'} # type: ignore 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 deleted file mode 100644 index 90e1ceb3501b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_secure_scores_operations.py +++ /dev/null @@ -1,164 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SecureScoresOperations: - """SecureScoresOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SecureScoresList"]: - """List secure scores for all your Security Center initiatives within your current scope. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecureScoresList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecureScoresList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecureScoresList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores'} # type: ignore - - async def get( - self, - secure_score_name: str, - **kwargs: Any - ) -> "_models.SecureScoreItem": - """Get secure score for a specific Security Center 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. - :type secure_score_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecureScoreItem, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecureScoreItem - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecureScoreItem"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'secureScoreName': self._serialize.url("secure_score_name", secure_score_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores/{secureScoreName}'} # 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 deleted file mode 100644 index d2466e69b609..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_contacts_operations.py +++ /dev/null @@ -1,337 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SecurityContactsOperations: - """SecurityContactsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SecurityContactList"]: - """Security contact configurations for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecurityContactList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecurityContactList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityContactList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts'} # type: ignore - - 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. - :type security_contact_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityContact, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityContact - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityContact"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'securityContactName': self._serialize.url("security_contact_name", security_contact_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}'} # type: ignore - - async def create( - self, - security_contact_name: str, - security_contact: "_models.SecurityContact", - **kwargs: Any - ) -> "_models.SecurityContact": - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. - :type security_contact_name: str - :param security_contact: Security contact object. - :type security_contact: ~azure.mgmt.security.models.SecurityContact - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityContact, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityContact - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityContact"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'securityContactName': self._serialize.url("security_contact_name", security_contact_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_contact, 'SecurityContact') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}'} # type: ignore - - async def delete( - self, - security_contact_name: str, - **kwargs: Any - ) -> None: - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. - :type security_contact_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'securityContactName': self._serialize.url("security_contact_name", security_contact_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}'} # type: ignore - - async def update( - self, - security_contact_name: str, - security_contact: "_models.SecurityContact", - **kwargs: Any - ) -> "_models.SecurityContact": - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. - :type security_contact_name: str - :param security_contact: Security contact object. - :type security_contact: ~azure.mgmt.security.models.SecurityContact - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityContact, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityContact - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityContact"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'securityContactName': self._serialize.url("security_contact_name", security_contact_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_contact, 'SecurityContact') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}'} # 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 deleted file mode 100644 index 24b5cc9fe67b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_solutions_operations.py +++ /dev/null @@ -1,168 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SecuritySolutionsOperations: - """SecuritySolutionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SecuritySolutionList"]: - """Gets a list of Security Solutions for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecuritySolutionList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecuritySolutionList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecuritySolutionList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutions'} # type: ignore - - async def get( - self, - resource_group_name: 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. - :type resource_group_name: str - :param security_solution_name: Name of security solution. - :type security_solution_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecuritySolution, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecuritySolution - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecuritySolution"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'securitySolutionName': self._serialize.url("security_solution_name", security_solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutions/{securitySolutionName}'} # 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 deleted file mode 100644 index 944d446ef9e1..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_security_solutions_reference_data_operations.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 typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SecuritySolutionsReferenceDataOperations: - """SecuritySolutionsReferenceDataOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def list( - self, - **kwargs: Any - ) -> "_models.SecuritySolutionsReferenceDataList": - """Gets a list of all supported Security Solutions for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecuritySolutionsReferenceDataList, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecuritySolutionsReferenceDataList - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecuritySolutionsReferenceDataList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutionsReferenceData'} # type: ignore - - async def list_by_home_region( - self, - **kwargs: Any - ) -> "_models.SecuritySolutionsReferenceDataList": - """Gets list of all supported Security Solutions for subscription and location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecuritySolutionsReferenceDataList, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecuritySolutionsReferenceDataList - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecuritySolutionsReferenceDataList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.list_by_home_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - list_by_home_region.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutionsReferenceData'} # 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 deleted file mode 100644 index f66bf8978920..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_server_vulnerability_assessment_operations.py +++ /dev/null @@ -1,376 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class ServerVulnerabilityAssessmentOperations: - """ServerVulnerabilityAssessmentOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - 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. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. - :type resource_namespace: str - :param resource_type: The type of the resource. - :type resource_type: str - :param resource_name: Name of the resource. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServerVulnerabilityAssessmentsList, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsList - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerVulnerabilityAssessmentsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.list_by_extended_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - list_by_extended_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments'} # type: ignore - - 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. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. - :type resource_namespace: str - :param resource_type: The type of the resource. - :type resource_type: str - :param resource_name: Name of the resource. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServerVulnerabilityAssessment, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessment - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerVulnerabilityAssessment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - server_vulnerability_assessment = "default" - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'serverVulnerabilityAssessment': self._serialize.url("server_vulnerability_assessment", server_vulnerability_assessment, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}'} # type: ignore - - 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. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. - :type resource_namespace: str - :param resource_type: The type of the resource. - :type resource_type: str - :param resource_name: Name of the resource. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServerVulnerabilityAssessment, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessment - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerVulnerabilityAssessment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - server_vulnerability_assessment = "default" - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'serverVulnerabilityAssessment': self._serialize.url("server_vulnerability_assessment", server_vulnerability_assessment, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}'} # type: ignore - - async def _delete_initial( - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - server_vulnerability_assessment = "default" - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'serverVulnerabilityAssessment': self._serialize.url("server_vulnerability_assessment", server_vulnerability_assessment, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}'} # type: ignore - - 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. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. - :type resource_namespace: str - :param resource_type: The type of the resource. - :type resource_type: str - :param resource_name: Name of the resource. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - 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, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - server_vulnerability_assessment = "default" - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'serverVulnerabilityAssessment': self._serialize.url("server_vulnerability_assessment", server_vulnerability_assessment, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}'} # 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 deleted file mode 100644 index bd641d4d7e72..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_settings_operations.py +++ /dev/null @@ -1,224 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SettingsOperations: - """SettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SettingsList"]: - """Settings about different configurations in security center. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SettingsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SettingsList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SettingsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings'} # type: ignore - - async def get( - self, - setting_name: Union[str, "_models.Enum69"], - **kwargs: Any - ) -> "_models.Setting": - """Settings of different configurations in security center. - - :param setting_name: The name of the setting. - :type setting_name: str or ~azure.mgmt.security.models.Enum69 - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Setting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Setting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Setting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'settingName': self._serialize.url("setting_name", setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}'} # type: ignore - - async def update( - self, - setting_name: Union[str, "_models.Enum69"], - setting: "_models.Setting", - **kwargs: Any - ) -> "_models.Setting": - """updating settings about different configurations in security center. - - :param setting_name: The name of the setting. - :type setting_name: str or ~azure.mgmt.security.models.Enum69 - :param setting: Setting object. - :type setting: ~azure.mgmt.security.models.Setting - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Setting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Setting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Setting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'settingName': self._serialize.url("setting_name", setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(setting, 'Setting') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}'} # 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 deleted file mode 100644 index d38fc050a78a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_software_inventories_operations.py +++ /dev/null @@ -1,262 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SoftwareInventoriesOperations: - """SoftwareInventoriesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_by_extended_resource( - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SoftwaresList"]: - """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. - :type resource_group_name: str - :param resource_namespace: The namespace of the resource. - :type resource_namespace: str - :param resource_type: The type of the resource. - :type resource_type: str - :param resource_name: Name of the resource. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SoftwaresList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SoftwaresList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SoftwaresList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_extended_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_extended_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/softwareInventories'} # type: ignore - - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SoftwaresList"]: - """Gets the software inventory of all virtual machines in the subscriptions. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SoftwaresList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SoftwaresList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SoftwaresList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/softwareInventories'} # type: ignore - - 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. - :type resource_group_name: str - :param resource_namespace: The namespace of the resource. - :type resource_namespace: str - :param resource_type: The type of the resource. - :type resource_type: str - :param resource_name: Name of the resource. - :type resource_name: str - :param software_name: Name of the installed software. - :type software_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Software, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Software - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Software"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'softwareName': self._serialize.url("software_name", software_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/softwareInventories/{softwareName}'} # 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 deleted file mode 100644 index 025272f789c9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_sql_vulnerability_assessment_baseline_rules_operations.py +++ /dev/null @@ -1,367 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SqlVulnerabilityAssessmentBaselineRulesOperations: - """SqlVulnerabilityAssessmentBaselineRulesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def create_or_update( - self, - rule_id: str, - workspace_id: str, - resource_id: str, - body: Optional["_models.RuleResultsInput"] = 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. - :type rule_id: str - :param workspace_id: The workspace Id. - :type workspace_id: str - :param resource_id: The identifier of the resource. - :type resource_id: str - :param body: The baseline results for this rule. - :type body: ~azure.mgmt.security.models.RuleResultsInput - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RuleResults, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.RuleResults - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RuleResults"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'ruleId': self._serialize.url("rule_id", rule_id, 'str'), - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['workspaceId'] = self._serialize.query("workspace_id", workspace_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'RuleResultsInput') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - create_or_update.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}'} # type: ignore - - 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. - :type rule_id: str - :param workspace_id: The workspace Id. - :type workspace_id: str - :param resource_id: The identifier of the resource. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RuleResults, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.RuleResults - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RuleResults"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'ruleId': self._serialize.url("rule_id", rule_id, 'str'), - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['workspaceId'] = self._serialize.query("workspace_id", workspace_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}'} # type: ignore - - 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. - :type rule_id: str - :param workspace_id: The workspace Id. - :type workspace_id: str - :param resource_id: The identifier of the resource. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'ruleId': self._serialize.url("rule_id", rule_id, 'str'), - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['workspaceId'] = self._serialize.query("workspace_id", workspace_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}'} # type: ignore - - 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. - :type workspace_id: str - :param resource_id: The identifier of the resource. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RulesResults, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.RulesResults - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RulesResults"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['workspaceId'] = self._serialize.query("workspace_id", workspace_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - list.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules'} # type: ignore - - async def add( - self, - workspace_id: str, - resource_id: str, - body: Optional["_models.RulesResultsInput"] = 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. - :type workspace_id: str - :param resource_id: The identifier of the resource. - :type resource_id: str - :param body: The baseline rules. - :type body: ~azure.mgmt.security.models.RulesResultsInput - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RulesResults, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.RulesResults - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RulesResults"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.add.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['workspaceId'] = self._serialize.query("workspace_id", workspace_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'RulesResultsInput') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - add.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules'} # 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 deleted file mode 100644 index 0ff8ebb2bbe3..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_sql_vulnerability_assessment_scan_results_operations.py +++ /dev/null @@ -1,171 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SqlVulnerabilityAssessmentScanResultsOperations: - """SqlVulnerabilityAssessmentScanResultsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - 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. - :type scan_id: str - :param scan_result_id: The rule Id of the results. - :type scan_result_id: str - :param workspace_id: The workspace Id. - :type workspace_id: str - :param resource_id: The identifier of the resource. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScanResult, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ScanResult - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScanResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'scanResultId': self._serialize.url("scan_result_id", scan_result_id, 'str'), - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['workspaceId'] = self._serialize.query("workspace_id", workspace_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}/scanResults/{scanResultId}'} # type: ignore - - 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. - :type scan_id: str - :param workspace_id: The workspace Id. - :type workspace_id: str - :param resource_id: The identifier of the resource. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScanResults, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ScanResults - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScanResults"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['workspaceId'] = self._serialize.query("workspace_id", workspace_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - list.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}/scanResults'} # 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 deleted file mode 100644 index dc4e1348504b..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_sql_vulnerability_assessment_scans_operations.py +++ /dev/null @@ -1,163 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SqlVulnerabilityAssessmentScansOperations: - """SqlVulnerabilityAssessmentScansOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - 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. - :type scan_id: str - :param workspace_id: The workspace Id. - :type workspace_id: str - :param resource_id: The identifier of the resource. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Scan, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Scan - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Scan"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['workspaceId'] = self._serialize.query("workspace_id", workspace_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}'} # type: ignore - - 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. - :type workspace_id: str - :param resource_id: The identifier of the resource. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Scans, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Scans - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Scans"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['workspaceId'] = self._serialize.query("workspace_id", workspace_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - list.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans'} # type: ignore 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 deleted file mode 100644 index 36f502551163..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_sub_assessments_operations.py +++ /dev/null @@ -1,251 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class SubAssessmentsOperations: - """SubAssessmentsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_all( - self, - scope: str, - **kwargs: Any - ) -> AsyncIterable["_models.SecuritySubAssessmentList"]: - """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). - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecuritySubAssessmentList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecuritySubAssessmentList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecuritySubAssessmentList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_all.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_all.metadata = {'url': '/{scope}/providers/Microsoft.Security/subAssessments'} # type: ignore - - def list( - self, - scope: str, - assessment_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SecuritySubAssessmentList"]: - """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). - :type scope: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. - :type assessment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecuritySubAssessmentList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecuritySubAssessmentList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecuritySubAssessmentList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'assessmentName': self._serialize.url("assessment_name", assessment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/subAssessments'} # type: ignore - - 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). - :type scope: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. - :type assessment_name: str - :param sub_assessment_name: The Sub-Assessment Key - Unique key for the sub-assessment type. - :type sub_assessment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecuritySubAssessment, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecuritySubAssessment - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecuritySubAssessment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'assessmentName': self._serialize.url("assessment_name", assessment_name, 'str'), - 'subAssessmentName': self._serialize.url("sub_assessment_name", sub_assessment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/subAssessments/{subAssessmentName}'} # 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 deleted file mode 100644 index db7bbd5d59af..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_tasks_operations.py +++ /dev/null @@ -1,494 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class TasksOperations: - """TasksOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.SecurityTaskList"]: - """Recommended tasks that will help improve the security of the subscription proactively. - - :param filter: OData filter. Optional. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecurityTaskList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecurityTaskList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityTaskList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/tasks'} # type: ignore - - def list_by_home_region( - self, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.SecurityTaskList"]: - """Recommended tasks that will help improve the security of the subscription proactively. - - :param filter: OData filter. Optional. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecurityTaskList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecurityTaskList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityTaskList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_home_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_home_region.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks'} # type: ignore - - async def get_subscription_level_task( - self, - task_name: str, - **kwargs: Any - ) -> "_models.SecurityTask": - """Recommended tasks that will help improve the security of the subscription proactively. - - :param task_name: Name of the task object, will be a GUID. - :type task_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityTask, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityTask - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityTask"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_subscription_level_task.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'taskName': self._serialize.url("task_name", task_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get_subscription_level_task.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}'} # type: ignore - - async def update_subscription_level_task_state( - self, - task_name: str, - task_update_action_type: Union[str, "_models.Enum13"], - **kwargs: Any - ) -> None: - """Recommended tasks that will help improve the security of the subscription proactively. - - :param task_name: Name of the task object, will be a GUID. - :type task_name: str - :param task_update_action_type: Type of the action to do on the task. - :type task_update_action_type: str or ~azure.mgmt.security.models.Enum13 - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.update_subscription_level_task_state.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'taskName': self._serialize.url("task_name", task_name, 'str'), - 'taskUpdateActionType': self._serialize.url("task_update_action_type", task_update_action_type, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - update_subscription_level_task_state.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}/{taskUpdateActionType}'} # type: ignore - - def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.SecurityTaskList"]: - """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. - :type resource_group_name: str - :param filter: OData filter. Optional. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecurityTaskList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.SecurityTaskList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityTaskList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks'} # type: ignore - - async def get_resource_group_level_task( - self, - resource_group_name: 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. - :type resource_group_name: str - :param task_name: Name of the task object, will be a GUID. - :type task_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityTask, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityTask - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityTask"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_resource_group_level_task.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'taskName': self._serialize.url("task_name", task_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get_resource_group_level_task.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}'} # type: ignore - - async def update_resource_group_level_task_state( - self, - resource_group_name: str, - task_name: str, - task_update_action_type: Union[str, "_models.Enum13"], - **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. - :type resource_group_name: str - :param task_name: Name of the task object, will be a GUID. - :type task_name: str - :param task_update_action_type: Type of the action to do on the task. - :type task_update_action_type: str or ~azure.mgmt.security.models.Enum13 - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.update_resource_group_level_task_state.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'taskName': self._serialize.url("task_name", task_name, 'str'), - 'taskUpdateActionType': self._serialize.url("task_update_action_type", task_update_action_type, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - update_resource_group_level_task_state.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}/{taskUpdateActionType}'} # 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 deleted file mode 100644 index 9f2d93a6b94c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_topology_operations.py +++ /dev/null @@ -1,235 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class TopologyOperations: - """TopologyOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TopologyList"]: - """Gets a list that allows to build a topology view of a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TopologyList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.TopologyList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TopologyList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/topologies'} # type: ignore - - def list_by_home_region( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TopologyList"]: - """Gets a list that allows to build a topology view of a subscription and location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TopologyList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.TopologyList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TopologyList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_home_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_home_region.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/topologies'} # type: ignore - - async def get( - self, - resource_group_name: 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. - :type resource_group_name: str - :param topology_resource_name: Name of a topology resources collection. - :type topology_resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TopologyResource, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.TopologyResource - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TopologyResource"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'topologyResourceName': self._serialize.url("topology_resource_name", topology_resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/topologies/{topologyResourceName}'} # 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 deleted file mode 100644 index e2f283eec3d4..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/operations/_workspace_settings_operations.py +++ /dev/null @@ -1,340 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class WorkspaceSettingsOperations: - """WorkspaceSettingsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.WorkspaceSettingList"]: - """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. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkspaceSettingList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.models.WorkspaceSettingList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceSettingList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings'} # type: ignore - - 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. - :type workspace_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkspaceSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.WorkspaceSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'workspaceSettingName': self._serialize.url("workspace_setting_name", workspace_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}'} # type: ignore - - async def create( - self, - workspace_setting_name: str, - workspace_setting: "_models.WorkspaceSetting", - **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. - :type workspace_setting_name: str - :param workspace_setting: Security data setting object. - :type workspace_setting: ~azure.mgmt.security.models.WorkspaceSetting - :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkspaceSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.WorkspaceSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'workspaceSettingName': self._serialize.url("workspace_setting_name", workspace_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workspace_setting, 'WorkspaceSetting') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}'} # type: ignore - - async def update( - self, - workspace_setting_name: str, - workspace_setting: "_models.WorkspaceSetting", - **kwargs: Any - ) -> "_models.WorkspaceSetting": - """Settings about where we should store your security data and logs. - - :param workspace_setting_name: Name of the security setting. - :type workspace_setting_name: str - :param workspace_setting: Security data setting object. - :type workspace_setting: ~azure.mgmt.security.models.WorkspaceSetting - :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkspaceSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.WorkspaceSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'workspaceSettingName': self._serialize.url("workspace_setting_name", workspace_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workspace_setting, 'WorkspaceSetting') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}'} # type: ignore - - 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. - :type workspace_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'workspaceSettingName': self._serialize.url("workspace_setting_name", workspace_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}'} # 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 new file mode 100644 index 000000000000..51e934c2369f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/models.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. +# -------------------------------------------------------------------------- +from .v2015_06_01_preview.models import * +from .v2017_08_01.models import * +from .v2017_08_01_preview.models import * +from .v2018_06_01.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 .v2020_07_01_preview.models import * +from .v2021_01_01.models import * +from .v2021_01_15_preview.models import * +from .v2021_05_01_preview.models import * +from .v2021_06_01.models import * +from .v2021_07_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 deleted file mode 100644 index f841b789d1e3..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/models/__init__.py +++ /dev/null @@ -1,871 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -try: - from ._models_py3 import AadConnectivityState - from ._models_py3 import AadExternalSecuritySolution - from ._models_py3 import AadSolutionProperties - from ._models_py3 import ActiveConnectionsNotInAllowedRange - 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 AdditionalData - from ._models_py3 import AdditionalWorkspacesProperties - from ._models_py3 import AdvancedThreatProtectionSetting - 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 AlertSyncSettings - from ._models_py3 import AlertsSuppressionRule - from ._models_py3 import AlertsSuppressionRulesList - from ._models_py3 import AllowedConnectionsList - from ._models_py3 import AllowedConnectionsResource - from ._models_py3 import AllowlistCustomAlertRule - from ._models_py3 import AmqpC2DMessagesNotInAllowedRange - from ._models_py3 import AmqpC2DRejectedMessagesNotInAllowedRange - from ._models_py3 import AmqpD2CMessagesNotInAllowedRange - from ._models_py3 import AscLocation - from ._models_py3 import AscLocationList - from ._models_py3 import AssessmentLinks - from ._models_py3 import AssessmentStatus - from ._models_py3 import AtaExternalSecuritySolution - from ._models_py3 import AtaSolutionProperties - from ._models_py3 import AuthenticationDetailsProperties - from ._models_py3 import AutoProvisioningSetting - from ._models_py3 import AutoProvisioningSettingList - 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 AwAssumeRoleAuthenticationDetailsProperties - from ._models_py3 import AwsCredsAuthenticationDetailsProperties - from ._models_py3 import AzureResourceDetails - from ._models_py3 import AzureResourceIdentifier - from ._models_py3 import AzureResourceLink - from ._models_py3 import AzureTrackedResourceLocation - from ._models_py3 import Baseline - from ._models_py3 import BaselineAdjustedResult - from ._models_py3 import BenchmarkReference - from ._models_py3 import CVE - from ._models_py3 import CVSS - from ._models_py3 import CefExternalSecuritySolution - from ._models_py3 import CefSolutionProperties - from ._models_py3 import CloudErrorBody - from ._models_py3 import Compliance - from ._models_py3 import ComplianceList - from ._models_py3 import ComplianceResult - from ._models_py3 import ComplianceResultList - from ._models_py3 import ComplianceSegment - from ._models_py3 import ConnectableResource - from ._models_py3 import ConnectedResource - from ._models_py3 import ConnectedWorkspace - from ._models_py3 import ConnectionFromIpNotAllowed - from ._models_py3 import ConnectionStrings - from ._models_py3 import ConnectionToIpNotAllowed - from ._models_py3 import ConnectorSetting - from ._models_py3 import ConnectorSettingList - from ._models_py3 import ContainerRegistryVulnerabilityProperties - from ._models_py3 import CustomAlertRule - from ._models_py3 import DataExportSettings - from ._models_py3 import DenylistCustomAlertRule - from ._models_py3 import DeviceSecurityGroup - from ._models_py3 import DeviceSecurityGroupList - from ._models_py3 import DirectMethodInvokesNotInAllowedRange - from ._models_py3 import DiscoveredSecuritySolution - from ._models_py3 import DiscoveredSecuritySolutionList - from ._models_py3 import ETag - 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 FailedLocalLoginsNotInAllowedRange - from ._models_py3 import FileUploadsNotInAllowedRange - from ._models_py3 import GcpCredentialsDetailsProperties - from ._models_py3 import HttpC2DMessagesNotInAllowedRange - from ._models_py3 import HttpC2DRejectedMessagesNotInAllowedRange - from ._models_py3 import HttpD2CMessagesNotInAllowedRange - from ._models_py3 import HybridComputeSettingsProperties - from ._models_py3 import InformationProtectionKeyword - from ._models_py3 import InformationProtectionPolicy - from ._models_py3 import InformationProtectionPolicyList - from ._models_py3 import InformationType - from ._models_py3 import IngestionConnectionString - from ._models_py3 import IngestionSetting - from ._models_py3 import IngestionSettingList - from ._models_py3 import IngestionSettingToken - 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 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 ListCustomAlertRule - from ._models_py3 import LocalUserNotAllowed - from ._models_py3 import Location - from ._models_py3 import LogAnalyticsIdentifier - from ._models_py3 import MqttC2DMessagesNotInAllowedRange - from ._models_py3 import MqttC2DRejectedMessagesNotInAllowedRange - from ._models_py3 import MqttD2CMessagesNotInAllowedRange - from ._models_py3 import OnPremiseResourceDetails - from ._models_py3 import OnPremiseSqlResourceDetails - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationList - from ._models_py3 import PathRecommendation - from ._models_py3 import Pricing - from ._models_py3 import PricingList - from ._models_py3 import ProcessNotAllowed - from ._models_py3 import ProtectionMode - from ._models_py3 import ProxyServerProperties - from ._models_py3 import PublisherInfo - from ._models_py3 import QueryCheck - from ._models_py3 import QueuePurgesNotInAllowedRange - from ._models_py3 import RecommendationConfigurationProperties - 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 Remediation - from ._models_py3 import Resource - from ._models_py3 import ResourceDetails - from ._models_py3 import ResourceIdentifier - from ._models_py3 import Rule - 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 ScopeElement - 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 SecurityContact - from ._models_py3 import SecurityContactList - from ._models_py3 import SecuritySolution - from ._models_py3 import SecuritySolutionList - from ._models_py3 import SecuritySolutionsReferenceData - from ._models_py3 import SecuritySolutionsReferenceDataList - from ._models_py3 import SecuritySubAssessment - from ._models_py3 import SecuritySubAssessmentList - from ._models_py3 import SecurityTask - from ._models_py3 import SecurityTaskList - from ._models_py3 import SecurityTaskParameters - from ._models_py3 import SensitivityLabel - from ._models_py3 import ServerVulnerabilityAssessment - from ._models_py3 import ServerVulnerabilityAssessmentsList - from ._models_py3 import ServerVulnerabilityProperties - from ._models_py3 import ServicePrincipalProperties - from ._models_py3 import Setting - from ._models_py3 import SettingsList - from ._models_py3 import Software - from ._models_py3 import SoftwaresList - from ._models_py3 import SqlServerVulnerabilityProperties - from ._models_py3 import SubAssessmentStatus - from ._models_py3 import SuppressionAlertsScope - from ._models_py3 import SystemData - from ._models_py3 import Tags - from ._models_py3 import TagsResource - from ._models_py3 import ThresholdCustomAlertRule - from ._models_py3 import TimeWindowCustomAlertRule - 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 TrackedResource - from ._models_py3 import TwinUpdatesNotInAllowedRange - from ._models_py3 import UnauthorizedOperationsNotInAllowedRange - from ._models_py3 import UpdateIotSecuritySolutionData - from ._models_py3 import UserDefinedResourcesProperties - from ._models_py3 import UserRecommendation - from ._models_py3 import VaRule - from ._models_py3 import VendorReference - from ._models_py3 import VmRecommendation - from ._models_py3 import WorkspaceSetting - from ._models_py3 import WorkspaceSettingList -except (SyntaxError, ImportError): - from ._models import AadConnectivityState # type: ignore - from ._models import AadExternalSecuritySolution # type: ignore - from ._models import AadSolutionProperties # type: ignore - from ._models import ActiveConnectionsNotInAllowedRange # type: ignore - from ._models import AdaptiveApplicationControlGroup # type: ignore - from ._models import AdaptiveApplicationControlGroups # type: ignore - from ._models import AdaptiveApplicationControlIssueSummary # type: ignore - from ._models import AdaptiveNetworkHardening # type: ignore - from ._models import AdaptiveNetworkHardeningEnforceRequest # type: ignore - from ._models import AdaptiveNetworkHardeningsList # type: ignore - from ._models import AdditionalData # type: ignore - from ._models import AdditionalWorkspacesProperties # type: ignore - from ._models import AdvancedThreatProtectionSetting # type: ignore - from ._models import Alert # type: ignore - from ._models import AlertEntity # type: ignore - from ._models import AlertList # type: ignore - from ._models import AlertSimulatorBundlesRequestProperties # type: ignore - from ._models import AlertSimulatorRequestBody # type: ignore - from ._models import AlertSimulatorRequestProperties # type: ignore - from ._models import AlertSyncSettings # type: ignore - from ._models import AlertsSuppressionRule # type: ignore - from ._models import AlertsSuppressionRulesList # type: ignore - from ._models import AllowedConnectionsList # type: ignore - from ._models import AllowedConnectionsResource # type: ignore - from ._models import AllowlistCustomAlertRule # type: ignore - from ._models import AmqpC2DMessagesNotInAllowedRange # type: ignore - from ._models import AmqpC2DRejectedMessagesNotInAllowedRange # type: ignore - from ._models import AmqpD2CMessagesNotInAllowedRange # type: ignore - from ._models import AscLocation # type: ignore - from ._models import AscLocationList # type: ignore - from ._models import AssessmentLinks # type: ignore - from ._models import AssessmentStatus # type: ignore - from ._models import AtaExternalSecuritySolution # type: ignore - from ._models import AtaSolutionProperties # type: ignore - from ._models import AuthenticationDetailsProperties # type: ignore - from ._models import AutoProvisioningSetting # type: ignore - from ._models import AutoProvisioningSettingList # type: ignore - from ._models import Automation # type: ignore - from ._models import AutomationAction # type: ignore - from ._models import AutomationActionEventHub # type: ignore - from ._models import AutomationActionLogicApp # type: ignore - from ._models import AutomationActionWorkspace # type: ignore - from ._models import AutomationList # type: ignore - from ._models import AutomationRuleSet # type: ignore - from ._models import AutomationScope # type: ignore - from ._models import AutomationSource # type: ignore - from ._models import AutomationTriggeringRule # type: ignore - from ._models import AutomationValidationStatus # type: ignore - from ._models import AwAssumeRoleAuthenticationDetailsProperties # type: ignore - from ._models import AwsCredsAuthenticationDetailsProperties # type: ignore - from ._models import AzureResourceDetails # type: ignore - from ._models import AzureResourceIdentifier # type: ignore - from ._models import AzureResourceLink # type: ignore - from ._models import AzureTrackedResourceLocation # type: ignore - from ._models import Baseline # type: ignore - from ._models import BaselineAdjustedResult # type: ignore - from ._models import BenchmarkReference # type: ignore - from ._models import CVE # type: ignore - from ._models import CVSS # type: ignore - from ._models import CefExternalSecuritySolution # type: ignore - from ._models import CefSolutionProperties # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import Compliance # type: ignore - from ._models import ComplianceList # type: ignore - from ._models import ComplianceResult # type: ignore - from ._models import ComplianceResultList # type: ignore - from ._models import ComplianceSegment # type: ignore - from ._models import ConnectableResource # type: ignore - from ._models import ConnectedResource # type: ignore - from ._models import ConnectedWorkspace # type: ignore - from ._models import ConnectionFromIpNotAllowed # type: ignore - from ._models import ConnectionStrings # type: ignore - from ._models import ConnectionToIpNotAllowed # type: ignore - from ._models import ConnectorSetting # type: ignore - from ._models import ConnectorSettingList # type: ignore - from ._models import ContainerRegistryVulnerabilityProperties # type: ignore - from ._models import CustomAlertRule # type: ignore - from ._models import DataExportSettings # type: ignore - from ._models import DenylistCustomAlertRule # type: ignore - from ._models import DeviceSecurityGroup # type: ignore - from ._models import DeviceSecurityGroupList # type: ignore - from ._models import DirectMethodInvokesNotInAllowedRange # type: ignore - from ._models import DiscoveredSecuritySolution # type: ignore - from ._models import DiscoveredSecuritySolutionList # type: ignore - from ._models import ETag # type: ignore - from ._models import EffectiveNetworkSecurityGroups # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ExternalSecuritySolution # type: ignore - from ._models import ExternalSecuritySolutionKind # type: ignore - from ._models import ExternalSecuritySolutionList # type: ignore - from ._models import ExternalSecuritySolutionProperties # type: ignore - from ._models import FailedLocalLoginsNotInAllowedRange # type: ignore - from ._models import FileUploadsNotInAllowedRange # type: ignore - from ._models import GcpCredentialsDetailsProperties # type: ignore - from ._models import HttpC2DMessagesNotInAllowedRange # type: ignore - from ._models import HttpC2DRejectedMessagesNotInAllowedRange # type: ignore - from ._models import HttpD2CMessagesNotInAllowedRange # type: ignore - from ._models import HybridComputeSettingsProperties # type: ignore - from ._models import InformationProtectionKeyword # type: ignore - from ._models import InformationProtectionPolicy # type: ignore - from ._models import InformationProtectionPolicyList # type: ignore - from ._models import InformationType # type: ignore - from ._models import IngestionConnectionString # type: ignore - from ._models import IngestionSetting # type: ignore - from ._models import IngestionSettingList # type: ignore - from ._models import IngestionSettingToken # type: ignore - from ._models import IoTSecurityAggregatedAlert # type: ignore - from ._models import IoTSecurityAggregatedAlertList # type: ignore - from ._models import IoTSecurityAggregatedAlertPropertiesTopDevicesListItem # type: ignore - from ._models import IoTSecurityAggregatedRecommendation # type: ignore - from ._models import IoTSecurityAggregatedRecommendationList # type: ignore - from ._models import IoTSecurityAlertedDevice # type: ignore - from ._models import IoTSecurityDeviceAlert # type: ignore - from ._models import IoTSecurityDeviceRecommendation # type: ignore - from ._models import IoTSecuritySolutionAnalyticsModel # type: ignore - from ._models import IoTSecuritySolutionAnalyticsModelList # type: ignore - from ._models import IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem # type: ignore - from ._models import IoTSecuritySolutionModel # type: ignore - from ._models import IoTSecuritySolutionsList # type: ignore - from ._models import IoTSeverityMetrics # type: ignore - from ._models import JitNetworkAccessPoliciesList # type: ignore - from ._models import JitNetworkAccessPolicy # type: ignore - from ._models import JitNetworkAccessPolicyInitiatePort # type: ignore - from ._models import JitNetworkAccessPolicyInitiateRequest # type: ignore - from ._models import JitNetworkAccessPolicyInitiateVirtualMachine # type: ignore - from ._models import JitNetworkAccessPolicyVirtualMachine # type: ignore - from ._models import JitNetworkAccessPortRule # type: ignore - from ._models import JitNetworkAccessRequest # type: ignore - from ._models import JitNetworkAccessRequestPort # type: ignore - from ._models import JitNetworkAccessRequestVirtualMachine # type: ignore - from ._models import Kind # type: ignore - from ._models import ListCustomAlertRule # type: ignore - from ._models import LocalUserNotAllowed # type: ignore - from ._models import Location # type: ignore - from ._models import LogAnalyticsIdentifier # type: ignore - from ._models import MqttC2DMessagesNotInAllowedRange # type: ignore - from ._models import MqttC2DRejectedMessagesNotInAllowedRange # type: ignore - from ._models import MqttD2CMessagesNotInAllowedRange # type: ignore - from ._models import OnPremiseResourceDetails # type: ignore - from ._models import OnPremiseSqlResourceDetails # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationList # type: ignore - from ._models import PathRecommendation # type: ignore - from ._models import Pricing # type: ignore - from ._models import PricingList # type: ignore - from ._models import ProcessNotAllowed # type: ignore - from ._models import ProtectionMode # type: ignore - from ._models import ProxyServerProperties # type: ignore - from ._models import PublisherInfo # type: ignore - from ._models import QueryCheck # type: ignore - from ._models import QueuePurgesNotInAllowedRange # type: ignore - from ._models import RecommendationConfigurationProperties # type: ignore - from ._models import RegulatoryComplianceAssessment # type: ignore - from ._models import RegulatoryComplianceAssessmentList # type: ignore - from ._models import RegulatoryComplianceControl # type: ignore - from ._models import RegulatoryComplianceControlList # type: ignore - from ._models import RegulatoryComplianceStandard # type: ignore - from ._models import RegulatoryComplianceStandardList # type: ignore - from ._models import Remediation # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourceDetails # type: ignore - from ._models import ResourceIdentifier # type: ignore - from ._models import Rule # type: ignore - from ._models import RuleResults # type: ignore - from ._models import RuleResultsInput # type: ignore - from ._models import RuleResultsProperties # type: ignore - from ._models import RulesResults # type: ignore - from ._models import RulesResultsInput # type: ignore - from ._models import Scan # type: ignore - from ._models import ScanProperties # type: ignore - from ._models import ScanResult # type: ignore - from ._models import ScanResultProperties # type: ignore - from ._models import ScanResults # type: ignore - from ._models import Scans # type: ignore - from ._models import ScopeElement # type: ignore - from ._models import SecureScoreControlDefinitionItem # type: ignore - from ._models import SecureScoreControlDefinitionList # type: ignore - from ._models import SecureScoreControlDefinitionSource # type: ignore - from ._models import SecureScoreControlDetails # type: ignore - from ._models import SecureScoreControlList # type: ignore - from ._models import SecureScoreControlScore # type: ignore - from ._models import SecureScoreItem # type: ignore - from ._models import SecureScoresList # type: ignore - from ._models import SecurityAssessment # type: ignore - from ._models import SecurityAssessmentList # type: ignore - from ._models import SecurityAssessmentMetadata # type: ignore - from ._models import SecurityAssessmentMetadataList # type: ignore - from ._models import SecurityAssessmentMetadataPartnerData # type: ignore - from ._models import SecurityAssessmentMetadataProperties # type: ignore - from ._models import SecurityAssessmentPartnerData # type: ignore - from ._models import SecurityContact # type: ignore - from ._models import SecurityContactList # type: ignore - from ._models import SecuritySolution # type: ignore - from ._models import SecuritySolutionList # type: ignore - from ._models import SecuritySolutionsReferenceData # type: ignore - from ._models import SecuritySolutionsReferenceDataList # type: ignore - from ._models import SecuritySubAssessment # type: ignore - from ._models import SecuritySubAssessmentList # type: ignore - from ._models import SecurityTask # type: ignore - from ._models import SecurityTaskList # type: ignore - from ._models import SecurityTaskParameters # type: ignore - from ._models import SensitivityLabel # type: ignore - from ._models import ServerVulnerabilityAssessment # type: ignore - from ._models import ServerVulnerabilityAssessmentsList # type: ignore - from ._models import ServerVulnerabilityProperties # type: ignore - from ._models import ServicePrincipalProperties # type: ignore - from ._models import Setting # type: ignore - from ._models import SettingsList # type: ignore - from ._models import Software # type: ignore - from ._models import SoftwaresList # type: ignore - from ._models import SqlServerVulnerabilityProperties # type: ignore - from ._models import SubAssessmentStatus # type: ignore - from ._models import SuppressionAlertsScope # type: ignore - from ._models import SystemData # type: ignore - from ._models import Tags # type: ignore - from ._models import TagsResource # type: ignore - from ._models import ThresholdCustomAlertRule # type: ignore - from ._models import TimeWindowCustomAlertRule # type: ignore - from ._models import TopologyList # type: ignore - from ._models import TopologyResource # type: ignore - from ._models import TopologySingleResource # type: ignore - from ._models import TopologySingleResourceChild # type: ignore - from ._models import TopologySingleResourceParent # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import TwinUpdatesNotInAllowedRange # type: ignore - from ._models import UnauthorizedOperationsNotInAllowedRange # type: ignore - from ._models import UpdateIotSecuritySolutionData # type: ignore - from ._models import UserDefinedResourcesProperties # type: ignore - from ._models import UserRecommendation # type: ignore - from ._models import VaRule # type: ignore - from ._models import VendorReference # type: ignore - from ._models import VmRecommendation # type: ignore - from ._models import WorkspaceSetting # type: ignore - from ._models import WorkspaceSettingList # type: ignore - -from ._security_center_enums import ( - AadConnectivityStateEnum, - ActionType, - AdaptiveApplicationControlIssue, - AdditionalWorkspaceDataType, - AdditionalWorkspaceType, - AlertNotifications, - AlertSeverity, - AlertStatus, - AlertsToAdmins, - AssessedResourceType, - AssessmentStatusCode, - AssessmentType, - AuthenticationProvisioningState, - AuthenticationType, - AutoProvision, - BundleType, - Categories, - ConfigurationStatus, - ConnectionType, - ControlType, - CreatedByType, - DataSource, - Direction, - EndOfSupportStatus, - EnforcementMode, - EnforcementSupport, - Enum13, - Enum15, - Enum69, - EventSource, - ExpandControlsEnum, - ExpandEnum, - ExportData, - ExternalSecuritySolutionKindEnum, - FileType, - HybridComputeProvisioningState, - ImplementationEffort, - Intent, - KindEnum, - Operator, - PermissionProperty, - PricingTier, - PropertyType, - ProtocolEnum, - ProvisioningState, - Rank, - RecommendationAction, - RecommendationConfigStatus, - RecommendationStatus, - RecommendationType, - ReportedSeverity, - ResourceIdentifierType, - ResourceStatus, - RuleSeverity, - RuleState, - RuleStatus, - RuleType, - ScanState, - ScanTriggerType, - SecurityFamily, - SecuritySolutionStatus, - ServerVulnerabilityAssessmentPropertiesProvisioningState, - SettingKind, - Severity, - Source, - SourceSystem, - State, - Status, - StatusReason, - SubAssessmentStatusCode, - Threats, - TransportProtocol, - UnmaskedIpLoggingStatus, - UserImpact, - ValueType, -) - -__all__ = [ - 'AadConnectivityState', - 'AadExternalSecuritySolution', - 'AadSolutionProperties', - 'ActiveConnectionsNotInAllowedRange', - 'AdaptiveApplicationControlGroup', - 'AdaptiveApplicationControlGroups', - 'AdaptiveApplicationControlIssueSummary', - 'AdaptiveNetworkHardening', - 'AdaptiveNetworkHardeningEnforceRequest', - 'AdaptiveNetworkHardeningsList', - 'AdditionalData', - 'AdditionalWorkspacesProperties', - 'AdvancedThreatProtectionSetting', - 'Alert', - 'AlertEntity', - 'AlertList', - 'AlertSimulatorBundlesRequestProperties', - 'AlertSimulatorRequestBody', - 'AlertSimulatorRequestProperties', - 'AlertSyncSettings', - 'AlertsSuppressionRule', - 'AlertsSuppressionRulesList', - 'AllowedConnectionsList', - 'AllowedConnectionsResource', - 'AllowlistCustomAlertRule', - 'AmqpC2DMessagesNotInAllowedRange', - 'AmqpC2DRejectedMessagesNotInAllowedRange', - 'AmqpD2CMessagesNotInAllowedRange', - 'AscLocation', - 'AscLocationList', - 'AssessmentLinks', - 'AssessmentStatus', - 'AtaExternalSecuritySolution', - 'AtaSolutionProperties', - 'AuthenticationDetailsProperties', - 'AutoProvisioningSetting', - 'AutoProvisioningSettingList', - 'Automation', - 'AutomationAction', - 'AutomationActionEventHub', - 'AutomationActionLogicApp', - 'AutomationActionWorkspace', - 'AutomationList', - 'AutomationRuleSet', - 'AutomationScope', - 'AutomationSource', - 'AutomationTriggeringRule', - 'AutomationValidationStatus', - 'AwAssumeRoleAuthenticationDetailsProperties', - 'AwsCredsAuthenticationDetailsProperties', - 'AzureResourceDetails', - 'AzureResourceIdentifier', - 'AzureResourceLink', - 'AzureTrackedResourceLocation', - 'Baseline', - 'BaselineAdjustedResult', - 'BenchmarkReference', - 'CVE', - 'CVSS', - 'CefExternalSecuritySolution', - 'CefSolutionProperties', - 'CloudErrorBody', - 'Compliance', - 'ComplianceList', - 'ComplianceResult', - 'ComplianceResultList', - 'ComplianceSegment', - 'ConnectableResource', - 'ConnectedResource', - 'ConnectedWorkspace', - 'ConnectionFromIpNotAllowed', - 'ConnectionStrings', - 'ConnectionToIpNotAllowed', - 'ConnectorSetting', - 'ConnectorSettingList', - 'ContainerRegistryVulnerabilityProperties', - 'CustomAlertRule', - 'DataExportSettings', - 'DenylistCustomAlertRule', - 'DeviceSecurityGroup', - 'DeviceSecurityGroupList', - 'DirectMethodInvokesNotInAllowedRange', - 'DiscoveredSecuritySolution', - 'DiscoveredSecuritySolutionList', - 'ETag', - 'EffectiveNetworkSecurityGroups', - 'ErrorAdditionalInfo', - 'ExternalSecuritySolution', - 'ExternalSecuritySolutionKind', - 'ExternalSecuritySolutionList', - 'ExternalSecuritySolutionProperties', - 'FailedLocalLoginsNotInAllowedRange', - 'FileUploadsNotInAllowedRange', - 'GcpCredentialsDetailsProperties', - 'HttpC2DMessagesNotInAllowedRange', - 'HttpC2DRejectedMessagesNotInAllowedRange', - 'HttpD2CMessagesNotInAllowedRange', - 'HybridComputeSettingsProperties', - 'InformationProtectionKeyword', - 'InformationProtectionPolicy', - 'InformationProtectionPolicyList', - 'InformationType', - 'IngestionConnectionString', - 'IngestionSetting', - 'IngestionSettingList', - 'IngestionSettingToken', - 'IoTSecurityAggregatedAlert', - 'IoTSecurityAggregatedAlertList', - 'IoTSecurityAggregatedAlertPropertiesTopDevicesListItem', - 'IoTSecurityAggregatedRecommendation', - 'IoTSecurityAggregatedRecommendationList', - 'IoTSecurityAlertedDevice', - 'IoTSecurityDeviceAlert', - 'IoTSecurityDeviceRecommendation', - 'IoTSecuritySolutionAnalyticsModel', - 'IoTSecuritySolutionAnalyticsModelList', - 'IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem', - 'IoTSecuritySolutionModel', - 'IoTSecuritySolutionsList', - 'IoTSeverityMetrics', - 'JitNetworkAccessPoliciesList', - 'JitNetworkAccessPolicy', - 'JitNetworkAccessPolicyInitiatePort', - 'JitNetworkAccessPolicyInitiateRequest', - 'JitNetworkAccessPolicyInitiateVirtualMachine', - 'JitNetworkAccessPolicyVirtualMachine', - 'JitNetworkAccessPortRule', - 'JitNetworkAccessRequest', - 'JitNetworkAccessRequestPort', - 'JitNetworkAccessRequestVirtualMachine', - 'Kind', - 'ListCustomAlertRule', - 'LocalUserNotAllowed', - 'Location', - 'LogAnalyticsIdentifier', - 'MqttC2DMessagesNotInAllowedRange', - 'MqttC2DRejectedMessagesNotInAllowedRange', - 'MqttD2CMessagesNotInAllowedRange', - 'OnPremiseResourceDetails', - 'OnPremiseSqlResourceDetails', - 'Operation', - 'OperationDisplay', - 'OperationList', - 'PathRecommendation', - 'Pricing', - 'PricingList', - 'ProcessNotAllowed', - 'ProtectionMode', - 'ProxyServerProperties', - 'PublisherInfo', - 'QueryCheck', - 'QueuePurgesNotInAllowedRange', - 'RecommendationConfigurationProperties', - 'RegulatoryComplianceAssessment', - 'RegulatoryComplianceAssessmentList', - 'RegulatoryComplianceControl', - 'RegulatoryComplianceControlList', - 'RegulatoryComplianceStandard', - 'RegulatoryComplianceStandardList', - 'Remediation', - 'Resource', - 'ResourceDetails', - 'ResourceIdentifier', - 'Rule', - 'RuleResults', - 'RuleResultsInput', - 'RuleResultsProperties', - 'RulesResults', - 'RulesResultsInput', - 'Scan', - 'ScanProperties', - 'ScanResult', - 'ScanResultProperties', - 'ScanResults', - 'Scans', - 'ScopeElement', - 'SecureScoreControlDefinitionItem', - 'SecureScoreControlDefinitionList', - 'SecureScoreControlDefinitionSource', - 'SecureScoreControlDetails', - 'SecureScoreControlList', - 'SecureScoreControlScore', - 'SecureScoreItem', - 'SecureScoresList', - 'SecurityAssessment', - 'SecurityAssessmentList', - 'SecurityAssessmentMetadata', - 'SecurityAssessmentMetadataList', - 'SecurityAssessmentMetadataPartnerData', - 'SecurityAssessmentMetadataProperties', - 'SecurityAssessmentPartnerData', - 'SecurityContact', - 'SecurityContactList', - 'SecuritySolution', - 'SecuritySolutionList', - 'SecuritySolutionsReferenceData', - 'SecuritySolutionsReferenceDataList', - 'SecuritySubAssessment', - 'SecuritySubAssessmentList', - 'SecurityTask', - 'SecurityTaskList', - 'SecurityTaskParameters', - 'SensitivityLabel', - 'ServerVulnerabilityAssessment', - 'ServerVulnerabilityAssessmentsList', - 'ServerVulnerabilityProperties', - 'ServicePrincipalProperties', - 'Setting', - 'SettingsList', - 'Software', - 'SoftwaresList', - 'SqlServerVulnerabilityProperties', - 'SubAssessmentStatus', - 'SuppressionAlertsScope', - 'SystemData', - 'Tags', - 'TagsResource', - 'ThresholdCustomAlertRule', - 'TimeWindowCustomAlertRule', - 'TopologyList', - 'TopologyResource', - 'TopologySingleResource', - 'TopologySingleResourceChild', - 'TopologySingleResourceParent', - 'TrackedResource', - 'TwinUpdatesNotInAllowedRange', - 'UnauthorizedOperationsNotInAllowedRange', - 'UpdateIotSecuritySolutionData', - 'UserDefinedResourcesProperties', - 'UserRecommendation', - 'VaRule', - 'VendorReference', - 'VmRecommendation', - 'WorkspaceSetting', - 'WorkspaceSettingList', - 'AadConnectivityStateEnum', - 'ActionType', - 'AdaptiveApplicationControlIssue', - 'AdditionalWorkspaceDataType', - 'AdditionalWorkspaceType', - 'AlertNotifications', - 'AlertSeverity', - 'AlertStatus', - 'AlertsToAdmins', - 'AssessedResourceType', - 'AssessmentStatusCode', - 'AssessmentType', - 'AuthenticationProvisioningState', - 'AuthenticationType', - 'AutoProvision', - 'BundleType', - 'Categories', - 'ConfigurationStatus', - 'ConnectionType', - 'ControlType', - 'CreatedByType', - 'DataSource', - 'Direction', - 'EndOfSupportStatus', - 'EnforcementMode', - 'EnforcementSupport', - 'Enum13', - 'Enum15', - 'Enum69', - 'EventSource', - 'ExpandControlsEnum', - 'ExpandEnum', - 'ExportData', - 'ExternalSecuritySolutionKindEnum', - 'FileType', - 'HybridComputeProvisioningState', - 'ImplementationEffort', - 'Intent', - 'KindEnum', - 'Operator', - 'PermissionProperty', - 'PricingTier', - 'PropertyType', - 'ProtocolEnum', - 'ProvisioningState', - 'Rank', - 'RecommendationAction', - 'RecommendationConfigStatus', - 'RecommendationStatus', - 'RecommendationType', - 'ReportedSeverity', - 'ResourceIdentifierType', - 'ResourceStatus', - 'RuleSeverity', - 'RuleState', - 'RuleStatus', - 'RuleType', - 'ScanState', - 'ScanTriggerType', - 'SecurityFamily', - 'SecuritySolutionStatus', - 'ServerVulnerabilityAssessmentPropertiesProvisioningState', - 'SettingKind', - 'Severity', - 'Source', - 'SourceSystem', - 'State', - 'Status', - 'StatusReason', - 'SubAssessmentStatusCode', - 'Threats', - 'TransportProtocol', - 'UnmaskedIpLoggingStatus', - 'UserImpact', - 'ValueType', -] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/models/_models.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/models/_models.py deleted file mode 100644 index 13b2d159b9d3..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/models/_models.py +++ /dev/null @@ -1,9600 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class AadConnectivityState(msrest.serialization.Model): - """Describes an Azure resource with kind. - - :param connectivity_state: The connectivity state of the external AAD solution. Possible values - include: "Discovered", "NotLicensed", "Connected". - :type connectivity_state: str or ~azure.mgmt.security.models.AadConnectivityStateEnum - """ - - _attribute_map = { - 'connectivity_state': {'key': 'connectivityState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AadConnectivityState, self).__init__(**kwargs) - self.connectivity_state = kwargs.get('connectivity_state', None) - - -class ExternalSecuritySolutionKind(msrest.serialization.Model): - """Describes an Azure resource with kind. - - :param kind: The kind of the external solution. Possible values include: "CEF", "ATA", "AAD". - :type kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum - """ - - _attribute_map = { - 'kind': {'key': 'kind', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExternalSecuritySolutionKind, self).__init__(**kwargs) - self.kind = kwargs.get('kind', None) - - -class Location(msrest.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 - ): - super(Location, self).__init__(**kwargs) - self.location = None - - -class Resource(msrest.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 - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ExternalSecuritySolution(Resource, Location, ExternalSecuritySolutionKind): - """Represents a security solution external to Azure Security Center which sends information to an OMS workspace and whose data is displayed by Azure Security Center. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param kind: The kind of the external solution. Possible values include: "CEF", "ATA", "AAD". - :type kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum - :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 = { - 'location': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - '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, - **kwargs - ): - super(ExternalSecuritySolution, self).__init__(**kwargs) - self.kind = kwargs.get('kind', None) - self.location = None - self.kind = kwargs.get('kind', None) - self.id = None - self.name = None - self.type = None - self.location = None - 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. - - :param kind: The kind of the external solution. Possible values include: "CEF", "ATA", "AAD". - :type kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum - :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 - :param properties: The external security solution properties for AAD solutions. - :type properties: ~azure.mgmt.security.models.AadSolutionProperties - """ - - _validation = { - 'location': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - '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'}, - 'properties': {'key': 'properties', 'type': 'AadSolutionProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(AadExternalSecuritySolution, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class ExternalSecuritySolutionProperties(msrest.serialization.Model): - """The solution properties (correspond to the solution kind). - - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type additional_properties: dict[str, any] - :param device_vendor: - :type device_vendor: str - :param device_type: - :type device_type: str - :param workspace: Represents an OMS workspace to which the solution is connected. - :type 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, - **kwargs - ): - super(ExternalSecuritySolutionProperties, self).__init__(**kwargs) - self.additional_properties = kwargs.get('additional_properties', None) - self.device_vendor = kwargs.get('device_vendor', None) - self.device_type = kwargs.get('device_type', None) - self.workspace = kwargs.get('workspace', None) - - -class AadSolutionProperties(ExternalSecuritySolutionProperties, AadConnectivityState): - """The external security solution properties for AAD solutions. - - :param connectivity_state: The connectivity state of the external AAD solution. Possible values - include: "Discovered", "NotLicensed", "Connected". - :type connectivity_state: str or ~azure.mgmt.security.models.AadConnectivityStateEnum - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type additional_properties: dict[str, any] - :param device_vendor: - :type device_vendor: str - :param device_type: - :type device_type: str - :param workspace: Represents an OMS workspace to which the solution is connected. - :type 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, - **kwargs - ): - super(AadSolutionProperties, self).__init__(**kwargs) - self.connectivity_state = kwargs.get('connectivity_state', None) - self.additional_properties = kwargs.get('additional_properties', None) - self.device_vendor = kwargs.get('device_vendor', None) - self.device_type = kwargs.get('device_type', None) - self.workspace = kwargs.get('workspace', None) - - -class CustomAlertRule(msrest.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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type 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, - **kwargs - ): - super(CustomAlertRule, self).__init__(**kwargs) - self.display_name = None - self.description = None - self.is_enabled = kwargs['is_enabled'] - self.rule_type = None # type: Optional[str] - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type 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, - **kwargs - ): - super(ThresholdCustomAlertRule, self).__init__(**kwargs) - self.rule_type = 'ThresholdCustomAlertRule' # type: str - self.min_threshold = kwargs['min_threshold'] - self.max_threshold = kwargs['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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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, - **kwargs - ): - super(TimeWindowCustomAlertRule, self).__init__(**kwargs) - self.rule_type = 'TimeWindowCustomAlertRule' # type: str - self.time_window_size = kwargs['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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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, - **kwargs - ): - super(ActiveConnectionsNotInAllowedRange, self).__init__(**kwargs) - self.rule_type = 'ActiveConnectionsNotInAllowedRange' # type: str - - -class AdaptiveApplicationControlGroup(Resource, Location): - """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 - :param enforcement_mode: The application control policy enforcement/protection mode of the - machine group. Possible values include: "Audit", "Enforce", "None". - :type enforcement_mode: str or ~azure.mgmt.security.models.EnforcementMode - :param protection_mode: The protection mode of the collection/file types. Exe/Msi/Script are - used for Windows, Executable is used for Linux. - :type protection_mode: ~azure.mgmt.security.models.ProtectionMode - :ivar configuration_status: The configuration status of the machines group or machine or rule. - Possible values include: "Configured", "NotConfigured", "InProgress", "Failed", "NoStatus". - :vartype configuration_status: str or ~azure.mgmt.security.models.ConfigurationStatus - :ivar recommendation_status: The initial recommendation status of the machine group or machine. - Possible values include: "Recommended", "NotRecommended", "NotAvailable", "NoStatus". - :vartype recommendation_status: str or ~azure.mgmt.security.models.RecommendationStatus - :ivar issues: - :vartype issues: list[~azure.mgmt.security.models.AdaptiveApplicationControlIssueSummary] - :ivar source_system: The source type of the machine group. Possible values include: - "Azure_AppLocker", "Azure_AuditD", "NonAzure_AppLocker", "NonAzure_AuditD", "None". - :vartype source_system: str or ~azure.mgmt.security.models.SourceSystem - :param vm_recommendations: - :type vm_recommendations: list[~azure.mgmt.security.models.VmRecommendation] - :param path_recommendations: - :type path_recommendations: list[~azure.mgmt.security.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, - **kwargs - ): - super(AdaptiveApplicationControlGroup, self).__init__(**kwargs) - self.location = None - self.enforcement_mode = kwargs.get('enforcement_mode', None) - self.protection_mode = kwargs.get('protection_mode', None) - self.configuration_status = None - self.recommendation_status = None - self.issues = None - self.source_system = None - self.vm_recommendations = kwargs.get('vm_recommendations', None) - self.path_recommendations = kwargs.get('path_recommendations', None) - self.id = None - self.name = None - self.type = None - self.enforcement_mode = kwargs.get('enforcement_mode', None) - self.protection_mode = kwargs.get('protection_mode', None) - self.configuration_status = None - self.recommendation_status = None - self.issues = None - self.source_system = None - self.vm_recommendations = kwargs.get('vm_recommendations', None) - self.path_recommendations = kwargs.get('path_recommendations', None) - - -class AdaptiveApplicationControlGroups(msrest.serialization.Model): - """Represents a list of machine groups and set of rules that are recommended by Azure Security Center to be allowed. - - :param value: - :type value: list[~azure.mgmt.security.models.AdaptiveApplicationControlGroup] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AdaptiveApplicationControlGroup]'}, - } - - def __init__( - self, - **kwargs - ): - super(AdaptiveApplicationControlGroups, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class AdaptiveApplicationControlIssueSummary(msrest.serialization.Model): - """Represents a summary of the alerts of the machine group. - - :param issue: An alert that machines within a group can have. Possible values include: - "ViolationsAudited", "ViolationsBlocked", "MsiAndScriptViolationsAudited", - "MsiAndScriptViolationsBlocked", "ExecutableViolationsAudited", "RulesViolatedManually". - :type issue: str or ~azure.mgmt.security.models.AdaptiveApplicationControlIssue - :param number_of_vms: The number of machines in the group that have this alert. - :type number_of_vms: float - """ - - _attribute_map = { - 'issue': {'key': 'issue', 'type': 'str'}, - 'number_of_vms': {'key': 'numberOfVms', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(AdaptiveApplicationControlIssueSummary, self).__init__(**kwargs) - self.issue = kwargs.get('issue', None) - self.number_of_vms = kwargs.get('number_of_vms', None) - - -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 - :param rules: The security rules which are recommended to be effective on the VM. - :type rules: list[~azure.mgmt.security.models.Rule] - :param rules_calculation_time: The UTC time on which the rules were calculated. - :type rules_calculation_time: ~datetime.datetime - :param effective_network_security_groups: The Network Security Groups effective on the network - interfaces of the protected resource. - :type effective_network_security_groups: - list[~azure.mgmt.security.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, - **kwargs - ): - super(AdaptiveNetworkHardening, self).__init__(**kwargs) - self.rules = kwargs.get('rules', None) - self.rules_calculation_time = kwargs.get('rules_calculation_time', None) - self.effective_network_security_groups = kwargs.get('effective_network_security_groups', None) - - -class AdaptiveNetworkHardeningEnforceRequest(msrest.serialization.Model): - """AdaptiveNetworkHardeningEnforceRequest. - - All required parameters must be populated in order to send to Azure. - - :param rules: Required. The rules to enforce. - :type rules: list[~azure.mgmt.security.models.Rule] - :param network_security_groups: Required. 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. - :type 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, - **kwargs - ): - super(AdaptiveNetworkHardeningEnforceRequest, self).__init__(**kwargs) - self.rules = kwargs['rules'] - self.network_security_groups = kwargs['network_security_groups'] - - -class AdaptiveNetworkHardeningsList(msrest.serialization.Model): - """Response for ListAdaptiveNetworkHardenings API service call. - - :param value: A list of Adaptive Network Hardenings resources. - :type value: list[~azure.mgmt.security.models.AdaptiveNetworkHardening] - :param next_link: The URL to get the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AdaptiveNetworkHardening]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AdaptiveNetworkHardeningsList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class AdditionalData(msrest.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 Azure. - - :param assessed_resource_type: Required. Sub-assessment resource type.Constant filled by - server. Possible values include: "SqlServerVulnerability", "ContainerRegistryVulnerability", - "ServerVulnerability". - :type 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 - ): - super(AdditionalData, self).__init__(**kwargs) - self.assessed_resource_type = None # type: Optional[str] - - -class AdditionalWorkspacesProperties(msrest.serialization.Model): - """Properties of the additional workspaces. - - :param workspace: Workspace resource id. - :type workspace: str - :param type: Workspace type. Possible values include: "Sentinel". Default value: "Sentinel". - :type type: str or ~azure.mgmt.security.models.AdditionalWorkspaceType - :param data_types: List of data types sent to workspace. - :type 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, - **kwargs - ): - super(AdditionalWorkspacesProperties, self).__init__(**kwargs) - self.workspace = kwargs.get('workspace', None) - self.type = kwargs.get('type', "Sentinel") - self.data_types = kwargs.get('data_types', 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 - :param is_enabled: Indicates whether Advanced Threat Protection is enabled. - :type 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, - **kwargs - ): - super(AdvancedThreatProtectionSetting, self).__init__(**kwargs) - self.is_enabled = kwargs.get('is_enabled', None) - - -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 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. - Possible values include: "Informational", "Low", "Medium", "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. Possible values include: - "Unknown", "PreAttack", "InitialAccess", "Persistence", "PrivilegeEscalation", - "DefenseEvasion", "CredentialAccess", "Discovery", "LateralMovement", "Execution", - "Collection", "Exfiltration", "CommandAndControl", "Impact", "Probing", "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. Possible values include: "Active", - "Resolved", "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 (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.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 - :param extended_properties: Custom properties for the alert. - :type 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__( - self, - **kwargs - ): - super(Alert, self).__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 = kwargs.get('extended_properties', None) - self.compromised_entity = None - - -class AlertEntity(msrest.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. - - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type additional_properties: dict[str, any] - :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, - **kwargs - ): - super(AlertEntity, self).__init__(**kwargs) - self.additional_properties = kwargs.get('additional_properties', None) - self.type = None - - -class AlertList(msrest.serialization.Model): - """List of security alerts. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: describes security alert properties. - :type 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, - **kwargs - ): - super(AlertList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class AlertSimulatorRequestProperties(msrest.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 Azure. - - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type additional_properties: dict[str, any] - :param kind: Required. The kind of alert simulation.Constant filled by server. Possible values - include: "Bundles". - :type 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, - **kwargs - ): - super(AlertSimulatorRequestProperties, self).__init__(**kwargs) - self.additional_properties = kwargs.get('additional_properties', None) - self.kind = 'AlertSimulatorRequestProperties' # type: str - - -class AlertSimulatorBundlesRequestProperties(AlertSimulatorRequestProperties): - """Simulate alerts according to this bundles. - - All required parameters must be populated in order to send to Azure. - - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type additional_properties: dict[str, any] - :param kind: Required. The kind of alert simulation.Constant filled by server. Possible values - include: "Bundles". - :type kind: str or ~azure.mgmt.security.models.KindEnum - :param bundles: Bundles list. - :type 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, - **kwargs - ): - super(AlertSimulatorBundlesRequestProperties, self).__init__(**kwargs) - self.kind = 'Bundles' # type: str - self.bundles = kwargs.get('bundles', None) - - -class AlertSimulatorRequestBody(msrest.serialization.Model): - """Alert Simulator request body. - - :param properties: Alert Simulator request body data. - :type properties: ~azure.mgmt.security.models.AlertSimulatorRequestProperties - """ - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'AlertSimulatorRequestProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertSimulatorRequestBody, self).__init__(**kwargs) - self.properties = kwargs.get('properties', 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 - :param alert_type: Type of the alert to automatically suppress. For all alert types, use '*'. - :type alert_type: str - :ivar last_modified_utc: The last time this rule was modified. - :vartype last_modified_utc: ~datetime.datetime - :param expiration_date_utc: Expiration date of the rule, if value is not provided or provided - as null this field will default to the maximum allowed expiration date. - :type expiration_date_utc: ~datetime.datetime - :param reason: The reason for dismissing the alert. - :type reason: str - :param state: Possible states of the rule. Possible values include: "Enabled", "Disabled", - "Expired". - :type state: str or ~azure.mgmt.security.models.RuleState - :param comment: Any comment regarding the rule. - :type comment: str - :param suppression_alerts_scope: The suppression conditions. - :type 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, - **kwargs - ): - super(AlertsSuppressionRule, self).__init__(**kwargs) - self.alert_type = kwargs.get('alert_type', None) - self.last_modified_utc = None - self.expiration_date_utc = kwargs.get('expiration_date_utc', None) - self.reason = kwargs.get('reason', None) - self.state = kwargs.get('state', None) - self.comment = kwargs.get('comment', None) - self.suppression_alerts_scope = kwargs.get('suppression_alerts_scope', None) - - -class AlertsSuppressionRulesList(msrest.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 Azure. - - :param value: Required. - :type 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, - **kwargs - ): - super(AlertsSuppressionRulesList, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = 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 Azure. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param kind: Required. the kind of the settings string.Constant filled by server. Possible - values include: "DataExportSettings", "AlertSuppressionSetting", "AlertSyncSettings". - :type 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 - ): - super(Setting, self).__init__(**kwargs) - self.kind = 'Setting' # type: str - - -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 Azure. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param kind: Required. the kind of the settings string.Constant filled by server. Possible - values include: "DataExportSettings", "AlertSuppressionSetting", "AlertSyncSettings". - :type kind: str or ~azure.mgmt.security.models.SettingKind - :param enabled: Is the alert sync setting enabled. - :type 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, - **kwargs - ): - super(AlertSyncSettings, self).__init__(**kwargs) - self.kind = 'AlertSyncSettings' # type: str - self.enabled = kwargs.get('enabled', None) - - -class AllowedConnectionsList(msrest.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 - ): - super(AllowedConnectionsList, self).__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.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 - ): - super(AllowedConnectionsResource, self).__init__(**kwargs) - self.location = None - self.calculated_date_time = None - self.connectable_resources = None - self.id = None - self.name = None - self.type = None - self.calculated_date_time = None - self.connectable_resources = 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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :ivar value_type: The value type of the items in the list. Possible values include: "IpCidr", - "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, - **kwargs - ): - super(ListCustomAlertRule, self).__init__(**kwargs) - self.rule_type = 'ListCustomAlertRule' # type: str - 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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :ivar value_type: The value type of the items in the list. Possible values include: "IpCidr", - "String". - :vartype value_type: str or ~azure.mgmt.security.models.ValueType - :param allowlist_values: Required. The values to allow. The format of the values depends on the - rule type. - :type 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, - **kwargs - ): - super(AllowlistCustomAlertRule, self).__init__(**kwargs) - self.rule_type = 'AllowlistCustomAlertRule' # type: str - self.allowlist_values = kwargs['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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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, - **kwargs - ): - super(AmqpC2DMessagesNotInAllowedRange, self).__init__(**kwargs) - self.rule_type = 'AmqpC2DMessagesNotInAllowedRange' # type: str - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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, - **kwargs - ): - super(AmqpC2DRejectedMessagesNotInAllowedRange, self).__init__(**kwargs) - self.rule_type = 'AmqpC2DRejectedMessagesNotInAllowedRange' # type: str - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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, - **kwargs - ): - super(AmqpD2CMessagesNotInAllowedRange, self).__init__(**kwargs) - self.rule_type = 'AmqpD2CMessagesNotInAllowedRange' # type: str - - -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 - :param properties: Any object. - :type properties: any - """ - - _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, - **kwargs - ): - super(AscLocation, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class AscLocationList(msrest.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 - ): - super(AscLocationList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class AssessmentLinks(msrest.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 - ): - super(AssessmentLinks, self).__init__(**kwargs) - self.azure_portal_uri = None - - -class AssessmentStatus(msrest.serialization.Model): - """The result of the assessment. - - All required parameters must be populated in order to send to Azure. - - :param code: Required. Programmatic code for the status of the assessment. Possible values - include: "Healthy", "Unhealthy", "NotApplicable". - :type code: str or ~azure.mgmt.security.models.AssessmentStatusCode - :param cause: Programmatic code for the cause of the assessment status. - :type cause: str - :param description: Human readable description of the assessment status. - :type 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, - **kwargs - ): - super(AssessmentStatus, self).__init__(**kwargs) - self.code = kwargs['code'] - self.cause = kwargs.get('cause', None) - self.description = kwargs.get('description', None) - - -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. - - :param kind: The kind of the external solution. Possible values include: "CEF", "ATA", "AAD". - :type kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum - :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 - :param properties: The external security solution properties for ATA solutions. - :type properties: ~azure.mgmt.security.models.AtaSolutionProperties - """ - - _validation = { - 'location': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - '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'}, - 'properties': {'key': 'properties', 'type': 'AtaSolutionProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(AtaExternalSecuritySolution, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class AtaSolutionProperties(ExternalSecuritySolutionProperties): - """The external security solution properties for ATA solutions. - - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type additional_properties: dict[str, any] - :param device_vendor: - :type device_vendor: str - :param device_type: - :type device_type: str - :param workspace: Represents an OMS workspace to which the solution is connected. - :type workspace: ~azure.mgmt.security.models.ConnectedWorkspace - :param last_event_received: - :type 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, - **kwargs - ): - super(AtaSolutionProperties, self).__init__(**kwargs) - self.last_event_received = kwargs.get('last_event_received', None) - - -class AuthenticationDetailsProperties(msrest.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 Azure. - - :ivar authentication_provisioning_state: State of the multi-cloud connector. Possible values - include: "Valid", "Invalid", "Expired", "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] - :param authentication_type: Required. Connect to your cloud account, for AWS use either account - credentials or role-based authentication. For GCP use account organization credentials.Constant - filled by server. Possible values include: "awsCreds", "awsAssumeRole", "gcpCredentials". - :type 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 - ): - super(AuthenticationDetailsProperties, self).__init__(**kwargs) - self.authentication_provisioning_state = None - self.granted_permissions = None - self.authentication_type = None # type: Optional[str] - - -class Tags(msrest.serialization.Model): - """A list of key value pairs that describe the resource. - - :param tags: A set of tags. A list of key value pairs that describe the resource. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Tags, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class ETag(msrest.serialization.Model): - """Entity tag is used for comparing two or more entities from the same requested resource. - - :param etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :type etag: str - """ - - _attribute_map = { - 'etag': {'key': 'etag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ETag, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - - -class Kind(msrest.serialization.Model): - """Describes an Azure resource with kind. - - :param kind: Kind of the resource. - :type kind: str - """ - - _attribute_map = { - 'kind': {'key': 'kind', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Kind, self).__init__(**kwargs) - self.kind = kwargs.get('kind', None) - - -class AzureTrackedResourceLocation(msrest.serialization.Model): - """Describes an Azure resource with location. - - :param location: Location where the resource is stored. - :type location: str - """ - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureTrackedResourceLocation, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - - -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. - - :param tags: A set of tags. A list of key value pairs that describe the resource. - :type tags: dict[str, str] - :param etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :type etag: str - :param kind: Kind of the resource. - :type kind: str - :param location: Location where the resource is stored. - :type 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, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.etag = kwargs.get('etag', None) - self.kind = kwargs.get('kind', None) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.etag = kwargs.get('etag', None) - self.kind = kwargs.get('kind', None) - self.id = None - self.name = None - self.type = None - self.tags = kwargs.get('tags', None) - self.etag = kwargs.get('etag', None) - self.location = kwargs.get('location', None) - self.id = None - self.name = None - self.type = None - self.tags = kwargs.get('tags', None) - self.kind = kwargs.get('kind', None) - self.location = kwargs.get('location', None) - self.id = None - self.name = None - self.type = None - self.etag = kwargs.get('etag', None) - self.kind = kwargs.get('kind', None) - self.location = kwargs.get('location', None) - self.id = None - self.name = None - self.type = None - - -class Automation(TrackedResource): - """The security automation resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param tags: A set of tags. A list of key value pairs that describe the resource. - :type tags: dict[str, str] - :param etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :type etag: str - :param kind: Kind of the resource. - :type kind: str - :param location: Location where the resource is stored. - :type location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param description: The security automation description. - :type description: str - :param is_enabled: Indicates whether the security automation is enabled. - :type is_enabled: bool - :param 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. - :type scopes: list[~azure.mgmt.security.models.AutomationScope] - :param sources: A collection of the source event types which evaluate the security automation - set of rules. - :type sources: list[~azure.mgmt.security.models.AutomationSource] - :param actions: A collection of the actions which are triggered if all the configured rules - evaluations, within at least one rule set, are true. - :type 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, - **kwargs - ): - super(Automation, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.is_enabled = kwargs.get('is_enabled', None) - self.scopes = kwargs.get('scopes', None) - self.sources = kwargs.get('sources', None) - self.actions = kwargs.get('actions', None) - - -class AutomationAction(msrest.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 Azure. - - :param action_type: Required. The type of the action that will be triggered by the - Automation.Constant filled by server. Possible values include: "LogicApp", "EventHub", - "Workspace". - :type 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 - ): - super(AutomationAction, self).__init__(**kwargs) - self.action_type = None # type: Optional[str] - - -class AutomationActionEventHub(AutomationAction): - """The target Event Hub to which event data will be exported. To learn more about Security Center 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 Azure. - - :param action_type: Required. The type of the action that will be triggered by the - Automation.Constant filled by server. Possible values include: "LogicApp", "EventHub", - "Workspace". - :type action_type: str or ~azure.mgmt.security.models.ActionType - :param event_hub_resource_id: The target Event Hub Azure Resource ID. - :type event_hub_resource_id: str - :ivar sas_policy_name: The target Event Hub SAS policy name. - :vartype sas_policy_name: str - :param connection_string: The target Event Hub connection string (it will not be included in - any response). - :type 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, - **kwargs - ): - super(AutomationActionEventHub, self).__init__(**kwargs) - self.action_type = 'EventHub' # type: str - self.event_hub_resource_id = kwargs.get('event_hub_resource_id', None) - self.sas_policy_name = None - self.connection_string = kwargs.get('connection_string', None) - - -class AutomationActionLogicApp(AutomationAction): - """The logic app action that should be triggered. To learn more about Security Center's Workflow Automation capabilities, visit https://aka.ms/ASCWorkflowAutomationLearnMore. - - All required parameters must be populated in order to send to Azure. - - :param action_type: Required. The type of the action that will be triggered by the - Automation.Constant filled by server. Possible values include: "LogicApp", "EventHub", - "Workspace". - :type action_type: str or ~azure.mgmt.security.models.ActionType - :param 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. - :type logic_app_resource_id: str - :param uri: The Logic App trigger URI endpoint (it will not be included in any response). - :type 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, - **kwargs - ): - super(AutomationActionLogicApp, self).__init__(**kwargs) - self.action_type = 'LogicApp' # type: str - self.logic_app_resource_id = kwargs.get('logic_app_resource_id', None) - self.uri = kwargs.get('uri', None) - - -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 Security Center continuous export capabilities, visit https://aka.ms/ASCExportLearnMore. - - All required parameters must be populated in order to send to Azure. - - :param action_type: Required. The type of the action that will be triggered by the - Automation.Constant filled by server. Possible values include: "LogicApp", "EventHub", - "Workspace". - :type action_type: str or ~azure.mgmt.security.models.ActionType - :param workspace_resource_id: The fully qualified Log Analytics Workspace Azure Resource ID. - :type 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, - **kwargs - ): - super(AutomationActionWorkspace, self).__init__(**kwargs) - self.action_type = 'Workspace' # type: str - self.workspace_resource_id = kwargs.get('workspace_resource_id', None) - - -class AutomationList(msrest.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 Azure. - - :param value: Required. The list of security automations under the given scope. - :type 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, - **kwargs - ): - super(AutomationList, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = None - - -class AutomationRuleSet(msrest.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. - - :param rules: - :type rules: list[~azure.mgmt.security.models.AutomationTriggeringRule] - """ - - _attribute_map = { - 'rules': {'key': 'rules', 'type': '[AutomationTriggeringRule]'}, - } - - def __init__( - self, - **kwargs - ): - super(AutomationRuleSet, self).__init__(**kwargs) - self.rules = kwargs.get('rules', None) - - -class AutomationScope(msrest.serialization.Model): - """A single automation scope. - - :param description: The resources scope description. - :type description: str - :param 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). - :type scope_path: str - """ - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'scope_path': {'key': 'scopePath', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutomationScope, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.scope_path = kwargs.get('scope_path', None) - - -class AutomationSource(msrest.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. - - :param event_source: A valid event source type. Possible values include: "Assessments", - "SubAssessments", "Alerts", "SecureScores", "SecureScoresSnapshot", "SecureScoreControls", - "SecureScoreControlsSnapshot", "RegulatoryComplianceAssessment", - "RegulatoryComplianceAssessmentSnapshot". - :type event_source: str or ~azure.mgmt.security.models.EventSource - :param rule_sets: A set of rules which evaluate upon event interception. A logical disjunction - is applied between defined rule sets (logical 'or'). - :type 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, - **kwargs - ): - super(AutomationSource, self).__init__(**kwargs) - self.event_source = kwargs.get('event_source', None) - self.rule_sets = kwargs.get('rule_sets', None) - - -class AutomationTriggeringRule(msrest.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. - - :param property_j_path: The JPath of the entity model property that should be checked. - :type property_j_path: str - :param property_type: The data type of the compared operands (string, integer, floating point - number or a boolean [true/false]]. Possible values include: "String", "Integer", "Number", - "Boolean". - :type property_type: str or ~azure.mgmt.security.models.PropertyType - :param expected_value: The expected value. - :type expected_value: str - :param operator: A valid comparer operator to use. A case-insensitive comparison will be - applied for String PropertyType. Possible values include: "Equals", "GreaterThan", - "GreaterThanOrEqualTo", "LesserThan", "LesserThanOrEqualTo", "NotEquals", "Contains", - "StartsWith", "EndsWith". - :type 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, - **kwargs - ): - super(AutomationTriggeringRule, self).__init__(**kwargs) - self.property_j_path = kwargs.get('property_j_path', None) - self.property_type = kwargs.get('property_type', None) - self.expected_value = kwargs.get('expected_value', None) - self.operator = kwargs.get('operator', None) - - -class AutomationValidationStatus(msrest.serialization.Model): - """The security automation model state property bag. - - :param is_valid: Indicates whether the model is valid or not. - :type is_valid: bool - :param message: The validation message. - :type message: str - """ - - _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutomationValidationStatus, self).__init__(**kwargs) - self.is_valid = kwargs.get('is_valid', None) - self.message = kwargs.get('message', 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 - :param auto_provision: Describes what kind of security agent provisioning action to take. - Possible values include: "On", "Off". - :type 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, - **kwargs - ): - super(AutoProvisioningSetting, self).__init__(**kwargs) - self.auto_provision = kwargs.get('auto_provision', None) - - -class AutoProvisioningSettingList(msrest.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. - - :param value: List of all the auto provisioning settings. - :type 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, - **kwargs - ): - super(AutoProvisioningSettingList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class AwAssumeRoleAuthenticationDetailsProperties(AuthenticationDetailsProperties): - """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 Azure. - - :ivar authentication_provisioning_state: State of the multi-cloud connector. Possible values - include: "Valid", "Invalid", "Expired", "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] - :param authentication_type: Required. Connect to your cloud account, for AWS use either account - credentials or role-based authentication. For GCP use account organization credentials.Constant - filled by server. Possible values include: "awsCreds", "awsAssumeRole", "gcpCredentials". - :type authentication_type: str or ~azure.mgmt.security.models.AuthenticationType - :ivar account_id: The ID of the cloud account. - :vartype account_id: str - :param aws_assume_role_arn: Required. Assumed role ID is an identifier that you can use to - create temporary security credentials. - :type aws_assume_role_arn: str - :param aws_external_id: Required. A unique identifier that is required when you assume a role - in another account. - :type 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, - **kwargs - ): - super(AwAssumeRoleAuthenticationDetailsProperties, self).__init__(**kwargs) - self.authentication_type = 'awsAssumeRole' # type: str - self.account_id = None - self.aws_assume_role_arn = kwargs['aws_assume_role_arn'] - self.aws_external_id = kwargs['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 Azure. - - :ivar authentication_provisioning_state: State of the multi-cloud connector. Possible values - include: "Valid", "Invalid", "Expired", "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] - :param authentication_type: Required. Connect to your cloud account, for AWS use either account - credentials or role-based authentication. For GCP use account organization credentials.Constant - filled by server. Possible values include: "awsCreds", "awsAssumeRole", "gcpCredentials". - :type authentication_type: str or ~azure.mgmt.security.models.AuthenticationType - :ivar account_id: The ID of the cloud account. - :vartype account_id: str - :param aws_access_key_id: Required. Public key element of the AWS credential object (write - only). - :type aws_access_key_id: str - :param aws_secret_access_key: Required. Secret key element of the AWS credential object (write - only). - :type 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, - **kwargs - ): - super(AwsCredsAuthenticationDetailsProperties, self).__init__(**kwargs) - self.authentication_type = 'awsCreds' # type: str - self.account_id = None - self.aws_access_key_id = kwargs['aws_access_key_id'] - self.aws_secret_access_key = kwargs['aws_secret_access_key'] - - -class ResourceDetails(msrest.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 Azure. - - :param source: Required. The platform where the assessed resource resides.Constant filled by - server. Possible values include: "Azure", "OnPremise", "OnPremiseSql". - :type 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 - ): - super(ResourceDetails, self).__init__(**kwargs) - self.source = None # type: Optional[str] - - -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 Azure. - - :param source: Required. The platform where the assessed resource resides.Constant filled by - server. Possible values include: "Azure", "OnPremise", "OnPremiseSql". - :type 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 - ): - super(AzureResourceDetails, self).__init__(**kwargs) - self.source = 'Azure' # type: str - self.id = None - - -class ResourceIdentifier(msrest.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 Azure. - - :param type: Required. There can be multiple identifiers of different type per alert, this - field specify the identifier type.Constant filled by server. Possible values include: - "AzureResource", "LogAnalytics". - :type 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 - ): - super(ResourceIdentifier, self).__init__(**kwargs) - self.type = None # type: Optional[str] - - -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 Azure. - - :param type: Required. There can be multiple identifiers of different type per alert, this - field specify the identifier type.Constant filled by server. Possible values include: - "AzureResource", "LogAnalytics". - :type 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 - ): - super(AzureResourceIdentifier, self).__init__(**kwargs) - self.type = 'AzureResource' # type: str - self.azure_resource_id = None - - -class AzureResourceLink(msrest.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 - ): - super(AzureResourceLink, self).__init__(**kwargs) - self.id = None - - -class Baseline(msrest.serialization.Model): - """Baseline details. - - :param expected_results: Expected results. - :type expected_results: list[list[str]] - :param updated_time: Baseline update time (UTC). - :type updated_time: ~datetime.datetime - """ - - _attribute_map = { - 'expected_results': {'key': 'expectedResults', 'type': '[[str]]'}, - 'updated_time': {'key': 'updatedTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(Baseline, self).__init__(**kwargs) - self.expected_results = kwargs.get('expected_results', None) - self.updated_time = kwargs.get('updated_time', None) - - -class BaselineAdjustedResult(msrest.serialization.Model): - """The rule result adjusted with baseline. - - :param baseline: Baseline details. - :type baseline: ~azure.mgmt.security.models.Baseline - :param status: The rule result status. Possible values include: "NonFinding", "Finding", - "InternalError". - :type status: str or ~azure.mgmt.security.models.RuleStatus - :param results_not_in_baseline: Results the are not in baseline. - :type results_not_in_baseline: list[list[str]] - :param results_only_in_baseline: Results the are in baseline. - :type 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, - **kwargs - ): - super(BaselineAdjustedResult, self).__init__(**kwargs) - self.baseline = kwargs.get('baseline', None) - self.status = kwargs.get('status', None) - self.results_not_in_baseline = kwargs.get('results_not_in_baseline', None) - self.results_only_in_baseline = kwargs.get('results_only_in_baseline', None) - - -class BenchmarkReference(msrest.serialization.Model): - """The benchmark references. - - :param benchmark: The benchmark name. - :type benchmark: str - :param reference: The benchmark reference. - :type reference: str - """ - - _attribute_map = { - 'benchmark': {'key': 'benchmark', 'type': 'str'}, - 'reference': {'key': 'reference', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BenchmarkReference, self).__init__(**kwargs) - self.benchmark = kwargs.get('benchmark', None) - self.reference = kwargs.get('reference', 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. - - :param kind: The kind of the external solution. Possible values include: "CEF", "ATA", "AAD". - :type kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum - :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 - :param properties: The external security solution properties for CEF solutions. - :type properties: ~azure.mgmt.security.models.CefSolutionProperties - """ - - _validation = { - 'location': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - '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'}, - 'properties': {'key': 'properties', 'type': 'CefSolutionProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(CefExternalSecuritySolution, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class CefSolutionProperties(ExternalSecuritySolutionProperties): - """The external security solution properties for CEF solutions. - - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type additional_properties: dict[str, any] - :param device_vendor: - :type device_vendor: str - :param device_type: - :type device_type: str - :param workspace: Represents an OMS workspace to which the solution is connected. - :type workspace: ~azure.mgmt.security.models.ConnectedWorkspace - :param hostname: - :type hostname: str - :param agent: - :type agent: str - :param last_event_received: - :type 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, - **kwargs - ): - super(CefSolutionProperties, self).__init__(**kwargs) - self.hostname = kwargs.get('hostname', None) - self.agent = kwargs.get('agent', None) - self.last_event_received = kwargs.get('last_event_received', None) - - -class CloudErrorBody(msrest.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 - ): - super(CloudErrorBody, self).__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.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 - ): - super(Compliance, self).__init__(**kwargs) - self.assessment_timestamp_utc_date = None - self.resource_count = None - self.assessment_result = None - - -class ComplianceList(msrest.serialization.Model): - """List of Compliance objects response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of Compliance objects. - :type 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, - **kwargs - ): - super(ComplianceList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = 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. Possible - values include: "Healthy", "NotApplicable", "OffByPolicy", "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 - ): - super(ComplianceResult, self).__init__(**kwargs) - self.resource_status = None - - -class ComplianceResultList(msrest.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 Azure. - - :param value: Required. List of compliance results. - :type 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, - **kwargs - ): - super(ComplianceResultList, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = None - - -class ComplianceSegment(msrest.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 - ): - super(ComplianceSegment, self).__init__(**kwargs) - self.segment_type = None - self.percentage = None - - -class ConnectableResource(msrest.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 - ): - super(ConnectableResource, self).__init__(**kwargs) - self.id = None - self.inbound_connected_resources = None - self.outbound_connected_resources = None - - -class ConnectedResource(msrest.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 - ): - super(ConnectedResource, self).__init__(**kwargs) - self.connected_resource_id = None - self.tcp_ports = None - self.udp_ports = None - - -class ConnectedWorkspace(msrest.serialization.Model): - """Represents an OMS workspace to which the solution is connected. - - :param id: Azure resource ID of the connected OMS workspace. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectedWorkspace, self).__init__(**kwargs) - self.id = kwargs.get('id', 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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :ivar value_type: The value type of the items in the list. Possible values include: "IpCidr", - "String". - :vartype value_type: str or ~azure.mgmt.security.models.ValueType - :param allowlist_values: Required. The values to allow. The format of the values depends on the - rule type. - :type 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, - **kwargs - ): - super(ConnectionFromIpNotAllowed, self).__init__(**kwargs) - self.rule_type = 'ConnectionFromIpNotAllowed' # type: str - - -class ConnectionStrings(msrest.serialization.Model): - """Connection string for ingesting security data and logs. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. Connection strings. - :type value: list[~azure.mgmt.security.models.IngestionConnectionString] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[IngestionConnectionString]'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectionStrings, self).__init__(**kwargs) - self.value = kwargs['value'] - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :ivar value_type: The value type of the items in the list. Possible values include: "IpCidr", - "String". - :vartype value_type: str or ~azure.mgmt.security.models.ValueType - :param allowlist_values: Required. The values to allow. The format of the values depends on the - rule type. - :type 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, - **kwargs - ): - super(ConnectionToIpNotAllowed, self).__init__(**kwargs) - self.rule_type = 'ConnectionToIpNotAllowed' # type: str - - -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 - :param hybrid_compute_settings: Settings for hybrid compute management. These settings are - relevant only for Arc autoProvision (Hybrid Compute). - :type hybrid_compute_settings: ~azure.mgmt.security.models.HybridComputeSettingsProperties - :param authentication_details: Settings for authentication management, these settings are - relevant only for the cloud connector. - :type 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, - **kwargs - ): - super(ConnectorSetting, self).__init__(**kwargs) - self.hybrid_compute_settings = kwargs.get('hybrid_compute_settings', None) - self.authentication_details = kwargs.get('authentication_details', None) - - -class ConnectorSettingList(msrest.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. - - :param value: List of all the cloud account connector settings. - :type 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, - **kwargs - ): - super(ConnectorSettingList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = 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 Azure. - - :param assessed_resource_type: Required. Sub-assessment resource type.Constant filled by - server. Possible values include: "SqlServerVulnerability", "ContainerRegistryVulnerability", - "ServerVulnerability". - :type 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 - ): - super(ContainerRegistryVulnerabilityProperties, self).__init__(**kwargs) - self.assessed_resource_type = 'ContainerRegistryVulnerability' # type: str - 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(msrest.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 - ): - super(CVE, self).__init__(**kwargs) - self.title = None - self.link = None - - -class CVSS(msrest.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 - ): - super(CVSS, self).__init__(**kwargs) - self.base = 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 Azure. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param kind: Required. the kind of the settings string.Constant filled by server. Possible - values include: "DataExportSettings", "AlertSuppressionSetting", "AlertSyncSettings". - :type kind: str or ~azure.mgmt.security.models.SettingKind - :param enabled: Is the data export setting enabled. - :type 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, - **kwargs - ): - super(DataExportSettings, self).__init__(**kwargs) - self.kind = 'DataExportSettings' # type: str - self.enabled = kwargs.get('enabled', None) - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :ivar value_type: The value type of the items in the list. Possible values include: "IpCidr", - "String". - :vartype value_type: str or ~azure.mgmt.security.models.ValueType - :param denylist_values: Required. The values to deny. The format of the values depends on the - rule type. - :type 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, - **kwargs - ): - super(DenylistCustomAlertRule, self).__init__(**kwargs) - self.rule_type = 'DenylistCustomAlertRule' # type: str - self.denylist_values = kwargs['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 - :param threshold_rules: The list of custom alert threshold rules. - :type threshold_rules: list[~azure.mgmt.security.models.ThresholdCustomAlertRule] - :param time_window_rules: The list of custom alert time-window rules. - :type time_window_rules: list[~azure.mgmt.security.models.TimeWindowCustomAlertRule] - :param allowlist_rules: The allow-list custom alert rules. - :type allowlist_rules: list[~azure.mgmt.security.models.AllowlistCustomAlertRule] - :param denylist_rules: The deny-list custom alert rules. - :type 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, - **kwargs - ): - super(DeviceSecurityGroup, self).__init__(**kwargs) - self.threshold_rules = kwargs.get('threshold_rules', None) - self.time_window_rules = kwargs.get('time_window_rules', None) - self.allowlist_rules = kwargs.get('allowlist_rules', None) - self.denylist_rules = kwargs.get('denylist_rules', None) - - -class DeviceSecurityGroupList(msrest.serialization.Model): - """List of device security groups. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of device security group objects. - :type 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, - **kwargs - ): - super(DeviceSecurityGroupList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - 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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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, - **kwargs - ): - super(DirectMethodInvokesNotInAllowedRange, self).__init__(**kwargs) - self.rule_type = 'DirectMethodInvokesNotInAllowedRange' # type: str - - -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 Azure. - - :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 - :param security_family: Required. The security family of the discovered solution. Possible - values include: "Waf", "Ngfw", "SaasWaf", "Va". - :type security_family: str or ~azure.mgmt.security.models.SecurityFamily - :param offer: Required. The security solutions' image offer. - :type offer: str - :param publisher: Required. The security solutions' image publisher. - :type publisher: str - :param sku: Required. The security solutions' image sku. - :type 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, - **kwargs - ): - super(DiscoveredSecuritySolution, self).__init__(**kwargs) - self.location = None - self.security_family = kwargs['security_family'] - self.offer = kwargs['offer'] - self.publisher = kwargs['publisher'] - self.sku = kwargs['sku'] - self.id = None - self.name = None - self.type = None - self.security_family = kwargs['security_family'] - self.offer = kwargs['offer'] - self.publisher = kwargs['publisher'] - self.sku = kwargs['sku'] - - -class DiscoveredSecuritySolutionList(msrest.serialization.Model): - """DiscoveredSecuritySolutionList. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: - :type 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, - **kwargs - ): - super(DiscoveredSecuritySolutionList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class EffectiveNetworkSecurityGroups(msrest.serialization.Model): - """Describes the Network Security Groups effective on a network interface. - - :param network_interface: The Azure resource ID of the network interface. - :type network_interface: str - :param network_security_groups: The Network Security Groups effective on the network interface. - :type network_security_groups: list[str] - """ - - _attribute_map = { - 'network_interface': {'key': 'networkInterface', 'type': 'str'}, - 'network_security_groups': {'key': 'networkSecurityGroups', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(EffectiveNetworkSecurityGroups, self).__init__(**kwargs) - self.network_interface = kwargs.get('network_interface', None) - self.network_security_groups = kwargs.get('network_security_groups', None) - - -class ErrorAdditionalInfo(msrest.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: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ExternalSecuritySolutionList(msrest.serialization.Model): - """ExternalSecuritySolutionList. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: - :type 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, - **kwargs - ): - super(ExternalSecuritySolutionList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = 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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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, - **kwargs - ): - super(FailedLocalLoginsNotInAllowedRange, self).__init__(**kwargs) - self.rule_type = 'FailedLocalLoginsNotInAllowedRange' # type: str - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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, - **kwargs - ): - super(FileUploadsNotInAllowedRange, self).__init__(**kwargs) - self.rule_type = 'FileUploadsNotInAllowedRange' # type: str - - -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 Azure. - - :ivar authentication_provisioning_state: State of the multi-cloud connector. Possible values - include: "Valid", "Invalid", "Expired", "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] - :param authentication_type: Required. Connect to your cloud account, for AWS use either account - credentials or role-based authentication. For GCP use account organization credentials.Constant - filled by server. Possible values include: "awsCreds", "awsAssumeRole", "gcpCredentials". - :type authentication_type: str or ~azure.mgmt.security.models.AuthenticationType - :param organization_id: Required. The organization ID of the GCP cloud account. - :type organization_id: str - :param type: Required. Type field of the API key (write only). - :type type: str - :param project_id: Required. Project ID field of the API key (write only). - :type project_id: str - :param private_key_id: Required. Private key ID field of the API key (write only). - :type private_key_id: str - :param private_key: Required. Private key field of the API key (write only). - :type private_key: str - :param client_email: Required. Client email field of the API key (write only). - :type client_email: str - :param client_id: Required. Client ID field of the API key (write only). - :type client_id: str - :param auth_uri: Required. Auth URI field of the API key (write only). - :type auth_uri: str - :param token_uri: Required. Token URI field of the API key (write only). - :type token_uri: str - :param auth_provider_x509_cert_url: Required. Auth provider x509 certificate URL field of the - API key (write only). - :type auth_provider_x509_cert_url: str - :param client_x509_cert_url: Required. Client x509 certificate URL field of the API key (write - only). - :type 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, - **kwargs - ): - super(GcpCredentialsDetailsProperties, self).__init__(**kwargs) - self.authentication_type = 'gcpCredentials' # type: str - self.organization_id = kwargs['organization_id'] - self.type = kwargs['type'] - self.project_id = kwargs['project_id'] - self.private_key_id = kwargs['private_key_id'] - self.private_key = kwargs['private_key'] - self.client_email = kwargs['client_email'] - self.client_id = kwargs['client_id'] - self.auth_uri = kwargs['auth_uri'] - self.token_uri = kwargs['token_uri'] - self.auth_provider_x509_cert_url = kwargs['auth_provider_x509_cert_url'] - self.client_x509_cert_url = kwargs['client_x509_cert_url'] - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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, - **kwargs - ): - super(HttpC2DMessagesNotInAllowedRange, self).__init__(**kwargs) - self.rule_type = 'HttpC2DMessagesNotInAllowedRange' # type: str - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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, - **kwargs - ): - super(HttpC2DRejectedMessagesNotInAllowedRange, self).__init__(**kwargs) - self.rule_type = 'HttpC2DRejectedMessagesNotInAllowedRange' # type: str - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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, - **kwargs - ): - super(HttpD2CMessagesNotInAllowedRange, self).__init__(**kwargs) - self.rule_type = 'HttpD2CMessagesNotInAllowedRange' # type: str - - -class HybridComputeSettingsProperties(msrest.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 Azure. - - :ivar hybrid_compute_provisioning_state: State of the service principal and its secret. - Possible values include: "Valid", "Invalid", "Expired". - :vartype hybrid_compute_provisioning_state: str or - ~azure.mgmt.security.models.HybridComputeProvisioningState - :param auto_provision: Required. Whether or not to automatically install Azure Arc (hybrid - compute) agents on machines. Possible values include: "On", "Off". - :type auto_provision: str or ~azure.mgmt.security.models.AutoProvision - :param resource_group_name: The name of the resource group where Arc (Hybrid Compute) - connectors are connected. - :type resource_group_name: str - :param region: The location where the metadata of machines will be stored. - :type region: str - :param 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. - :type proxy_server: ~azure.mgmt.security.models.ProxyServerProperties - :param service_principal: An object to access resources that are secured by an Azure AD tenant. - :type 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, - **kwargs - ): - super(HybridComputeSettingsProperties, self).__init__(**kwargs) - self.hybrid_compute_provisioning_state = None - self.auto_provision = kwargs['auto_provision'] - self.resource_group_name = kwargs.get('resource_group_name', None) - self.region = kwargs.get('region', None) - self.proxy_server = kwargs.get('proxy_server', None) - self.service_principal = kwargs.get('service_principal', None) - - -class InformationProtectionKeyword(msrest.serialization.Model): - """The information type keyword. - - :param pattern: The keyword pattern. - :type pattern: str - :param custom: Indicates whether the keyword is custom or not. - :type custom: bool - :param can_be_numeric: Indicates whether the keyword can be applied on numeric types or not. - :type can_be_numeric: bool - :param excluded: Indicates whether the keyword is excluded or not. - :type 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, - **kwargs - ): - super(InformationProtectionKeyword, self).__init__(**kwargs) - self.pattern = kwargs.get('pattern', None) - self.custom = kwargs.get('custom', None) - self.can_be_numeric = kwargs.get('can_be_numeric', None) - self.excluded = kwargs.get('excluded', None) - - -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 - :param labels: Dictionary of sensitivity labels. - :type labels: dict[str, ~azure.mgmt.security.models.SensitivityLabel] - :param information_types: The sensitivity information types. - :type 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, - **kwargs - ): - super(InformationProtectionPolicy, self).__init__(**kwargs) - self.last_modified_utc = None - self.version = None - self.labels = kwargs.get('labels', None) - self.information_types = kwargs.get('information_types', None) - - -class InformationProtectionPolicyList(msrest.serialization.Model): - """Information protection policies response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of information protection policies. - :type 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, - **kwargs - ): - super(InformationProtectionPolicyList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class InformationType(msrest.serialization.Model): - """The information type. - - :param display_name: The name of the information type. - :type display_name: str - :param description: The description of the information type. - :type description: str - :param order: The order of the information type. - :type order: int - :param recommended_label_id: The recommended label id to be associated with this information - type. - :type recommended_label_id: str - :param enabled: Indicates whether the information type is enabled or not. - :type enabled: bool - :param custom: Indicates whether the information type is custom or not. - :type custom: bool - :param keywords: The information type keywords. - :type 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, - **kwargs - ): - super(InformationType, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.description = kwargs.get('description', None) - self.order = kwargs.get('order', None) - self.recommended_label_id = kwargs.get('recommended_label_id', None) - self.enabled = kwargs.get('enabled', None) - self.custom = kwargs.get('custom', None) - self.keywords = kwargs.get('keywords', None) - - -class IngestionConnectionString(msrest.serialization.Model): - """Connection string for ingesting security data and logs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: The region where ingested logs and data resides. - :vartype location: str - :ivar value: Connection string value. - :vartype value: str - """ - - _validation = { - 'location': {'readonly': True}, - 'value': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IngestionConnectionString, self).__init__(**kwargs) - self.location = None - self.value = None - - -class IngestionSetting(Resource): - """Configures how to correlate scan data and logs with resources associated with the subscription. - - 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 - :param properties: Ingestion setting data. - :type properties: any - """ - - _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, - **kwargs - ): - super(IngestionSetting, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class IngestionSettingList(msrest.serialization.Model): - """List of ingestion settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of ingestion settings. - :vartype value: list[~azure.mgmt.security.models.IngestionSetting] - :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': '[IngestionSetting]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IngestionSettingList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class IngestionSettingToken(msrest.serialization.Model): - """Configures how to correlate scan data and logs with resources associated with the subscription. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar token: The token is used for correlating security data and logs with the resources in the - subscription. - :vartype token: str - """ - - _validation = { - 'token': {'readonly': True}, - } - - _attribute_map = { - 'token': {'key': 'token', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IngestionSettingToken, self).__init__(**kwargs) - self.token = None - - -class TagsResource(msrest.serialization.Model): - """A container holding only the Tags for a resource, allowing the user to update the tags. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TagsResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class IoTSecurityAggregatedAlert(Resource, TagsResource): - """Security Solution Aggregated Alert information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param tags: A set of tags. Resource tags. - :type 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. Possible values include: "Informational", - "Low", "Medium", "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: long - :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': 'long'}, - '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, - **kwargs - ): - super(IoTSecurityAggregatedAlert, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - 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 - 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 - - -class IoTSecurityAggregatedAlertList(msrest.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 Azure. - - :param value: Required. List of aggregated alerts data. - :type 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, - **kwargs - ): - super(IoTSecurityAggregatedAlertList, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = None - - -class IoTSecurityAggregatedAlertPropertiesTopDevicesListItem(msrest.serialization.Model): - """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: long - :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': 'long'}, - 'last_occurrence': {'key': 'lastOccurrence', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTSecurityAggregatedAlertPropertiesTopDevicesListItem, self).__init__(**kwargs) - self.device_id = None - self.alerts_count = None - self.last_occurrence = 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. - - :param tags: A set of tags. Resource tags. - :type 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 - :param recommendation_name: Name of the recommendation. - :type 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. Possible values include: - "Informational", "Low", "Medium", "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: long - :ivar unhealthy_device_count: Number of unhealthy devices within the IoT Security solution. - :vartype unhealthy_device_count: long - :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': 'long'}, - 'unhealthy_device_count': {'key': 'properties.unhealthyDeviceCount', 'type': 'long'}, - 'log_analytics_query': {'key': 'properties.logAnalyticsQuery', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTSecurityAggregatedRecommendation, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.recommendation_name = kwargs.get('recommendation_name', None) - 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 - self.recommendation_name = kwargs.get('recommendation_name', None) - 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 - - -class IoTSecurityAggregatedRecommendationList(msrest.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 Azure. - - :param value: Required. List of aggregated recommendations data. - :type 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, - **kwargs - ): - super(IoTSecurityAggregatedRecommendationList, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = None - - -class IoTSecurityAlertedDevice(msrest.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: long - """ - - _validation = { - 'device_id': {'readonly': True}, - 'alerts_count': {'readonly': True}, - } - - _attribute_map = { - 'device_id': {'key': 'deviceId', 'type': 'str'}, - 'alerts_count': {'key': 'alertsCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTSecurityAlertedDevice, self).__init__(**kwargs) - self.device_id = None - self.alerts_count = None - - -class IoTSecurityDeviceAlert(msrest.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. Possible values include: "Informational", - "Low", "Medium", "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: long - """ - - _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': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTSecurityDeviceAlert, self).__init__(**kwargs) - self.alert_display_name = None - self.reported_severity = None - self.alerts_count = None - - -class IoTSecurityDeviceRecommendation(msrest.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. Possible values include: - "Informational", "Low", "Medium", "High". - :vartype reported_severity: str or ~azure.mgmt.security.models.ReportedSeverity - :ivar devices_count: Number of devices with this recommendation. - :vartype devices_count: long - """ - - _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': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTSecurityDeviceRecommendation, self).__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.models.IoTSeverityMetrics - :ivar unhealthy_device_count: Number of unhealthy devices within your IoT Security solution. - :vartype unhealthy_device_count: long - :ivar devices_metrics: List of device metrics by the aggregation date. - :vartype devices_metrics: - list[~azure.mgmt.security.models.IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem] - :param top_alerted_devices: List of the 3 devices with the most alerts. - :type top_alerted_devices: list[~azure.mgmt.security.models.IoTSecurityAlertedDevice] - :param most_prevalent_device_alerts: List of the 3 most prevalent device alerts. - :type most_prevalent_device_alerts: list[~azure.mgmt.security.models.IoTSecurityDeviceAlert] - :param most_prevalent_device_recommendations: List of the 3 most prevalent device - recommendations. - :type 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': 'long'}, - '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, - **kwargs - ): - super(IoTSecuritySolutionAnalyticsModel, self).__init__(**kwargs) - self.metrics = None - self.unhealthy_device_count = None - self.devices_metrics = None - self.top_alerted_devices = kwargs.get('top_alerted_devices', None) - self.most_prevalent_device_alerts = kwargs.get('most_prevalent_device_alerts', None) - self.most_prevalent_device_recommendations = kwargs.get('most_prevalent_device_recommendations', None) - - -class IoTSecuritySolutionAnalyticsModelList(msrest.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 Azure. - - :param value: Required. List of Security analytics of your IoT Security solution. - :type 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, - **kwargs - ): - super(IoTSecuritySolutionAnalyticsModelList, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = None - - -class IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem(msrest.serialization.Model): - """IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem. - - :param date: Aggregation of IoT Security solution device alert metrics by date. - :type date: ~datetime.datetime - :param devices_metrics: Device alert count by severity. - :type devices_metrics: ~azure.mgmt.security.models.IoTSeverityMetrics - """ - - _attribute_map = { - 'date': {'key': 'date', 'type': 'iso-8601'}, - 'devices_metrics': {'key': 'devicesMetrics', 'type': 'IoTSeverityMetrics'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem, self).__init__(**kwargs) - self.date = kwargs.get('date', None) - self.devices_metrics = kwargs.get('devices_metrics', None) - - -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. - - :param tags: A set of tags. Resource tags. - :type 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 - :param location: The resource location. - :type location: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.security.models.SystemData - :param workspace: Workspace resource ID. - :type workspace: str - :param display_name: Resource display name. - :type display_name: str - :param status: Status of the IoT Security solution. Possible values include: "Enabled", - "Disabled". Default value: "Enabled". - :type status: str or ~azure.mgmt.security.models.SecuritySolutionStatus - :param export: List of additional options for exporting to workspace data. - :type export: list[str or ~azure.mgmt.security.models.ExportData] - :param disabled_data_sources: Disabled data sources. Disabling these data sources compromises - the system. - :type disabled_data_sources: list[str or ~azure.mgmt.security.models.DataSource] - :param iot_hubs: IoT Hub resource IDs. - :type iot_hubs: list[str] - :param user_defined_resources: Properties of the IoT Security solution's user defined - resources. - :type 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] - :param recommendations_configuration: List of the configuration status for each recommendation - type. - :type recommendations_configuration: - list[~azure.mgmt.security.models.RecommendationConfigurationProperties] - :param unmasked_ip_logging_status: Unmasked IP address logging status. Possible values include: - "Disabled", "Enabled". Default value: "Disabled". - :type unmasked_ip_logging_status: str or ~azure.mgmt.security.models.UnmaskedIpLoggingStatus - :param additional_workspaces: List of additional workspaces. - :type 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, - **kwargs - ): - super(IoTSecuritySolutionModel, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.location = kwargs.get('location', None) - self.system_data = None - self.workspace = kwargs.get('workspace', None) - self.display_name = kwargs.get('display_name', None) - self.status = kwargs.get('status', "Enabled") - self.export = kwargs.get('export', None) - self.disabled_data_sources = kwargs.get('disabled_data_sources', None) - self.iot_hubs = kwargs.get('iot_hubs', None) - self.user_defined_resources = kwargs.get('user_defined_resources', None) - self.auto_discovered_resources = None - self.recommendations_configuration = kwargs.get('recommendations_configuration', None) - self.unmasked_ip_logging_status = kwargs.get('unmasked_ip_logging_status', "Disabled") - self.additional_workspaces = kwargs.get('additional_workspaces', None) - self.id = None - self.name = None - self.type = None - self.location = kwargs.get('location', None) - self.system_data = None - self.workspace = kwargs.get('workspace', None) - self.display_name = kwargs.get('display_name', None) - self.status = kwargs.get('status', "Enabled") - self.export = kwargs.get('export', None) - self.disabled_data_sources = kwargs.get('disabled_data_sources', None) - self.iot_hubs = kwargs.get('iot_hubs', None) - self.user_defined_resources = kwargs.get('user_defined_resources', None) - self.auto_discovered_resources = None - self.recommendations_configuration = kwargs.get('recommendations_configuration', None) - self.unmasked_ip_logging_status = kwargs.get('unmasked_ip_logging_status', "Disabled") - self.additional_workspaces = kwargs.get('additional_workspaces', None) - - -class IoTSecuritySolutionsList(msrest.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 Azure. - - :param value: Required. List of IoT Security solutions. - :type 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, - **kwargs - ): - super(IoTSecuritySolutionsList, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = None - - -class IoTSeverityMetrics(msrest.serialization.Model): - """IoT Security solution analytics severity metrics. - - :param high: Count of high severity alerts/recommendations. - :type high: long - :param medium: Count of medium severity alerts/recommendations. - :type medium: long - :param low: Count of low severity alerts/recommendations. - :type low: long - """ - - _attribute_map = { - 'high': {'key': 'high', 'type': 'long'}, - 'medium': {'key': 'medium', 'type': 'long'}, - 'low': {'key': 'low', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTSeverityMetrics, self).__init__(**kwargs) - self.high = kwargs.get('high', None) - self.medium = kwargs.get('medium', None) - self.low = kwargs.get('low', None) - - -class JitNetworkAccessPoliciesList(msrest.serialization.Model): - """JitNetworkAccessPoliciesList. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: - :type 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, - **kwargs - ): - super(JitNetworkAccessPoliciesList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = 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 Azure. - - :ivar location: Location where the resource is stored. - :vartype location: str - :param kind: Kind of the resource. - :type kind: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param virtual_machines: Required. Configurations for Microsoft.Compute/virtualMachines - resource type. - :type virtual_machines: list[~azure.mgmt.security.models.JitNetworkAccessPolicyVirtualMachine] - :param requests: - :type 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, - **kwargs - ): - super(JitNetworkAccessPolicy, self).__init__(**kwargs) - self.location = None - self.kind = kwargs.get('kind', None) - self.virtual_machines = kwargs['virtual_machines'] - self.requests = kwargs.get('requests', None) - self.provisioning_state = None - self.location = None - self.id = None - self.name = None - self.type = None - self.virtual_machines = kwargs['virtual_machines'] - self.requests = kwargs.get('requests', None) - self.provisioning_state = None - self.kind = kwargs.get('kind', None) - self.id = None - self.name = None - self.type = None - self.virtual_machines = kwargs['virtual_machines'] - self.requests = kwargs.get('requests', None) - self.provisioning_state = None - - -class JitNetworkAccessPolicyInitiatePort(msrest.serialization.Model): - """JitNetworkAccessPolicyInitiatePort. - - All required parameters must be populated in order to send to Azure. - - :param number: Required. - :type number: int - :param allowed_source_address_prefix: Source of the allowed traffic. If omitted, the request - will be for the source IP address of the initiate request. - :type allowed_source_address_prefix: str - :param end_time_utc: Required. The time to close the request in UTC. - :type 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, - **kwargs - ): - super(JitNetworkAccessPolicyInitiatePort, self).__init__(**kwargs) - self.number = kwargs['number'] - self.allowed_source_address_prefix = kwargs.get('allowed_source_address_prefix', None) - self.end_time_utc = kwargs['end_time_utc'] - - -class JitNetworkAccessPolicyInitiateRequest(msrest.serialization.Model): - """JitNetworkAccessPolicyInitiateRequest. - - All required parameters must be populated in order to send to Azure. - - :param virtual_machines: Required. A list of virtual machines & ports to open access for. - :type virtual_machines: - list[~azure.mgmt.security.models.JitNetworkAccessPolicyInitiateVirtualMachine] - :param justification: The justification for making the initiate request. - :type justification: str - """ - - _validation = { - 'virtual_machines': {'required': True}, - } - - _attribute_map = { - 'virtual_machines': {'key': 'virtualMachines', 'type': '[JitNetworkAccessPolicyInitiateVirtualMachine]'}, - 'justification': {'key': 'justification', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(JitNetworkAccessPolicyInitiateRequest, self).__init__(**kwargs) - self.virtual_machines = kwargs['virtual_machines'] - self.justification = kwargs.get('justification', None) - - -class JitNetworkAccessPolicyInitiateVirtualMachine(msrest.serialization.Model): - """JitNetworkAccessPolicyInitiateVirtualMachine. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Resource ID of the virtual machine that is linked to this policy. - :type id: str - :param ports: Required. The ports to open for the resource with the ``id``. - :type 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, - **kwargs - ): - super(JitNetworkAccessPolicyInitiateVirtualMachine, self).__init__(**kwargs) - self.id = kwargs['id'] - self.ports = kwargs['ports'] - - -class JitNetworkAccessPolicyVirtualMachine(msrest.serialization.Model): - """JitNetworkAccessPolicyVirtualMachine. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Resource ID of the virtual machine that is linked to this policy. - :type id: str - :param ports: Required. Port configurations for the virtual machine. - :type ports: list[~azure.mgmt.security.models.JitNetworkAccessPortRule] - :param public_ip_address: Public IP address of the Azure Firewall that is linked to this - policy, if applicable. - :type 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, - **kwargs - ): - super(JitNetworkAccessPolicyVirtualMachine, self).__init__(**kwargs) - self.id = kwargs['id'] - self.ports = kwargs['ports'] - self.public_ip_address = kwargs.get('public_ip_address', None) - - -class JitNetworkAccessPortRule(msrest.serialization.Model): - """JitNetworkAccessPortRule. - - All required parameters must be populated in order to send to Azure. - - :param number: Required. - :type number: int - :param protocol: Required. Possible values include: "TCP", "UDP", "*". - :type protocol: str or ~azure.mgmt.security.models.ProtocolEnum - :param 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". - :type allowed_source_address_prefix: str - :param allowed_source_address_prefixes: Mutually exclusive with the - "allowedSourceAddressPrefix" parameter. - :type allowed_source_address_prefixes: list[str] - :param max_request_access_duration: Required. Maximum duration requests can be made for. In ISO - 8601 duration format. Minimum 5 minutes, maximum 1 day. - :type 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, - **kwargs - ): - super(JitNetworkAccessPortRule, self).__init__(**kwargs) - self.number = kwargs['number'] - self.protocol = kwargs['protocol'] - self.allowed_source_address_prefix = kwargs.get('allowed_source_address_prefix', None) - self.allowed_source_address_prefixes = kwargs.get('allowed_source_address_prefixes', None) - self.max_request_access_duration = kwargs['max_request_access_duration'] - - -class JitNetworkAccessRequest(msrest.serialization.Model): - """JitNetworkAccessRequest. - - All required parameters must be populated in order to send to Azure. - - :param virtual_machines: Required. - :type virtual_machines: list[~azure.mgmt.security.models.JitNetworkAccessRequestVirtualMachine] - :param start_time_utc: Required. The start time of the request in UTC. - :type start_time_utc: ~datetime.datetime - :param requestor: Required. The identity of the person who made the request. - :type requestor: str - :param justification: The justification for making the initiate request. - :type 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, - **kwargs - ): - super(JitNetworkAccessRequest, self).__init__(**kwargs) - self.virtual_machines = kwargs['virtual_machines'] - self.start_time_utc = kwargs['start_time_utc'] - self.requestor = kwargs['requestor'] - self.justification = kwargs.get('justification', None) - - -class JitNetworkAccessRequestPort(msrest.serialization.Model): - """JitNetworkAccessRequestPort. - - All required parameters must be populated in order to send to Azure. - - :param number: Required. - :type number: int - :param 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". - :type allowed_source_address_prefix: str - :param allowed_source_address_prefixes: Mutually exclusive with the - "allowedSourceAddressPrefix" parameter. - :type allowed_source_address_prefixes: list[str] - :param end_time_utc: Required. The date & time at which the request ends in UTC. - :type end_time_utc: ~datetime.datetime - :param status: Required. The status of the port. Possible values include: "Revoked", - "Initiated". - :type status: str or ~azure.mgmt.security.models.Status - :param status_reason: Required. A description of why the ``status`` has its value. Possible - values include: "Expired", "UserRequested", "NewerRequestInitiated". - :type status_reason: str or ~azure.mgmt.security.models.StatusReason - :param mapped_port: The port which is mapped to this port's ``number`` in the Azure Firewall, - if applicable. - :type 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, - **kwargs - ): - super(JitNetworkAccessRequestPort, self).__init__(**kwargs) - self.number = kwargs['number'] - self.allowed_source_address_prefix = kwargs.get('allowed_source_address_prefix', None) - self.allowed_source_address_prefixes = kwargs.get('allowed_source_address_prefixes', None) - self.end_time_utc = kwargs['end_time_utc'] - self.status = kwargs['status'] - self.status_reason = kwargs['status_reason'] - self.mapped_port = kwargs.get('mapped_port', None) - - -class JitNetworkAccessRequestVirtualMachine(msrest.serialization.Model): - """JitNetworkAccessRequestVirtualMachine. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Resource ID of the virtual machine that is linked to this policy. - :type id: str - :param ports: Required. The ports that were opened for the virtual machine. - :type 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, - **kwargs - ): - super(JitNetworkAccessRequestVirtualMachine, self).__init__(**kwargs) - self.id = kwargs['id'] - self.ports = kwargs['ports'] - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :ivar value_type: The value type of the items in the list. Possible values include: "IpCidr", - "String". - :vartype value_type: str or ~azure.mgmt.security.models.ValueType - :param allowlist_values: Required. The values to allow. The format of the values depends on the - rule type. - :type 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, - **kwargs - ): - super(LocalUserNotAllowed, self).__init__(**kwargs) - self.rule_type = 'LocalUserNotAllowed' # type: str - - -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 Azure. - - :param type: Required. There can be multiple identifiers of different type per alert, this - field specify the identifier type.Constant filled by server. Possible values include: - "AzureResource", "LogAnalytics". - :type 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 - ): - super(LogAnalyticsIdentifier, self).__init__(**kwargs) - self.type = 'LogAnalytics' # type: str - self.workspace_id = None - self.workspace_subscription_id = None - self.workspace_resource_group = None - self.agent_id = None - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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, - **kwargs - ): - super(MqttC2DMessagesNotInAllowedRange, self).__init__(**kwargs) - self.rule_type = 'MqttC2DMessagesNotInAllowedRange' # type: str - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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, - **kwargs - ): - super(MqttC2DRejectedMessagesNotInAllowedRange, self).__init__(**kwargs) - self.rule_type = 'MqttC2DRejectedMessagesNotInAllowedRange' # type: str - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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, - **kwargs - ): - super(MqttD2CMessagesNotInAllowedRange, self).__init__(**kwargs) - self.rule_type = 'MqttD2CMessagesNotInAllowedRange' # type: str - - -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 Azure. - - :param source: Required. The platform where the assessed resource resides.Constant filled by - server. Possible values include: "Azure", "OnPremise", "OnPremiseSql". - :type source: str or ~azure.mgmt.security.models.Source - :param workspace_id: Required. Azure resource Id of the workspace the machine is attached to. - :type workspace_id: str - :param vmuuid: Required. The unique Id of the machine. - :type vmuuid: str - :param source_computer_id: Required. The oms agent Id installed on the machine. - :type source_computer_id: str - :param machine_name: Required. The name of the machine. - :type 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, - **kwargs - ): - super(OnPremiseResourceDetails, self).__init__(**kwargs) - self.source = 'OnPremise' # type: str - self.workspace_id = kwargs['workspace_id'] - self.vmuuid = kwargs['vmuuid'] - self.source_computer_id = kwargs['source_computer_id'] - self.machine_name = kwargs['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 Azure. - - :param source: Required. The platform where the assessed resource resides.Constant filled by - server. Possible values include: "Azure", "OnPremise", "OnPremiseSql". - :type source: str or ~azure.mgmt.security.models.Source - :param workspace_id: Required. Azure resource Id of the workspace the machine is attached to. - :type workspace_id: str - :param vmuuid: Required. The unique Id of the machine. - :type vmuuid: str - :param source_computer_id: Required. The oms agent Id installed on the machine. - :type source_computer_id: str - :param machine_name: Required. The name of the machine. - :type machine_name: str - :param server_name: Required. The Sql server name installed on the machine. - :type server_name: str - :param database_name: Required. The Sql database name installed on the machine. - :type 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, - **kwargs - ): - super(OnPremiseSqlResourceDetails, self).__init__(**kwargs) - self.source = 'OnPremiseSql' # type: str - self.server_name = kwargs['server_name'] - self.database_name = kwargs['database_name'] - - -class Operation(msrest.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 - :param display: Security operation display. - :type display: ~azure.mgmt.security.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, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.origin = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.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 - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationList(msrest.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. - - :param value: List of Security operations. - :type value: list[~azure.mgmt.security.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, - **kwargs - ): - super(OperationList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class PathRecommendation(msrest.serialization.Model): - """Represents a path that is recommended to be allowed and its properties. - - :param path: The full path of the file, or an identifier of the application. - :type path: str - :param action: The recommendation action of the machine or rule. Possible values include: - "Recommended", "Add", "Remove". - :type action: str or ~azure.mgmt.security.models.RecommendationAction - :param type: The type of IoT Security recommendation. Possible values include: - "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", - "IoT_VulnerableTLSCipherSuite". - :type type: str or ~azure.mgmt.security.models.RecommendationType - :param publisher_info: Represents the publisher information of a process/rule. - :type publisher_info: ~azure.mgmt.security.models.PublisherInfo - :param common: Whether the application is commonly run on the machine. - :type common: bool - :param user_sids: - :type user_sids: list[str] - :param usernames: - :type usernames: list[~azure.mgmt.security.models.UserRecommendation] - :param file_type: The type of the file (for Linux files - Executable is used). Possible values - include: "Exe", "Dll", "Msi", "Script", "Executable", "Unknown". - :type file_type: str or ~azure.mgmt.security.models.FileType - :param configuration_status: The configuration status of the machines group or machine or rule. - Possible values include: "Configured", "NotConfigured", "InProgress", "Failed", "NoStatus". - :type configuration_status: str or ~azure.mgmt.security.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, - **kwargs - ): - super(PathRecommendation, self).__init__(**kwargs) - self.path = kwargs.get('path', None) - self.action = kwargs.get('action', None) - self.type = kwargs.get('type', None) - self.publisher_info = kwargs.get('publisher_info', None) - self.common = kwargs.get('common', None) - self.user_sids = kwargs.get('user_sids', None) - self.usernames = kwargs.get('usernames', None) - self.file_type = kwargs.get('file_type', None) - self.configuration_status = kwargs.get('configuration_status', None) - - -class Pricing(Resource): - """Azure Security Center 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 - :param pricing_tier: The pricing tier value. Azure Security Center 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. - Possible values include: "Free", "Standard". - :type pricing_tier: str or ~azure.mgmt.security.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, - **kwargs - ): - super(Pricing, self).__init__(**kwargs) - self.pricing_tier = kwargs.get('pricing_tier', None) - self.free_trial_remaining_time = None - - -class PricingList(msrest.serialization.Model): - """List of pricing configurations response. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. List of pricing configurations. - :type value: list[~azure.mgmt.security.models.Pricing] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Pricing]'}, - } - - def __init__( - self, - **kwargs - ): - super(PricingList, self).__init__(**kwargs) - self.value = kwargs['value'] - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :ivar value_type: The value type of the items in the list. Possible values include: "IpCidr", - "String". - :vartype value_type: str or ~azure.mgmt.security.models.ValueType - :param allowlist_values: Required. The values to allow. The format of the values depends on the - rule type. - :type 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, - **kwargs - ): - super(ProcessNotAllowed, self).__init__(**kwargs) - self.rule_type = 'ProcessNotAllowed' # type: str - - -class ProtectionMode(msrest.serialization.Model): - """The protection mode of the collection/file types. Exe/Msi/Script are used for Windows, Executable is used for Linux. - - :param exe: The application control policy enforcement/protection mode of the machine group. - Possible values include: "Audit", "Enforce", "None". - :type exe: str or ~azure.mgmt.security.models.EnforcementMode - :param msi: The application control policy enforcement/protection mode of the machine group. - Possible values include: "Audit", "Enforce", "None". - :type msi: str or ~azure.mgmt.security.models.EnforcementMode - :param script: The application control policy enforcement/protection mode of the machine group. - Possible values include: "Audit", "Enforce", "None". - :type script: str or ~azure.mgmt.security.models.EnforcementMode - :param executable: The application control policy enforcement/protection mode of the machine - group. Possible values include: "Audit", "Enforce", "None". - :type executable: str or ~azure.mgmt.security.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, - **kwargs - ): - super(ProtectionMode, self).__init__(**kwargs) - self.exe = kwargs.get('exe', None) - self.msi = kwargs.get('msi', None) - self.script = kwargs.get('script', None) - self.executable = kwargs.get('executable', None) - - -class ProxyServerProperties(msrest.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. - - :param ip: Proxy server IP. - :type ip: str - :param port: Proxy server port. - :type port: str - """ - - _attribute_map = { - 'ip': {'key': 'ip', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxyServerProperties, self).__init__(**kwargs) - self.ip = kwargs.get('ip', None) - self.port = kwargs.get('port', None) - - -class PublisherInfo(msrest.serialization.Model): - """Represents the publisher information of a process/rule. - - :param 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. - :type publisher_name: str - :param product_name: The product name taken from the file's version resource. - :type product_name: str - :param binary_name: The "OriginalName" field taken from the file's version resource. - :type binary_name: str - :param version: The binary file version taken from the file's version resource. - :type 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, - **kwargs - ): - super(PublisherInfo, self).__init__(**kwargs) - self.publisher_name = kwargs.get('publisher_name', None) - self.product_name = kwargs.get('product_name', None) - self.binary_name = kwargs.get('binary_name', None) - self.version = kwargs.get('version', None) - - -class QueryCheck(msrest.serialization.Model): - """The rule query details. - - :param query: The rule query. - :type query: str - :param expected_result: Expected result. - :type expected_result: list[list[str]] - :param column_names: Column names of expected result. - :type 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, - **kwargs - ): - super(QueryCheck, self).__init__(**kwargs) - self.query = kwargs.get('query', None) - self.expected_result = kwargs.get('expected_result', None) - self.column_names = kwargs.get('column_names', None) - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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, - **kwargs - ): - super(QueuePurgesNotInAllowedRange, self).__init__(**kwargs) - self.rule_type = 'QueuePurgesNotInAllowedRange' # type: str - - -class RecommendationConfigurationProperties(msrest.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 Azure. - - :param recommendation_type: Required. The type of IoT Security recommendation. Possible values - include: "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", - "IoT_VulnerableTLSCipherSuite". - :type recommendation_type: str or ~azure.mgmt.security.models.RecommendationType - :ivar name: - :vartype name: str - :param status: Required. Recommendation status. When the recommendation status is disabled - recommendations are not generated. Possible values include: "Disabled", "Enabled". Default - value: "Enabled". - :type 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, - **kwargs - ): - super(RecommendationConfigurationProperties, self).__init__(**kwargs) - self.recommendation_type = kwargs['recommendation_type'] - self.name = None - self.status = kwargs.get('status', "Enabled") - - -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 - :param state: Aggregative state based on the assessment's scanned resources states. Possible - values include: "Passed", "Failed", "Skipped", "Unsupported". - :type 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, - **kwargs - ): - super(RegulatoryComplianceAssessment, self).__init__(**kwargs) - self.description = None - self.assessment_type = None - self.assessment_details_link = None - self.state = kwargs.get('state', None) - self.passed_resources = None - self.failed_resources = None - self.skipped_resources = None - self.unsupported_resources = None - - -class RegulatoryComplianceAssessmentList(msrest.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 Azure. - - :param value: Required. - :type 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, - **kwargs - ): - super(RegulatoryComplianceAssessmentList, self).__init__(**kwargs) - self.value = kwargs['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 - :param state: Aggregative state based on the control's supported assessments states. Possible - values include: "Passed", "Failed", "Skipped", "Unsupported". - :type 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, - **kwargs - ): - super(RegulatoryComplianceControl, self).__init__(**kwargs) - self.description = None - self.state = kwargs.get('state', None) - self.passed_assessments = None - self.failed_assessments = None - self.skipped_assessments = None - - -class RegulatoryComplianceControlList(msrest.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 Azure. - - :param value: Required. List of regulatory compliance controls. - :type 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, - **kwargs - ): - super(RegulatoryComplianceControlList, self).__init__(**kwargs) - self.value = kwargs['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 - :param state: Aggregative state based on the standard's supported controls states. Possible - values include: "Passed", "Failed", "Skipped", "Unsupported". - :type 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, - **kwargs - ): - super(RegulatoryComplianceStandard, self).__init__(**kwargs) - self.state = kwargs.get('state', None) - self.passed_controls = None - self.failed_controls = None - self.skipped_controls = None - self.unsupported_controls = None - - -class RegulatoryComplianceStandardList(msrest.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 Azure. - - :param value: Required. - :type 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, - **kwargs - ): - super(RegulatoryComplianceStandardList, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = None - - -class Remediation(msrest.serialization.Model): - """Remediation details. - - :param description: Remediation description. - :type description: str - :param scripts: Remediation script. - :type scripts: list[str] - :param automated: Is remediation automated. - :type automated: bool - :param portal_link: Optional link to remediate in Azure Portal. - :type 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, - **kwargs - ): - super(Remediation, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.scripts = kwargs.get('scripts', None) - self.automated = kwargs.get('automated', None) - self.portal_link = kwargs.get('portal_link', None) - - -class Rule(msrest.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. - - :param name: The name of the rule. - :type name: str - :param direction: The rule's direction. Possible values include: "Inbound", "Outbound". - :type direction: str or ~azure.mgmt.security.models.Direction - :param destination_port: The rule's destination port. - :type destination_port: int - :param protocols: The rule's transport protocols. - :type protocols: list[str or ~azure.mgmt.security.models.TransportProtocol] - :param ip_addresses: The remote IP addresses that should be able to communicate with the Azure - resource on the rule's destination port and protocol. - :type 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, - **kwargs - ): - super(Rule, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.direction = kwargs.get('direction', None) - self.destination_port = kwargs.get('destination_port', None) - self.protocols = kwargs.get('protocols', None) - self.ip_addresses = kwargs.get('ip_addresses', 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 - :param properties: Rule results properties. - :type 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, - **kwargs - ): - super(RuleResults, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class RuleResultsInput(msrest.serialization.Model): - """Rule results input. - - :param latest_scan: Take results from latest scan. - :type latest_scan: bool - :param results: Expected results to be inserted into the baseline. - Leave this field empty it LatestScan == true. - :type results: list[list[str]] - """ - - _attribute_map = { - 'latest_scan': {'key': 'latestScan', 'type': 'bool'}, - 'results': {'key': 'results', 'type': '[[str]]'}, - } - - def __init__( - self, - **kwargs - ): - super(RuleResultsInput, self).__init__(**kwargs) - self.latest_scan = kwargs.get('latest_scan', None) - self.results = kwargs.get('results', None) - - -class RuleResultsProperties(msrest.serialization.Model): - """Rule results properties. - - :param results: Expected results in the baseline. - :type results: list[list[str]] - """ - - _attribute_map = { - 'results': {'key': 'results', 'type': '[[str]]'}, - } - - def __init__( - self, - **kwargs - ): - super(RuleResultsProperties, self).__init__(**kwargs) - self.results = kwargs.get('results', None) - - -class RulesResults(msrest.serialization.Model): - """A list of rules results. - - :param value: List of rule results. - :type value: list[~azure.mgmt.security.models.RuleResults] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RuleResults]'}, - } - - def __init__( - self, - **kwargs - ): - super(RulesResults, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class RulesResultsInput(msrest.serialization.Model): - """Rules results input. - - :param latest_scan: Take results from latest scan. - :type latest_scan: bool - :param results: Expected results to be inserted into the baseline. - Leave this field empty it LatestScan == true. - :type results: dict[str, list[list[str]]] - """ - - _attribute_map = { - 'latest_scan': {'key': 'latestScan', 'type': 'bool'}, - 'results': {'key': 'results', 'type': '{[[str]]}'}, - } - - def __init__( - self, - **kwargs - ): - super(RulesResultsInput, self).__init__(**kwargs) - self.latest_scan = kwargs.get('latest_scan', None) - self.results = kwargs.get('results', None) - - -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 - :param properties: A vulnerability assessment scan record properties. - :type 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, - **kwargs - ): - super(Scan, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class ScanProperties(msrest.serialization.Model): - """A vulnerability assessment scan record properties. - - :param trigger_type: The scan trigger type. Possible values include: "OnDemand", "Recurring". - :type trigger_type: str or ~azure.mgmt.security.models.ScanTriggerType - :param state: The scan status. Possible values include: "Failed", "FailedToRun", "InProgress", - "Passed". - :type state: str or ~azure.mgmt.security.models.ScanState - :param server: The server name. - :type server: str - :param database: The database name. - :type database: str - :param sql_version: The SQL version. - :type sql_version: str - :param start_time: The scan start time (UTC). - :type start_time: ~datetime.datetime - :param end_time: Scan results are valid until end time (UTC). - :type end_time: ~datetime.datetime - :param high_severity_failed_rules_count: The number of failed rules with high severity. - :type high_severity_failed_rules_count: int - :param medium_severity_failed_rules_count: The number of failed rules with medium severity. - :type medium_severity_failed_rules_count: int - :param low_severity_failed_rules_count: The number of failed rules with low severity. - :type low_severity_failed_rules_count: int - :param total_passed_rules_count: The number of total passed rules. - :type total_passed_rules_count: int - :param total_failed_rules_count: The number of total failed rules. - :type total_failed_rules_count: int - :param total_rules_count: The number of total rules assessed. - :type total_rules_count: int - :param is_baseline_applied: Baseline created for this database, and has one or more rules. - :type 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, - **kwargs - ): - super(ScanProperties, self).__init__(**kwargs) - self.trigger_type = kwargs.get('trigger_type', None) - self.state = kwargs.get('state', None) - self.server = kwargs.get('server', None) - self.database = kwargs.get('database', None) - self.sql_version = kwargs.get('sql_version', None) - self.start_time = kwargs.get('start_time', None) - self.end_time = kwargs.get('end_time', None) - self.high_severity_failed_rules_count = kwargs.get('high_severity_failed_rules_count', None) - self.medium_severity_failed_rules_count = kwargs.get('medium_severity_failed_rules_count', None) - self.low_severity_failed_rules_count = kwargs.get('low_severity_failed_rules_count', None) - self.total_passed_rules_count = kwargs.get('total_passed_rules_count', None) - self.total_failed_rules_count = kwargs.get('total_failed_rules_count', None) - self.total_rules_count = kwargs.get('total_rules_count', None) - self.is_baseline_applied = kwargs.get('is_baseline_applied', None) - - -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 - :param properties: A vulnerability assessment scan result properties for a single rule. - :type 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, - **kwargs - ): - super(ScanResult, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class ScanResultProperties(msrest.serialization.Model): - """A vulnerability assessment scan result properties for a single rule. - - :param rule_id: The rule Id. - :type rule_id: str - :param status: The rule result status. Possible values include: "NonFinding", "Finding", - "InternalError". - :type status: str or ~azure.mgmt.security.models.RuleStatus - :param is_trimmed: Indicated whether the results specified here are trimmed. - :type is_trimmed: bool - :param query_results: The results of the query that was run. - :type query_results: list[list[str]] - :param remediation: Remediation details. - :type remediation: ~azure.mgmt.security.models.Remediation - :param baseline_adjusted_result: The rule result adjusted with baseline. - :type baseline_adjusted_result: ~azure.mgmt.security.models.BaselineAdjustedResult - :param rule_metadata: vulnerability assessment rule metadata details. - :type 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, - **kwargs - ): - super(ScanResultProperties, self).__init__(**kwargs) - self.rule_id = kwargs.get('rule_id', None) - self.status = kwargs.get('status', None) - self.is_trimmed = kwargs.get('is_trimmed', None) - self.query_results = kwargs.get('query_results', None) - self.remediation = kwargs.get('remediation', None) - self.baseline_adjusted_result = kwargs.get('baseline_adjusted_result', None) - self.rule_metadata = kwargs.get('rule_metadata', None) - - -class ScanResults(msrest.serialization.Model): - """A list of vulnerability assessment scan results. - - :param value: List of vulnerability assessment scan results. - :type value: list[~azure.mgmt.security.models.ScanResult] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ScanResult]'}, - } - - def __init__( - self, - **kwargs - ): - super(ScanResults, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class Scans(msrest.serialization.Model): - """A list of vulnerability assessment scan records. - - :param value: List of vulnerability assessment scan records. - :type value: list[~azure.mgmt.security.models.Scan] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Scan]'}, - } - - def __init__( - self, - **kwargs - ): - super(Scans, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ScopeElement(msrest.serialization.Model): - """A more specific scope used to identify the alerts to suppress. - - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type additional_properties: dict[str, any] - :param field: The alert entity type to suppress by. - :type field: str - """ - - _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'field': {'key': 'field', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScopeElement, self).__init__(**kwargs) - self.additional_properties = kwargs.get('additional_properties', None) - self.field = kwargs.get('field', None) - - -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, 'min_length': 0}, - '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 - ): - super(SecureScoreControlDefinitionItem, self).__init__(**kwargs) - self.display_name = None - self.description = None - self.max_score = None - self.source = None - self.assessment_definitions = None - - -class SecureScoreControlDefinitionList(msrest.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 - ): - super(SecureScoreControlDefinitionList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SecureScoreControlDefinitionSource(msrest.serialization.Model): - """The type of the security control (For example, BuiltIn). - - :param source_type: The type of security control (for example, BuiltIn). Possible values - include: "BuiltIn", "Custom". - :type source_type: str or ~azure.mgmt.security.models.ControlType - """ - - _attribute_map = { - 'source_type': {'key': 'sourceType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SecureScoreControlDefinitionSource, self).__init__(**kwargs) - self.source_type = kwargs.get('source_type', None) - - -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: long - :param definition: Information about the security control. - :type 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': 'long'}, - '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, - **kwargs - ): - super(SecureScoreControlDetails, self).__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 = kwargs.get('definition', None) - self.max = None - self.current = None - self.percentage = None - - -class SecureScoreControlList(msrest.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 - ): - super(SecureScoreControlList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SecureScoreControlScore(msrest.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 - ): - super(SecureScoreControlScore, self).__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: long - :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': 'long'}, - '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 - ): - super(SecureScoreItem, self).__init__(**kwargs) - self.display_name = None - self.weight = None - self.max = None - self.current = None - self.percentage = None - - -class SecureScoresList(msrest.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 - ): - super(SecureScoresList, self).__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 - :param resource_details: Details of the resource that was assessed. - :type resource_details: ~azure.mgmt.security.models.ResourceDetails - :ivar display_name: User friendly display name of the assessment. - :vartype display_name: str - :param status: The result of the assessment. - :type status: ~azure.mgmt.security.models.AssessmentStatus - :param additional_data: Additional data regarding the assessment. - :type additional_data: dict[str, str] - :ivar links: Links relevant to the assessment. - :vartype links: ~azure.mgmt.security.models.AssessmentLinks - :param metadata: Describes properties of an assessment metadata. - :type metadata: ~azure.mgmt.security.models.SecurityAssessmentMetadataProperties - :param partners_data: Data regarding 3rd party partner integration. - :type partners_data: ~azure.mgmt.security.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, - **kwargs - ): - super(SecurityAssessment, self).__init__(**kwargs) - self.resource_details = kwargs.get('resource_details', None) - self.display_name = None - self.status = kwargs.get('status', None) - self.additional_data = kwargs.get('additional_data', None) - self.links = None - self.metadata = kwargs.get('metadata', None) - self.partners_data = kwargs.get('partners_data', None) - - -class SecurityAssessmentList(msrest.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.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 - ): - super(SecurityAssessmentList, self).__init__(**kwargs) - self.value = None - self.next_link = 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 - :param display_name: User friendly display name of the assessment. - :type 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 - :param description: Human readable description of the assessment. - :type description: str - :param remediation_description: Human readable description of what you should do to mitigate - this security issue. - :type remediation_description: str - :param categories: - :type categories: list[str or ~azure.mgmt.security.models.Categories] - :param severity: The severity level of the assessment. Possible values include: "Low", - "Medium", "High". - :type severity: str or ~azure.mgmt.security.models.Severity - :param user_impact: The user impact of the assessment. Possible values include: "Low", - "Moderate", "High". - :type user_impact: str or ~azure.mgmt.security.models.UserImpact - :param implementation_effort: The implementation effort required to remediate this assessment. - Possible values include: "Low", "Moderate", "High". - :type implementation_effort: str or ~azure.mgmt.security.models.ImplementationEffort - :param threats: - :type threats: list[str or ~azure.mgmt.security.models.Threats] - :param preview: True if this assessment is in preview release status. - :type preview: bool - :param assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, - Custom if the assessment based on custom Azure Policy definition. Possible values include: - "BuiltIn", "CustomPolicy", "CustomerManaged", "VerifiedPartner". - :type assessment_type: str or ~azure.mgmt.security.models.AssessmentType - :param partner_data: Describes the partner that created the assessment. - :type 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, - **kwargs - ): - super(SecurityAssessmentMetadata, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.policy_definition_id = None - self.description = kwargs.get('description', None) - self.remediation_description = kwargs.get('remediation_description', None) - self.categories = kwargs.get('categories', None) - self.severity = kwargs.get('severity', None) - self.user_impact = kwargs.get('user_impact', None) - self.implementation_effort = kwargs.get('implementation_effort', None) - self.threats = kwargs.get('threats', None) - self.preview = kwargs.get('preview', None) - self.assessment_type = kwargs.get('assessment_type', None) - self.partner_data = kwargs.get('partner_data', None) - - -class SecurityAssessmentMetadataList(msrest.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.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 - ): - super(SecurityAssessmentMetadataList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SecurityAssessmentMetadataPartnerData(msrest.serialization.Model): - """Describes the partner that created the assessment. - - All required parameters must be populated in order to send to Azure. - - :param partner_name: Required. Name of the company of the partner. - :type partner_name: str - :param product_name: Name of the product of the partner that created the assessment. - :type product_name: str - :param secret: Required. Secret to authenticate the partner and verify it created the - assessment - write only. - :type 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, - **kwargs - ): - super(SecurityAssessmentMetadataPartnerData, self).__init__(**kwargs) - self.partner_name = kwargs['partner_name'] - self.product_name = kwargs.get('product_name', None) - self.secret = kwargs['secret'] - - -class SecurityAssessmentMetadataProperties(msrest.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 Azure. - - :param display_name: Required. User friendly display name of the assessment. - :type 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 - :param description: Human readable description of the assessment. - :type description: str - :param remediation_description: Human readable description of what you should do to mitigate - this security issue. - :type remediation_description: str - :param categories: - :type categories: list[str or ~azure.mgmt.security.models.Categories] - :param severity: Required. The severity level of the assessment. Possible values include: - "Low", "Medium", "High". - :type severity: str or ~azure.mgmt.security.models.Severity - :param user_impact: The user impact of the assessment. Possible values include: "Low", - "Moderate", "High". - :type user_impact: str or ~azure.mgmt.security.models.UserImpact - :param implementation_effort: The implementation effort required to remediate this assessment. - Possible values include: "Low", "Moderate", "High". - :type implementation_effort: str or ~azure.mgmt.security.models.ImplementationEffort - :param threats: - :type threats: list[str or ~azure.mgmt.security.models.Threats] - :param preview: True if this assessment is in preview release status. - :type preview: bool - :param assessment_type: Required. BuiltIn if the assessment based on built-in Azure Policy - definition, Custom if the assessment based on custom Azure Policy definition. Possible values - include: "BuiltIn", "CustomPolicy", "CustomerManaged", "VerifiedPartner". - :type assessment_type: str or ~azure.mgmt.security.models.AssessmentType - :param partner_data: Describes the partner that created the assessment. - :type 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, - **kwargs - ): - super(SecurityAssessmentMetadataProperties, self).__init__(**kwargs) - self.display_name = kwargs['display_name'] - self.policy_definition_id = None - self.description = kwargs.get('description', None) - self.remediation_description = kwargs.get('remediation_description', None) - self.categories = kwargs.get('categories', None) - self.severity = kwargs['severity'] - self.user_impact = kwargs.get('user_impact', None) - self.implementation_effort = kwargs.get('implementation_effort', None) - self.threats = kwargs.get('threats', None) - self.preview = kwargs.get('preview', None) - self.assessment_type = kwargs['assessment_type'] - self.partner_data = kwargs.get('partner_data', None) - - -class SecurityAssessmentPartnerData(msrest.serialization.Model): - """Data regarding 3rd party partner integration. - - All required parameters must be populated in order to send to Azure. - - :param partner_name: Required. Name of the company of the partner. - :type partner_name: str - :param secret: Required. secret to authenticate the partner - write only. - :type 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, - **kwargs - ): - super(SecurityAssessmentPartnerData, self).__init__(**kwargs) - self.partner_name = kwargs['partner_name'] - self.secret = kwargs['secret'] - - -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 - :param email: The email of this security contact. - :type email: str - :param phone: The phone number of this security contact. - :type phone: str - :param alert_notifications: Whether to send security alerts notifications to the security - contact. Possible values include: "On", "Off". - :type alert_notifications: str or ~azure.mgmt.security.models.AlertNotifications - :param alerts_to_admins: Whether to send security alerts notifications to subscription admins. - Possible values include: "On", "Off". - :type alerts_to_admins: str or ~azure.mgmt.security.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, - **kwargs - ): - super(SecurityContact, self).__init__(**kwargs) - self.email = kwargs.get('email', None) - self.phone = kwargs.get('phone', None) - self.alert_notifications = kwargs.get('alert_notifications', None) - self.alerts_to_admins = kwargs.get('alerts_to_admins', None) - - -class SecurityContactList(msrest.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.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 - ): - super(SecurityContactList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -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 - :param security_family: The security family of the security solution. Possible values include: - "Waf", "Ngfw", "SaasWaf", "Va". - :type security_family: str or ~azure.mgmt.security.models.SecurityFamily - :param provisioning_state: The security family provisioning State. Possible values include: - "Succeeded", "Failed", "Updating". - :type provisioning_state: str or ~azure.mgmt.security.models.ProvisioningState - :param template: The security solutions' template. - :type template: str - :param protection_status: The security solutions' status. - :type 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, - **kwargs - ): - super(SecuritySolution, self).__init__(**kwargs) - self.location = None - self.security_family = kwargs.get('security_family', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.template = kwargs.get('template', None) - self.protection_status = kwargs.get('protection_status', None) - self.id = None - self.name = None - self.type = None - self.security_family = kwargs.get('security_family', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.template = kwargs.get('template', None) - self.protection_status = kwargs.get('protection_status', None) - - -class SecuritySolutionList(msrest.serialization.Model): - """SecuritySolutionList. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: - :type 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, - **kwargs - ): - super(SecuritySolutionList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = 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 Azure. - - :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 - :param security_family: Required. The security family of the security solution. Possible values - include: "Waf", "Ngfw", "SaasWaf", "Va". - :type security_family: str or ~azure.mgmt.security.models.SecurityFamily - :param alert_vendor_name: Required. The security solutions' vendor name. - :type alert_vendor_name: str - :param package_info_url: Required. The security solutions' package info url. - :type package_info_url: str - :param product_name: Required. The security solutions' product name. - :type product_name: str - :param publisher: Required. The security solutions' publisher. - :type publisher: str - :param publisher_display_name: Required. The security solutions' publisher display name. - :type publisher_display_name: str - :param template: Required. The security solutions' template. - :type 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, - **kwargs - ): - super(SecuritySolutionsReferenceData, self).__init__(**kwargs) - self.location = None - self.security_family = kwargs['security_family'] - self.alert_vendor_name = kwargs['alert_vendor_name'] - self.package_info_url = kwargs['package_info_url'] - self.product_name = kwargs['product_name'] - self.publisher = kwargs['publisher'] - self.publisher_display_name = kwargs['publisher_display_name'] - self.template = kwargs['template'] - self.id = None - self.name = None - self.type = None - self.security_family = kwargs['security_family'] - self.alert_vendor_name = kwargs['alert_vendor_name'] - self.package_info_url = kwargs['package_info_url'] - self.product_name = kwargs['product_name'] - self.publisher = kwargs['publisher'] - self.publisher_display_name = kwargs['publisher_display_name'] - self.template = kwargs['template'] - - -class SecuritySolutionsReferenceDataList(msrest.serialization.Model): - """SecuritySolutionsReferenceDataList. - - :param value: - :type value: list[~azure.mgmt.security.models.SecuritySolutionsReferenceData] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SecuritySolutionsReferenceData]'}, - } - - def __init__( - self, - **kwargs - ): - super(SecuritySolutionsReferenceDataList, self).__init__(**kwargs) - self.value = kwargs.get('value', 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 - :param status: Status of the sub-assessment. - :type 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 - :param resource_details: Details of the resource that was assessed. - :type resource_details: ~azure.mgmt.security.models.ResourceDetails - :param additional_data: Details of the sub-assessment. - :type 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, - **kwargs - ): - super(SecuritySubAssessment, self).__init__(**kwargs) - self.id_properties_id = None - self.display_name = None - self.status = kwargs.get('status', None) - self.remediation = None - self.impact = None - self.category = None - self.description = None - self.time_generated = None - self.resource_details = kwargs.get('resource_details', None) - self.additional_data = kwargs.get('additional_data', None) - - -class SecuritySubAssessmentList(msrest.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 - ): - super(SecuritySubAssessmentList, self).__init__(**kwargs) - self.value = None - 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 - :param security_task_parameters: Changing set of properties, depending on the task type that is - derived from the name field. - :type 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, - **kwargs - ): - super(SecurityTask, self).__init__(**kwargs) - self.state = None - self.creation_time_utc = None - self.security_task_parameters = kwargs.get('security_task_parameters', None) - self.last_state_change_time_utc = None - self.sub_state = None - - -class SecurityTaskList(msrest.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 - ): - super(SecurityTaskList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SecurityTaskParameters(msrest.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. - - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type 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, - **kwargs - ): - super(SecurityTaskParameters, self).__init__(**kwargs) - self.additional_properties = kwargs.get('additional_properties', None) - self.name = None - - -class SensitivityLabel(msrest.serialization.Model): - """The sensitivity label. - - :param display_name: The name of the sensitivity label. - :type display_name: str - :param description: The description of the sensitivity label. - :type description: str - :param rank: The rank of the sensitivity label. Possible values include: "None", "Low", - "Medium", "High", "Critical". - :type rank: str or ~azure.mgmt.security.models.Rank - :param order: The order of the sensitivity label. - :type order: int - :param enabled: Indicates whether the label is enabled or not. - :type 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, - **kwargs - ): - super(SensitivityLabel, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.description = kwargs.get('description', None) - self.rank = kwargs.get('rank', None) - self.order = kwargs.get('order', None) - self.enabled = kwargs.get('enabled', None) - - -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. Possible values include: "Succeeded", "Failed", "Canceled", "Provisioning", - "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 - ): - super(ServerVulnerabilityAssessment, self).__init__(**kwargs) - self.provisioning_state = None - - -class ServerVulnerabilityAssessmentsList(msrest.serialization.Model): - """List of server vulnerability assessments. - - :param value: - :type value: list[~azure.mgmt.security.models.ServerVulnerabilityAssessment] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ServerVulnerabilityAssessment]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServerVulnerabilityAssessmentsList, self).__init__(**kwargs) - self.value = kwargs.get('value', 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 Azure. - - :param assessed_resource_type: Required. Sub-assessment resource type.Constant filled by - server. Possible values include: "SqlServerVulnerability", "ContainerRegistryVulnerability", - "ServerVulnerability". - :type 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 - ): - super(ServerVulnerabilityProperties, self).__init__(**kwargs) - self.assessed_resource_type = 'ServerVulnerabilityAssessment' # type: str - self.type = None - self.cvss = None - self.patchable = None - self.cve = None - self.threat = None - self.published_time = None - self.vendor_references = None - - -class ServicePrincipalProperties(msrest.serialization.Model): - """Details of the service principal. - - :param application_id: Application ID of service principal. - :type application_id: str - :param secret: A secret string that the application uses to prove its identity, also can be - referred to as application password (write only). - :type secret: str - """ - - _attribute_map = { - 'application_id': {'key': 'applicationId', 'type': 'str'}, - 'secret': {'key': 'secret', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServicePrincipalProperties, self).__init__(**kwargs) - self.application_id = kwargs.get('application_id', None) - self.secret = kwargs.get('secret', None) - - -class SettingsList(msrest.serialization.Model): - """Subscription settings list. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The settings list. - :type 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, - **kwargs - ): - super(SettingsList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = 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 - :param device_id: Unique identifier for the virtual machine in the service. - :type device_id: str - :param os_platform: Platform of the operating system running on the device. - :type os_platform: str - :param vendor: Name of the software vendor. - :type vendor: str - :param software_name: Name of the software product. - :type software_name: str - :param version: Version number of the software product. - :type version: str - :param end_of_support_status: End of support status. Possible values include: "None", - "noLongerSupported", "versionNoLongerSupported", "upcomingNoLongerSupported", - "upcomingVersionNoLongerSupported". - :type end_of_support_status: str or ~azure.mgmt.security.models.EndOfSupportStatus - :param end_of_support_date: The end of support date in case the product is upcoming end of - support. - :type end_of_support_date: str - :param number_of_known_vulnerabilities: Number of weaknesses. - :type number_of_known_vulnerabilities: int - :param first_seen_at: First time that the software was seen in the device. - :type 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, - **kwargs - ): - super(Software, self).__init__(**kwargs) - self.device_id = kwargs.get('device_id', None) - self.os_platform = kwargs.get('os_platform', None) - self.vendor = kwargs.get('vendor', None) - self.software_name = kwargs.get('software_name', None) - self.version = kwargs.get('version', None) - self.end_of_support_status = kwargs.get('end_of_support_status', None) - self.end_of_support_date = kwargs.get('end_of_support_date', None) - self.number_of_known_vulnerabilities = kwargs.get('number_of_known_vulnerabilities', None) - self.first_seen_at = kwargs.get('first_seen_at', None) - - -class SoftwaresList(msrest.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. - - :param value: - :type 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, - **kwargs - ): - super(SoftwaresList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = 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 Azure. - - :param assessed_resource_type: Required. Sub-assessment resource type.Constant filled by - server. Possible values include: "SqlServerVulnerability", "ContainerRegistryVulnerability", - "ServerVulnerability". - :type 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 - ): - super(SqlServerVulnerabilityProperties, self).__init__(**kwargs) - self.assessed_resource_type = 'SqlServerVulnerability' # type: str - self.type = None - self.query = None - - -class SubAssessmentStatus(msrest.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. Possible values include: - "Healthy", "Unhealthy", "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. Possible values include: "Low", "Medium", - "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 - ): - super(SubAssessmentStatus, self).__init__(**kwargs) - self.code = None - self.cause = None - self.description = None - self.severity = None - - -class SuppressionAlertsScope(msrest.serialization.Model): - """SuppressionAlertsScope. - - All required parameters must be populated in order to send to Azure. - - :param all_of: Required. All the conditions inside need to be true in order to suppress the - alert. - :type all_of: list[~azure.mgmt.security.models.ScopeElement] - """ - - _validation = { - 'all_of': {'required': True}, - } - - _attribute_map = { - 'all_of': {'key': 'allOf', 'type': '[ScopeElement]'}, - } - - def __init__( - self, - **kwargs - ): - super(SuppressionAlertsScope, self).__init__(**kwargs) - self.all_of = kwargs['all_of'] - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.security.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.security.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type 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, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class TopologyList(msrest.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 - ): - super(TopologyList, self).__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.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 - ): - super(TopologyResource, self).__init__(**kwargs) - self.location = None - self.calculated_date_time = None - self.topology_resources = None - self.id = None - self.name = None - self.type = None - self.calculated_date_time = None - self.topology_resources = None - - -class TopologySingleResource(msrest.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 - ): - super(TopologySingleResource, self).__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(msrest.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 - ): - super(TopologySingleResourceChild, self).__init__(**kwargs) - self.resource_id = None - - -class TopologySingleResourceParent(msrest.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 - ): - super(TopologySingleResourceParent, self).__init__(**kwargs) - self.resource_id = 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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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, - **kwargs - ): - super(TwinUpdatesNotInAllowedRange, self).__init__(**kwargs) - self.rule_type = 'TwinUpdatesNotInAllowedRange' # type: str - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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, - **kwargs - ): - super(UnauthorizedOperationsNotInAllowedRange, self).__init__(**kwargs) - self.rule_type = 'UnauthorizedOperationsNotInAllowedRange' # type: str - - -class UpdateIotSecuritySolutionData(TagsResource): - """UpdateIotSecuritySolutionData. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param user_defined_resources: Properties of the IoT Security solution's user defined - resources. - :type user_defined_resources: ~azure.mgmt.security.models.UserDefinedResourcesProperties - :param recommendations_configuration: List of the configuration status for each recommendation - type. - :type 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, - **kwargs - ): - super(UpdateIotSecuritySolutionData, self).__init__(**kwargs) - self.user_defined_resources = kwargs.get('user_defined_resources', None) - self.recommendations_configuration = kwargs.get('recommendations_configuration', None) - - -class UserDefinedResourcesProperties(msrest.serialization.Model): - """Properties of the IoT Security solution's user defined resources. - - All required parameters must be populated in order to send to Azure. - - :param query: Required. Azure Resource Graph query which represents the security solution's - user defined resources. Required to start with "where type != "Microsoft.Devices/IotHubs"". - :type query: str - :param query_subscriptions: Required. List of Azure subscription ids on which the user defined - resources query should be executed. - :type 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, - **kwargs - ): - super(UserDefinedResourcesProperties, self).__init__(**kwargs) - self.query = kwargs['query'] - self.query_subscriptions = kwargs['query_subscriptions'] - - -class UserRecommendation(msrest.serialization.Model): - """Represents a user that is recommended to be allowed for a certain rule. - - :param username: Represents a user that is recommended to be allowed for a certain rule. - :type username: str - :param recommendation_action: The recommendation action of the machine or rule. Possible values - include: "Recommended", "Add", "Remove". - :type recommendation_action: str or ~azure.mgmt.security.models.RecommendationAction - """ - - _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'recommendation_action': {'key': 'recommendationAction', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserRecommendation, self).__init__(**kwargs) - self.username = kwargs.get('username', None) - self.recommendation_action = kwargs.get('recommendation_action', None) - - -class VaRule(msrest.serialization.Model): - """vulnerability assessment rule metadata details. - - :param rule_id: The rule Id. - :type rule_id: str - :param severity: The rule severity. Possible values include: "High", "Medium", "Low", - "Informational", "Obsolete". - :type severity: str or ~azure.mgmt.security.models.RuleSeverity - :param category: The rule category. - :type category: str - :param rule_type: The rule type. Possible values include: "Binary", "BaselineExpected", - "PositiveList", "NegativeList". - :type rule_type: str or ~azure.mgmt.security.models.RuleType - :param title: The rule title. - :type title: str - :param description: The rule description. - :type description: str - :param rationale: The rule rationale. - :type rationale: str - :param query_check: The rule query details. - :type query_check: ~azure.mgmt.security.models.QueryCheck - :param benchmark_references: The benchmark references. - :type 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, - **kwargs - ): - super(VaRule, self).__init__(**kwargs) - self.rule_id = kwargs.get('rule_id', None) - self.severity = kwargs.get('severity', None) - self.category = kwargs.get('category', None) - self.rule_type = kwargs.get('rule_type', None) - self.title = kwargs.get('title', None) - self.description = kwargs.get('description', None) - self.rationale = kwargs.get('rationale', None) - self.query_check = kwargs.get('query_check', None) - self.benchmark_references = kwargs.get('benchmark_references', None) - - -class VendorReference(msrest.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 - ): - super(VendorReference, self).__init__(**kwargs) - self.title = None - self.link = None - - -class VmRecommendation(msrest.serialization.Model): - """Represents a machine that is part of a machine group. - - :param configuration_status: The configuration status of the machines group or machine or rule. - Possible values include: "Configured", "NotConfigured", "InProgress", "Failed", "NoStatus". - :type configuration_status: str or ~azure.mgmt.security.models.ConfigurationStatus - :param recommendation_action: The recommendation action of the machine or rule. Possible values - include: "Recommended", "Add", "Remove". - :type recommendation_action: str or ~azure.mgmt.security.models.RecommendationAction - :param resource_id: The full resource id of the machine. - :type resource_id: str - :param enforcement_support: The machine supportability of Enforce feature. Possible values - include: "Supported", "NotSupported", "Unknown". - :type enforcement_support: str or ~azure.mgmt.security.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, - **kwargs - ): - super(VmRecommendation, self).__init__(**kwargs) - self.configuration_status = kwargs.get('configuration_status', None) - self.recommendation_action = kwargs.get('recommendation_action', None) - self.resource_id = kwargs.get('resource_id', None) - self.enforcement_support = kwargs.get('enforcement_support', None) - - -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 - :param workspace_id: The full Azure ID of the workspace to save the data in. - :type workspace_id: str - :param 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. - :type 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, - **kwargs - ): - super(WorkspaceSetting, self).__init__(**kwargs) - self.workspace_id = kwargs.get('workspace_id', None) - self.scope = kwargs.get('scope', None) - - -class WorkspaceSettingList(msrest.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 Azure. - - :param value: Required. List of workspace settings. - :type 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, - **kwargs - ): - super(WorkspaceSettingList, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = None 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 deleted file mode 100644 index cc336c5b2ea0..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/models/_models_py3.py +++ /dev/null @@ -1,10289 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, Union - -import msrest.serialization - -from ._security_center_enums import * - - -class AadConnectivityState(msrest.serialization.Model): - """Describes an Azure resource with kind. - - :param connectivity_state: The connectivity state of the external AAD solution. Possible values - include: "Discovered", "NotLicensed", "Connected". - :type 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, "AadConnectivityStateEnum"]] = None, - **kwargs - ): - super(AadConnectivityState, self).__init__(**kwargs) - self.connectivity_state = connectivity_state - - -class ExternalSecuritySolutionKind(msrest.serialization.Model): - """Describes an Azure resource with kind. - - :param kind: The kind of the external solution. Possible values include: "CEF", "ATA", "AAD". - :type kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum - """ - - _attribute_map = { - 'kind': {'key': 'kind', 'type': 'str'}, - } - - def __init__( - self, - *, - kind: Optional[Union[str, "ExternalSecuritySolutionKindEnum"]] = None, - **kwargs - ): - super(ExternalSecuritySolutionKind, self).__init__(**kwargs) - self.kind = kind - - -class Location(msrest.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 - ): - super(Location, self).__init__(**kwargs) - self.location = None - - -class Resource(msrest.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 - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ExternalSecuritySolution(Resource, Location, ExternalSecuritySolutionKind): - """Represents a security solution external to Azure Security Center which sends information to an OMS workspace and whose data is displayed by Azure Security Center. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param kind: The kind of the external solution. Possible values include: "CEF", "ATA", "AAD". - :type kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum - :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 = { - 'location': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - '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, - *, - kind: Optional[Union[str, "ExternalSecuritySolutionKindEnum"]] = None, - **kwargs - ): - super(ExternalSecuritySolution, self).__init__(kind=kind, **kwargs) - self.kind = kind - self.location = None - self.kind = kind - self.id = None - self.name = None - self.type = None - self.location = None - 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. - - :param kind: The kind of the external solution. Possible values include: "CEF", "ATA", "AAD". - :type kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum - :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 - :param properties: The external security solution properties for AAD solutions. - :type properties: ~azure.mgmt.security.models.AadSolutionProperties - """ - - _validation = { - 'location': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - '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'}, - 'properties': {'key': 'properties', 'type': 'AadSolutionProperties'}, - } - - def __init__( - self, - *, - kind: Optional[Union[str, "ExternalSecuritySolutionKindEnum"]] = None, - properties: Optional["AadSolutionProperties"] = None, - **kwargs - ): - super(AadExternalSecuritySolution, self).__init__(kind=kind, **kwargs) - self.properties = properties - - -class ExternalSecuritySolutionProperties(msrest.serialization.Model): - """The solution properties (correspond to the solution kind). - - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type additional_properties: dict[str, any] - :param device_vendor: - :type device_vendor: str - :param device_type: - :type device_type: str - :param workspace: Represents an OMS workspace to which the solution is connected. - :type 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["ConnectedWorkspace"] = None, - **kwargs - ): - super(ExternalSecuritySolutionProperties, self).__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. - - :param connectivity_state: The connectivity state of the external AAD solution. Possible values - include: "Discovered", "NotLicensed", "Connected". - :type connectivity_state: str or ~azure.mgmt.security.models.AadConnectivityStateEnum - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type additional_properties: dict[str, any] - :param device_vendor: - :type device_vendor: str - :param device_type: - :type device_type: str - :param workspace: Represents an OMS workspace to which the solution is connected. - :type 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, "AadConnectivityStateEnum"]] = None, - additional_properties: Optional[Dict[str, Any]] = None, - device_vendor: Optional[str] = None, - device_type: Optional[str] = None, - workspace: Optional["ConnectedWorkspace"] = None, - **kwargs - ): - super(AadSolutionProperties, self).__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 CustomAlertRule(msrest.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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type 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 - ): - super(CustomAlertRule, self).__init__(**kwargs) - self.display_name = None - self.description = None - self.is_enabled = is_enabled - self.rule_type = None # type: Optional[str] - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type 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 - ): - super(ThresholdCustomAlertRule, self).__init__(is_enabled=is_enabled, **kwargs) - self.rule_type = 'ThresholdCustomAlertRule' # type: str - 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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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 - ): - super(TimeWindowCustomAlertRule, self).__init__(is_enabled=is_enabled, min_threshold=min_threshold, max_threshold=max_threshold, **kwargs) - self.rule_type = 'TimeWindowCustomAlertRule' # type: str - 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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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 - ): - super(ActiveConnectionsNotInAllowedRange, self).__init__(is_enabled=is_enabled, min_threshold=min_threshold, max_threshold=max_threshold, time_window_size=time_window_size, **kwargs) - self.rule_type = 'ActiveConnectionsNotInAllowedRange' # type: str - - -class AdaptiveApplicationControlGroup(Resource, Location): - """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 - :param enforcement_mode: The application control policy enforcement/protection mode of the - machine group. Possible values include: "Audit", "Enforce", "None". - :type enforcement_mode: str or ~azure.mgmt.security.models.EnforcementMode - :param protection_mode: The protection mode of the collection/file types. Exe/Msi/Script are - used for Windows, Executable is used for Linux. - :type protection_mode: ~azure.mgmt.security.models.ProtectionMode - :ivar configuration_status: The configuration status of the machines group or machine or rule. - Possible values include: "Configured", "NotConfigured", "InProgress", "Failed", "NoStatus". - :vartype configuration_status: str or ~azure.mgmt.security.models.ConfigurationStatus - :ivar recommendation_status: The initial recommendation status of the machine group or machine. - Possible values include: "Recommended", "NotRecommended", "NotAvailable", "NoStatus". - :vartype recommendation_status: str or ~azure.mgmt.security.models.RecommendationStatus - :ivar issues: - :vartype issues: list[~azure.mgmt.security.models.AdaptiveApplicationControlIssueSummary] - :ivar source_system: The source type of the machine group. Possible values include: - "Azure_AppLocker", "Azure_AuditD", "NonAzure_AppLocker", "NonAzure_AuditD", "None". - :vartype source_system: str or ~azure.mgmt.security.models.SourceSystem - :param vm_recommendations: - :type vm_recommendations: list[~azure.mgmt.security.models.VmRecommendation] - :param path_recommendations: - :type path_recommendations: list[~azure.mgmt.security.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, "EnforcementMode"]] = None, - protection_mode: Optional["ProtectionMode"] = None, - vm_recommendations: Optional[List["VmRecommendation"]] = None, - path_recommendations: Optional[List["PathRecommendation"]] = None, - **kwargs - ): - super(AdaptiveApplicationControlGroup, self).__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 - 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 - - -class AdaptiveApplicationControlGroups(msrest.serialization.Model): - """Represents a list of machine groups and set of rules that are recommended by Azure Security Center to be allowed. - - :param value: - :type value: list[~azure.mgmt.security.models.AdaptiveApplicationControlGroup] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AdaptiveApplicationControlGroup]'}, - } - - def __init__( - self, - *, - value: Optional[List["AdaptiveApplicationControlGroup"]] = None, - **kwargs - ): - super(AdaptiveApplicationControlGroups, self).__init__(**kwargs) - self.value = value - - -class AdaptiveApplicationControlIssueSummary(msrest.serialization.Model): - """Represents a summary of the alerts of the machine group. - - :param issue: An alert that machines within a group can have. Possible values include: - "ViolationsAudited", "ViolationsBlocked", "MsiAndScriptViolationsAudited", - "MsiAndScriptViolationsBlocked", "ExecutableViolationsAudited", "RulesViolatedManually". - :type issue: str or ~azure.mgmt.security.models.AdaptiveApplicationControlIssue - :param number_of_vms: The number of machines in the group that have this alert. - :type 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, "AdaptiveApplicationControlIssue"]] = None, - number_of_vms: Optional[float] = None, - **kwargs - ): - super(AdaptiveApplicationControlIssueSummary, self).__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 - :param rules: The security rules which are recommended to be effective on the VM. - :type rules: list[~azure.mgmt.security.models.Rule] - :param rules_calculation_time: The UTC time on which the rules were calculated. - :type rules_calculation_time: ~datetime.datetime - :param effective_network_security_groups: The Network Security Groups effective on the network - interfaces of the protected resource. - :type effective_network_security_groups: - list[~azure.mgmt.security.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["Rule"]] = None, - rules_calculation_time: Optional[datetime.datetime] = None, - effective_network_security_groups: Optional[List["EffectiveNetworkSecurityGroups"]] = None, - **kwargs - ): - super(AdaptiveNetworkHardening, self).__init__(**kwargs) - self.rules = rules - self.rules_calculation_time = rules_calculation_time - self.effective_network_security_groups = effective_network_security_groups - - -class AdaptiveNetworkHardeningEnforceRequest(msrest.serialization.Model): - """AdaptiveNetworkHardeningEnforceRequest. - - All required parameters must be populated in order to send to Azure. - - :param rules: Required. The rules to enforce. - :type rules: list[~azure.mgmt.security.models.Rule] - :param network_security_groups: Required. 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. - :type 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["Rule"], - network_security_groups: List[str], - **kwargs - ): - super(AdaptiveNetworkHardeningEnforceRequest, self).__init__(**kwargs) - self.rules = rules - self.network_security_groups = network_security_groups - - -class AdaptiveNetworkHardeningsList(msrest.serialization.Model): - """Response for ListAdaptiveNetworkHardenings API service call. - - :param value: A list of Adaptive Network Hardenings resources. - :type value: list[~azure.mgmt.security.models.AdaptiveNetworkHardening] - :param next_link: The URL to get the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AdaptiveNetworkHardening]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - *, - value: Optional[List["AdaptiveNetworkHardening"]] = None, - next_link: Optional[str] = None, - **kwargs - ): - super(AdaptiveNetworkHardeningsList, self).__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AdditionalData(msrest.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 Azure. - - :param assessed_resource_type: Required. Sub-assessment resource type.Constant filled by - server. Possible values include: "SqlServerVulnerability", "ContainerRegistryVulnerability", - "ServerVulnerability". - :type 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 - ): - super(AdditionalData, self).__init__(**kwargs) - self.assessed_resource_type = None # type: Optional[str] - - -class AdditionalWorkspacesProperties(msrest.serialization.Model): - """Properties of the additional workspaces. - - :param workspace: Workspace resource id. - :type workspace: str - :param type: Workspace type. Possible values include: "Sentinel". Default value: "Sentinel". - :type type: str or ~azure.mgmt.security.models.AdditionalWorkspaceType - :param data_types: List of data types sent to workspace. - :type 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: Optional[Union[str, "AdditionalWorkspaceType"]] = "Sentinel", - data_types: Optional[List[Union[str, "AdditionalWorkspaceDataType"]]] = None, - **kwargs - ): - super(AdditionalWorkspacesProperties, self).__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 - :param is_enabled: Indicates whether Advanced Threat Protection is enabled. - :type 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 - ): - super(AdvancedThreatProtectionSetting, self).__init__(**kwargs) - self.is_enabled = is_enabled - - -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 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. - Possible values include: "Informational", "Low", "Medium", "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. Possible values include: - "Unknown", "PreAttack", "InitialAccess", "Persistence", "PrivilegeEscalation", - "DefenseEvasion", "CredentialAccess", "Discovery", "LateralMovement", "Execution", - "Collection", "Exfiltration", "CommandAndControl", "Impact", "Probing", "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. Possible values include: "Active", - "Resolved", "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 (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.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 - :param extended_properties: Custom properties for the alert. - :type 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__( - self, - *, - extended_properties: Optional[Dict[str, str]] = None, - **kwargs - ): - super(Alert, self).__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(msrest.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. - - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type additional_properties: dict[str, any] - :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, Any]] = None, - **kwargs - ): - super(AlertEntity, self).__init__(**kwargs) - self.additional_properties = additional_properties - self.type = None - - -class AlertList(msrest.serialization.Model): - """List of security alerts. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: describes security alert properties. - :type 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["Alert"]] = None, - **kwargs - ): - super(AlertList, self).__init__(**kwargs) - self.value = value - self.next_link = None - - -class AlertSimulatorRequestProperties(msrest.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 Azure. - - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type additional_properties: dict[str, any] - :param kind: Required. The kind of alert simulation.Constant filled by server. Possible values - include: "Bundles". - :type 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 - ): - super(AlertSimulatorRequestProperties, self).__init__(**kwargs) - self.additional_properties = additional_properties - self.kind = 'AlertSimulatorRequestProperties' # type: str - - -class AlertSimulatorBundlesRequestProperties(AlertSimulatorRequestProperties): - """Simulate alerts according to this bundles. - - All required parameters must be populated in order to send to Azure. - - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type additional_properties: dict[str, any] - :param kind: Required. The kind of alert simulation.Constant filled by server. Possible values - include: "Bundles". - :type kind: str or ~azure.mgmt.security.models.KindEnum - :param bundles: Bundles list. - :type 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, "BundleType"]]] = None, - **kwargs - ): - super(AlertSimulatorBundlesRequestProperties, self).__init__(additional_properties=additional_properties, **kwargs) - self.kind = 'Bundles' # type: str - self.bundles = bundles - - -class AlertSimulatorRequestBody(msrest.serialization.Model): - """Alert Simulator request body. - - :param properties: Alert Simulator request body data. - :type properties: ~azure.mgmt.security.models.AlertSimulatorRequestProperties - """ - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'AlertSimulatorRequestProperties'}, - } - - def __init__( - self, - *, - properties: Optional["AlertSimulatorRequestProperties"] = None, - **kwargs - ): - super(AlertSimulatorRequestBody, self).__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 - :param alert_type: Type of the alert to automatically suppress. For all alert types, use '*'. - :type alert_type: str - :ivar last_modified_utc: The last time this rule was modified. - :vartype last_modified_utc: ~datetime.datetime - :param expiration_date_utc: Expiration date of the rule, if value is not provided or provided - as null this field will default to the maximum allowed expiration date. - :type expiration_date_utc: ~datetime.datetime - :param reason: The reason for dismissing the alert. - :type reason: str - :param state: Possible states of the rule. Possible values include: "Enabled", "Disabled", - "Expired". - :type state: str or ~azure.mgmt.security.models.RuleState - :param comment: Any comment regarding the rule. - :type comment: str - :param suppression_alerts_scope: The suppression conditions. - :type 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, "RuleState"]] = None, - comment: Optional[str] = None, - suppression_alerts_scope: Optional["SuppressionAlertsScope"] = None, - **kwargs - ): - super(AlertsSuppressionRule, self).__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(msrest.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 Azure. - - :param value: Required. - :type 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["AlertsSuppressionRule"], - **kwargs - ): - super(AlertsSuppressionRulesList, self).__init__(**kwargs) - self.value = value - self.next_link = 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 Azure. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param kind: Required. the kind of the settings string.Constant filled by server. Possible - values include: "DataExportSettings", "AlertSuppressionSetting", "AlertSyncSettings". - :type 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 - ): - super(Setting, self).__init__(**kwargs) - self.kind = 'Setting' # type: str - - -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 Azure. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param kind: Required. the kind of the settings string.Constant filled by server. Possible - values include: "DataExportSettings", "AlertSuppressionSetting", "AlertSyncSettings". - :type kind: str or ~azure.mgmt.security.models.SettingKind - :param enabled: Is the alert sync setting enabled. - :type 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 - ): - super(AlertSyncSettings, self).__init__(**kwargs) - self.kind = 'AlertSyncSettings' # type: str - self.enabled = enabled - - -class AllowedConnectionsList(msrest.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 - ): - super(AllowedConnectionsList, self).__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.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 - ): - super(AllowedConnectionsResource, self).__init__(**kwargs) - self.location = None - self.calculated_date_time = None - self.connectable_resources = None - self.id = None - self.name = None - self.type = None - self.calculated_date_time = None - self.connectable_resources = 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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :ivar value_type: The value type of the items in the list. Possible values include: "IpCidr", - "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 - ): - super(ListCustomAlertRule, self).__init__(is_enabled=is_enabled, **kwargs) - self.rule_type = 'ListCustomAlertRule' # type: str - 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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :ivar value_type: The value type of the items in the list. Possible values include: "IpCidr", - "String". - :vartype value_type: str or ~azure.mgmt.security.models.ValueType - :param allowlist_values: Required. The values to allow. The format of the values depends on the - rule type. - :type 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 - ): - super(AllowlistCustomAlertRule, self).__init__(is_enabled=is_enabled, **kwargs) - self.rule_type = 'AllowlistCustomAlertRule' # type: str - 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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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 - ): - super(AmqpC2DMessagesNotInAllowedRange, self).__init__(is_enabled=is_enabled, min_threshold=min_threshold, max_threshold=max_threshold, time_window_size=time_window_size, **kwargs) - self.rule_type = 'AmqpC2DMessagesNotInAllowedRange' # type: str - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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 - ): - super(AmqpC2DRejectedMessagesNotInAllowedRange, self).__init__(is_enabled=is_enabled, min_threshold=min_threshold, max_threshold=max_threshold, time_window_size=time_window_size, **kwargs) - self.rule_type = 'AmqpC2DRejectedMessagesNotInAllowedRange' # type: str - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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 - ): - super(AmqpD2CMessagesNotInAllowedRange, self).__init__(is_enabled=is_enabled, min_threshold=min_threshold, max_threshold=max_threshold, time_window_size=time_window_size, **kwargs) - self.rule_type = 'AmqpD2CMessagesNotInAllowedRange' # type: str - - -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 - :param properties: Any object. - :type properties: any - """ - - _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[Any] = None, - **kwargs - ): - super(AscLocation, self).__init__(**kwargs) - self.properties = properties - - -class AscLocationList(msrest.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 - ): - super(AscLocationList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class AssessmentLinks(msrest.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 - ): - super(AssessmentLinks, self).__init__(**kwargs) - self.azure_portal_uri = None - - -class AssessmentStatus(msrest.serialization.Model): - """The result of the assessment. - - All required parameters must be populated in order to send to Azure. - - :param code: Required. Programmatic code for the status of the assessment. Possible values - include: "Healthy", "Unhealthy", "NotApplicable". - :type code: str or ~azure.mgmt.security.models.AssessmentStatusCode - :param cause: Programmatic code for the cause of the assessment status. - :type cause: str - :param description: Human readable description of the assessment status. - :type 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, "AssessmentStatusCode"], - cause: Optional[str] = None, - description: Optional[str] = None, - **kwargs - ): - super(AssessmentStatus, self).__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. - - :param kind: The kind of the external solution. Possible values include: "CEF", "ATA", "AAD". - :type kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum - :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 - :param properties: The external security solution properties for ATA solutions. - :type properties: ~azure.mgmt.security.models.AtaSolutionProperties - """ - - _validation = { - 'location': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - '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'}, - 'properties': {'key': 'properties', 'type': 'AtaSolutionProperties'}, - } - - def __init__( - self, - *, - kind: Optional[Union[str, "ExternalSecuritySolutionKindEnum"]] = None, - properties: Optional["AtaSolutionProperties"] = None, - **kwargs - ): - super(AtaExternalSecuritySolution, self).__init__(kind=kind, **kwargs) - self.properties = properties - - -class AtaSolutionProperties(ExternalSecuritySolutionProperties): - """The external security solution properties for ATA solutions. - - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type additional_properties: dict[str, any] - :param device_vendor: - :type device_vendor: str - :param device_type: - :type device_type: str - :param workspace: Represents an OMS workspace to which the solution is connected. - :type workspace: ~azure.mgmt.security.models.ConnectedWorkspace - :param last_event_received: - :type 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["ConnectedWorkspace"] = None, - last_event_received: Optional[str] = None, - **kwargs - ): - super(AtaSolutionProperties, self).__init__(additional_properties=additional_properties, device_vendor=device_vendor, device_type=device_type, workspace=workspace, **kwargs) - self.last_event_received = last_event_received - - -class AuthenticationDetailsProperties(msrest.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 Azure. - - :ivar authentication_provisioning_state: State of the multi-cloud connector. Possible values - include: "Valid", "Invalid", "Expired", "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] - :param authentication_type: Required. Connect to your cloud account, for AWS use either account - credentials or role-based authentication. For GCP use account organization credentials.Constant - filled by server. Possible values include: "awsCreds", "awsAssumeRole", "gcpCredentials". - :type 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 - ): - super(AuthenticationDetailsProperties, self).__init__(**kwargs) - self.authentication_provisioning_state = None - self.granted_permissions = None - self.authentication_type = None # type: Optional[str] - - -class Tags(msrest.serialization.Model): - """A list of key value pairs that describe the resource. - - :param tags: A set of tags. A list of key value pairs that describe the resource. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): - super(Tags, self).__init__(**kwargs) - self.tags = tags - - -class ETag(msrest.serialization.Model): - """Entity tag is used for comparing two or more entities from the same requested resource. - - :param etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :type etag: str - """ - - _attribute_map = { - 'etag': {'key': 'etag', 'type': 'str'}, - } - - def __init__( - self, - *, - etag: Optional[str] = None, - **kwargs - ): - super(ETag, self).__init__(**kwargs) - self.etag = etag - - -class Kind(msrest.serialization.Model): - """Describes an Azure resource with kind. - - :param kind: Kind of the resource. - :type kind: str - """ - - _attribute_map = { - 'kind': {'key': 'kind', 'type': 'str'}, - } - - def __init__( - self, - *, - kind: Optional[str] = None, - **kwargs - ): - super(Kind, self).__init__(**kwargs) - self.kind = kind - - -class AzureTrackedResourceLocation(msrest.serialization.Model): - """Describes an Azure resource with location. - - :param location: Location where the resource is stored. - :type location: str - """ - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - **kwargs - ): - super(AzureTrackedResourceLocation, self).__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. - - :param tags: A set of tags. A list of key value pairs that describe the resource. - :type tags: dict[str, str] - :param etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :type etag: str - :param kind: Kind of the resource. - :type kind: str - :param location: Location where the resource is stored. - :type 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 - ): - super(TrackedResource, self).__init__(location=location, kind=kind, etag=etag, tags=tags, **kwargs) - self.tags = tags - self.etag = etag - self.kind = kind - self.location = location - self.tags = tags - self.etag = etag - self.kind = kind - self.id = None - self.name = None - self.type = None - self.tags = tags - self.etag = etag - self.location = location - self.id = None - self.name = None - self.type = None - self.tags = tags - self.kind = kind - self.location = location - self.id = None - self.name = None - self.type = None - self.etag = etag - self.kind = kind - self.location = location - self.id = None - self.name = None - self.type = None - - -class Automation(TrackedResource): - """The security automation resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param tags: A set of tags. A list of key value pairs that describe the resource. - :type tags: dict[str, str] - :param etag: Entity tag is used for comparing two or more entities from the same requested - resource. - :type etag: str - :param kind: Kind of the resource. - :type kind: str - :param location: Location where the resource is stored. - :type location: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param description: The security automation description. - :type description: str - :param is_enabled: Indicates whether the security automation is enabled. - :type is_enabled: bool - :param 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. - :type scopes: list[~azure.mgmt.security.models.AutomationScope] - :param sources: A collection of the source event types which evaluate the security automation - set of rules. - :type sources: list[~azure.mgmt.security.models.AutomationSource] - :param actions: A collection of the actions which are triggered if all the configured rules - evaluations, within at least one rule set, are true. - :type 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["AutomationScope"]] = None, - sources: Optional[List["AutomationSource"]] = None, - actions: Optional[List["AutomationAction"]] = None, - **kwargs - ): - super(Automation, self).__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(msrest.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 Azure. - - :param action_type: Required. The type of the action that will be triggered by the - Automation.Constant filled by server. Possible values include: "LogicApp", "EventHub", - "Workspace". - :type 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 - ): - super(AutomationAction, self).__init__(**kwargs) - self.action_type = None # type: Optional[str] - - -class AutomationActionEventHub(AutomationAction): - """The target Event Hub to which event data will be exported. To learn more about Security Center 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 Azure. - - :param action_type: Required. The type of the action that will be triggered by the - Automation.Constant filled by server. Possible values include: "LogicApp", "EventHub", - "Workspace". - :type action_type: str or ~azure.mgmt.security.models.ActionType - :param event_hub_resource_id: The target Event Hub Azure Resource ID. - :type event_hub_resource_id: str - :ivar sas_policy_name: The target Event Hub SAS policy name. - :vartype sas_policy_name: str - :param connection_string: The target Event Hub connection string (it will not be included in - any response). - :type 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 - ): - super(AutomationActionEventHub, self).__init__(**kwargs) - self.action_type = 'EventHub' # type: str - 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 Security Center's Workflow Automation capabilities, visit https://aka.ms/ASCWorkflowAutomationLearnMore. - - All required parameters must be populated in order to send to Azure. - - :param action_type: Required. The type of the action that will be triggered by the - Automation.Constant filled by server. Possible values include: "LogicApp", "EventHub", - "Workspace". - :type action_type: str or ~azure.mgmt.security.models.ActionType - :param 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. - :type logic_app_resource_id: str - :param uri: The Logic App trigger URI endpoint (it will not be included in any response). - :type 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 - ): - super(AutomationActionLogicApp, self).__init__(**kwargs) - self.action_type = 'LogicApp' # type: str - 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 Security Center continuous export capabilities, visit https://aka.ms/ASCExportLearnMore. - - All required parameters must be populated in order to send to Azure. - - :param action_type: Required. The type of the action that will be triggered by the - Automation.Constant filled by server. Possible values include: "LogicApp", "EventHub", - "Workspace". - :type action_type: str or ~azure.mgmt.security.models.ActionType - :param workspace_resource_id: The fully qualified Log Analytics Workspace Azure Resource ID. - :type 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 - ): - super(AutomationActionWorkspace, self).__init__(**kwargs) - self.action_type = 'Workspace' # type: str - self.workspace_resource_id = workspace_resource_id - - -class AutomationList(msrest.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 Azure. - - :param value: Required. The list of security automations under the given scope. - :type 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["Automation"], - **kwargs - ): - super(AutomationList, self).__init__(**kwargs) - self.value = value - self.next_link = None - - -class AutomationRuleSet(msrest.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. - - :param rules: - :type rules: list[~azure.mgmt.security.models.AutomationTriggeringRule] - """ - - _attribute_map = { - 'rules': {'key': 'rules', 'type': '[AutomationTriggeringRule]'}, - } - - def __init__( - self, - *, - rules: Optional[List["AutomationTriggeringRule"]] = None, - **kwargs - ): - super(AutomationRuleSet, self).__init__(**kwargs) - self.rules = rules - - -class AutomationScope(msrest.serialization.Model): - """A single automation scope. - - :param description: The resources scope description. - :type description: str - :param 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). - :type 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 - ): - super(AutomationScope, self).__init__(**kwargs) - self.description = description - self.scope_path = scope_path - - -class AutomationSource(msrest.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. - - :param event_source: A valid event source type. Possible values include: "Assessments", - "SubAssessments", "Alerts", "SecureScores", "SecureScoresSnapshot", "SecureScoreControls", - "SecureScoreControlsSnapshot", "RegulatoryComplianceAssessment", - "RegulatoryComplianceAssessmentSnapshot". - :type event_source: str or ~azure.mgmt.security.models.EventSource - :param rule_sets: A set of rules which evaluate upon event interception. A logical disjunction - is applied between defined rule sets (logical 'or'). - :type 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, "EventSource"]] = None, - rule_sets: Optional[List["AutomationRuleSet"]] = None, - **kwargs - ): - super(AutomationSource, self).__init__(**kwargs) - self.event_source = event_source - self.rule_sets = rule_sets - - -class AutomationTriggeringRule(msrest.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. - - :param property_j_path: The JPath of the entity model property that should be checked. - :type property_j_path: str - :param property_type: The data type of the compared operands (string, integer, floating point - number or a boolean [true/false]]. Possible values include: "String", "Integer", "Number", - "Boolean". - :type property_type: str or ~azure.mgmt.security.models.PropertyType - :param expected_value: The expected value. - :type expected_value: str - :param operator: A valid comparer operator to use. A case-insensitive comparison will be - applied for String PropertyType. Possible values include: "Equals", "GreaterThan", - "GreaterThanOrEqualTo", "LesserThan", "LesserThanOrEqualTo", "NotEquals", "Contains", - "StartsWith", "EndsWith". - :type 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, "PropertyType"]] = None, - expected_value: Optional[str] = None, - operator: Optional[Union[str, "Operator"]] = None, - **kwargs - ): - super(AutomationTriggeringRule, self).__init__(**kwargs) - self.property_j_path = property_j_path - self.property_type = property_type - self.expected_value = expected_value - self.operator = operator - - -class AutomationValidationStatus(msrest.serialization.Model): - """The security automation model state property bag. - - :param is_valid: Indicates whether the model is valid or not. - :type is_valid: bool - :param message: The validation message. - :type 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 - ): - super(AutomationValidationStatus, self).__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 - :param auto_provision: Describes what kind of security agent provisioning action to take. - Possible values include: "On", "Off". - :type 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, "AutoProvision"]] = None, - **kwargs - ): - super(AutoProvisioningSetting, self).__init__(**kwargs) - self.auto_provision = auto_provision - - -class AutoProvisioningSettingList(msrest.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. - - :param value: List of all the auto provisioning settings. - :type 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["AutoProvisioningSetting"]] = None, - **kwargs - ): - super(AutoProvisioningSettingList, self).__init__(**kwargs) - self.value = value - self.next_link = None - - -class AwAssumeRoleAuthenticationDetailsProperties(AuthenticationDetailsProperties): - """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 Azure. - - :ivar authentication_provisioning_state: State of the multi-cloud connector. Possible values - include: "Valid", "Invalid", "Expired", "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] - :param authentication_type: Required. Connect to your cloud account, for AWS use either account - credentials or role-based authentication. For GCP use account organization credentials.Constant - filled by server. Possible values include: "awsCreds", "awsAssumeRole", "gcpCredentials". - :type authentication_type: str or ~azure.mgmt.security.models.AuthenticationType - :ivar account_id: The ID of the cloud account. - :vartype account_id: str - :param aws_assume_role_arn: Required. Assumed role ID is an identifier that you can use to - create temporary security credentials. - :type aws_assume_role_arn: str - :param aws_external_id: Required. A unique identifier that is required when you assume a role - in another account. - :type 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 - ): - super(AwAssumeRoleAuthenticationDetailsProperties, self).__init__(**kwargs) - self.authentication_type = 'awsAssumeRole' # type: str - 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 Azure. - - :ivar authentication_provisioning_state: State of the multi-cloud connector. Possible values - include: "Valid", "Invalid", "Expired", "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] - :param authentication_type: Required. Connect to your cloud account, for AWS use either account - credentials or role-based authentication. For GCP use account organization credentials.Constant - filled by server. Possible values include: "awsCreds", "awsAssumeRole", "gcpCredentials". - :type authentication_type: str or ~azure.mgmt.security.models.AuthenticationType - :ivar account_id: The ID of the cloud account. - :vartype account_id: str - :param aws_access_key_id: Required. Public key element of the AWS credential object (write - only). - :type aws_access_key_id: str - :param aws_secret_access_key: Required. Secret key element of the AWS credential object (write - only). - :type 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 - ): - super(AwsCredsAuthenticationDetailsProperties, self).__init__(**kwargs) - self.authentication_type = 'awsCreds' # type: str - self.account_id = None - self.aws_access_key_id = aws_access_key_id - self.aws_secret_access_key = aws_secret_access_key - - -class ResourceDetails(msrest.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 Azure. - - :param source: Required. The platform where the assessed resource resides.Constant filled by - server. Possible values include: "Azure", "OnPremise", "OnPremiseSql". - :type 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 - ): - super(ResourceDetails, self).__init__(**kwargs) - self.source = None # type: Optional[str] - - -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 Azure. - - :param source: Required. The platform where the assessed resource resides.Constant filled by - server. Possible values include: "Azure", "OnPremise", "OnPremiseSql". - :type 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 - ): - super(AzureResourceDetails, self).__init__(**kwargs) - self.source = 'Azure' # type: str - self.id = None - - -class ResourceIdentifier(msrest.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 Azure. - - :param type: Required. There can be multiple identifiers of different type per alert, this - field specify the identifier type.Constant filled by server. Possible values include: - "AzureResource", "LogAnalytics". - :type 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 - ): - super(ResourceIdentifier, self).__init__(**kwargs) - self.type = None # type: Optional[str] - - -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 Azure. - - :param type: Required. There can be multiple identifiers of different type per alert, this - field specify the identifier type.Constant filled by server. Possible values include: - "AzureResource", "LogAnalytics". - :type 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 - ): - super(AzureResourceIdentifier, self).__init__(**kwargs) - self.type = 'AzureResource' # type: str - self.azure_resource_id = None - - -class AzureResourceLink(msrest.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 - ): - super(AzureResourceLink, self).__init__(**kwargs) - self.id = None - - -class Baseline(msrest.serialization.Model): - """Baseline details. - - :param expected_results: Expected results. - :type expected_results: list[list[str]] - :param updated_time: Baseline update time (UTC). - :type 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 - ): - super(Baseline, self).__init__(**kwargs) - self.expected_results = expected_results - self.updated_time = updated_time - - -class BaselineAdjustedResult(msrest.serialization.Model): - """The rule result adjusted with baseline. - - :param baseline: Baseline details. - :type baseline: ~azure.mgmt.security.models.Baseline - :param status: The rule result status. Possible values include: "NonFinding", "Finding", - "InternalError". - :type status: str or ~azure.mgmt.security.models.RuleStatus - :param results_not_in_baseline: Results the are not in baseline. - :type results_not_in_baseline: list[list[str]] - :param results_only_in_baseline: Results the are in baseline. - :type 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["Baseline"] = None, - status: Optional[Union[str, "RuleStatus"]] = None, - results_not_in_baseline: Optional[List[List[str]]] = None, - results_only_in_baseline: Optional[List[List[str]]] = None, - **kwargs - ): - super(BaselineAdjustedResult, self).__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(msrest.serialization.Model): - """The benchmark references. - - :param benchmark: The benchmark name. - :type benchmark: str - :param reference: The benchmark reference. - :type 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 - ): - super(BenchmarkReference, self).__init__(**kwargs) - self.benchmark = benchmark - self.reference = reference - - -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. - - :param kind: The kind of the external solution. Possible values include: "CEF", "ATA", "AAD". - :type kind: str or ~azure.mgmt.security.models.ExternalSecuritySolutionKindEnum - :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 - :param properties: The external security solution properties for CEF solutions. - :type properties: ~azure.mgmt.security.models.CefSolutionProperties - """ - - _validation = { - 'location': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - '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'}, - 'properties': {'key': 'properties', 'type': 'CefSolutionProperties'}, - } - - def __init__( - self, - *, - kind: Optional[Union[str, "ExternalSecuritySolutionKindEnum"]] = None, - properties: Optional["CefSolutionProperties"] = None, - **kwargs - ): - super(CefExternalSecuritySolution, self).__init__(kind=kind, **kwargs) - self.properties = properties - - -class CefSolutionProperties(ExternalSecuritySolutionProperties): - """The external security solution properties for CEF solutions. - - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type additional_properties: dict[str, any] - :param device_vendor: - :type device_vendor: str - :param device_type: - :type device_type: str - :param workspace: Represents an OMS workspace to which the solution is connected. - :type workspace: ~azure.mgmt.security.models.ConnectedWorkspace - :param hostname: - :type hostname: str - :param agent: - :type agent: str - :param last_event_received: - :type 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["ConnectedWorkspace"] = None, - hostname: Optional[str] = None, - agent: Optional[str] = None, - last_event_received: Optional[str] = None, - **kwargs - ): - super(CefSolutionProperties, self).__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(msrest.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 - ): - super(CloudErrorBody, self).__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.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 - ): - super(Compliance, self).__init__(**kwargs) - self.assessment_timestamp_utc_date = None - self.resource_count = None - self.assessment_result = None - - -class ComplianceList(msrest.serialization.Model): - """List of Compliance objects response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of Compliance objects. - :type 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["Compliance"]] = None, - **kwargs - ): - super(ComplianceList, self).__init__(**kwargs) - self.value = value - self.next_link = 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. Possible - values include: "Healthy", "NotApplicable", "OffByPolicy", "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 - ): - super(ComplianceResult, self).__init__(**kwargs) - self.resource_status = None - - -class ComplianceResultList(msrest.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 Azure. - - :param value: Required. List of compliance results. - :type 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["ComplianceResult"], - **kwargs - ): - super(ComplianceResultList, self).__init__(**kwargs) - self.value = value - self.next_link = None - - -class ComplianceSegment(msrest.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 - ): - super(ComplianceSegment, self).__init__(**kwargs) - self.segment_type = None - self.percentage = None - - -class ConnectableResource(msrest.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 - ): - super(ConnectableResource, self).__init__(**kwargs) - self.id = None - self.inbound_connected_resources = None - self.outbound_connected_resources = None - - -class ConnectedResource(msrest.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 - ): - super(ConnectedResource, self).__init__(**kwargs) - self.connected_resource_id = None - self.tcp_ports = None - self.udp_ports = None - - -class ConnectedWorkspace(msrest.serialization.Model): - """Represents an OMS workspace to which the solution is connected. - - :param id: Azure resource ID of the connected OMS workspace. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): - super(ConnectedWorkspace, self).__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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :ivar value_type: The value type of the items in the list. Possible values include: "IpCidr", - "String". - :vartype value_type: str or ~azure.mgmt.security.models.ValueType - :param allowlist_values: Required. The values to allow. The format of the values depends on the - rule type. - :type 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 - ): - super(ConnectionFromIpNotAllowed, self).__init__(is_enabled=is_enabled, allowlist_values=allowlist_values, **kwargs) - self.rule_type = 'ConnectionFromIpNotAllowed' # type: str - - -class ConnectionStrings(msrest.serialization.Model): - """Connection string for ingesting security data and logs. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. Connection strings. - :type value: list[~azure.mgmt.security.models.IngestionConnectionString] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[IngestionConnectionString]'}, - } - - def __init__( - self, - *, - value: List["IngestionConnectionString"], - **kwargs - ): - super(ConnectionStrings, self).__init__(**kwargs) - self.value = value - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :ivar value_type: The value type of the items in the list. Possible values include: "IpCidr", - "String". - :vartype value_type: str or ~azure.mgmt.security.models.ValueType - :param allowlist_values: Required. The values to allow. The format of the values depends on the - rule type. - :type 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 - ): - super(ConnectionToIpNotAllowed, self).__init__(is_enabled=is_enabled, allowlist_values=allowlist_values, **kwargs) - self.rule_type = 'ConnectionToIpNotAllowed' # type: str - - -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 - :param hybrid_compute_settings: Settings for hybrid compute management. These settings are - relevant only for Arc autoProvision (Hybrid Compute). - :type hybrid_compute_settings: ~azure.mgmt.security.models.HybridComputeSettingsProperties - :param authentication_details: Settings for authentication management, these settings are - relevant only for the cloud connector. - :type 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["HybridComputeSettingsProperties"] = None, - authentication_details: Optional["AuthenticationDetailsProperties"] = None, - **kwargs - ): - super(ConnectorSetting, self).__init__(**kwargs) - self.hybrid_compute_settings = hybrid_compute_settings - self.authentication_details = authentication_details - - -class ConnectorSettingList(msrest.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. - - :param value: List of all the cloud account connector settings. - :type 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["ConnectorSetting"]] = None, - **kwargs - ): - super(ConnectorSettingList, self).__init__(**kwargs) - self.value = value - self.next_link = 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 Azure. - - :param assessed_resource_type: Required. Sub-assessment resource type.Constant filled by - server. Possible values include: "SqlServerVulnerability", "ContainerRegistryVulnerability", - "ServerVulnerability". - :type 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 - ): - super(ContainerRegistryVulnerabilityProperties, self).__init__(**kwargs) - self.assessed_resource_type = 'ContainerRegistryVulnerability' # type: str - 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(msrest.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 - ): - super(CVE, self).__init__(**kwargs) - self.title = None - self.link = None - - -class CVSS(msrest.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 - ): - super(CVSS, self).__init__(**kwargs) - self.base = 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 Azure. - - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param kind: Required. the kind of the settings string.Constant filled by server. Possible - values include: "DataExportSettings", "AlertSuppressionSetting", "AlertSyncSettings". - :type kind: str or ~azure.mgmt.security.models.SettingKind - :param enabled: Is the data export setting enabled. - :type 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 - ): - super(DataExportSettings, self).__init__(**kwargs) - self.kind = 'DataExportSettings' # type: str - self.enabled = enabled - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :ivar value_type: The value type of the items in the list. Possible values include: "IpCidr", - "String". - :vartype value_type: str or ~azure.mgmt.security.models.ValueType - :param denylist_values: Required. The values to deny. The format of the values depends on the - rule type. - :type 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 - ): - super(DenylistCustomAlertRule, self).__init__(is_enabled=is_enabled, **kwargs) - self.rule_type = 'DenylistCustomAlertRule' # type: str - 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 - :param threshold_rules: The list of custom alert threshold rules. - :type threshold_rules: list[~azure.mgmt.security.models.ThresholdCustomAlertRule] - :param time_window_rules: The list of custom alert time-window rules. - :type time_window_rules: list[~azure.mgmt.security.models.TimeWindowCustomAlertRule] - :param allowlist_rules: The allow-list custom alert rules. - :type allowlist_rules: list[~azure.mgmt.security.models.AllowlistCustomAlertRule] - :param denylist_rules: The deny-list custom alert rules. - :type 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["ThresholdCustomAlertRule"]] = None, - time_window_rules: Optional[List["TimeWindowCustomAlertRule"]] = None, - allowlist_rules: Optional[List["AllowlistCustomAlertRule"]] = None, - denylist_rules: Optional[List["DenylistCustomAlertRule"]] = None, - **kwargs - ): - super(DeviceSecurityGroup, self).__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(msrest.serialization.Model): - """List of device security groups. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of device security group objects. - :type 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["DeviceSecurityGroup"]] = None, - **kwargs - ): - super(DeviceSecurityGroupList, self).__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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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 - ): - super(DirectMethodInvokesNotInAllowedRange, self).__init__(is_enabled=is_enabled, min_threshold=min_threshold, max_threshold=max_threshold, time_window_size=time_window_size, **kwargs) - self.rule_type = 'DirectMethodInvokesNotInAllowedRange' # type: str - - -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 Azure. - - :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 - :param security_family: Required. The security family of the discovered solution. Possible - values include: "Waf", "Ngfw", "SaasWaf", "Va". - :type security_family: str or ~azure.mgmt.security.models.SecurityFamily - :param offer: Required. The security solutions' image offer. - :type offer: str - :param publisher: Required. The security solutions' image publisher. - :type publisher: str - :param sku: Required. The security solutions' image sku. - :type 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, "SecurityFamily"], - offer: str, - publisher: str, - sku: str, - **kwargs - ): - super(DiscoveredSecuritySolution, self).__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 - self.security_family = security_family - self.offer = offer - self.publisher = publisher - self.sku = sku - - -class DiscoveredSecuritySolutionList(msrest.serialization.Model): - """DiscoveredSecuritySolutionList. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: - :type 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["DiscoveredSecuritySolution"]] = None, - **kwargs - ): - super(DiscoveredSecuritySolutionList, self).__init__(**kwargs) - self.value = value - self.next_link = None - - -class EffectiveNetworkSecurityGroups(msrest.serialization.Model): - """Describes the Network Security Groups effective on a network interface. - - :param network_interface: The Azure resource ID of the network interface. - :type network_interface: str - :param network_security_groups: The Network Security Groups effective on the network interface. - :type 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 - ): - super(EffectiveNetworkSecurityGroups, self).__init__(**kwargs) - self.network_interface = network_interface - self.network_security_groups = network_security_groups - - -class ErrorAdditionalInfo(msrest.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: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ExternalSecuritySolutionList(msrest.serialization.Model): - """ExternalSecuritySolutionList. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: - :type 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["ExternalSecuritySolution"]] = None, - **kwargs - ): - super(ExternalSecuritySolutionList, self).__init__(**kwargs) - self.value = value - self.next_link = 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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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 - ): - super(FailedLocalLoginsNotInAllowedRange, self).__init__(is_enabled=is_enabled, min_threshold=min_threshold, max_threshold=max_threshold, time_window_size=time_window_size, **kwargs) - self.rule_type = 'FailedLocalLoginsNotInAllowedRange' # type: str - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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 - ): - super(FileUploadsNotInAllowedRange, self).__init__(is_enabled=is_enabled, min_threshold=min_threshold, max_threshold=max_threshold, time_window_size=time_window_size, **kwargs) - self.rule_type = 'FileUploadsNotInAllowedRange' # type: str - - -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 Azure. - - :ivar authentication_provisioning_state: State of the multi-cloud connector. Possible values - include: "Valid", "Invalid", "Expired", "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] - :param authentication_type: Required. Connect to your cloud account, for AWS use either account - credentials or role-based authentication. For GCP use account organization credentials.Constant - filled by server. Possible values include: "awsCreds", "awsAssumeRole", "gcpCredentials". - :type authentication_type: str or ~azure.mgmt.security.models.AuthenticationType - :param organization_id: Required. The organization ID of the GCP cloud account. - :type organization_id: str - :param type: Required. Type field of the API key (write only). - :type type: str - :param project_id: Required. Project ID field of the API key (write only). - :type project_id: str - :param private_key_id: Required. Private key ID field of the API key (write only). - :type private_key_id: str - :param private_key: Required. Private key field of the API key (write only). - :type private_key: str - :param client_email: Required. Client email field of the API key (write only). - :type client_email: str - :param client_id: Required. Client ID field of the API key (write only). - :type client_id: str - :param auth_uri: Required. Auth URI field of the API key (write only). - :type auth_uri: str - :param token_uri: Required. Token URI field of the API key (write only). - :type token_uri: str - :param auth_provider_x509_cert_url: Required. Auth provider x509 certificate URL field of the - API key (write only). - :type auth_provider_x509_cert_url: str - :param client_x509_cert_url: Required. Client x509 certificate URL field of the API key (write - only). - :type 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 - ): - super(GcpCredentialsDetailsProperties, self).__init__(**kwargs) - self.authentication_type = 'gcpCredentials' # type: str - 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 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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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 - ): - super(HttpC2DMessagesNotInAllowedRange, self).__init__(is_enabled=is_enabled, min_threshold=min_threshold, max_threshold=max_threshold, time_window_size=time_window_size, **kwargs) - self.rule_type = 'HttpC2DMessagesNotInAllowedRange' # type: str - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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 - ): - super(HttpC2DRejectedMessagesNotInAllowedRange, self).__init__(is_enabled=is_enabled, min_threshold=min_threshold, max_threshold=max_threshold, time_window_size=time_window_size, **kwargs) - self.rule_type = 'HttpC2DRejectedMessagesNotInAllowedRange' # type: str - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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 - ): - super(HttpD2CMessagesNotInAllowedRange, self).__init__(is_enabled=is_enabled, min_threshold=min_threshold, max_threshold=max_threshold, time_window_size=time_window_size, **kwargs) - self.rule_type = 'HttpD2CMessagesNotInAllowedRange' # type: str - - -class HybridComputeSettingsProperties(msrest.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 Azure. - - :ivar hybrid_compute_provisioning_state: State of the service principal and its secret. - Possible values include: "Valid", "Invalid", "Expired". - :vartype hybrid_compute_provisioning_state: str or - ~azure.mgmt.security.models.HybridComputeProvisioningState - :param auto_provision: Required. Whether or not to automatically install Azure Arc (hybrid - compute) agents on machines. Possible values include: "On", "Off". - :type auto_provision: str or ~azure.mgmt.security.models.AutoProvision - :param resource_group_name: The name of the resource group where Arc (Hybrid Compute) - connectors are connected. - :type resource_group_name: str - :param region: The location where the metadata of machines will be stored. - :type region: str - :param 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. - :type proxy_server: ~azure.mgmt.security.models.ProxyServerProperties - :param service_principal: An object to access resources that are secured by an Azure AD tenant. - :type 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, "AutoProvision"], - resource_group_name: Optional[str] = None, - region: Optional[str] = None, - proxy_server: Optional["ProxyServerProperties"] = None, - service_principal: Optional["ServicePrincipalProperties"] = None, - **kwargs - ): - super(HybridComputeSettingsProperties, self).__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 InformationProtectionKeyword(msrest.serialization.Model): - """The information type keyword. - - :param pattern: The keyword pattern. - :type pattern: str - :param custom: Indicates whether the keyword is custom or not. - :type custom: bool - :param can_be_numeric: Indicates whether the keyword can be applied on numeric types or not. - :type can_be_numeric: bool - :param excluded: Indicates whether the keyword is excluded or not. - :type 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 - ): - super(InformationProtectionKeyword, self).__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 - :param labels: Dictionary of sensitivity labels. - :type labels: dict[str, ~azure.mgmt.security.models.SensitivityLabel] - :param information_types: The sensitivity information types. - :type 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, "SensitivityLabel"]] = None, - information_types: Optional[Dict[str, "InformationType"]] = None, - **kwargs - ): - super(InformationProtectionPolicy, self).__init__(**kwargs) - self.last_modified_utc = None - self.version = None - self.labels = labels - self.information_types = information_types - - -class InformationProtectionPolicyList(msrest.serialization.Model): - """Information protection policies response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of information protection policies. - :type 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["InformationProtectionPolicy"]] = None, - **kwargs - ): - super(InformationProtectionPolicyList, self).__init__(**kwargs) - self.value = value - self.next_link = None - - -class InformationType(msrest.serialization.Model): - """The information type. - - :param display_name: The name of the information type. - :type display_name: str - :param description: The description of the information type. - :type description: str - :param order: The order of the information type. - :type order: int - :param recommended_label_id: The recommended label id to be associated with this information - type. - :type recommended_label_id: str - :param enabled: Indicates whether the information type is enabled or not. - :type enabled: bool - :param custom: Indicates whether the information type is custom or not. - :type custom: bool - :param keywords: The information type keywords. - :type 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["InformationProtectionKeyword"]] = None, - **kwargs - ): - super(InformationType, self).__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 IngestionConnectionString(msrest.serialization.Model): - """Connection string for ingesting security data and logs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: The region where ingested logs and data resides. - :vartype location: str - :ivar value: Connection string value. - :vartype value: str - """ - - _validation = { - 'location': {'readonly': True}, - 'value': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IngestionConnectionString, self).__init__(**kwargs) - self.location = None - self.value = None - - -class IngestionSetting(Resource): - """Configures how to correlate scan data and logs with resources associated with the subscription. - - 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 - :param properties: Ingestion setting data. - :type properties: any - """ - - _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[Any] = None, - **kwargs - ): - super(IngestionSetting, self).__init__(**kwargs) - self.properties = properties - - -class IngestionSettingList(msrest.serialization.Model): - """List of ingestion settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of ingestion settings. - :vartype value: list[~azure.mgmt.security.models.IngestionSetting] - :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': '[IngestionSetting]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IngestionSettingList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class IngestionSettingToken(msrest.serialization.Model): - """Configures how to correlate scan data and logs with resources associated with the subscription. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar token: The token is used for correlating security data and logs with the resources in the - subscription. - :vartype token: str - """ - - _validation = { - 'token': {'readonly': True}, - } - - _attribute_map = { - 'token': {'key': 'token', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IngestionSettingToken, self).__init__(**kwargs) - self.token = None - - -class TagsResource(msrest.serialization.Model): - """A container holding only the Tags for a resource, allowing the user to update the tags. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): - super(TagsResource, self).__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. - - :param tags: A set of tags. Resource tags. - :type 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. Possible values include: "Informational", - "Low", "Medium", "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: long - :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': 'long'}, - '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 - ): - super(IoTSecurityAggregatedAlert, self).__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 - 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 - - -class IoTSecurityAggregatedAlertList(msrest.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 Azure. - - :param value: Required. List of aggregated alerts data. - :type 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["IoTSecurityAggregatedAlert"], - **kwargs - ): - super(IoTSecurityAggregatedAlertList, self).__init__(**kwargs) - self.value = value - self.next_link = None - - -class IoTSecurityAggregatedAlertPropertiesTopDevicesListItem(msrest.serialization.Model): - """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: long - :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': 'long'}, - 'last_occurrence': {'key': 'lastOccurrence', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTSecurityAggregatedAlertPropertiesTopDevicesListItem, self).__init__(**kwargs) - self.device_id = None - self.alerts_count = None - self.last_occurrence = 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. - - :param tags: A set of tags. Resource tags. - :type 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 - :param recommendation_name: Name of the recommendation. - :type 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. Possible values include: - "Informational", "Low", "Medium", "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: long - :ivar unhealthy_device_count: Number of unhealthy devices within the IoT Security solution. - :vartype unhealthy_device_count: long - :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': 'long'}, - 'unhealthy_device_count': {'key': 'properties.unhealthyDeviceCount', 'type': 'long'}, - 'log_analytics_query': {'key': 'properties.logAnalyticsQuery', 'type': 'str'}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - recommendation_name: Optional[str] = None, - **kwargs - ): - super(IoTSecurityAggregatedRecommendation, self).__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 - 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 - - -class IoTSecurityAggregatedRecommendationList(msrest.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 Azure. - - :param value: Required. List of aggregated recommendations data. - :type 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["IoTSecurityAggregatedRecommendation"], - **kwargs - ): - super(IoTSecurityAggregatedRecommendationList, self).__init__(**kwargs) - self.value = value - self.next_link = None - - -class IoTSecurityAlertedDevice(msrest.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: long - """ - - _validation = { - 'device_id': {'readonly': True}, - 'alerts_count': {'readonly': True}, - } - - _attribute_map = { - 'device_id': {'key': 'deviceId', 'type': 'str'}, - 'alerts_count': {'key': 'alertsCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTSecurityAlertedDevice, self).__init__(**kwargs) - self.device_id = None - self.alerts_count = None - - -class IoTSecurityDeviceAlert(msrest.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. Possible values include: "Informational", - "Low", "Medium", "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: long - """ - - _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': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTSecurityDeviceAlert, self).__init__(**kwargs) - self.alert_display_name = None - self.reported_severity = None - self.alerts_count = None - - -class IoTSecurityDeviceRecommendation(msrest.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. Possible values include: - "Informational", "Low", "Medium", "High". - :vartype reported_severity: str or ~azure.mgmt.security.models.ReportedSeverity - :ivar devices_count: Number of devices with this recommendation. - :vartype devices_count: long - """ - - _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': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IoTSecurityDeviceRecommendation, self).__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.models.IoTSeverityMetrics - :ivar unhealthy_device_count: Number of unhealthy devices within your IoT Security solution. - :vartype unhealthy_device_count: long - :ivar devices_metrics: List of device metrics by the aggregation date. - :vartype devices_metrics: - list[~azure.mgmt.security.models.IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem] - :param top_alerted_devices: List of the 3 devices with the most alerts. - :type top_alerted_devices: list[~azure.mgmt.security.models.IoTSecurityAlertedDevice] - :param most_prevalent_device_alerts: List of the 3 most prevalent device alerts. - :type most_prevalent_device_alerts: list[~azure.mgmt.security.models.IoTSecurityDeviceAlert] - :param most_prevalent_device_recommendations: List of the 3 most prevalent device - recommendations. - :type 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': 'long'}, - '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["IoTSecurityAlertedDevice"]] = None, - most_prevalent_device_alerts: Optional[List["IoTSecurityDeviceAlert"]] = None, - most_prevalent_device_recommendations: Optional[List["IoTSecurityDeviceRecommendation"]] = None, - **kwargs - ): - super(IoTSecuritySolutionAnalyticsModel, self).__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(msrest.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 Azure. - - :param value: Required. List of Security analytics of your IoT Security solution. - :type 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["IoTSecuritySolutionAnalyticsModel"], - **kwargs - ): - super(IoTSecuritySolutionAnalyticsModelList, self).__init__(**kwargs) - self.value = value - self.next_link = None - - -class IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem(msrest.serialization.Model): - """IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem. - - :param date: Aggregation of IoT Security solution device alert metrics by date. - :type date: ~datetime.datetime - :param devices_metrics: Device alert count by severity. - :type 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["IoTSeverityMetrics"] = None, - **kwargs - ): - super(IoTSecuritySolutionAnalyticsModelPropertiesDevicesMetricsItem, self).__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. - - :param tags: A set of tags. Resource tags. - :type 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 - :param location: The resource location. - :type location: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.security.models.SystemData - :param workspace: Workspace resource ID. - :type workspace: str - :param display_name: Resource display name. - :type display_name: str - :param status: Status of the IoT Security solution. Possible values include: "Enabled", - "Disabled". Default value: "Enabled". - :type status: str or ~azure.mgmt.security.models.SecuritySolutionStatus - :param export: List of additional options for exporting to workspace data. - :type export: list[str or ~azure.mgmt.security.models.ExportData] - :param disabled_data_sources: Disabled data sources. Disabling these data sources compromises - the system. - :type disabled_data_sources: list[str or ~azure.mgmt.security.models.DataSource] - :param iot_hubs: IoT Hub resource IDs. - :type iot_hubs: list[str] - :param user_defined_resources: Properties of the IoT Security solution's user defined - resources. - :type 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] - :param recommendations_configuration: List of the configuration status for each recommendation - type. - :type recommendations_configuration: - list[~azure.mgmt.security.models.RecommendationConfigurationProperties] - :param unmasked_ip_logging_status: Unmasked IP address logging status. Possible values include: - "Disabled", "Enabled". Default value: "Disabled". - :type unmasked_ip_logging_status: str or ~azure.mgmt.security.models.UnmaskedIpLoggingStatus - :param additional_workspaces: List of additional workspaces. - :type 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: Optional[Union[str, "SecuritySolutionStatus"]] = "Enabled", - export: Optional[List[Union[str, "ExportData"]]] = None, - disabled_data_sources: Optional[List[Union[str, "DataSource"]]] = None, - iot_hubs: Optional[List[str]] = None, - user_defined_resources: Optional["UserDefinedResourcesProperties"] = None, - recommendations_configuration: Optional[List["RecommendationConfigurationProperties"]] = None, - unmasked_ip_logging_status: Optional[Union[str, "UnmaskedIpLoggingStatus"]] = "Disabled", - additional_workspaces: Optional[List["AdditionalWorkspacesProperties"]] = None, - **kwargs - ): - super(IoTSecuritySolutionModel, self).__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 - 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 - - -class IoTSecuritySolutionsList(msrest.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 Azure. - - :param value: Required. List of IoT Security solutions. - :type 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["IoTSecuritySolutionModel"], - **kwargs - ): - super(IoTSecuritySolutionsList, self).__init__(**kwargs) - self.value = value - self.next_link = None - - -class IoTSeverityMetrics(msrest.serialization.Model): - """IoT Security solution analytics severity metrics. - - :param high: Count of high severity alerts/recommendations. - :type high: long - :param medium: Count of medium severity alerts/recommendations. - :type medium: long - :param low: Count of low severity alerts/recommendations. - :type low: long - """ - - _attribute_map = { - 'high': {'key': 'high', 'type': 'long'}, - 'medium': {'key': 'medium', 'type': 'long'}, - 'low': {'key': 'low', 'type': 'long'}, - } - - def __init__( - self, - *, - high: Optional[int] = None, - medium: Optional[int] = None, - low: Optional[int] = None, - **kwargs - ): - super(IoTSeverityMetrics, self).__init__(**kwargs) - self.high = high - self.medium = medium - self.low = low - - -class JitNetworkAccessPoliciesList(msrest.serialization.Model): - """JitNetworkAccessPoliciesList. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: - :type 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["JitNetworkAccessPolicy"]] = None, - **kwargs - ): - super(JitNetworkAccessPoliciesList, self).__init__(**kwargs) - self.value = value - self.next_link = 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 Azure. - - :ivar location: Location where the resource is stored. - :vartype location: str - :param kind: Kind of the resource. - :type kind: str - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param virtual_machines: Required. Configurations for Microsoft.Compute/virtualMachines - resource type. - :type virtual_machines: list[~azure.mgmt.security.models.JitNetworkAccessPolicyVirtualMachine] - :param requests: - :type 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["JitNetworkAccessPolicyVirtualMachine"], - kind: Optional[str] = None, - requests: Optional[List["JitNetworkAccessRequest"]] = None, - **kwargs - ): - super(JitNetworkAccessPolicy, self).__init__(kind=kind, **kwargs) - self.location = None - self.kind = kind - self.virtual_machines = virtual_machines - self.requests = requests - self.provisioning_state = None - self.location = None - self.id = None - self.name = None - self.type = None - self.virtual_machines = virtual_machines - self.requests = requests - self.provisioning_state = None - self.kind = kind - self.id = None - self.name = None - self.type = None - self.virtual_machines = virtual_machines - self.requests = requests - self.provisioning_state = None - - -class JitNetworkAccessPolicyInitiatePort(msrest.serialization.Model): - """JitNetworkAccessPolicyInitiatePort. - - All required parameters must be populated in order to send to Azure. - - :param number: Required. - :type number: int - :param allowed_source_address_prefix: Source of the allowed traffic. If omitted, the request - will be for the source IP address of the initiate request. - :type allowed_source_address_prefix: str - :param end_time_utc: Required. The time to close the request in UTC. - :type 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 - ): - super(JitNetworkAccessPolicyInitiatePort, self).__init__(**kwargs) - self.number = number - self.allowed_source_address_prefix = allowed_source_address_prefix - self.end_time_utc = end_time_utc - - -class JitNetworkAccessPolicyInitiateRequest(msrest.serialization.Model): - """JitNetworkAccessPolicyInitiateRequest. - - All required parameters must be populated in order to send to Azure. - - :param virtual_machines: Required. A list of virtual machines & ports to open access for. - :type virtual_machines: - list[~azure.mgmt.security.models.JitNetworkAccessPolicyInitiateVirtualMachine] - :param justification: The justification for making the initiate request. - :type 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["JitNetworkAccessPolicyInitiateVirtualMachine"], - justification: Optional[str] = None, - **kwargs - ): - super(JitNetworkAccessPolicyInitiateRequest, self).__init__(**kwargs) - self.virtual_machines = virtual_machines - self.justification = justification - - -class JitNetworkAccessPolicyInitiateVirtualMachine(msrest.serialization.Model): - """JitNetworkAccessPolicyInitiateVirtualMachine. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Resource ID of the virtual machine that is linked to this policy. - :type id: str - :param ports: Required. The ports to open for the resource with the ``id``. - :type 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, - ports: List["JitNetworkAccessPolicyInitiatePort"], - **kwargs - ): - super(JitNetworkAccessPolicyInitiateVirtualMachine, self).__init__(**kwargs) - self.id = id - self.ports = ports - - -class JitNetworkAccessPolicyVirtualMachine(msrest.serialization.Model): - """JitNetworkAccessPolicyVirtualMachine. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Resource ID of the virtual machine that is linked to this policy. - :type id: str - :param ports: Required. Port configurations for the virtual machine. - :type ports: list[~azure.mgmt.security.models.JitNetworkAccessPortRule] - :param public_ip_address: Public IP address of the Azure Firewall that is linked to this - policy, if applicable. - :type 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, - ports: List["JitNetworkAccessPortRule"], - public_ip_address: Optional[str] = None, - **kwargs - ): - super(JitNetworkAccessPolicyVirtualMachine, self).__init__(**kwargs) - self.id = id - self.ports = ports - self.public_ip_address = public_ip_address - - -class JitNetworkAccessPortRule(msrest.serialization.Model): - """JitNetworkAccessPortRule. - - All required parameters must be populated in order to send to Azure. - - :param number: Required. - :type number: int - :param protocol: Required. Possible values include: "TCP", "UDP", "*". - :type protocol: str or ~azure.mgmt.security.models.ProtocolEnum - :param 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". - :type allowed_source_address_prefix: str - :param allowed_source_address_prefixes: Mutually exclusive with the - "allowedSourceAddressPrefix" parameter. - :type allowed_source_address_prefixes: list[str] - :param max_request_access_duration: Required. Maximum duration requests can be made for. In ISO - 8601 duration format. Minimum 5 minutes, maximum 1 day. - :type 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, "ProtocolEnum"], - max_request_access_duration: str, - allowed_source_address_prefix: Optional[str] = None, - allowed_source_address_prefixes: Optional[List[str]] = None, - **kwargs - ): - super(JitNetworkAccessPortRule, self).__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(msrest.serialization.Model): - """JitNetworkAccessRequest. - - All required parameters must be populated in order to send to Azure. - - :param virtual_machines: Required. - :type virtual_machines: list[~azure.mgmt.security.models.JitNetworkAccessRequestVirtualMachine] - :param start_time_utc: Required. The start time of the request in UTC. - :type start_time_utc: ~datetime.datetime - :param requestor: Required. The identity of the person who made the request. - :type requestor: str - :param justification: The justification for making the initiate request. - :type 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["JitNetworkAccessRequestVirtualMachine"], - start_time_utc: datetime.datetime, - requestor: str, - justification: Optional[str] = None, - **kwargs - ): - super(JitNetworkAccessRequest, self).__init__(**kwargs) - self.virtual_machines = virtual_machines - self.start_time_utc = start_time_utc - self.requestor = requestor - self.justification = justification - - -class JitNetworkAccessRequestPort(msrest.serialization.Model): - """JitNetworkAccessRequestPort. - - All required parameters must be populated in order to send to Azure. - - :param number: Required. - :type number: int - :param 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". - :type allowed_source_address_prefix: str - :param allowed_source_address_prefixes: Mutually exclusive with the - "allowedSourceAddressPrefix" parameter. - :type allowed_source_address_prefixes: list[str] - :param end_time_utc: Required. The date & time at which the request ends in UTC. - :type end_time_utc: ~datetime.datetime - :param status: Required. The status of the port. Possible values include: "Revoked", - "Initiated". - :type status: str or ~azure.mgmt.security.models.Status - :param status_reason: Required. A description of why the ``status`` has its value. Possible - values include: "Expired", "UserRequested", "NewerRequestInitiated". - :type status_reason: str or ~azure.mgmt.security.models.StatusReason - :param mapped_port: The port which is mapped to this port's ``number`` in the Azure Firewall, - if applicable. - :type 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, "Status"], - status_reason: Union[str, "StatusReason"], - allowed_source_address_prefix: Optional[str] = None, - allowed_source_address_prefixes: Optional[List[str]] = None, - mapped_port: Optional[int] = None, - **kwargs - ): - super(JitNetworkAccessRequestPort, self).__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(msrest.serialization.Model): - """JitNetworkAccessRequestVirtualMachine. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Resource ID of the virtual machine that is linked to this policy. - :type id: str - :param ports: Required. The ports that were opened for the virtual machine. - :type 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, - ports: List["JitNetworkAccessRequestPort"], - **kwargs - ): - super(JitNetworkAccessRequestVirtualMachine, self).__init__(**kwargs) - self.id = id - self.ports = ports - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :ivar value_type: The value type of the items in the list. Possible values include: "IpCidr", - "String". - :vartype value_type: str or ~azure.mgmt.security.models.ValueType - :param allowlist_values: Required. The values to allow. The format of the values depends on the - rule type. - :type 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 - ): - super(LocalUserNotAllowed, self).__init__(is_enabled=is_enabled, allowlist_values=allowlist_values, **kwargs) - self.rule_type = 'LocalUserNotAllowed' # type: str - - -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 Azure. - - :param type: Required. There can be multiple identifiers of different type per alert, this - field specify the identifier type.Constant filled by server. Possible values include: - "AzureResource", "LogAnalytics". - :type 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 - ): - super(LogAnalyticsIdentifier, self).__init__(**kwargs) - self.type = 'LogAnalytics' # type: str - self.workspace_id = None - self.workspace_subscription_id = None - self.workspace_resource_group = None - self.agent_id = None - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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 - ): - super(MqttC2DMessagesNotInAllowedRange, self).__init__(is_enabled=is_enabled, min_threshold=min_threshold, max_threshold=max_threshold, time_window_size=time_window_size, **kwargs) - self.rule_type = 'MqttC2DMessagesNotInAllowedRange' # type: str - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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 - ): - super(MqttC2DRejectedMessagesNotInAllowedRange, self).__init__(is_enabled=is_enabled, min_threshold=min_threshold, max_threshold=max_threshold, time_window_size=time_window_size, **kwargs) - self.rule_type = 'MqttC2DRejectedMessagesNotInAllowedRange' # type: str - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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 - ): - super(MqttD2CMessagesNotInAllowedRange, self).__init__(is_enabled=is_enabled, min_threshold=min_threshold, max_threshold=max_threshold, time_window_size=time_window_size, **kwargs) - self.rule_type = 'MqttD2CMessagesNotInAllowedRange' # type: str - - -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 Azure. - - :param source: Required. The platform where the assessed resource resides.Constant filled by - server. Possible values include: "Azure", "OnPremise", "OnPremiseSql". - :type source: str or ~azure.mgmt.security.models.Source - :param workspace_id: Required. Azure resource Id of the workspace the machine is attached to. - :type workspace_id: str - :param vmuuid: Required. The unique Id of the machine. - :type vmuuid: str - :param source_computer_id: Required. The oms agent Id installed on the machine. - :type source_computer_id: str - :param machine_name: Required. The name of the machine. - :type 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 - ): - super(OnPremiseResourceDetails, self).__init__(**kwargs) - self.source = 'OnPremise' # type: str - 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 Azure. - - :param source: Required. The platform where the assessed resource resides.Constant filled by - server. Possible values include: "Azure", "OnPremise", "OnPremiseSql". - :type source: str or ~azure.mgmt.security.models.Source - :param workspace_id: Required. Azure resource Id of the workspace the machine is attached to. - :type workspace_id: str - :param vmuuid: Required. The unique Id of the machine. - :type vmuuid: str - :param source_computer_id: Required. The oms agent Id installed on the machine. - :type source_computer_id: str - :param machine_name: Required. The name of the machine. - :type machine_name: str - :param server_name: Required. The Sql server name installed on the machine. - :type server_name: str - :param database_name: Required. The Sql database name installed on the machine. - :type 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 - ): - super(OnPremiseSqlResourceDetails, self).__init__(workspace_id=workspace_id, vmuuid=vmuuid, source_computer_id=source_computer_id, machine_name=machine_name, **kwargs) - self.source = 'OnPremiseSql' # type: str - self.server_name = server_name - self.database_name = database_name - - -class Operation(msrest.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 - :param display: Security operation display. - :type display: ~azure.mgmt.security.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["OperationDisplay"] = None, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.origin = None - self.display = display - - -class OperationDisplay(msrest.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 - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationList(msrest.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. - - :param value: List of Security operations. - :type value: list[~azure.mgmt.security.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["Operation"]] = None, - **kwargs - ): - super(OperationList, self).__init__(**kwargs) - self.value = value - self.next_link = None - - -class PathRecommendation(msrest.serialization.Model): - """Represents a path that is recommended to be allowed and its properties. - - :param path: The full path of the file, or an identifier of the application. - :type path: str - :param action: The recommendation action of the machine or rule. Possible values include: - "Recommended", "Add", "Remove". - :type action: str or ~azure.mgmt.security.models.RecommendationAction - :param type: The type of IoT Security recommendation. Possible values include: - "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", - "IoT_VulnerableTLSCipherSuite". - :type type: str or ~azure.mgmt.security.models.RecommendationType - :param publisher_info: Represents the publisher information of a process/rule. - :type publisher_info: ~azure.mgmt.security.models.PublisherInfo - :param common: Whether the application is commonly run on the machine. - :type common: bool - :param user_sids: - :type user_sids: list[str] - :param usernames: - :type usernames: list[~azure.mgmt.security.models.UserRecommendation] - :param file_type: The type of the file (for Linux files - Executable is used). Possible values - include: "Exe", "Dll", "Msi", "Script", "Executable", "Unknown". - :type file_type: str or ~azure.mgmt.security.models.FileType - :param configuration_status: The configuration status of the machines group or machine or rule. - Possible values include: "Configured", "NotConfigured", "InProgress", "Failed", "NoStatus". - :type configuration_status: str or ~azure.mgmt.security.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, "RecommendationAction"]] = None, - type: Optional[Union[str, "RecommendationType"]] = None, - publisher_info: Optional["PublisherInfo"] = None, - common: Optional[bool] = None, - user_sids: Optional[List[str]] = None, - usernames: Optional[List["UserRecommendation"]] = None, - file_type: Optional[Union[str, "FileType"]] = None, - configuration_status: Optional[Union[str, "ConfigurationStatus"]] = None, - **kwargs - ): - super(PathRecommendation, self).__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 Pricing(Resource): - """Azure Security Center 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 - :param pricing_tier: The pricing tier value. Azure Security Center 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. - Possible values include: "Free", "Standard". - :type pricing_tier: str or ~azure.mgmt.security.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, "PricingTier"]] = None, - **kwargs - ): - super(Pricing, self).__init__(**kwargs) - self.pricing_tier = pricing_tier - self.free_trial_remaining_time = None - - -class PricingList(msrest.serialization.Model): - """List of pricing configurations response. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. List of pricing configurations. - :type value: list[~azure.mgmt.security.models.Pricing] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Pricing]'}, - } - - def __init__( - self, - *, - value: List["Pricing"], - **kwargs - ): - super(PricingList, self).__init__(**kwargs) - self.value = value - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :ivar value_type: The value type of the items in the list. Possible values include: "IpCidr", - "String". - :vartype value_type: str or ~azure.mgmt.security.models.ValueType - :param allowlist_values: Required. The values to allow. The format of the values depends on the - rule type. - :type 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 - ): - super(ProcessNotAllowed, self).__init__(is_enabled=is_enabled, allowlist_values=allowlist_values, **kwargs) - self.rule_type = 'ProcessNotAllowed' # type: str - - -class ProtectionMode(msrest.serialization.Model): - """The protection mode of the collection/file types. Exe/Msi/Script are used for Windows, Executable is used for Linux. - - :param exe: The application control policy enforcement/protection mode of the machine group. - Possible values include: "Audit", "Enforce", "None". - :type exe: str or ~azure.mgmt.security.models.EnforcementMode - :param msi: The application control policy enforcement/protection mode of the machine group. - Possible values include: "Audit", "Enforce", "None". - :type msi: str or ~azure.mgmt.security.models.EnforcementMode - :param script: The application control policy enforcement/protection mode of the machine group. - Possible values include: "Audit", "Enforce", "None". - :type script: str or ~azure.mgmt.security.models.EnforcementMode - :param executable: The application control policy enforcement/protection mode of the machine - group. Possible values include: "Audit", "Enforce", "None". - :type executable: str or ~azure.mgmt.security.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, "EnforcementMode"]] = None, - msi: Optional[Union[str, "EnforcementMode"]] = None, - script: Optional[Union[str, "EnforcementMode"]] = None, - executable: Optional[Union[str, "EnforcementMode"]] = None, - **kwargs - ): - super(ProtectionMode, self).__init__(**kwargs) - self.exe = exe - self.msi = msi - self.script = script - self.executable = executable - - -class ProxyServerProperties(msrest.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. - - :param ip: Proxy server IP. - :type ip: str - :param port: Proxy server port. - :type 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 - ): - super(ProxyServerProperties, self).__init__(**kwargs) - self.ip = ip - self.port = port - - -class PublisherInfo(msrest.serialization.Model): - """Represents the publisher information of a process/rule. - - :param 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. - :type publisher_name: str - :param product_name: The product name taken from the file's version resource. - :type product_name: str - :param binary_name: The "OriginalName" field taken from the file's version resource. - :type binary_name: str - :param version: The binary file version taken from the file's version resource. - :type 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 - ): - super(PublisherInfo, self).__init__(**kwargs) - self.publisher_name = publisher_name - self.product_name = product_name - self.binary_name = binary_name - self.version = version - - -class QueryCheck(msrest.serialization.Model): - """The rule query details. - - :param query: The rule query. - :type query: str - :param expected_result: Expected result. - :type expected_result: list[list[str]] - :param column_names: Column names of expected result. - :type 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 - ): - super(QueryCheck, self).__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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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 - ): - super(QueuePurgesNotInAllowedRange, self).__init__(is_enabled=is_enabled, min_threshold=min_threshold, max_threshold=max_threshold, time_window_size=time_window_size, **kwargs) - self.rule_type = 'QueuePurgesNotInAllowedRange' # type: str - - -class RecommendationConfigurationProperties(msrest.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 Azure. - - :param recommendation_type: Required. The type of IoT Security recommendation. Possible values - include: "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", - "IoT_VulnerableTLSCipherSuite". - :type recommendation_type: str or ~azure.mgmt.security.models.RecommendationType - :ivar name: - :vartype name: str - :param status: Required. Recommendation status. When the recommendation status is disabled - recommendations are not generated. Possible values include: "Disabled", "Enabled". Default - value: "Enabled". - :type 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, "RecommendationType"], - status: Union[str, "RecommendationConfigStatus"] = "Enabled", - **kwargs - ): - super(RecommendationConfigurationProperties, self).__init__(**kwargs) - self.recommendation_type = recommendation_type - self.name = 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 - :param state: Aggregative state based on the assessment's scanned resources states. Possible - values include: "Passed", "Failed", "Skipped", "Unsupported". - :type 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, "State"]] = None, - **kwargs - ): - super(RegulatoryComplianceAssessment, self).__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(msrest.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 Azure. - - :param value: Required. - :type 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["RegulatoryComplianceAssessment"], - **kwargs - ): - super(RegulatoryComplianceAssessmentList, self).__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 - :param state: Aggregative state based on the control's supported assessments states. Possible - values include: "Passed", "Failed", "Skipped", "Unsupported". - :type 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, "State"]] = None, - **kwargs - ): - super(RegulatoryComplianceControl, self).__init__(**kwargs) - self.description = None - self.state = state - self.passed_assessments = None - self.failed_assessments = None - self.skipped_assessments = None - - -class RegulatoryComplianceControlList(msrest.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 Azure. - - :param value: Required. List of regulatory compliance controls. - :type 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["RegulatoryComplianceControl"], - **kwargs - ): - super(RegulatoryComplianceControlList, self).__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 - :param state: Aggregative state based on the standard's supported controls states. Possible - values include: "Passed", "Failed", "Skipped", "Unsupported". - :type 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, "State"]] = None, - **kwargs - ): - super(RegulatoryComplianceStandard, self).__init__(**kwargs) - self.state = state - self.passed_controls = None - self.failed_controls = None - self.skipped_controls = None - self.unsupported_controls = None - - -class RegulatoryComplianceStandardList(msrest.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 Azure. - - :param value: Required. - :type 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["RegulatoryComplianceStandard"], - **kwargs - ): - super(RegulatoryComplianceStandardList, self).__init__(**kwargs) - self.value = value - self.next_link = None - - -class Remediation(msrest.serialization.Model): - """Remediation details. - - :param description: Remediation description. - :type description: str - :param scripts: Remediation script. - :type scripts: list[str] - :param automated: Is remediation automated. - :type automated: bool - :param portal_link: Optional link to remediate in Azure Portal. - :type 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 - ): - super(Remediation, self).__init__(**kwargs) - self.description = description - self.scripts = scripts - self.automated = automated - self.portal_link = portal_link - - -class Rule(msrest.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. - - :param name: The name of the rule. - :type name: str - :param direction: The rule's direction. Possible values include: "Inbound", "Outbound". - :type direction: str or ~azure.mgmt.security.models.Direction - :param destination_port: The rule's destination port. - :type destination_port: int - :param protocols: The rule's transport protocols. - :type protocols: list[str or ~azure.mgmt.security.models.TransportProtocol] - :param ip_addresses: The remote IP addresses that should be able to communicate with the Azure - resource on the rule's destination port and protocol. - :type 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, "Direction"]] = None, - destination_port: Optional[int] = None, - protocols: Optional[List[Union[str, "TransportProtocol"]]] = None, - ip_addresses: Optional[List[str]] = None, - **kwargs - ): - super(Rule, self).__init__(**kwargs) - self.name = name - self.direction = direction - self.destination_port = destination_port - self.protocols = protocols - self.ip_addresses = ip_addresses - - -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 - :param properties: Rule results properties. - :type 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["RuleResultsProperties"] = None, - **kwargs - ): - super(RuleResults, self).__init__(**kwargs) - self.properties = properties - - -class RuleResultsInput(msrest.serialization.Model): - """Rule results input. - - :param latest_scan: Take results from latest scan. - :type latest_scan: bool - :param results: Expected results to be inserted into the baseline. - Leave this field empty it LatestScan == true. - :type 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 - ): - super(RuleResultsInput, self).__init__(**kwargs) - self.latest_scan = latest_scan - self.results = results - - -class RuleResultsProperties(msrest.serialization.Model): - """Rule results properties. - - :param results: Expected results in the baseline. - :type results: list[list[str]] - """ - - _attribute_map = { - 'results': {'key': 'results', 'type': '[[str]]'}, - } - - def __init__( - self, - *, - results: Optional[List[List[str]]] = None, - **kwargs - ): - super(RuleResultsProperties, self).__init__(**kwargs) - self.results = results - - -class RulesResults(msrest.serialization.Model): - """A list of rules results. - - :param value: List of rule results. - :type value: list[~azure.mgmt.security.models.RuleResults] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RuleResults]'}, - } - - def __init__( - self, - *, - value: Optional[List["RuleResults"]] = None, - **kwargs - ): - super(RulesResults, self).__init__(**kwargs) - self.value = value - - -class RulesResultsInput(msrest.serialization.Model): - """Rules results input. - - :param latest_scan: Take results from latest scan. - :type latest_scan: bool - :param results: Expected results to be inserted into the baseline. - Leave this field empty it LatestScan == true. - :type 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 - ): - super(RulesResultsInput, self).__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 - :param properties: A vulnerability assessment scan record properties. - :type 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["ScanProperties"] = None, - **kwargs - ): - super(Scan, self).__init__(**kwargs) - self.properties = properties - - -class ScanProperties(msrest.serialization.Model): - """A vulnerability assessment scan record properties. - - :param trigger_type: The scan trigger type. Possible values include: "OnDemand", "Recurring". - :type trigger_type: str or ~azure.mgmt.security.models.ScanTriggerType - :param state: The scan status. Possible values include: "Failed", "FailedToRun", "InProgress", - "Passed". - :type state: str or ~azure.mgmt.security.models.ScanState - :param server: The server name. - :type server: str - :param database: The database name. - :type database: str - :param sql_version: The SQL version. - :type sql_version: str - :param start_time: The scan start time (UTC). - :type start_time: ~datetime.datetime - :param end_time: Scan results are valid until end time (UTC). - :type end_time: ~datetime.datetime - :param high_severity_failed_rules_count: The number of failed rules with high severity. - :type high_severity_failed_rules_count: int - :param medium_severity_failed_rules_count: The number of failed rules with medium severity. - :type medium_severity_failed_rules_count: int - :param low_severity_failed_rules_count: The number of failed rules with low severity. - :type low_severity_failed_rules_count: int - :param total_passed_rules_count: The number of total passed rules. - :type total_passed_rules_count: int - :param total_failed_rules_count: The number of total failed rules. - :type total_failed_rules_count: int - :param total_rules_count: The number of total rules assessed. - :type total_rules_count: int - :param is_baseline_applied: Baseline created for this database, and has one or more rules. - :type 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, "ScanTriggerType"]] = None, - state: Optional[Union[str, "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 - ): - super(ScanProperties, self).__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 - :param properties: A vulnerability assessment scan result properties for a single rule. - :type 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["ScanResultProperties"] = None, - **kwargs - ): - super(ScanResult, self).__init__(**kwargs) - self.properties = properties - - -class ScanResultProperties(msrest.serialization.Model): - """A vulnerability assessment scan result properties for a single rule. - - :param rule_id: The rule Id. - :type rule_id: str - :param status: The rule result status. Possible values include: "NonFinding", "Finding", - "InternalError". - :type status: str or ~azure.mgmt.security.models.RuleStatus - :param is_trimmed: Indicated whether the results specified here are trimmed. - :type is_trimmed: bool - :param query_results: The results of the query that was run. - :type query_results: list[list[str]] - :param remediation: Remediation details. - :type remediation: ~azure.mgmt.security.models.Remediation - :param baseline_adjusted_result: The rule result adjusted with baseline. - :type baseline_adjusted_result: ~azure.mgmt.security.models.BaselineAdjustedResult - :param rule_metadata: vulnerability assessment rule metadata details. - :type 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, "RuleStatus"]] = None, - is_trimmed: Optional[bool] = None, - query_results: Optional[List[List[str]]] = None, - remediation: Optional["Remediation"] = None, - baseline_adjusted_result: Optional["BaselineAdjustedResult"] = None, - rule_metadata: Optional["VaRule"] = None, - **kwargs - ): - super(ScanResultProperties, self).__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(msrest.serialization.Model): - """A list of vulnerability assessment scan results. - - :param value: List of vulnerability assessment scan results. - :type value: list[~azure.mgmt.security.models.ScanResult] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ScanResult]'}, - } - - def __init__( - self, - *, - value: Optional[List["ScanResult"]] = None, - **kwargs - ): - super(ScanResults, self).__init__(**kwargs) - self.value = value - - -class Scans(msrest.serialization.Model): - """A list of vulnerability assessment scan records. - - :param value: List of vulnerability assessment scan records. - :type value: list[~azure.mgmt.security.models.Scan] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Scan]'}, - } - - def __init__( - self, - *, - value: Optional[List["Scan"]] = None, - **kwargs - ): - super(Scans, self).__init__(**kwargs) - self.value = value - - -class ScopeElement(msrest.serialization.Model): - """A more specific scope used to identify the alerts to suppress. - - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type additional_properties: dict[str, any] - :param field: The alert entity type to suppress by. - :type 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 - ): - super(ScopeElement, self).__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, 'min_length': 0}, - '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 - ): - super(SecureScoreControlDefinitionItem, self).__init__(**kwargs) - self.display_name = None - self.description = None - self.max_score = None - self.source = None - self.assessment_definitions = None - - -class SecureScoreControlDefinitionList(msrest.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 - ): - super(SecureScoreControlDefinitionList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SecureScoreControlDefinitionSource(msrest.serialization.Model): - """The type of the security control (For example, BuiltIn). - - :param source_type: The type of security control (for example, BuiltIn). Possible values - include: "BuiltIn", "Custom". - :type 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, "ControlType"]] = None, - **kwargs - ): - super(SecureScoreControlDefinitionSource, self).__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: long - :param definition: Information about the security control. - :type 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': 'long'}, - '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["SecureScoreControlDefinitionItem"] = None, - **kwargs - ): - super(SecureScoreControlDetails, self).__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(msrest.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 - ): - super(SecureScoreControlList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SecureScoreControlScore(msrest.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 - ): - super(SecureScoreControlScore, self).__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: long - :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': 'long'}, - '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 - ): - super(SecureScoreItem, self).__init__(**kwargs) - self.display_name = None - self.weight = None - self.max = None - self.current = None - self.percentage = None - - -class SecureScoresList(msrest.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 - ): - super(SecureScoresList, self).__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 - :param resource_details: Details of the resource that was assessed. - :type resource_details: ~azure.mgmt.security.models.ResourceDetails - :ivar display_name: User friendly display name of the assessment. - :vartype display_name: str - :param status: The result of the assessment. - :type status: ~azure.mgmt.security.models.AssessmentStatus - :param additional_data: Additional data regarding the assessment. - :type additional_data: dict[str, str] - :ivar links: Links relevant to the assessment. - :vartype links: ~azure.mgmt.security.models.AssessmentLinks - :param metadata: Describes properties of an assessment metadata. - :type metadata: ~azure.mgmt.security.models.SecurityAssessmentMetadataProperties - :param partners_data: Data regarding 3rd party partner integration. - :type partners_data: ~azure.mgmt.security.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["ResourceDetails"] = None, - status: Optional["AssessmentStatus"] = None, - additional_data: Optional[Dict[str, str]] = None, - metadata: Optional["SecurityAssessmentMetadataProperties"] = None, - partners_data: Optional["SecurityAssessmentPartnerData"] = None, - **kwargs - ): - super(SecurityAssessment, self).__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(msrest.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.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 - ): - super(SecurityAssessmentList, self).__init__(**kwargs) - self.value = None - self.next_link = 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 - :param display_name: User friendly display name of the assessment. - :type 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 - :param description: Human readable description of the assessment. - :type description: str - :param remediation_description: Human readable description of what you should do to mitigate - this security issue. - :type remediation_description: str - :param categories: - :type categories: list[str or ~azure.mgmt.security.models.Categories] - :param severity: The severity level of the assessment. Possible values include: "Low", - "Medium", "High". - :type severity: str or ~azure.mgmt.security.models.Severity - :param user_impact: The user impact of the assessment. Possible values include: "Low", - "Moderate", "High". - :type user_impact: str or ~azure.mgmt.security.models.UserImpact - :param implementation_effort: The implementation effort required to remediate this assessment. - Possible values include: "Low", "Moderate", "High". - :type implementation_effort: str or ~azure.mgmt.security.models.ImplementationEffort - :param threats: - :type threats: list[str or ~azure.mgmt.security.models.Threats] - :param preview: True if this assessment is in preview release status. - :type preview: bool - :param assessment_type: BuiltIn if the assessment based on built-in Azure Policy definition, - Custom if the assessment based on custom Azure Policy definition. Possible values include: - "BuiltIn", "CustomPolicy", "CustomerManaged", "VerifiedPartner". - :type assessment_type: str or ~azure.mgmt.security.models.AssessmentType - :param partner_data: Describes the partner that created the assessment. - :type 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, "Categories"]]] = None, - severity: Optional[Union[str, "Severity"]] = None, - user_impact: Optional[Union[str, "UserImpact"]] = None, - implementation_effort: Optional[Union[str, "ImplementationEffort"]] = None, - threats: Optional[List[Union[str, "Threats"]]] = None, - preview: Optional[bool] = None, - assessment_type: Optional[Union[str, "AssessmentType"]] = None, - partner_data: Optional["SecurityAssessmentMetadataPartnerData"] = None, - **kwargs - ): - super(SecurityAssessmentMetadata, self).__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(msrest.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.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 - ): - super(SecurityAssessmentMetadataList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SecurityAssessmentMetadataPartnerData(msrest.serialization.Model): - """Describes the partner that created the assessment. - - All required parameters must be populated in order to send to Azure. - - :param partner_name: Required. Name of the company of the partner. - :type partner_name: str - :param product_name: Name of the product of the partner that created the assessment. - :type product_name: str - :param secret: Required. Secret to authenticate the partner and verify it created the - assessment - write only. - :type 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 - ): - super(SecurityAssessmentMetadataPartnerData, self).__init__(**kwargs) - self.partner_name = partner_name - self.product_name = product_name - self.secret = secret - - -class SecurityAssessmentMetadataProperties(msrest.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 Azure. - - :param display_name: Required. User friendly display name of the assessment. - :type 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 - :param description: Human readable description of the assessment. - :type description: str - :param remediation_description: Human readable description of what you should do to mitigate - this security issue. - :type remediation_description: str - :param categories: - :type categories: list[str or ~azure.mgmt.security.models.Categories] - :param severity: Required. The severity level of the assessment. Possible values include: - "Low", "Medium", "High". - :type severity: str or ~azure.mgmt.security.models.Severity - :param user_impact: The user impact of the assessment. Possible values include: "Low", - "Moderate", "High". - :type user_impact: str or ~azure.mgmt.security.models.UserImpact - :param implementation_effort: The implementation effort required to remediate this assessment. - Possible values include: "Low", "Moderate", "High". - :type implementation_effort: str or ~azure.mgmt.security.models.ImplementationEffort - :param threats: - :type threats: list[str or ~azure.mgmt.security.models.Threats] - :param preview: True if this assessment is in preview release status. - :type preview: bool - :param assessment_type: Required. BuiltIn if the assessment based on built-in Azure Policy - definition, Custom if the assessment based on custom Azure Policy definition. Possible values - include: "BuiltIn", "CustomPolicy", "CustomerManaged", "VerifiedPartner". - :type assessment_type: str or ~azure.mgmt.security.models.AssessmentType - :param partner_data: Describes the partner that created the assessment. - :type 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, "Severity"], - assessment_type: Union[str, "AssessmentType"], - description: Optional[str] = None, - remediation_description: Optional[str] = None, - categories: Optional[List[Union[str, "Categories"]]] = None, - user_impact: Optional[Union[str, "UserImpact"]] = None, - implementation_effort: Optional[Union[str, "ImplementationEffort"]] = None, - threats: Optional[List[Union[str, "Threats"]]] = None, - preview: Optional[bool] = None, - partner_data: Optional["SecurityAssessmentMetadataPartnerData"] = None, - **kwargs - ): - super(SecurityAssessmentMetadataProperties, self).__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(msrest.serialization.Model): - """Data regarding 3rd party partner integration. - - All required parameters must be populated in order to send to Azure. - - :param partner_name: Required. Name of the company of the partner. - :type partner_name: str - :param secret: Required. secret to authenticate the partner - write only. - :type 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 - ): - super(SecurityAssessmentPartnerData, self).__init__(**kwargs) - self.partner_name = partner_name - self.secret = secret - - -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 - :param email: The email of this security contact. - :type email: str - :param phone: The phone number of this security contact. - :type phone: str - :param alert_notifications: Whether to send security alerts notifications to the security - contact. Possible values include: "On", "Off". - :type alert_notifications: str or ~azure.mgmt.security.models.AlertNotifications - :param alerts_to_admins: Whether to send security alerts notifications to subscription admins. - Possible values include: "On", "Off". - :type alerts_to_admins: str or ~azure.mgmt.security.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, "AlertNotifications"]] = None, - alerts_to_admins: Optional[Union[str, "AlertsToAdmins"]] = None, - **kwargs - ): - super(SecurityContact, self).__init__(**kwargs) - self.email = email - self.phone = phone - self.alert_notifications = alert_notifications - self.alerts_to_admins = alerts_to_admins - - -class SecurityContactList(msrest.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.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 - ): - super(SecurityContactList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -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 - :param security_family: The security family of the security solution. Possible values include: - "Waf", "Ngfw", "SaasWaf", "Va". - :type security_family: str or ~azure.mgmt.security.models.SecurityFamily - :param provisioning_state: The security family provisioning State. Possible values include: - "Succeeded", "Failed", "Updating". - :type provisioning_state: str or ~azure.mgmt.security.models.ProvisioningState - :param template: The security solutions' template. - :type template: str - :param protection_status: The security solutions' status. - :type 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, "SecurityFamily"]] = None, - provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, - template: Optional[str] = None, - protection_status: Optional[str] = None, - **kwargs - ): - super(SecuritySolution, self).__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 - self.security_family = security_family - self.provisioning_state = provisioning_state - self.template = template - self.protection_status = protection_status - - -class SecuritySolutionList(msrest.serialization.Model): - """SecuritySolutionList. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: - :type 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["SecuritySolution"]] = None, - **kwargs - ): - super(SecuritySolutionList, self).__init__(**kwargs) - self.value = value - self.next_link = 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 Azure. - - :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 - :param security_family: Required. The security family of the security solution. Possible values - include: "Waf", "Ngfw", "SaasWaf", "Va". - :type security_family: str or ~azure.mgmt.security.models.SecurityFamily - :param alert_vendor_name: Required. The security solutions' vendor name. - :type alert_vendor_name: str - :param package_info_url: Required. The security solutions' package info url. - :type package_info_url: str - :param product_name: Required. The security solutions' product name. - :type product_name: str - :param publisher: Required. The security solutions' publisher. - :type publisher: str - :param publisher_display_name: Required. The security solutions' publisher display name. - :type publisher_display_name: str - :param template: Required. The security solutions' template. - :type 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, "SecurityFamily"], - alert_vendor_name: str, - package_info_url: str, - product_name: str, - publisher: str, - publisher_display_name: str, - template: str, - **kwargs - ): - super(SecuritySolutionsReferenceData, self).__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 - 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 - - -class SecuritySolutionsReferenceDataList(msrest.serialization.Model): - """SecuritySolutionsReferenceDataList. - - :param value: - :type value: list[~azure.mgmt.security.models.SecuritySolutionsReferenceData] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SecuritySolutionsReferenceData]'}, - } - - def __init__( - self, - *, - value: Optional[List["SecuritySolutionsReferenceData"]] = None, - **kwargs - ): - super(SecuritySolutionsReferenceDataList, self).__init__(**kwargs) - self.value = value - - -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 - :param status: Status of the sub-assessment. - :type 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 - :param resource_details: Details of the resource that was assessed. - :type resource_details: ~azure.mgmt.security.models.ResourceDetails - :param additional_data: Details of the sub-assessment. - :type 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["SubAssessmentStatus"] = None, - resource_details: Optional["ResourceDetails"] = None, - additional_data: Optional["AdditionalData"] = None, - **kwargs - ): - super(SecuritySubAssessment, self).__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(msrest.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 - ): - super(SecuritySubAssessmentList, self).__init__(**kwargs) - self.value = None - 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 - :param security_task_parameters: Changing set of properties, depending on the task type that is - derived from the name field. - :type 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["SecurityTaskParameters"] = None, - **kwargs - ): - super(SecurityTask, self).__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(msrest.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 - ): - super(SecurityTaskList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SecurityTaskParameters(msrest.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. - - :param additional_properties: Unmatched properties from the message are deserialized to this - collection. - :type 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 - ): - super(SecurityTaskParameters, self).__init__(**kwargs) - self.additional_properties = additional_properties - self.name = None - - -class SensitivityLabel(msrest.serialization.Model): - """The sensitivity label. - - :param display_name: The name of the sensitivity label. - :type display_name: str - :param description: The description of the sensitivity label. - :type description: str - :param rank: The rank of the sensitivity label. Possible values include: "None", "Low", - "Medium", "High", "Critical". - :type rank: str or ~azure.mgmt.security.models.Rank - :param order: The order of the sensitivity label. - :type order: int - :param enabled: Indicates whether the label is enabled or not. - :type 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, "Rank"]] = None, - order: Optional[int] = None, - enabled: Optional[bool] = None, - **kwargs - ): - super(SensitivityLabel, self).__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. Possible values include: "Succeeded", "Failed", "Canceled", "Provisioning", - "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 - ): - super(ServerVulnerabilityAssessment, self).__init__(**kwargs) - self.provisioning_state = None - - -class ServerVulnerabilityAssessmentsList(msrest.serialization.Model): - """List of server vulnerability assessments. - - :param value: - :type value: list[~azure.mgmt.security.models.ServerVulnerabilityAssessment] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ServerVulnerabilityAssessment]'}, - } - - def __init__( - self, - *, - value: Optional[List["ServerVulnerabilityAssessment"]] = None, - **kwargs - ): - super(ServerVulnerabilityAssessmentsList, self).__init__(**kwargs) - self.value = value - - -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 Azure. - - :param assessed_resource_type: Required. Sub-assessment resource type.Constant filled by - server. Possible values include: "SqlServerVulnerability", "ContainerRegistryVulnerability", - "ServerVulnerability". - :type 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 - ): - super(ServerVulnerabilityProperties, self).__init__(**kwargs) - self.assessed_resource_type = 'ServerVulnerabilityAssessment' # type: str - self.type = None - self.cvss = None - self.patchable = None - self.cve = None - self.threat = None - self.published_time = None - self.vendor_references = None - - -class ServicePrincipalProperties(msrest.serialization.Model): - """Details of the service principal. - - :param application_id: Application ID of service principal. - :type application_id: str - :param secret: A secret string that the application uses to prove its identity, also can be - referred to as application password (write only). - :type 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 - ): - super(ServicePrincipalProperties, self).__init__(**kwargs) - self.application_id = application_id - self.secret = secret - - -class SettingsList(msrest.serialization.Model): - """Subscription settings list. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The settings list. - :type 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["Setting"]] = None, - **kwargs - ): - super(SettingsList, self).__init__(**kwargs) - self.value = value - self.next_link = 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 - :param device_id: Unique identifier for the virtual machine in the service. - :type device_id: str - :param os_platform: Platform of the operating system running on the device. - :type os_platform: str - :param vendor: Name of the software vendor. - :type vendor: str - :param software_name: Name of the software product. - :type software_name: str - :param version: Version number of the software product. - :type version: str - :param end_of_support_status: End of support status. Possible values include: "None", - "noLongerSupported", "versionNoLongerSupported", "upcomingNoLongerSupported", - "upcomingVersionNoLongerSupported". - :type end_of_support_status: str or ~azure.mgmt.security.models.EndOfSupportStatus - :param end_of_support_date: The end of support date in case the product is upcoming end of - support. - :type end_of_support_date: str - :param number_of_known_vulnerabilities: Number of weaknesses. - :type number_of_known_vulnerabilities: int - :param first_seen_at: First time that the software was seen in the device. - :type 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, "EndOfSupportStatus"]] = None, - end_of_support_date: Optional[str] = None, - number_of_known_vulnerabilities: Optional[int] = None, - first_seen_at: Optional[str] = None, - **kwargs - ): - super(Software, self).__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(msrest.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. - - :param value: - :type 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["Software"]] = None, - **kwargs - ): - super(SoftwaresList, self).__init__(**kwargs) - self.value = value - self.next_link = 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 Azure. - - :param assessed_resource_type: Required. Sub-assessment resource type.Constant filled by - server. Possible values include: "SqlServerVulnerability", "ContainerRegistryVulnerability", - "ServerVulnerability". - :type 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 - ): - super(SqlServerVulnerabilityProperties, self).__init__(**kwargs) - self.assessed_resource_type = 'SqlServerVulnerability' # type: str - self.type = None - self.query = None - - -class SubAssessmentStatus(msrest.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. Possible values include: - "Healthy", "Unhealthy", "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. Possible values include: "Low", "Medium", - "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 - ): - super(SubAssessmentStatus, self).__init__(**kwargs) - self.code = None - self.cause = None - self.description = None - self.severity = None - - -class SuppressionAlertsScope(msrest.serialization.Model): - """SuppressionAlertsScope. - - All required parameters must be populated in order to send to Azure. - - :param all_of: Required. All the conditions inside need to be true in order to suppress the - alert. - :type 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["ScopeElement"], - **kwargs - ): - super(SuppressionAlertsScope, self).__init__(**kwargs) - self.all_of = all_of - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.security.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.security.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type 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, "CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs - ): - super(SystemData, self).__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 TopologyList(msrest.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 - ): - super(TopologyList, self).__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.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 - ): - super(TopologyResource, self).__init__(**kwargs) - self.location = None - self.calculated_date_time = None - self.topology_resources = None - self.id = None - self.name = None - self.type = None - self.calculated_date_time = None - self.topology_resources = None - - -class TopologySingleResource(msrest.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 - ): - super(TopologySingleResource, self).__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(msrest.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 - ): - super(TopologySingleResourceChild, self).__init__(**kwargs) - self.resource_id = None - - -class TopologySingleResourceParent(msrest.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 - ): - super(TopologySingleResourceParent, self).__init__(**kwargs) - self.resource_id = 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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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 - ): - super(TwinUpdatesNotInAllowedRange, self).__init__(is_enabled=is_enabled, min_threshold=min_threshold, max_threshold=max_threshold, time_window_size=time_window_size, **kwargs) - self.rule_type = 'TwinUpdatesNotInAllowedRange' # type: str - - -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 Azure. - - :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 - :param is_enabled: Required. Status of the custom alert. - :type is_enabled: bool - :param rule_type: Required. The type of the custom alert rule.Constant filled by server. - :type rule_type: str - :param min_threshold: Required. The minimum threshold. - :type min_threshold: int - :param max_threshold: Required. The maximum threshold. - :type max_threshold: int - :param time_window_size: Required. The time window size in iso8601 format. - :type 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 - ): - super(UnauthorizedOperationsNotInAllowedRange, self).__init__(is_enabled=is_enabled, min_threshold=min_threshold, max_threshold=max_threshold, time_window_size=time_window_size, **kwargs) - self.rule_type = 'UnauthorizedOperationsNotInAllowedRange' # type: str - - -class UpdateIotSecuritySolutionData(TagsResource): - """UpdateIotSecuritySolutionData. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param user_defined_resources: Properties of the IoT Security solution's user defined - resources. - :type user_defined_resources: ~azure.mgmt.security.models.UserDefinedResourcesProperties - :param recommendations_configuration: List of the configuration status for each recommendation - type. - :type 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["UserDefinedResourcesProperties"] = None, - recommendations_configuration: Optional[List["RecommendationConfigurationProperties"]] = None, - **kwargs - ): - super(UpdateIotSecuritySolutionData, self).__init__(tags=tags, **kwargs) - self.user_defined_resources = user_defined_resources - self.recommendations_configuration = recommendations_configuration - - -class UserDefinedResourcesProperties(msrest.serialization.Model): - """Properties of the IoT Security solution's user defined resources. - - All required parameters must be populated in order to send to Azure. - - :param query: Required. Azure Resource Graph query which represents the security solution's - user defined resources. Required to start with "where type != "Microsoft.Devices/IotHubs"". - :type query: str - :param query_subscriptions: Required. List of Azure subscription ids on which the user defined - resources query should be executed. - :type 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 - ): - super(UserDefinedResourcesProperties, self).__init__(**kwargs) - self.query = query - self.query_subscriptions = query_subscriptions - - -class UserRecommendation(msrest.serialization.Model): - """Represents a user that is recommended to be allowed for a certain rule. - - :param username: Represents a user that is recommended to be allowed for a certain rule. - :type username: str - :param recommendation_action: The recommendation action of the machine or rule. Possible values - include: "Recommended", "Add", "Remove". - :type recommendation_action: str or ~azure.mgmt.security.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, "RecommendationAction"]] = None, - **kwargs - ): - super(UserRecommendation, self).__init__(**kwargs) - self.username = username - self.recommendation_action = recommendation_action - - -class VaRule(msrest.serialization.Model): - """vulnerability assessment rule metadata details. - - :param rule_id: The rule Id. - :type rule_id: str - :param severity: The rule severity. Possible values include: "High", "Medium", "Low", - "Informational", "Obsolete". - :type severity: str or ~azure.mgmt.security.models.RuleSeverity - :param category: The rule category. - :type category: str - :param rule_type: The rule type. Possible values include: "Binary", "BaselineExpected", - "PositiveList", "NegativeList". - :type rule_type: str or ~azure.mgmt.security.models.RuleType - :param title: The rule title. - :type title: str - :param description: The rule description. - :type description: str - :param rationale: The rule rationale. - :type rationale: str - :param query_check: The rule query details. - :type query_check: ~azure.mgmt.security.models.QueryCheck - :param benchmark_references: The benchmark references. - :type 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, "RuleSeverity"]] = None, - category: Optional[str] = None, - rule_type: Optional[Union[str, "RuleType"]] = None, - title: Optional[str] = None, - description: Optional[str] = None, - rationale: Optional[str] = None, - query_check: Optional["QueryCheck"] = None, - benchmark_references: Optional[List["BenchmarkReference"]] = None, - **kwargs - ): - super(VaRule, self).__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(msrest.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 - ): - super(VendorReference, self).__init__(**kwargs) - self.title = None - self.link = None - - -class VmRecommendation(msrest.serialization.Model): - """Represents a machine that is part of a machine group. - - :param configuration_status: The configuration status of the machines group or machine or rule. - Possible values include: "Configured", "NotConfigured", "InProgress", "Failed", "NoStatus". - :type configuration_status: str or ~azure.mgmt.security.models.ConfigurationStatus - :param recommendation_action: The recommendation action of the machine or rule. Possible values - include: "Recommended", "Add", "Remove". - :type recommendation_action: str or ~azure.mgmt.security.models.RecommendationAction - :param resource_id: The full resource id of the machine. - :type resource_id: str - :param enforcement_support: The machine supportability of Enforce feature. Possible values - include: "Supported", "NotSupported", "Unknown". - :type enforcement_support: str or ~azure.mgmt.security.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, "ConfigurationStatus"]] = None, - recommendation_action: Optional[Union[str, "RecommendationAction"]] = None, - resource_id: Optional[str] = None, - enforcement_support: Optional[Union[str, "EnforcementSupport"]] = None, - **kwargs - ): - super(VmRecommendation, self).__init__(**kwargs) - self.configuration_status = configuration_status - self.recommendation_action = recommendation_action - self.resource_id = resource_id - self.enforcement_support = enforcement_support - - -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 - :param workspace_id: The full Azure ID of the workspace to save the data in. - :type workspace_id: str - :param 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. - :type 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 - ): - super(WorkspaceSetting, self).__init__(**kwargs) - self.workspace_id = workspace_id - self.scope = scope - - -class WorkspaceSettingList(msrest.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 Azure. - - :param value: Required. List of workspace settings. - :type 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["WorkspaceSetting"], - **kwargs - ): - super(WorkspaceSettingList, self).__init__(**kwargs) - self.value = value - self.next_link = None 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 deleted file mode 100644 index 5a8510226b69..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/models/_security_center_enums.py +++ /dev/null @@ -1,829 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AadConnectivityStateEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The connectivity state of the external AAD solution - """ - - DISCOVERED = "Discovered" - NOT_LICENSED = "NotLicensed" - CONNECTED = "Connected" - -class ActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the action that will be triggered by the Automation - """ - - LOGIC_APP = "LogicApp" - EVENT_HUB = "EventHub" - WORKSPACE = "Workspace" - -class AdaptiveApplicationControlIssue(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """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 AdditionalWorkspaceDataType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Data types sent to workspace. - """ - - ALERTS = "Alerts" - RAW_EVENTS = "RawEvents" - -class AdditionalWorkspaceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Workspace type. - """ - - SENTINEL = "Sentinel" - -class AlertNotifications(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Whether to send security alerts notifications to the security contact - """ - - #: Get notifications on new alerts. - ON = "On" - #: Don't get notifications on new alerts. - OFF = "Off" - -class AlertSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """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(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The life cycle status of the alert. - """ - - #: An alert which doesn't specify a value is assigned the status 'Active'. - ACTIVE = "Active" - #: Alert closed after handling. - RESOLVED = "Resolved" - #: Alert dismissed as false positive. - DISMISSED = "Dismissed" - -class AlertsToAdmins(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Whether to send security alerts notifications to subscription admins - """ - - #: Send notification on new alerts to the subscription's admins. - ON = "On" - #: Don't send notification on new alerts to the subscription's admins. - OFF = "Off" - -class AssessedResourceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Sub-assessment resource type - """ - - SQL_SERVER_VULNERABILITY = "SqlServerVulnerability" - CONTAINER_REGISTRY_VULNERABILITY = "ContainerRegistryVulnerability" - SERVER_VULNERABILITY = "ServerVulnerability" - -class AssessmentStatusCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Programmatic code for the status of the assessment - """ - - #: The resource is healthy. - HEALTHY = "Healthy" - #: The resource has a security issue that needs to be addressed. - UNHEALTHY = "Unhealthy" - #: Assessment for this resource did not happen. - NOT_APPLICABLE = "NotApplicable" - -class AssessmentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """BuiltIn if the assessment based on built-in Azure Policy definition, Custom if the assessment - based on custom Azure Policy definition - """ - - #: Azure Security Center managed assessments. - BUILT_IN = "BuiltIn" - #: User defined policies that are automatically ingested from Azure Policy to Azure Security - #: Center. - CUSTOM_POLICY = "CustomPolicy" - #: User assessments pushed directly by the user or other third party to Azure Security Center. - CUSTOMER_MANAGED = "CustomerManaged" - #: An assessment that was created by a verified 3rd party if the user connected it to ASC. - VERIFIED_PARTNER = "VerifiedPartner" - -class AuthenticationProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """State of the multi-cloud connector - """ - - #: Valid connector. - VALID = "Valid" - #: Invalid connector. - INVALID = "Invalid" - #: the connection has expired. - EXPIRED = "Expired" - #: Incorrect policy of the connector. - INCORRECT_POLICY = "IncorrectPolicy" - -class AuthenticationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Connect to your cloud account, for AWS use either account credentials or role-based - authentication. For GCP use account organization credentials. - """ - - #: AWS cloud account connector user credentials authentication. - AWS_CREDS = "awsCreds" - #: AWS account connector assume role authentication. - AWS_ASSUME_ROLE = "awsAssumeRole" - #: GCP account connector service to service authentication. - GCP_CREDENTIALS = "gcpCredentials" - -class AutoProvision(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Describes what kind of security agent provisioning action to take - """ - - #: Install missing security agent on VMs automatically. - ON = "On" - #: Do not install security agent on the VMs automatically. - OFF = "Off" - -class BundleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """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 Categories(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """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(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """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(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - - INTERNAL = "Internal" - EXTERNAL = "External" - -class ControlType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of security control (for example, BuiltIn) - """ - - #: Azure Security Center managed assessments. - BUILT_IN = "BuiltIn" - #: Non Azure Security Center managed assessments. - CUSTOM = "Custom" - -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ - - USER = "User" - APPLICATION = "Application" - MANAGED_IDENTITY = "ManagedIdentity" - KEY = "Key" - -class DataSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - - #: Devices twin data. - TWIN_DATA = "TwinData" - -class Direction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The rule's direction - """ - - INBOUND = "Inbound" - OUTBOUND = "Outbound" - -class EndOfSupportStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """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 EnforcementMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The application control policy enforcement/protection mode of the machine group - """ - - AUDIT = "Audit" - ENFORCE = "Enforce" - NONE = "None" - -class EnforcementSupport(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The machine supportability of Enforce feature - """ - - SUPPORTED = "Supported" - NOT_SUPPORTED = "NotSupported" - UNKNOWN = "Unknown" - -class Enum13(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - - ACTIVATE = "Activate" - DISMISS = "Dismiss" - START = "Start" - RESOLVE = "Resolve" - CLOSE = "Close" - -class Enum15(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - - EFFECTIVE = "effective" - CUSTOM = "custom" - -class Enum69(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - - MCAS = "MCAS" - WDATP = "WDATP" - WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW = "WDATP_EXCLUDE_LINUX_PUBLIC_PREVIEW" - SENTINEL = "Sentinel" - -class EventSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """A valid event source type. - """ - - ASSESSMENTS = "Assessments" - SUB_ASSESSMENTS = "SubAssessments" - 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 ExpandControlsEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - - #: Add definition object for each control. - DEFINITION = "definition" - -class ExpandEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - - #: All links associated with an assessment. - LINKS = "links" - #: Assessment metadata. - METADATA = "metadata" - -class ExportData(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - - #: Agent raw events. - RAW_EVENTS = "RawEvents" - -class ExternalSecuritySolutionKindEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The kind of the external solution - """ - - CEF = "CEF" - ATA = "ATA" - AAD = "AAD" - -class FileType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of the file (for Linux files - Executable is used) - """ - - EXE = "Exe" - DLL = "Dll" - MSI = "Msi" - SCRIPT = "Script" - EXECUTABLE = "Executable" - UNKNOWN = "Unknown" - -class HybridComputeProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """State of the service principal and its secret - """ - - #: Valid service principal details. - VALID = "Valid" - #: Invalid service principal details. - INVALID = "Invalid" - #: the service principal details are expired. - EXPIRED = "Expired" - -class ImplementationEffort(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The implementation effort required to remediate this assessment - """ - - LOW = "Low" - MODERATE = "Moderate" - HIGH = "High" - -class Intent(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """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" - #: 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 `_. - PRE_ATTACK = "PreAttack" - #: InitialAccess is the stage where an attacker manages to get foothold on the attacked resource. - INITIAL_ACCESS = "InitialAccess" - #: Persistence is any access, action, or configuration change to a system that gives a threat - #: actor a persistent presence on that system. - PERSISTENCE = "Persistence" - #: Privilege escalation is the result of actions that allow an adversary to obtain a higher level - #: of permissions on a system or network. - PRIVILEGE_ESCALATION = "PrivilegeEscalation" - #: Defense evasion consists of techniques an adversary may use to evade detection or avoid other - #: defenses. - DEFENSE_EVASION = "DefenseEvasion" - #: Credential access represents techniques resulting in access to or control over system, domain, - #: or service credentials that are used within an enterprise environment. - CREDENTIAL_ACCESS = "CredentialAccess" - #: Discovery consists of techniques that allow the adversary to gain knowledge about the system - #: and internal network. - DISCOVERY = "Discovery" - #: 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. - LATERAL_MOVEMENT = "LateralMovement" - #: The execution tactic represents techniques that result in execution of adversary-controlled - #: code on a local or remote system. - EXECUTION = "Execution" - #: Collection consists of techniques used to identify and gather information, such as sensitive - #: files, from a target network prior to exfiltration. - COLLECTION = "Collection" - #: Exfiltration refers to techniques and attributes that result or aid in the adversary removing - #: files and information from a target network. - EXFILTRATION = "Exfiltration" - #: The command and control tactic represents how adversaries communicate with systems under their - #: control within a target network. - COMMAND_AND_CONTROL = "CommandAndControl" - #: 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. - IMPACT = "Impact" - #: 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. - PROBING = "Probing" - #: 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. - EXPLOITATION = "Exploitation" - -class KindEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The kind of alert simulation. - """ - - #: Simulate alerts according to bundles. - BUNDLES = "Bundles" - -class Operator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """A valid comparer operator to use. A case-insensitive comparison will be applied for String - PropertyType. - """ - - #: Applies for decimal and non-decimal operands. - EQUALS = "Equals" - #: Applies only for 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 for decimal and non-decimal operands. - NOT_EQUALS = "NotEquals" - #: Applies only for non-decimal operands. - CONTAINS = "Contains" - #: Applies only for non-decimal operands. - STARTS_WITH = "StartsWith" - #: Applies only for non-decimal operands. - ENDS_WITH = "EndsWith" - -class PermissionProperty(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """A permission detected in the cloud account. - """ - - #: This permission provides read only access to AWS Security Hub resources. - AWS_AWS_SECURITY_HUB_READ_ONLY_ACCESS = "AWS::AWSSecurityHubReadOnlyAccess" - #: This permission grants access to read security configuration metadata. - AWS_SECURITY_AUDIT = "AWS::SecurityAudit" - #: The permission provides for EC2 Automation service to execute activities defined within - #: Automation documents. - AWS_AMAZON_SSM_AUTOMATION_ROLE = "AWS::AmazonSSMAutomationRole" - #: This permission provides read only access to GCP Security Command Center. - GCP_SECURITY_CENTER_ADMIN_VIEWER = "GCP::Security Center Admin Viewer" - -class PricingTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The pricing tier value. Azure Security Center 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. - """ - - #: Get free Azure security center experience with basic security features. - FREE = "Free" - #: Get the standard Azure security center experience with advanced security features. - STANDARD = "Standard" - -class PropertyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """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(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - - TCP = "TCP" - UDP = "UDP" - ALL = "*" - -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The security family provisioning State - """ - - SUCCEEDED = "Succeeded" - FAILED = "Failed" - UPDATING = "Updating" - -class Rank(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The rank of the sensitivity label. - """ - - NONE = "None" - LOW = "Low" - MEDIUM = "Medium" - HIGH = "High" - CRITICAL = "Critical" - -class RecommendationAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The recommendation action of the machine or rule - """ - - RECOMMENDED = "Recommended" - ADD = "Add" - REMOVE = "Remove" - -class RecommendationConfigStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Recommendation status. When the recommendation status is disabled recommendations are not - generated. - """ - - DISABLED = "Disabled" - ENABLED = "Enabled" - -class RecommendationStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The initial recommendation status of the machine group or machine - """ - - RECOMMENDED = "Recommended" - NOT_RECOMMENDED = "NotRecommended" - NOT_AVAILABLE = "NotAvailable" - NO_STATUS = "NoStatus" - -class RecommendationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of IoT Security recommendation. - """ - - #: Authentication schema used for pull an edge module from an ACR repository does not use Service - #: Principal Authentication. - IO_T_ACRAUTHENTICATION = "IoT_ACRAuthentication" - #: 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_AGENT_SENDS_UNUTILIZED_MESSAGES = "IoT_AgentSendsUnutilizedMessages" - #: Identified security related system configuration issues. - IO_T_BASELINE = "IoT_Baseline" - #: 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_HUB_MEM_OPTIMIZE = "IoT_EdgeHubMemOptimize" - #: Logging is disabled for this edge module. - IO_T_EDGE_LOGGING_OPTIONS = "IoT_EdgeLoggingOptions" - #: A minority within a device security group has inconsistent Edge Module settings with the rest - #: of their group. - IO_T_INCONSISTENT_MODULE_SETTINGS = "IoT_InconsistentModuleSettings" - #: Install the Azure Security of Things Agent. - IO_T_INSTALL_AGENT = "IoT_InstallAgent" - #: IP Filter Configuration should have rules defined for allowed traffic and should deny all other - #: traffic by default. - IO_T_IPFILTER_DENY_ALL = "IoT_IPFilter_DenyAll" - #: An Allow IP Filter rules source IP range is too large. Overly permissive rules might expose - #: your IoT hub to malicious intenders. - IO_T_IPFILTER_PERMISSIVE_RULE = "IoT_IPFilter_PermissiveRule" - #: A listening endpoint was found on the device. - IO_T_OPEN_PORTS = "IoT_OpenPorts" - #: 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_FIREWALL_POLICY = "IoT_PermissiveFirewallPolicy" - #: 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_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" - #: 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_PRIVILEGED_DOCKER_OPTIONS = "IoT_PrivilegedDockerOptions" - #: 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_SHARED_CREDENTIALS = "IoT_SharedCredentials" - #: Insecure TLS configurations detected. Immediate upgrade recommended. - IO_T_VULNERABLE_TLS_CIPHER_SUITE = "IoT_VulnerableTLSCipherSuite" - -class ReportedSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Assessed alert severity. - """ - - INFORMATIONAL = "Informational" - LOW = "Low" - MEDIUM = "Medium" - HIGH = "High" - -class ResourceIdentifierType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """There can be multiple identifiers of different type per alert, this field specify the - identifier type. - """ - - AZURE_RESOURCE = "AzureResource" - LOG_ANALYTICS = "LogAnalytics" - -class ResourceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The status of the resource regarding a single assessment - """ - - #: This assessment on the resource is healthy. - HEALTHY = "Healthy" - #: This assessment is not applicable to this resource. - NOT_APPLICABLE = "NotApplicable" - #: This assessment is turned off by policy on this subscription. - OFF_BY_POLICY = "OffByPolicy" - #: This assessment on the resource is not healthy. - NOT_HEALTHY = "NotHealthy" - -class RuleSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The rule severity. - """ - - #: High. - HIGH = "High" - #: Medium. - MEDIUM = "Medium" - #: Low. - LOW = "Low" - #: Informational. - INFORMATIONAL = "Informational" - #: Obsolete. - OBSOLETE = "Obsolete" - -class RuleState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Possible states of the rule - """ - - ENABLED = "Enabled" - DISABLED = "Disabled" - EXPIRED = "Expired" - -class RuleStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The rule result status. - """ - - #: NonFinding. - NON_FINDING = "NonFinding" - #: Finding. - FINDING = "Finding" - #: InternalError. - INTERNAL_ERROR = "InternalError" - -class RuleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The rule type. - """ - - #: Binary. - BINARY = "Binary" - #: BaselineExpected. - BASELINE_EXPECTED = "BaselineExpected" - #: PositiveList. - POSITIVE_LIST = "PositiveList" - #: NegativeList. - NEGATIVE_LIST = "NegativeList" - -class ScanState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The scan status. - """ - - #: Failed. - FAILED = "Failed" - #: FailedToRun. - FAILED_TO_RUN = "FailedToRun" - #: InProgress. - IN_PROGRESS = "InProgress" - #: Passed. - PASSED = "Passed" - -class ScanTriggerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The scan trigger type. - """ - - #: OnDemand. - ON_DEMAND = "OnDemand" - #: Recurring. - RECURRING = "Recurring" - -class SecurityFamily(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The security family of the discovered solution - """ - - WAF = "Waf" - NGFW = "Ngfw" - SAAS_WAF = "SaasWaf" - VA = "Va" - -class SecuritySolutionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Status of the IoT Security solution. - """ - - ENABLED = "Enabled" - DISABLED = "Disabled" - -class ServerVulnerabilityAssessmentPropertiesProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The provisioningState of the vulnerability assessment capability on the VM - """ - - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - PROVISIONING = "Provisioning" - DEPROVISIONING = "Deprovisioning" - -class SettingKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """the kind of the settings string - """ - - DATA_EXPORT_SETTINGS = "DataExportSettings" - ALERT_SUPPRESSION_SETTING = "AlertSuppressionSetting" - ALERT_SYNC_SETTINGS = "AlertSyncSettings" - -class Severity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The sub-assessment severity level - """ - - LOW = "Low" - MEDIUM = "Medium" - HIGH = "High" - -class Source(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The platform where the assessed resource resides - """ - - #: Resource is in Azure. - AZURE = "Azure" - #: Resource in an on premise machine connected to Azure cloud. - ON_PREMISE = "OnPremise" - #: SQL Resource in an on premise machine connected to Azure cloud. - ON_PREMISE_SQL = "OnPremiseSql" - -class SourceSystem(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """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 State(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Aggregative state based on the standard's supported controls states - """ - - #: All supported regulatory compliance controls in the given standard have a passed state. - PASSED = "Passed" - #: At least one supported regulatory compliance control in the given standard has a state of - #: failed. - FAILED = "Failed" - #: All supported regulatory compliance controls in the given standard have a state of skipped. - SKIPPED = "Skipped" - #: No supported regulatory compliance data for the given standard. - UNSUPPORTED = "Unsupported" - -class Status(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The status of the port - """ - - REVOKED = "Revoked" - INITIATED = "Initiated" - -class StatusReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """A description of why the ``status`` has its value - """ - - EXPIRED = "Expired" - USER_REQUESTED = "UserRequested" - NEWER_REQUEST_INITIATED = "NewerRequestInitiated" - -class SubAssessmentStatusCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Programmatic code for the status of the assessment - """ - - #: The resource is healthy. - HEALTHY = "Healthy" - #: The resource has a security issue that needs to be addressed. - UNHEALTHY = "Unhealthy" - #: Assessment for this resource did not happen. - NOT_APPLICABLE = "NotApplicable" - -class Threats(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """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(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - - TCP = "TCP" - UDP = "UDP" - -class UnmaskedIpLoggingStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Unmasked IP address logging status - """ - - #: Unmasked IP logging is disabled. - DISABLED = "Disabled" - #: Unmasked IP logging is enabled. - ENABLED = "Enabled" - -class UserImpact(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The user impact of the assessment - """ - - LOW = "Low" - MODERATE = "Moderate" - HIGH = "High" - -class ValueType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The value type of the items in the list. - """ - - #: An IP range in CIDR format (e.g. '192.168.0.1/8'). - IP_CIDR = "IpCidr" - #: Any string value. - STRING = "String" 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 deleted file mode 100644 index 65df4fa5ef35..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/__init__.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 ._compliance_results_operations import ComplianceResultsOperations -from ._pricings_operations import PricingsOperations -from ._advanced_threat_protection_operations import AdvancedThreatProtectionOperations -from ._device_security_groups_operations import DeviceSecurityGroupsOperations -from ._iot_security_solution_operations import IotSecuritySolutionOperations -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 ._locations_operations import LocationsOperations -from ._operations import Operations -from ._tasks_operations import TasksOperations -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 ._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 ._automations_operations import AutomationsOperations -from ._alerts_suppression_rules_operations import AlertsSuppressionRulesOperations -from ._server_vulnerability_assessment_operations import ServerVulnerabilityAssessmentOperations -from ._assessments_metadata_operations import AssessmentsMetadataOperations -from ._assessments_operations import AssessmentsOperations -from ._adaptive_application_controls_operations import AdaptiveApplicationControlsOperations -from ._adaptive_network_hardenings_operations import AdaptiveNetworkHardeningsOperations -from ._allowed_connections_operations import AllowedConnectionsOperations -from ._topology_operations import TopologyOperations -from ._jit_network_access_policies_operations import JitNetworkAccessPoliciesOperations -from ._discovered_security_solutions_operations import DiscoveredSecuritySolutionsOperations -from ._security_solutions_reference_data_operations import SecuritySolutionsReferenceDataOperations -from ._external_security_solutions_operations import ExternalSecuritySolutionsOperations -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 ._connectors_operations import ConnectorsOperations -from ._sql_vulnerability_assessment_scans_operations import SqlVulnerabilityAssessmentScansOperations -from ._sql_vulnerability_assessment_scan_results_operations import SqlVulnerabilityAssessmentScanResultsOperations -from ._sql_vulnerability_assessment_baseline_rules_operations import SqlVulnerabilityAssessmentBaselineRulesOperations -from ._alerts_operations import AlertsOperations -from ._settings_operations import SettingsOperations -from ._ingestion_settings_operations import IngestionSettingsOperations -from ._software_inventories_operations import SoftwareInventoriesOperations - -__all__ = [ - 'ComplianceResultsOperations', - 'PricingsOperations', - 'AdvancedThreatProtectionOperations', - 'DeviceSecurityGroupsOperations', - 'IotSecuritySolutionOperations', - 'IotSecuritySolutionAnalyticsOperations', - 'IotSecuritySolutionsAnalyticsAggregatedAlertOperations', - 'IotSecuritySolutionsAnalyticsRecommendationOperations', - 'LocationsOperations', - 'Operations', - 'TasksOperations', - 'AutoProvisioningSettingsOperations', - 'CompliancesOperations', - 'InformationProtectionPoliciesOperations', - 'SecurityContactsOperations', - 'WorkspaceSettingsOperations', - 'RegulatoryComplianceStandardsOperations', - 'RegulatoryComplianceControlsOperations', - 'RegulatoryComplianceAssessmentsOperations', - 'SubAssessmentsOperations', - 'AutomationsOperations', - 'AlertsSuppressionRulesOperations', - 'ServerVulnerabilityAssessmentOperations', - 'AssessmentsMetadataOperations', - 'AssessmentsOperations', - 'AdaptiveApplicationControlsOperations', - 'AdaptiveNetworkHardeningsOperations', - 'AllowedConnectionsOperations', - 'TopologyOperations', - 'JitNetworkAccessPoliciesOperations', - 'DiscoveredSecuritySolutionsOperations', - 'SecuritySolutionsReferenceDataOperations', - 'ExternalSecuritySolutionsOperations', - 'SecureScoresOperations', - 'SecureScoreControlsOperations', - 'SecureScoreControlDefinitionsOperations', - 'SecuritySolutionsOperations', - 'ConnectorsOperations', - 'SqlVulnerabilityAssessmentScansOperations', - 'SqlVulnerabilityAssessmentScanResultsOperations', - 'SqlVulnerabilityAssessmentBaselineRulesOperations', - 'AlertsOperations', - 'SettingsOperations', - 'IngestionSettingsOperations', - 'SoftwareInventoriesOperations', -] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_adaptive_application_controls_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_adaptive_application_controls_operations.py deleted file mode 100644 index ff1fdae05480..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_adaptive_application_controls_operations.py +++ /dev/null @@ -1,279 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AdaptiveApplicationControlsOperations(object): - """AdaptiveApplicationControlsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - include_path_recommendations=None, # type: Optional[bool] - summary=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> "_models.AdaptiveApplicationControlGroups" - """Gets a list of application control machine groups for the subscription. - - :param include_path_recommendations: Include the policy rules. - :type include_path_recommendations: bool - :param summary: Return output in a summarized form. - :type summary: bool - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AdaptiveApplicationControlGroups, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AdaptiveApplicationControlGroups - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AdaptiveApplicationControlGroups"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if include_path_recommendations is not None: - query_parameters['includePathRecommendations'] = self._serialize.query("include_path_recommendations", include_path_recommendations, 'bool') - if summary is not None: - query_parameters['summary'] = self._serialize.query("summary", summary, 'bool') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/applicationWhitelistings'} # type: ignore - - def get( - self, - group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AdaptiveApplicationControlGroup" - """Gets an application control VM/server group. - - :param group_name: Name of an application control machine group. - :type group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AdaptiveApplicationControlGroup, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AdaptiveApplicationControlGroup - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AdaptiveApplicationControlGroup"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'groupName': self._serialize.url("group_name", group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}'} # type: ignore - - def put( - self, - group_name, # type: str - body, # type: "_models.AdaptiveApplicationControlGroup" - **kwargs # type: Any - ): - # type: (...) -> "_models.AdaptiveApplicationControlGroup" - """Update an application control machine group. - - :param group_name: Name of an application control machine group. - :type group_name: str - :param body: - :type body: ~azure.mgmt.security.models.AdaptiveApplicationControlGroup - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AdaptiveApplicationControlGroup, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AdaptiveApplicationControlGroup - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AdaptiveApplicationControlGroup"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'groupName': self._serialize.url("group_name", group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'AdaptiveApplicationControlGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}'} # type: ignore - - def delete( - self, - group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Delete an application control machine group. - - :param group_name: Name of an application control machine group. - :type group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'groupName': self._serialize.url("group_name", group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}'} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_adaptive_network_hardenings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_adaptive_network_hardenings_operations.py deleted file mode 100644 index 9bb7da3b503f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_adaptive_network_hardenings_operations.py +++ /dev/null @@ -1,352 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AdaptiveNetworkHardeningsOperations(object): - """AdaptiveNetworkHardeningsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_by_extended_resource( - self, - resource_group_name, # type: str - resource_namespace, # type: str - resource_type, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AdaptiveNetworkHardeningsList"] - """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. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. - :type resource_namespace: str - :param resource_type: The type of the resource. - :type resource_type: str - :param resource_name: Name of the resource. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AdaptiveNetworkHardeningsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AdaptiveNetworkHardeningsList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AdaptiveNetworkHardeningsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_extended_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_extended_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings'} # type: ignore - - def get( - self, - resource_group_name, # type: str - resource_namespace, # type: str - resource_type, # type: str - resource_name, # type: str - adaptive_network_hardening_resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. - :type resource_namespace: str - :param resource_type: The type of the resource. - :type resource_type: str - :param resource_name: Name of the resource. - :type resource_name: str - :param adaptive_network_hardening_resource_name: The name of the Adaptive Network Hardening - resource. - :type adaptive_network_hardening_resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AdaptiveNetworkHardening, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AdaptiveNetworkHardening - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AdaptiveNetworkHardening"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'adaptiveNetworkHardeningResourceName': self._serialize.url("adaptive_network_hardening_resource_name", adaptive_network_hardening_resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}'} # type: ignore - - def _enforce_initial( - self, - resource_group_name, # type: str - resource_namespace, # type: str - resource_type, # type: str - resource_name, # type: str - adaptive_network_hardening_resource_name, # type: str - body, # type: "_models.AdaptiveNetworkHardeningEnforceRequest" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - adaptive_network_hardening_enforce_action = "enforce" - api_version = "2020-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._enforce_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'adaptiveNetworkHardeningResourceName': self._serialize.url("adaptive_network_hardening_resource_name", adaptive_network_hardening_resource_name, 'str'), - 'adaptiveNetworkHardeningEnforceAction': self._serialize.url("adaptive_network_hardening_enforce_action", adaptive_network_hardening_enforce_action, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'AdaptiveNetworkHardeningEnforceRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - _enforce_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}/{adaptiveNetworkHardeningEnforceAction}'} # type: ignore - - def begin_enforce( - self, - resource_group_name, # type: str - resource_namespace, # type: str - resource_type, # type: str - resource_name, # type: str - adaptive_network_hardening_resource_name, # type: str - body, # type: "_models.AdaptiveNetworkHardeningEnforceRequest" - **kwargs # type: Any - ): - # type: (...) -> 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. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. - :type resource_namespace: str - :param resource_type: The type of the resource. - :type resource_type: str - :param resource_name: Name of the resource. - :type resource_name: str - :param adaptive_network_hardening_resource_name: The name of the Adaptive Network Hardening - resource. - :type adaptive_network_hardening_resource_name: str - :param body: - :type body: ~azure.mgmt.security.models.AdaptiveNetworkHardeningEnforceRequest - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._enforce_initial( - 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, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - adaptive_network_hardening_enforce_action = "enforce" - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'adaptiveNetworkHardeningResourceName': self._serialize.url("adaptive_network_hardening_resource_name", adaptive_network_hardening_resource_name, 'str'), - 'adaptiveNetworkHardeningEnforceAction': self._serialize.url("adaptive_network_hardening_enforce_action", adaptive_network_hardening_enforce_action, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_enforce.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}/{adaptiveNetworkHardeningEnforceAction}'} # type: ignore 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 deleted file mode 100644 index 359abd268523..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_advanced_threat_protection_operations.py +++ /dev/null @@ -1,165 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AdvancedThreatProtectionOperations(object): - """AdvancedThreatProtectionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - resource_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AdvancedThreatProtectionSetting" - """Gets the Advanced Threat Protection settings for the specified resource. - - :param resource_id: The identifier of the resource. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AdvancedThreatProtectionSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AdvancedThreatProtectionSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AdvancedThreatProtectionSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - setting_name = "current" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - 'settingName': self._serialize.url("setting_name", setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/advancedThreatProtectionSettings/{settingName}'} # type: ignore - - def create( - self, - resource_id, # type: str - advanced_threat_protection_setting, # type: "_models.AdvancedThreatProtectionSetting" - **kwargs # type: Any - ): - # type: (...) -> "_models.AdvancedThreatProtectionSetting" - """Creates or updates the Advanced Threat Protection settings on a specified resource. - - :param resource_id: The identifier of the resource. - :type resource_id: str - :param advanced_threat_protection_setting: Advanced Threat Protection Settings. - :type advanced_threat_protection_setting: ~azure.mgmt.security.models.AdvancedThreatProtectionSetting - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AdvancedThreatProtectionSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AdvancedThreatProtectionSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AdvancedThreatProtectionSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01" - setting_name = "current" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - 'settingName': self._serialize.url("setting_name", setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(advanced_threat_protection_setting, 'AdvancedThreatProtectionSetting') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - create.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/advancedThreatProtectionSettings/{settingName}'} # 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 deleted file mode 100644 index 531b78365081..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_alerts_operations.py +++ /dev/null @@ -1,888 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AlertsOperations(object): - """AlertsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AlertList"] - """List all the alerts that are associated with the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/alerts'} # type: ignore - - def list_by_resource_group( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AlertList"] - """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. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/alerts'} # type: ignore - - def list_subscription_level_by_region( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AlertList"] - """List all the alerts that are associated with the subscription that are stored in a specific - location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_subscription_level_by_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_subscription_level_by_region.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts'} # type: ignore - - def list_resource_group_level_by_region( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AlertList"] - """List all the alerts that are associated with the resource group that are stored in a specific - location. - - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AlertList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_resource_group_level_by_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_resource_group_level_by_region.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts'} # type: ignore - - def get_subscription_level( - self, - alert_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Alert" - """Get an alert that is associated with a subscription. - - :param alert_name: Name of the alert object. - :type alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_subscription_level.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'alertName': self._serialize.url("alert_name", alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get_subscription_level.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}'} # type: ignore - - def get_resource_group_level( - self, - alert_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Alert" - """Get an alert that is associated a resource group or a resource in a resource group. - - :param alert_name: Name of the alert object. - :type alert_name: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Alert, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Alert - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Alert"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.get_resource_group_level.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'alertName': self._serialize.url("alert_name", alert_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get_resource_group_level.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}'} # type: ignore - - def update_subscription_level_state_to_dismiss( - self, - alert_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Update the alert's state. - - :param alert_name: Name of the alert object. - :type alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.update_subscription_level_state_to_dismiss.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'alertName': self._serialize.url("alert_name", alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - update_subscription_level_state_to_dismiss.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss'} # type: ignore - - def update_subscription_level_state_to_resolve( - self, - alert_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Update the alert's state. - - :param alert_name: Name of the alert object. - :type alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.update_subscription_level_state_to_resolve.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'alertName': self._serialize.url("alert_name", alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - update_subscription_level_state_to_resolve.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/resolve'} # type: ignore - - def update_subscription_level_state_to_activate( - self, - alert_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Update the alert's state. - - :param alert_name: Name of the alert object. - :type alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.update_subscription_level_state_to_activate.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'alertName': self._serialize.url("alert_name", alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - update_subscription_level_state_to_activate.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/activate'} # type: ignore - - def update_resource_group_level_state_to_resolve( - self, - alert_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Update the alert's state. - - :param alert_name: Name of the alert object. - :type alert_name: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.update_resource_group_level_state_to_resolve.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'alertName': self._serialize.url("alert_name", alert_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - update_resource_group_level_state_to_resolve.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/resolve'} # type: ignore - - def update_resource_group_level_state_to_dismiss( - self, - alert_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Update the alert's state. - - :param alert_name: Name of the alert object. - :type alert_name: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.update_resource_group_level_state_to_dismiss.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'alertName': self._serialize.url("alert_name", alert_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - update_resource_group_level_state_to_dismiss.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss'} # type: ignore - - def update_resource_group_level_state_to_activate( - self, - alert_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Update the alert's state. - - :param alert_name: Name of the alert object. - :type alert_name: str - :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - accept = "application/json" - - # Construct URL - url = self.update_resource_group_level_state_to_activate.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'alertName': self._serialize.url("alert_name", alert_name, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - update_resource_group_level_state_to_activate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/activate'} # type: ignore - - def _simulate_initial( - self, - alert_simulator_request_body, # type: "_models.AlertSimulatorRequestBody" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._simulate_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(alert_simulator_request_body, 'AlertSimulatorRequestBody') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - _simulate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/default/simulate'} # type: ignore - - def begin_simulate( - self, - alert_simulator_request_body, # type: "_models.AlertSimulatorRequestBody" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Simulate security alerts. - - :param alert_simulator_request_body: Alert Simulator Request Properties. - :type alert_simulator_request_body: ~azure.mgmt.security.models.AlertSimulatorRequestBody - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._simulate_initial( - alert_simulator_request_body=alert_simulator_request_body, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_simulate.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/default/simulate'} # 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 deleted file mode 100644 index 21a4be9ec102..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_alerts_suppression_rules_operations.py +++ /dev/null @@ -1,288 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AlertsSuppressionRulesOperations(object): - """AlertsSuppressionRulesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - alert_type=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AlertsSuppressionRulesList"] - """List of all the dismiss rules for the given subscription. - - :param alert_type: Type of the alert to get rules for. - :type alert_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertsSuppressionRulesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AlertsSuppressionRulesList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertsSuppressionRulesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if alert_type is not None: - query_parameters['AlertType'] = self._serialize.query("alert_type", alert_type, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules'} # type: ignore - - def get( - self, - alerts_suppression_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type alerts_suppression_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertsSuppressionRule, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AlertsSuppressionRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertsSuppressionRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'alertsSuppressionRuleName': self._serialize.url("alerts_suppression_rule_name", alerts_suppression_rule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}'} # type: ignore - - def update( - self, - alerts_suppression_rule_name, # type: str - alerts_suppression_rule, # type: "_models.AlertsSuppressionRule" - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type alerts_suppression_rule_name: str - :param alerts_suppression_rule: Suppression rule object. - :type alerts_suppression_rule: ~azure.mgmt.security.models.AlertsSuppressionRule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertsSuppressionRule, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AlertsSuppressionRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertsSuppressionRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'alertsSuppressionRuleName': self._serialize.url("alerts_suppression_rule_name", alerts_suppression_rule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(alerts_suppression_rule, 'AlertsSuppressionRule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}'} # type: ignore - - def delete( - self, - alerts_suppression_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Delete dismiss alert rule for this subscription. - - :param alerts_suppression_rule_name: The unique name of the suppression alert rule. - :type alerts_suppression_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'alertsSuppressionRuleName': self._serialize.url("alerts_suppression_rule_name", alerts_suppression_rule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}'} # 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 deleted file mode 100644 index 5efee309b189..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_allowed_connections_operations.py +++ /dev/null @@ -1,243 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AllowedConnectionsOperations(object): - """AllowedConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AllowedConnectionsList"] - """Gets the list of all possible traffic between resources for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AllowedConnectionsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AllowedConnectionsList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AllowedConnectionsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/allowedConnections'} # type: ignore - - def list_by_home_region( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AllowedConnectionsList"] - """Gets the list of all possible traffic between resources for the subscription and location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AllowedConnectionsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AllowedConnectionsList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AllowedConnectionsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_home_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_home_region.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections'} # type: ignore - - def get( - self, - resource_group_name, # type: str - connection_type, # type: Union[str, "_models.ConnectionType"] - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param connection_type: The type of allowed connections (Internal, External). - :type connection_type: str or ~azure.mgmt.security.models.ConnectionType - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AllowedConnectionsResource, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AllowedConnectionsResource - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AllowedConnectionsResource"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'connectionType': self._serialize.url("connection_type", connection_type, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections/{connectionType}'} # type: ignore 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 deleted file mode 100644 index df24fe791662..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_assessments_metadata_operations.py +++ /dev/null @@ -1,401 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AssessmentsMetadataOperations(object): - """AssessmentsMetadataOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SecurityAssessmentMetadataList"] - """Get metadata information on all assessment types. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecurityAssessmentMetadataList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecurityAssessmentMetadataList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityAssessmentMetadataList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/providers/Microsoft.Security/assessmentMetadata'} # type: ignore - - def get( - self, - assessment_metadata_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SecurityAssessmentMetadata" - """Get metadata information on an assessment type. - - :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. - :type assessment_metadata_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityAssessmentMetadata, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityAssessmentMetadata - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityAssessmentMetadata"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'assessmentMetadataName': self._serialize.url("assessment_metadata_name", assessment_metadata_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}'} # type: ignore - - def list_by_subscription( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SecurityAssessmentMetadataList"] - """Get metadata information on all assessment types in a specific subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecurityAssessmentMetadataList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecurityAssessmentMetadataList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityAssessmentMetadataList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata'} # type: ignore - - def get_in_subscription( - self, - assessment_metadata_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type assessment_metadata_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityAssessmentMetadata, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityAssessmentMetadata - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityAssessmentMetadata"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get_in_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'assessmentMetadataName': self._serialize.url("assessment_metadata_name", assessment_metadata_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get_in_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}'} # type: ignore - - def create_in_subscription( - self, - assessment_metadata_name, # type: str - assessment_metadata, # type: "_models.SecurityAssessmentMetadata" - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type assessment_metadata_name: str - :param assessment_metadata: AssessmentMetadata object. - :type assessment_metadata: ~azure.mgmt.security.models.SecurityAssessmentMetadata - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityAssessmentMetadata, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityAssessmentMetadata - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityAssessmentMetadata"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_in_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'assessmentMetadataName': self._serialize.url("assessment_metadata_name", assessment_metadata_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(assessment_metadata, 'SecurityAssessmentMetadata') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - create_in_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}'} # type: ignore - - def delete_in_subscription( - self, - assessment_metadata_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> 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. - :type assessment_metadata_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.delete_in_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'assessmentMetadataName': self._serialize.url("assessment_metadata_name", assessment_metadata_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_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, {}) - - delete_in_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}'} # 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 deleted file mode 100644 index 0b7b28c2f6a3..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_assessments_operations.py +++ /dev/null @@ -1,308 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AssessmentsOperations(object): - """AssessmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SecurityAssessmentList"] - """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). - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecurityAssessmentList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecurityAssessmentList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityAssessmentList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Security/assessments'} # type: ignore - - def get( - self, - resource_id, # type: str - assessment_name, # type: str - expand=None, # type: Optional[Union[str, "_models.ExpandEnum"]] - **kwargs # type: Any - ): - # type: (...) -> "_models.SecurityAssessment" - """Get a security assessment on your scanned resource. - - :param resource_id: The identifier of the resource. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. - :type assessment_name: str - :param expand: OData expand. Optional. - :type expand: str or ~azure.mgmt.security.models.ExpandEnum - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityAssessment, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityAssessment - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityAssessment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - 'assessmentName': self._serialize.url("assessment_name", assessment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}'} # type: ignore - - def create_or_update( - self, - resource_id, # type: str - assessment_name, # type: str - assessment, # type: "_models.SecurityAssessment" - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. - :type assessment_name: str - :param assessment: Calculated assessment on a pre-defined assessment metadata. - :type assessment: ~azure.mgmt.security.models.SecurityAssessment - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityAssessment, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityAssessment - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityAssessment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - 'assessmentName': self._serialize.url("assessment_name", assessment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(assessment, 'SecurityAssessment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - return deserialized - create_or_update.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}'} # type: ignore - - def delete( - self, - resource_id, # type: str - assessment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> 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. - :type resource_id: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. - :type assessment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - 'assessmentName': self._serialize.url("assessment_name", assessment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}'} # 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 deleted file mode 100644 index 415b662697ab..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_auto_provisioning_settings_operations.py +++ /dev/null @@ -1,231 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AutoProvisioningSettingsOperations(object): - """AutoProvisioningSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AutoProvisioningSettingList"] - """Exposes the auto provisioning settings of the subscriptions. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoProvisioningSettingList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AutoProvisioningSettingList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoProvisioningSettingList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings'} # type: ignore - - def get( - self, - setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AutoProvisioningSetting" - """Details of a specific setting. - - :param setting_name: Auto provisioning setting key. - :type setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoProvisioningSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AutoProvisioningSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoProvisioningSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'settingName': self._serialize.url("setting_name", setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings/{settingName}'} # type: ignore - - def create( - self, - setting_name, # type: str - setting, # type: "_models.AutoProvisioningSetting" - **kwargs # type: Any - ): - # type: (...) -> "_models.AutoProvisioningSetting" - """Details of a specific setting. - - :param setting_name: Auto provisioning setting key. - :type setting_name: str - :param setting: Auto provisioning setting key. - :type setting: ~azure.mgmt.security.models.AutoProvisioningSetting - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutoProvisioningSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AutoProvisioningSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoProvisioningSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'settingName': self._serialize.url("setting_name", setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(setting, 'AutoProvisioningSetting') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings/{settingName}'} # 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 deleted file mode 100644 index 97727d493b0e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_automations_operations.py +++ /dev/null @@ -1,446 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class AutomationsOperations(object): - """AutomationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AutomationList"] - """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. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutomationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AutomationList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/automations'} # type: ignore - - def list_by_resource_group( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AutomationList"] - """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. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutomationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AutomationList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations'} # type: ignore - - def get( - self, - resource_group_name, # type: str - automation_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param automation_name: The security automation name. - :type automation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Automation, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Automation - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Automation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'automationName': self._serialize.url("automation_name", automation_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}'} # type: ignore - - def create_or_update( - self, - resource_group_name, # type: str - automation_name, # type: str - automation, # type: "_models.Automation" - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param automation_name: The security automation name. - :type automation_name: str - :param automation: The security automation resource. - :type automation: ~azure.mgmt.security.models.Automation - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Automation, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Automation - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Automation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'automationName': self._serialize.url("automation_name", automation_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(automation, 'Automation') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}'} # type: ignore - - def delete( - self, - resource_group_name, # type: str - automation_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> 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. - :type resource_group_name: str - :param automation_name: The security automation name. - :type automation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'automationName': self._serialize.url("automation_name", automation_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}'} # type: ignore - - def validate( - self, - resource_group_name, # type: str - automation_name, # type: str - automation, # type: "_models.Automation" - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param automation_name: The security automation name. - :type automation_name: str - :param automation: The security automation resource. - :type automation: ~azure.mgmt.security.models.Automation - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AutomationValidationStatus, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AutomationValidationStatus - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AutomationValidationStatus"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'automationName': self._serialize.url("automation_name", automation_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(automation, 'Automation') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}/validate'} # 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 deleted file mode 100644 index 19c0725e83ec..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_compliance_results_operations.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 typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ComplianceResultsOperations(object): - """ComplianceResultsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ComplianceResultList"] - """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). - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ComplianceResultList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.ComplianceResultList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComplianceResultList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Security/complianceResults'} # type: ignore - - def get( - self, - resource_id, # type: str - compliance_result_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ComplianceResult" - """Security Compliance Result. - - :param resource_id: The identifier of the resource. - :type resource_id: str - :param compliance_result_name: name of the desired assessment compliance result. - :type compliance_result_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ComplianceResult, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ComplianceResult - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComplianceResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - 'complianceResultName': self._serialize.url("compliance_result_name", compliance_result_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/complianceResults/{complianceResultName}'} # 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 deleted file mode 100644 index c8b529670f49..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_compliances_operations.py +++ /dev/null @@ -1,178 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class CompliancesOperations(object): - """CompliancesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ComplianceList"] - """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). - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ComplianceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.ComplianceList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComplianceList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Security/compliances'} # type: ignore - - def get( - self, - scope, # type: str - compliance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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). - :type scope: str - :param compliance_name: name of the Compliance. - :type compliance_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Compliance, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Compliance - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Compliance"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'complianceName': self._serialize.url("compliance_name", compliance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Security/compliances/{complianceName}'} # 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 deleted file mode 100644 index 53148912e51f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_connectors_operations.py +++ /dev/null @@ -1,285 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ConnectorsOperations(object): - """ConnectorsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ConnectorSettingList"] - """Cloud accounts connectors of a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConnectorSettingList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.ConnectorSettingList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectorSettingList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors'} # type: ignore - - def get( - self, - connector_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ConnectorSetting" - """Details of a specific cloud account connector. - - :param connector_name: Name of the cloud account connector. - :type connector_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConnectorSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ConnectorSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectorSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'connectorName': self._serialize.url("connector_name", connector_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}'} # type: ignore - - def create_or_update( - self, - connector_name, # type: str - connector_setting, # type: "_models.ConnectorSetting" - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type connector_name: str - :param connector_setting: Settings for the cloud account connector. - :type connector_setting: ~azure.mgmt.security.models.ConnectorSetting - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConnectorSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ConnectorSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectorSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'connectorName': self._serialize.url("connector_name", connector_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(connector_setting, 'ConnectorSetting') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}'} # type: ignore - - def delete( - self, - connector_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Delete a cloud account connector from a subscription. - - :param connector_name: Name of the cloud account connector. - :type connector_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'connectorName': self._serialize.url("connector_name", connector_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}'} # 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 deleted file mode 100644 index 35044ec43bdf..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_device_security_groups_operations.py +++ /dev/null @@ -1,303 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class DeviceSecurityGroupsOperations(object): - """DeviceSecurityGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - resource_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DeviceSecurityGroupList"] - """Use this method get the list of device security groups for the specified IoT Hub resource. - - :param resource_id: The identifier of the resource. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeviceSecurityGroupList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.DeviceSecurityGroupList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceSecurityGroupList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups'} # type: ignore - - def get( - self, - resource_id, # type: str - device_security_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :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. - :type device_security_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeviceSecurityGroup, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.DeviceSecurityGroup - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceSecurityGroup"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - 'deviceSecurityGroupName': self._serialize.url("device_security_group_name", device_security_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}'} # type: ignore - - def create_or_update( - self, - resource_id, # type: str - device_security_group_name, # type: str - device_security_group, # type: "_models.DeviceSecurityGroup" - **kwargs # type: Any - ): - # type: (...) -> "_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. - :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. - :type device_security_group_name: str - :param device_security_group: Security group object. - :type device_security_group: ~azure.mgmt.security.models.DeviceSecurityGroup - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeviceSecurityGroup, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.DeviceSecurityGroup - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeviceSecurityGroup"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - 'deviceSecurityGroupName': self._serialize.url("device_security_group_name", device_security_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(device_security_group, 'DeviceSecurityGroup') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - return deserialized - create_or_update.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}'} # type: ignore - - def delete( - self, - resource_id, # type: str - device_security_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """User this method to deletes the device security group. - - :param resource_id: The identifier of the resource. - :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. - :type device_security_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - 'deviceSecurityGroupName': self._serialize.url("device_security_group_name", device_security_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}'} # 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 deleted file mode 100644 index 5a628e8a1123..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_discovered_security_solutions_operations.py +++ /dev/null @@ -1,242 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class DiscoveredSecuritySolutionsOperations(object): - """DiscoveredSecuritySolutionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DiscoveredSecuritySolutionList"] - """Gets a list of discovered Security Solutions for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiscoveredSecuritySolutionList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.DiscoveredSecuritySolutionList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiscoveredSecuritySolutionList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/discoveredSecuritySolutions'} # type: ignore - - def list_by_home_region( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DiscoveredSecuritySolutionList"] - """Gets a list of discovered Security Solutions for the subscription and location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiscoveredSecuritySolutionList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.DiscoveredSecuritySolutionList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiscoveredSecuritySolutionList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_home_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_home_region.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/discoveredSecuritySolutions'} # type: ignore - - def get( - self, - resource_group_name, # type: str - discovered_security_solution_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param discovered_security_solution_name: Name of a discovered security solution. - :type discovered_security_solution_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: DiscoveredSecuritySolution, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.DiscoveredSecuritySolution - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiscoveredSecuritySolution"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'discoveredSecuritySolutionName': self._serialize.url("discovered_security_solution_name", discovered_security_solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/discoveredSecuritySolutions/{discoveredSecuritySolutionName}'} # 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 deleted file mode 100644 index 6a9375abd1a9..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_external_security_solutions_operations.py +++ /dev/null @@ -1,242 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ExternalSecuritySolutionsOperations(object): - """ExternalSecuritySolutionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ExternalSecuritySolutionList"] - """Gets a list of external security solutions for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExternalSecuritySolutionList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.ExternalSecuritySolutionList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExternalSecuritySolutionList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/externalSecuritySolutions'} # type: ignore - - def list_by_home_region( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ExternalSecuritySolutionList"] - """Gets a list of external Security Solutions for the subscription and location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExternalSecuritySolutionList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.ExternalSecuritySolutionList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExternalSecuritySolutionList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_home_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_home_region.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/ExternalSecuritySolutions'} # type: ignore - - def get( - self, - resource_group_name, # type: str - external_security_solutions_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param external_security_solutions_name: Name of an external security solution. - :type external_security_solutions_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExternalSecuritySolution, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ExternalSecuritySolution - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExternalSecuritySolution"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'externalSecuritySolutionsName': self._serialize.url("external_security_solutions_name", external_security_solutions_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/ExternalSecuritySolutions/{externalSecuritySolutionsName}'} # 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 deleted file mode 100644 index 891af46bac01..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_information_protection_policies_operations.py +++ /dev/null @@ -1,250 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class InformationProtectionPoliciesOperations(object): - """InformationProtectionPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - scope, # type: str - information_protection_policy_name, # type: Union[str, "_models.Enum15"] - **kwargs # type: Any - ): - # type: (...) -> "_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). - :type scope: str - :param information_protection_policy_name: Name of the information protection policy. - :type information_protection_policy_name: str or ~azure.mgmt.security.models.Enum15 - :keyword callable cls: A custom type or function that will be passed the direct response - :return: InformationProtectionPolicy, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.InformationProtectionPolicy - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.InformationProtectionPolicy"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'informationProtectionPolicyName': self._serialize.url("information_protection_policy_name", information_protection_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Security/informationProtectionPolicies/{informationProtectionPolicyName}'} # type: ignore - - def create_or_update( - self, - scope, # type: str - information_protection_policy_name, # type: Union[str, "_models.Enum15"] - information_protection_policy, # type: "_models.InformationProtectionPolicy" - **kwargs # type: Any - ): - # type: (...) -> "_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). - :type scope: str - :param information_protection_policy_name: Name of the information protection policy. - :type information_protection_policy_name: str or ~azure.mgmt.security.models.Enum15 - :param information_protection_policy: Information protection policy. - :type information_protection_policy: ~azure.mgmt.security.models.InformationProtectionPolicy - :keyword callable cls: A custom type or function that will be passed the direct response - :return: InformationProtectionPolicy, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.InformationProtectionPolicy - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.InformationProtectionPolicy"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'informationProtectionPolicyName': self._serialize.url("information_protection_policy_name", information_protection_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(information_protection_policy, 'InformationProtectionPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - return deserialized - create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Security/informationProtectionPolicies/{informationProtectionPolicyName}'} # type: ignore - - def list( - self, - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.InformationProtectionPolicyList"] - """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). - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either InformationProtectionPolicyList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.InformationProtectionPolicyList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.InformationProtectionPolicyList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Security/informationProtectionPolicies'} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_ingestion_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_ingestion_settings_operations.py deleted file mode 100644 index 0e8366ffbd0e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_ingestion_settings_operations.py +++ /dev/null @@ -1,397 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class IngestionSettingsOperations(object): - """IngestionSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IngestionSettingList"] - """Settings for ingesting security data and logs to correlate with resources associated with the - subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IngestionSettingList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.IngestionSettingList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IngestionSettingList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-15-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('IngestionSettingList', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings'} # type: ignore - - def get( - self, - ingestion_setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.IngestionSetting" - """Settings for ingesting security data and logs to correlate with resources associated with the - subscription. - - :param ingestion_setting_name: Name of the ingestion setting. - :type ingestion_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IngestionSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IngestionSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IngestionSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-15-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ingestionSettingName': self._serialize.url("ingestion_setting_name", ingestion_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('IngestionSetting', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}'} # type: ignore - - def create( - self, - ingestion_setting_name, # type: str - ingestion_setting, # type: "_models.IngestionSetting" - **kwargs # type: Any - ): - # type: (...) -> "_models.IngestionSetting" - """Create setting for ingesting security data and logs to correlate with resources associated with - the subscription. - - :param ingestion_setting_name: Name of the ingestion setting. - :type ingestion_setting_name: str - :param ingestion_setting: Ingestion setting object. - :type ingestion_setting: ~azure.mgmt.security.models.IngestionSetting - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IngestionSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IngestionSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IngestionSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-15-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ingestionSettingName': self._serialize.url("ingestion_setting_name", ingestion_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(ingestion_setting, 'IngestionSetting') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('IngestionSetting', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}'} # type: ignore - - def delete( - self, - ingestion_setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Deletes the ingestion settings for this subscription. - - :param ingestion_setting_name: Name of the ingestion setting. - :type ingestion_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-15-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ingestionSettingName': self._serialize.url("ingestion_setting_name", ingestion_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}'} # type: ignore - - def list_tokens( - self, - ingestion_setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.IngestionSettingToken" - """Returns the token that is used for correlating ingested telemetry with the resources in the - subscription. - - :param ingestion_setting_name: Name of the ingestion setting. - :type ingestion_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IngestionSettingToken, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IngestionSettingToken - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IngestionSettingToken"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-15-preview" - accept = "application/json" - - # Construct URL - url = self.list_tokens.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ingestionSettingName': self._serialize.url("ingestion_setting_name", ingestion_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('IngestionSettingToken', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - list_tokens.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}/listTokens'} # type: ignore - - def list_connection_strings( - self, - ingestion_setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ConnectionStrings" - """Connection strings for ingesting security scan logs and data. - - :param ingestion_setting_name: Name of the ingestion setting. - :type ingestion_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ConnectionStrings, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ConnectionStrings - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionStrings"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-15-preview" - accept = "application/json" - - # Construct URL - url = self.list_connection_strings.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ingestionSettingName': self._serialize.url("ingestion_setting_name", ingestion_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('ConnectionStrings', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - list_connection_strings.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}/listConnectionStrings'} # type: ignore 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 deleted file mode 100644 index 298a0942fff6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_iot_security_solution_analytics_operations.py +++ /dev/null @@ -1,165 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class IotSecuritySolutionAnalyticsOperations(object): - """IotSecuritySolutionAnalyticsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - resource_group_name, # type: str - solution_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IoTSecuritySolutionAnalyticsModelList, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionAnalyticsModelList - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecuritySolutionAnalyticsModelList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels'} # type: ignore - - def get( - self, - resource_group_name, # type: str - solution_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IoTSecuritySolutionAnalyticsModel, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionAnalyticsModel - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecuritySolutionAnalyticsModel"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default'} # 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 deleted file mode 100644 index 61ddebb95518..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_iot_security_solution_operations.py +++ /dev/null @@ -1,455 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class IotSecuritySolutionOperations(object): - """IotSecuritySolutionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_by_subscription( - self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IoTSecuritySolutionsList"] - """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. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IoTSecuritySolutionsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.IoTSecuritySolutionsList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecuritySolutionsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/iotSecuritySolutions'} # type: ignore - - def list_by_resource_group( - self, - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IoTSecuritySolutionsList"] - """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. - :type resource_group_name: str - :param filter: Filter the IoT Security solution with OData syntax. Supports filtering by - iotHubs. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IoTSecuritySolutionsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.IoTSecuritySolutionsList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecuritySolutionsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions'} # type: ignore - - def get( - self, - resource_group_name, # type: str - solution_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IoTSecuritySolutionModel, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecuritySolutionModel"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}'} # type: ignore - - def create_or_update( - self, - resource_group_name, # type: str - solution_name, # type: str - iot_security_solution_data, # type: "_models.IoTSecuritySolutionModel" - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :param iot_security_solution_data: The security solution data. - :type iot_security_solution_data: ~azure.mgmt.security.models.IoTSecuritySolutionModel - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IoTSecuritySolutionModel, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecuritySolutionModel"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_security_solution_data, 'IoTSecuritySolutionModel') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}'} # type: ignore - - def update( - self, - resource_group_name, # type: str - solution_name, # type: str - update_iot_security_solution_data, # type: "_models.UpdateIotSecuritySolutionData" - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :param update_iot_security_solution_data: The security solution data. - :type update_iot_security_solution_data: ~azure.mgmt.security.models.UpdateIotSecuritySolutionData - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IoTSecuritySolutionModel, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IoTSecuritySolutionModel - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecuritySolutionModel"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(update_iot_security_solution_data, 'UpdateIotSecuritySolutionData') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}'} # type: ignore - - def delete( - self, - resource_group_name, # type: str - solution_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> 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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}'} # 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 deleted file mode 100644 index 65f9c6b52018..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py +++ /dev/null @@ -1,253 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class IotSecuritySolutionsAnalyticsAggregatedAlertOperations(object): - """IotSecuritySolutionsAnalyticsAggregatedAlertOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - resource_group_name, # type: str - solution_name, # type: str - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IoTSecurityAggregatedAlertList"] - """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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :param top: Number of results to retrieve. - :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IoTSecurityAggregatedAlertList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.IoTSecurityAggregatedAlertList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecurityAggregatedAlertList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts'} # type: ignore - - def get( - self, - resource_group_name, # type: str - solution_name, # type: str - aggregated_alert_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :param aggregated_alert_name: Identifier of the aggregated alert. - :type aggregated_alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IoTSecurityAggregatedAlert, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IoTSecurityAggregatedAlert - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecurityAggregatedAlert"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - 'aggregatedAlertName': self._serialize.url("aggregated_alert_name", aggregated_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts/{aggregatedAlertName}'} # type: ignore - - def dismiss( - self, - resource_group_name, # type: str - solution_name, # type: str - aggregated_alert_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> 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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :param aggregated_alert_name: Identifier of the aggregated alert. - :type aggregated_alert_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.dismiss.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - 'aggregatedAlertName': self._serialize.url("aggregated_alert_name", aggregated_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_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, {}) - - dismiss.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts/{aggregatedAlertName}/dismiss'} # 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 deleted file mode 100644 index 6b59514a802a..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_iot_security_solutions_analytics_recommendation_operations.py +++ /dev/null @@ -1,193 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class IotSecuritySolutionsAnalyticsRecommendationOperations(object): - """IotSecuritySolutionsAnalyticsRecommendationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - resource_group_name, # type: str - solution_name, # type: str - aggregated_recommendation_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :param aggregated_recommendation_name: Name of the recommendation aggregated for this query. - :type aggregated_recommendation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: IoTSecurityAggregatedRecommendation, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.IoTSecurityAggregatedRecommendation - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecurityAggregatedRecommendation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - 'aggregatedRecommendationName': self._serialize.url("aggregated_recommendation_name", aggregated_recommendation_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedRecommendations/{aggregatedRecommendationName}'} # type: ignore - - def list( - self, - resource_group_name, # type: str - solution_name, # type: str - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IoTSecurityAggregatedRecommendationList"] - """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. - :type resource_group_name: str - :param solution_name: The name of the IoT Security solution. - :type solution_name: str - :param top: Number of results to retrieve. - :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IoTSecurityAggregatedRecommendationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.IoTSecurityAggregatedRecommendationList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IoTSecurityAggregatedRecommendationList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'solutionName': self._serialize.url("solution_name", solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedRecommendations'} # type: ignore 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 deleted file mode 100644 index 83347ca88ca1..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_jit_network_access_policies_operations.py +++ /dev/null @@ -1,589 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class JitNetworkAccessPoliciesOperations(object): - """JitNetworkAccessPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JitNetworkAccessPoliciesList"] - """Policies for protecting resources using Just-in-Time access control. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JitNetworkAccessPoliciesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.JitNetworkAccessPoliciesList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JitNetworkAccessPoliciesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/jitNetworkAccessPolicies'} # type: ignore - - def list_by_region( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JitNetworkAccessPoliciesList"] - """Policies for protecting resources using Just-in-Time access control for the subscription, - location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JitNetworkAccessPoliciesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.JitNetworkAccessPoliciesList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JitNetworkAccessPoliciesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_region.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies'} # type: ignore - - def list_by_resource_group( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JitNetworkAccessPoliciesList"] - """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. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JitNetworkAccessPoliciesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.JitNetworkAccessPoliciesList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JitNetworkAccessPoliciesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/jitNetworkAccessPolicies'} # type: ignore - - def list_by_resource_group_and_region( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JitNetworkAccessPoliciesList"] - """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. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JitNetworkAccessPoliciesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.JitNetworkAccessPoliciesList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JitNetworkAccessPoliciesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_resource_group_and_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_resource_group_and_region.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies'} # type: ignore - - def get( - self, - resource_group_name, # type: str - jit_network_access_policy_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - :type jit_network_access_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JitNetworkAccessPolicy, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.JitNetworkAccessPolicy - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JitNetworkAccessPolicy"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'jitNetworkAccessPolicyName': self._serialize.url("jit_network_access_policy_name", jit_network_access_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}'} # type: ignore - - def create_or_update( - self, - resource_group_name, # type: str - jit_network_access_policy_name, # type: str - body, # type: "_models.JitNetworkAccessPolicy" - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - :type jit_network_access_policy_name: str - :param body: - :type body: ~azure.mgmt.security.models.JitNetworkAccessPolicy - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JitNetworkAccessPolicy, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.JitNetworkAccessPolicy - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JitNetworkAccessPolicy"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'jitNetworkAccessPolicyName': self._serialize.url("jit_network_access_policy_name", jit_network_access_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'JitNetworkAccessPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}'} # type: ignore - - def delete( - self, - resource_group_name, # type: str - jit_network_access_policy_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> 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. - :type resource_group_name: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - :type jit_network_access_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'jitNetworkAccessPolicyName': self._serialize.url("jit_network_access_policy_name", jit_network_access_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}'} # type: ignore - - def initiate( - self, - resource_group_name, # type: str - jit_network_access_policy_name, # type: str - body, # type: "_models.JitNetworkAccessPolicyInitiateRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param jit_network_access_policy_name: Name of a Just-in-Time access configuration policy. - :type jit_network_access_policy_name: str - :param body: - :type body: ~azure.mgmt.security.models.JitNetworkAccessPolicyInitiateRequest - :keyword callable cls: A custom type or function that will be passed the direct response - :return: JitNetworkAccessRequest, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.JitNetworkAccessRequest - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.JitNetworkAccessRequest"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - jit_network_access_policy_initiate_type = "initiate" - api_version = "2020-01-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.initiate.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'jitNetworkAccessPolicyName': self._serialize.url("jit_network_access_policy_name", jit_network_access_policy_name, 'str'), - 'jitNetworkAccessPolicyInitiateType': self._serialize.url("jit_network_access_policy_initiate_type", jit_network_access_policy_initiate_type, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(body, 'JitNetworkAccessPolicyInitiateRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - return deserialized - initiate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}/{jitNetworkAccessPolicyInitiateType}'} # 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 deleted file mode 100644 index 13291ea538d6..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_locations_operations.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 typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class LocationsOperations(object): - """LocationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AscLocationList"] - """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. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AscLocationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.AscLocationList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AscLocationList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations'} # type: ignore - - def get( - self, - **kwargs # type: Any - ): - # type: (...) -> "_models.AscLocation" - """Details of a specific location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AscLocation, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.AscLocation - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AscLocation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}'} # 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 deleted file mode 100644 index 7021bf97353c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_operations.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 typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationList"] - """Exposes all available operations for discovery purposes. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.OperationList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/providers/Microsoft.Security/operations'} # type: ignore 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 deleted file mode 100644 index a52746e23b27..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_pricings_operations.py +++ /dev/null @@ -1,214 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class PricingsOperations(object): - """PricingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> "_models.PricingList" - """Lists Security Center pricing configurations in the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: PricingList, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.PricingList - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PricingList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings'} # type: ignore - - def get( - self, - pricing_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Pricing" - """Gets a provided Security Center pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. - :type pricing_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Pricing, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Pricing - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Pricing"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'pricingName': self._serialize.url("pricing_name", pricing_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}'} # type: ignore - - def update( - self, - pricing_name, # type: str - pricing, # type: "_models.Pricing" - **kwargs # type: Any - ): - # type: (...) -> "_models.Pricing" - """Updates a provided Security Center pricing configuration in the subscription. - - :param pricing_name: name of the pricing configuration. - :type pricing_name: str - :param pricing: Pricing object. - :type pricing: ~azure.mgmt.security.models.Pricing - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Pricing, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Pricing - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Pricing"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'pricingName': self._serialize.url("pricing_name", pricing_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(pricing, 'Pricing') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}'} # 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 deleted file mode 100644 index 1510be8b7bea..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_regulatory_compliance_assessments_operations.py +++ /dev/null @@ -1,190 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RegulatoryComplianceAssessmentsOperations(object): - """RegulatoryComplianceAssessmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - regulatory_compliance_standard_name, # type: str - regulatory_compliance_control_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RegulatoryComplianceAssessmentList"] - """Details and state of assessments mapped to selected regulatory compliance control. - - :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. - :type regulatory_compliance_standard_name: str - :param regulatory_compliance_control_name: Name of the regulatory compliance control object. - :type regulatory_compliance_control_name: str - :param filter: OData filter. Optional. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegulatoryComplianceAssessmentList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.RegulatoryComplianceAssessmentList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegulatoryComplianceAssessmentList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'regulatoryComplianceStandardName': self._serialize.url("regulatory_compliance_standard_name", regulatory_compliance_standard_name, 'str'), - 'regulatoryComplianceControlName': self._serialize.url("regulatory_compliance_control_name", regulatory_compliance_control_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}/regulatoryComplianceAssessments'} # type: ignore - - def get( - self, - regulatory_compliance_standard_name, # type: str - regulatory_compliance_control_name, # type: str - regulatory_compliance_assessment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RegulatoryComplianceAssessment" - """Supported regulatory compliance details and state for selected assessment. - - :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. - :type regulatory_compliance_standard_name: str - :param regulatory_compliance_control_name: Name of the regulatory compliance control object. - :type regulatory_compliance_control_name: str - :param regulatory_compliance_assessment_name: Name of the regulatory compliance assessment - object. - :type regulatory_compliance_assessment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegulatoryComplianceAssessment, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.RegulatoryComplianceAssessment - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegulatoryComplianceAssessment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'regulatoryComplianceStandardName': self._serialize.url("regulatory_compliance_standard_name", regulatory_compliance_standard_name, 'str'), - 'regulatoryComplianceControlName': self._serialize.url("regulatory_compliance_control_name", regulatory_compliance_control_name, 'str'), - 'regulatoryComplianceAssessmentName': self._serialize.url("regulatory_compliance_assessment_name", regulatory_compliance_assessment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}/regulatoryComplianceAssessments/{regulatoryComplianceAssessmentName}'} # 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 deleted file mode 100644 index 181e4a4f4905..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_regulatory_compliance_controls_operations.py +++ /dev/null @@ -1,181 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RegulatoryComplianceControlsOperations(object): - """RegulatoryComplianceControlsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - regulatory_compliance_standard_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RegulatoryComplianceControlList"] - """All supported regulatory compliance controls details and state for selected standard. - - :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. - :type regulatory_compliance_standard_name: str - :param filter: OData filter. Optional. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegulatoryComplianceControlList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.RegulatoryComplianceControlList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegulatoryComplianceControlList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'regulatoryComplianceStandardName': self._serialize.url("regulatory_compliance_standard_name", regulatory_compliance_standard_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls'} # type: ignore - - def get( - self, - regulatory_compliance_standard_name, # type: str - regulatory_compliance_control_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RegulatoryComplianceControl" - """Selected regulatory compliance control details and state. - - :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. - :type regulatory_compliance_standard_name: str - :param regulatory_compliance_control_name: Name of the regulatory compliance control object. - :type regulatory_compliance_control_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegulatoryComplianceControl, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.RegulatoryComplianceControl - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegulatoryComplianceControl"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'regulatoryComplianceStandardName': self._serialize.url("regulatory_compliance_standard_name", regulatory_compliance_standard_name, 'str'), - 'regulatoryComplianceControlName': self._serialize.url("regulatory_compliance_control_name", regulatory_compliance_control_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}'} # 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 deleted file mode 100644 index 506a32bc4add..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_regulatory_compliance_standards_operations.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 typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class RegulatoryComplianceStandardsOperations(object): - """RegulatoryComplianceStandardsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RegulatoryComplianceStandardList"] - """Supported regulatory compliance standards details and state. - - :param filter: OData filter. Optional. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RegulatoryComplianceStandardList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.RegulatoryComplianceStandardList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegulatoryComplianceStandardList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards'} # type: ignore - - def get( - self, - regulatory_compliance_standard_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RegulatoryComplianceStandard" - """Supported regulatory compliance details state for selected standard. - - :param regulatory_compliance_standard_name: Name of the regulatory compliance standard object. - :type regulatory_compliance_standard_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RegulatoryComplianceStandard, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.RegulatoryComplianceStandard - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RegulatoryComplianceStandard"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'regulatoryComplianceStandardName': self._serialize.url("regulatory_compliance_standard_name", regulatory_compliance_standard_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}'} # 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 deleted file mode 100644 index 8d0d8eab0fd3..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_secure_score_control_definitions_operations.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 typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SecureScoreControlDefinitionsOperations(object): - """SecureScoreControlDefinitionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SecureScoreControlDefinitionList"] - """List the available security controls, their assessments, and the max score. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecureScoreControlDefinitionList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecureScoreControlDefinitionList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecureScoreControlDefinitionList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/providers/Microsoft.Security/secureScoreControlDefinitions'} # type: ignore - - def list_by_subscription( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SecureScoreControlDefinitionList"] - """For a specified subscription, list the available security controls, their assessments, and the - max score. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecureScoreControlDefinitionList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecureScoreControlDefinitionList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecureScoreControlDefinitionList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScoreControlDefinitions'} # type: ignore 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 deleted file mode 100644 index 096bc5571b5c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_secure_score_controls_operations.py +++ /dev/null @@ -1,195 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SecureScoreControlsOperations(object): - """SecureScoreControlsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_by_secure_score( - self, - secure_score_name, # type: str - expand=None, # type: Optional[Union[str, "_models.ExpandControlsEnum"]] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SecureScoreControlList"] - """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. - :type secure_score_name: str - :param expand: OData expand. Optional. - :type expand: str or ~azure.mgmt.security.models.ExpandControlsEnum - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecureScoreControlList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecureScoreControlList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecureScoreControlList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_secure_score.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'secureScoreName': self._serialize.url("secure_score_name", secure_score_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_secure_score.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores/{secureScoreName}/secureScoreControls'} # type: ignore - - def list( - self, - expand=None, # type: Optional[Union[str, "_models.ExpandControlsEnum"]] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SecureScoreControlList"] - """Get all security controls within a scope. - - :param expand: OData expand. Optional. - :type expand: str or ~azure.mgmt.security.models.ExpandControlsEnum - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecureScoreControlList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecureScoreControlList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecureScoreControlList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScoreControls'} # type: ignore 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 deleted file mode 100644 index cd3e5835e36e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_secure_scores_operations.py +++ /dev/null @@ -1,170 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SecureScoresOperations(object): - """SecureScoresOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SecureScoresList"] - """List secure scores for all your Security Center initiatives within your current scope. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecureScoresList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecureScoresList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecureScoresList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores'} # type: ignore - - def get( - self, - secure_score_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SecureScoreItem" - """Get secure score for a specific Security Center 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. - :type secure_score_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecureScoreItem, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecureScoreItem - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecureScoreItem"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'secureScoreName': self._serialize.url("secure_score_name", secure_score_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores/{secureScoreName}'} # 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 deleted file mode 100644 index 6f48ee66bb1c..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_contacts_operations.py +++ /dev/null @@ -1,346 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SecurityContactsOperations(object): - """SecurityContactsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SecurityContactList"] - """Security contact configurations for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecurityContactList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecurityContactList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityContactList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts'} # type: ignore - - def get( - self, - security_contact_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SecurityContact" - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. - :type security_contact_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityContact, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityContact - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityContact"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'securityContactName': self._serialize.url("security_contact_name", security_contact_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}'} # type: ignore - - def create( - self, - security_contact_name, # type: str - security_contact, # type: "_models.SecurityContact" - **kwargs # type: Any - ): - # type: (...) -> "_models.SecurityContact" - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. - :type security_contact_name: str - :param security_contact: Security contact object. - :type security_contact: ~azure.mgmt.security.models.SecurityContact - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityContact, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityContact - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityContact"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'securityContactName': self._serialize.url("security_contact_name", security_contact_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_contact, 'SecurityContact') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}'} # type: ignore - - def delete( - self, - security_contact_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. - :type security_contact_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'securityContactName': self._serialize.url("security_contact_name", security_contact_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}'} # type: ignore - - def update( - self, - security_contact_name, # type: str - security_contact, # type: "_models.SecurityContact" - **kwargs # type: Any - ): - # type: (...) -> "_models.SecurityContact" - """Security contact configurations for the subscription. - - :param security_contact_name: Name of the security contact object. - :type security_contact_name: str - :param security_contact: Security contact object. - :type security_contact: ~azure.mgmt.security.models.SecurityContact - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityContact, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityContact - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityContact"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'securityContactName': self._serialize.url("security_contact_name", security_contact_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(security_contact, 'SecurityContact') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}'} # 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 deleted file mode 100644 index 8bce5009e5ab..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_solutions_operations.py +++ /dev/null @@ -1,174 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SecuritySolutionsOperations(object): - """SecuritySolutionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SecuritySolutionList"] - """Gets a list of Security Solutions for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecuritySolutionList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecuritySolutionList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecuritySolutionList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutions'} # type: ignore - - def get( - self, - resource_group_name, # type: str - security_solution_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param security_solution_name: Name of security solution. - :type security_solution_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecuritySolution, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecuritySolution - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecuritySolution"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'securitySolutionName': self._serialize.url("security_solution_name", security_solution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutions/{securitySolutionName}'} # 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 deleted file mode 100644 index 513b9aa41c01..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_security_solutions_reference_data_operations.py +++ /dev/null @@ -1,148 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SecuritySolutionsReferenceDataOperations(object): - """SecuritySolutionsReferenceDataOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> "_models.SecuritySolutionsReferenceDataList" - """Gets a list of all supported Security Solutions for the subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecuritySolutionsReferenceDataList, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecuritySolutionsReferenceDataList - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecuritySolutionsReferenceDataList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutionsReferenceData'} # type: ignore - - def list_by_home_region( - self, - **kwargs # type: Any - ): - # type: (...) -> "_models.SecuritySolutionsReferenceDataList" - """Gets list of all supported Security Solutions for subscription and location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecuritySolutionsReferenceDataList, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecuritySolutionsReferenceDataList - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecuritySolutionsReferenceDataList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.list_by_home_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - list_by_home_region.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutionsReferenceData'} # 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 deleted file mode 100644 index 8d66fb87767e..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_server_vulnerability_assessment_operations.py +++ /dev/null @@ -1,385 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ServerVulnerabilityAssessmentOperations(object): - """ServerVulnerabilityAssessmentOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_by_extended_resource( - self, - resource_group_name, # type: str - resource_namespace, # type: str - resource_type, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. - :type resource_namespace: str - :param resource_type: The type of the resource. - :type resource_type: str - :param resource_name: Name of the resource. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServerVulnerabilityAssessmentsList, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessmentsList - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerVulnerabilityAssessmentsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.list_by_extended_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - list_by_extended_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments'} # type: ignore - - def get( - self, - resource_group_name, # type: str - resource_namespace, # type: str - resource_type, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. - :type resource_namespace: str - :param resource_type: The type of the resource. - :type resource_type: str - :param resource_name: Name of the resource. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServerVulnerabilityAssessment, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessment - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerVulnerabilityAssessment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - server_vulnerability_assessment = "default" - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'serverVulnerabilityAssessment': self._serialize.url("server_vulnerability_assessment", server_vulnerability_assessment, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}'} # type: ignore - - def create_or_update( - self, - resource_group_name, # type: str - resource_namespace, # type: str - resource_type, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. - :type resource_namespace: str - :param resource_type: The type of the resource. - :type resource_type: str - :param resource_name: Name of the resource. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ServerVulnerabilityAssessment, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ServerVulnerabilityAssessment - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerVulnerabilityAssessment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - server_vulnerability_assessment = "default" - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'serverVulnerabilityAssessment': self._serialize.url("server_vulnerability_assessment", server_vulnerability_assessment, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}'} # type: ignore - - def _delete_initial( - self, - resource_group_name, # type: str - resource_namespace, # type: str - resource_type, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - server_vulnerability_assessment = "default" - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'serverVulnerabilityAssessment': self._serialize.url("server_vulnerability_assessment", server_vulnerability_assessment, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}'} # type: ignore - - def begin_delete( - self, - resource_group_name, # type: str - resource_namespace, # type: str - resource_type, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> 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. - :type resource_group_name: str - :param resource_namespace: The Namespace of the resource. - :type resource_namespace: str - :param resource_type: The type of the resource. - :type resource_type: str - :param resource_name: Name of the resource. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - 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, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - server_vulnerability_assessment = "default" - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'serverVulnerabilityAssessment': self._serialize.url("server_vulnerability_assessment", server_vulnerability_assessment, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}'} # 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 deleted file mode 100644 index 6d8ccf6bd044..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_settings_operations.py +++ /dev/null @@ -1,231 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SettingsOperations(object): - """SettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SettingsList"] - """Settings about different configurations in security center. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SettingsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SettingsList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SettingsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings'} # type: ignore - - def get( - self, - setting_name, # type: Union[str, "_models.Enum69"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Setting" - """Settings of different configurations in security center. - - :param setting_name: The name of the setting. - :type setting_name: str or ~azure.mgmt.security.models.Enum69 - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Setting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Setting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Setting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'settingName': self._serialize.url("setting_name", setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}'} # type: ignore - - def update( - self, - setting_name, # type: Union[str, "_models.Enum69"] - setting, # type: "_models.Setting" - **kwargs # type: Any - ): - # type: (...) -> "_models.Setting" - """updating settings about different configurations in security center. - - :param setting_name: The name of the setting. - :type setting_name: str or ~azure.mgmt.security.models.Enum69 - :param setting: Setting object. - :type setting: ~azure.mgmt.security.models.Setting - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Setting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Setting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Setting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'settingName': self._serialize.url("setting_name", setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(setting, 'Setting') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}'} # 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 deleted file mode 100644 index 410d6ff4e69f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_software_inventories_operations.py +++ /dev/null @@ -1,269 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SoftwareInventoriesOperations(object): - """SoftwareInventoriesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_by_extended_resource( - self, - resource_group_name, # type: str - resource_namespace, # type: str - resource_type, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SoftwaresList"] - """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. - :type resource_group_name: str - :param resource_namespace: The namespace of the resource. - :type resource_namespace: str - :param resource_type: The type of the resource. - :type resource_type: str - :param resource_name: Name of the resource. - :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SoftwaresList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SoftwaresList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SoftwaresList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_extended_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_extended_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/softwareInventories'} # type: ignore - - def list_by_subscription( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SoftwaresList"] - """Gets the software inventory of all virtual machines in the subscriptions. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SoftwaresList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SoftwaresList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SoftwaresList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/softwareInventories'} # type: ignore - - def get( - self, - resource_group_name, # type: str - resource_namespace, # type: str - resource_type, # type: str - resource_name, # type: str - software_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param resource_namespace: The namespace of the resource. - :type resource_namespace: str - :param resource_type: The type of the resource. - :type resource_type: str - :param resource_name: Name of the resource. - :type resource_name: str - :param software_name: Name of the installed software. - :type software_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Software, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Software - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Software"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'resourceNamespace': self._serialize.url("resource_namespace", resource_namespace, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'softwareName': self._serialize.url("software_name", software_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/softwareInventories/{softwareName}'} # 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 deleted file mode 100644 index 7830d316df6f..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_sql_vulnerability_assessment_baseline_rules_operations.py +++ /dev/null @@ -1,376 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SqlVulnerabilityAssessmentBaselineRulesOperations(object): - """SqlVulnerabilityAssessmentBaselineRulesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def create_or_update( - self, - rule_id, # type: str - workspace_id, # type: str - resource_id, # type: str - body=None, # type: Optional["_models.RuleResultsInput"] - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type rule_id: str - :param workspace_id: The workspace Id. - :type workspace_id: str - :param resource_id: The identifier of the resource. - :type resource_id: str - :param body: The baseline results for this rule. - :type body: ~azure.mgmt.security.models.RuleResultsInput - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RuleResults, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.RuleResults - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RuleResults"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'ruleId': self._serialize.url("rule_id", rule_id, 'str'), - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['workspaceId'] = self._serialize.query("workspace_id", workspace_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'RuleResultsInput') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - create_or_update.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}'} # type: ignore - - def get( - self, - rule_id, # type: str - workspace_id, # type: str - resource_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type rule_id: str - :param workspace_id: The workspace Id. - :type workspace_id: str - :param resource_id: The identifier of the resource. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RuleResults, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.RuleResults - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RuleResults"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'ruleId': self._serialize.url("rule_id", rule_id, 'str'), - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['workspaceId'] = self._serialize.query("workspace_id", workspace_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}'} # type: ignore - - def delete( - self, - rule_id, # type: str - workspace_id, # type: str - resource_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> 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. - :type rule_id: str - :param workspace_id: The workspace Id. - :type workspace_id: str - :param resource_id: The identifier of the resource. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'ruleId': self._serialize.url("rule_id", rule_id, 'str'), - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['workspaceId'] = self._serialize.query("workspace_id", workspace_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}'} # type: ignore - - def list( - self, - workspace_id, # type: str - resource_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type workspace_id: str - :param resource_id: The identifier of the resource. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RulesResults, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.RulesResults - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RulesResults"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['workspaceId'] = self._serialize.query("workspace_id", workspace_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - list.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules'} # type: ignore - - def add( - self, - workspace_id, # type: str - resource_id, # type: str - body=None, # type: Optional["_models.RulesResultsInput"] - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type workspace_id: str - :param resource_id: The identifier of the resource. - :type resource_id: str - :param body: The baseline rules. - :type body: ~azure.mgmt.security.models.RulesResultsInput - :keyword callable cls: A custom type or function that will be passed the direct response - :return: RulesResults, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.RulesResults - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RulesResults"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.add.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['workspaceId'] = self._serialize.query("workspace_id", workspace_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'RulesResultsInput') - else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - add.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules'} # 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 deleted file mode 100644 index b768ddc1fa64..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_sql_vulnerability_assessment_scan_results_operations.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 typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SqlVulnerabilityAssessmentScanResultsOperations(object): - """SqlVulnerabilityAssessmentScanResultsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - scan_id, # type: str - scan_result_id, # type: str - workspace_id, # type: str - resource_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type scan_id: str - :param scan_result_id: The rule Id of the results. - :type scan_result_id: str - :param workspace_id: The workspace Id. - :type workspace_id: str - :param resource_id: The identifier of the resource. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScanResult, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ScanResult - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScanResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'scanResultId': self._serialize.url("scan_result_id", scan_result_id, 'str'), - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['workspaceId'] = self._serialize.query("workspace_id", workspace_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}/scanResults/{scanResultId}'} # type: ignore - - def list( - self, - scan_id, # type: str - workspace_id, # type: str - resource_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type scan_id: str - :param workspace_id: The workspace Id. - :type workspace_id: str - :param resource_id: The identifier of the resource. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScanResults, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.ScanResults - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScanResults"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['workspaceId'] = self._serialize.query("workspace_id", workspace_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - list.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}/scanResults'} # 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 deleted file mode 100644 index 715745a22c63..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_sql_vulnerability_assessment_scans_operations.py +++ /dev/null @@ -1,169 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SqlVulnerabilityAssessmentScansOperations(object): - """SqlVulnerabilityAssessmentScansOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def get( - self, - scan_id, # type: str - workspace_id, # type: str - resource_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type scan_id: str - :param workspace_id: The workspace Id. - :type workspace_id: str - :param resource_id: The identifier of the resource. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Scan, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Scan - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Scan"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scanId': self._serialize.url("scan_id", scan_id, 'str'), - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['workspaceId'] = self._serialize.query("workspace_id", workspace_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}'} # type: ignore - - def list( - self, - workspace_id, # type: str - resource_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Scans" - """Gets a list of scan records. - - Gets a list of scan records. - - :param workspace_id: The workspace Id. - :type workspace_id: str - :param resource_id: The identifier of the resource. - :type resource_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Scans, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.Scans - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Scans"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['workspaceId'] = self._serialize.query("workspace_id", workspace_id, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - list.metadata = {'url': '/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans'} # type: ignore 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 deleted file mode 100644 index 98bf219f2712..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_sub_assessments_operations.py +++ /dev/null @@ -1,258 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class SubAssessmentsOperations(object): - """SubAssessmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_all( - self, - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SecuritySubAssessmentList"] - """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). - :type scope: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecuritySubAssessmentList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecuritySubAssessmentList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecuritySubAssessmentList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_all.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_all.metadata = {'url': '/{scope}/providers/Microsoft.Security/subAssessments'} # type: ignore - - def list( - self, - scope, # type: str - assessment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SecuritySubAssessmentList"] - """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). - :type scope: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. - :type assessment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecuritySubAssessmentList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecuritySubAssessmentList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecuritySubAssessmentList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'assessmentName': self._serialize.url("assessment_name", assessment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/subAssessments'} # type: ignore - - def get( - self, - scope, # type: str - assessment_name, # type: str - sub_assessment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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). - :type scope: str - :param assessment_name: The Assessment Key - Unique key for the assessment type. - :type assessment_name: str - :param sub_assessment_name: The Sub-Assessment Key - Unique key for the sub-assessment type. - :type sub_assessment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecuritySubAssessment, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecuritySubAssessment - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecuritySubAssessment"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'assessmentName': self._serialize.url("assessment_name", assessment_name, 'str'), - 'subAssessmentName': self._serialize.url("sub_assessment_name", sub_assessment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/subAssessments/{subAssessmentName}'} # 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 deleted file mode 100644 index 387baf6aafbd..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_tasks_operations.py +++ /dev/null @@ -1,505 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class TasksOperations(object): - """TasksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SecurityTaskList"] - """Recommended tasks that will help improve the security of the subscription proactively. - - :param filter: OData filter. Optional. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecurityTaskList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecurityTaskList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityTaskList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/tasks'} # type: ignore - - def list_by_home_region( - self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SecurityTaskList"] - """Recommended tasks that will help improve the security of the subscription proactively. - - :param filter: OData filter. Optional. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecurityTaskList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecurityTaskList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityTaskList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_home_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_home_region.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks'} # type: ignore - - def get_subscription_level_task( - self, - task_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SecurityTask" - """Recommended tasks that will help improve the security of the subscription proactively. - - :param task_name: Name of the task object, will be a GUID. - :type task_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityTask, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityTask - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityTask"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_subscription_level_task.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'taskName': self._serialize.url("task_name", task_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get_subscription_level_task.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}'} # type: ignore - - def update_subscription_level_task_state( - self, - task_name, # type: str - task_update_action_type, # type: Union[str, "_models.Enum13"] - **kwargs # type: Any - ): - # type: (...) -> None - """Recommended tasks that will help improve the security of the subscription proactively. - - :param task_name: Name of the task object, will be a GUID. - :type task_name: str - :param task_update_action_type: Type of the action to do on the task. - :type task_update_action_type: str or ~azure.mgmt.security.models.Enum13 - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.update_subscription_level_task_state.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'taskName': self._serialize.url("task_name", task_name, 'str'), - 'taskUpdateActionType': self._serialize.url("task_update_action_type", task_update_action_type, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - update_subscription_level_task_state.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}/{taskUpdateActionType}'} # type: ignore - - def list_by_resource_group( - self, - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SecurityTaskList"] - """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. - :type resource_group_name: str - :param filter: OData filter. Optional. - :type filter: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SecurityTaskList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.SecurityTaskList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityTaskList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks'} # type: ignore - - def get_resource_group_level_task( - self, - resource_group_name, # type: str - task_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param task_name: Name of the task object, will be a GUID. - :type task_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecurityTask, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.SecurityTask - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecurityTask"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_resource_group_level_task.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'taskName': self._serialize.url("task_name", task_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get_resource_group_level_task.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}'} # type: ignore - - def update_resource_group_level_task_state( - self, - resource_group_name, # type: str - task_name, # type: str - task_update_action_type, # type: Union[str, "_models.Enum13"] - **kwargs # type: Any - ): - # type: (...) -> 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. - :type resource_group_name: str - :param task_name: Name of the task object, will be a GUID. - :type task_name: str - :param task_update_action_type: Type of the action to do on the task. - :type task_update_action_type: str or ~azure.mgmt.security.models.Enum13 - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.update_resource_group_level_task_state.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'taskName': self._serialize.url("task_name", task_name, 'str'), - 'taskUpdateActionType': self._serialize.url("task_update_action_type", task_update_action_type, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - update_resource_group_level_task_state.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}/{taskUpdateActionType}'} # 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 deleted file mode 100644 index b016e0dfe85d..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_topology_operations.py +++ /dev/null @@ -1,242 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class TopologyOperations(object): - """TopologyOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TopologyList"] - """Gets a list that allows to build a topology view of a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TopologyList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.TopologyList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TopologyList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/topologies'} # type: ignore - - def list_by_home_region( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TopologyList"] - """Gets a list that allows to build a topology view of a subscription and location. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TopologyList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.TopologyList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TopologyList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_home_region.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list_by_home_region.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/topologies'} # type: ignore - - def get( - self, - resource_group_name, # type: str - topology_resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type resource_group_name: str - :param topology_resource_name: Name of a topology resources collection. - :type topology_resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: TopologyResource, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.TopologyResource - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TopologyResource"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'ascLocation': self._serialize.url("self._config.asc_location", self._config.asc_location, 'str'), - 'topologyResourceName': self._serialize.url("topology_resource_name", topology_resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/topologies/{topologyResourceName}'} # 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 deleted file mode 100644 index 44fdc6da27c8..000000000000 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/operations/_workspace_settings_operations.py +++ /dev/null @@ -1,349 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class WorkspaceSettingsOperations(object): - """WorkspaceSettingsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.security.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkspaceSettingList"] - """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. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkspaceSettingList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.models.WorkspaceSettingList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceSettingList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - 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) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - 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 - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings'} # type: ignore - - def get( - self, - workspace_setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. - :type workspace_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkspaceSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.WorkspaceSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'workspaceSettingName': self._serialize.url("workspace_setting_name", workspace_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}'} # type: ignore - - def create( - self, - workspace_setting_name, # type: str - workspace_setting, # type: "_models.WorkspaceSetting" - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkspaceSetting" - """creating settings about where we should store your security data and logs. - - :param workspace_setting_name: Name of the security setting. - :type workspace_setting_name: str - :param workspace_setting: Security data setting object. - :type workspace_setting: ~azure.mgmt.security.models.WorkspaceSetting - :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkspaceSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.WorkspaceSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'workspaceSettingName': self._serialize.url("workspace_setting_name", workspace_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workspace_setting, 'WorkspaceSetting') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}'} # type: ignore - - def update( - self, - workspace_setting_name, # type: str - workspace_setting, # type: "_models.WorkspaceSetting" - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkspaceSetting" - """Settings about where we should store your security data and logs. - - :param workspace_setting_name: Name of the security setting. - :type workspace_setting_name: str - :param workspace_setting: Security data setting object. - :type workspace_setting: ~azure.mgmt.security.models.WorkspaceSetting - :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkspaceSetting, or the result of cls(response) - :rtype: ~azure.mgmt.security.models.WorkspaceSetting - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkspaceSetting"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'workspaceSettingName': self._serialize.url("workspace_setting_name", workspace_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(workspace_setting, 'WorkspaceSetting') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [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, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}'} # type: ignore - - def delete( - self, - workspace_setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> 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. - :type workspace_setting_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - 'workspaceSettingName': self._serialize.url("workspace_setting_name", workspace_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **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, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}'} # 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 new file mode 100644 index 000000000000..a5eaeae6d251 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..b06d35a46ae4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_configuration.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2015-06-01-preview") # type: str + + 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._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> 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.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") + 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 new file mode 100644 index 000000000000..d15b751677b8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_metadata.json @@ -0,0 +1,104 @@ +{ + "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_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"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 + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Azure subscription ID. Required.", + "docstring_type": "str", + "required": true + } + }, + "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=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "locations": "LocationsOperations", + "operations": "Operations", + "tasks": "TasksOperations" + } +} \ No newline at end of file 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..ac8a0bbd061b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +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) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.tasks = TasksOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SecurityCenter + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (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 new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) 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 new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" 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 new file mode 100644 index 000000000000..23906b4c7b04 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..29d705f2e381 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/_configuration.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. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2015-06-01-preview") # type: str + + 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._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') + 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..901fc920ecb1 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/_security_center.py @@ -0,0 +1,103 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +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) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.locations = LocationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.tasks = TasksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SecurityCenter": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> 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 new file mode 100644 index 000000000000..a5ecd9bc7118 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/__init__.py @@ -0,0 +1,22 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..e8e68d81edb8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_locations_operations.py @@ -0,0 +1,185 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @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. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AscLocationList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AscLocation] + + + request = build_get_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}"} # 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 new file mode 100644 index 000000000000..58a44d3bea5c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_operations.py @@ -0,0 +1,120 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.Operation"]: + """Exposes all available operations for discovery purposes. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/providers/Microsoft.Security/operations"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..0a32103cfc0a --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_tasks_operations.py @@ -0,0 +1,575 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityTaskList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/tasks"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityTaskList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_home_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_home_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityTask] + + + 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, + template_url=self.get_subscription_level_task.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get_subscription_level_task.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.update_subscription_level_task_state.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + update_subscription_level_task_state.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}/{taskUpdateActionType}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityTaskList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityTask] + + + 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, + template_url=self.get_resource_group_level_task.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get_resource_group_level_task.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.update_resource_group_level_task_state.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + update_resource_group_level_task_state.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}/{taskUpdateActionType}"} # 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 new file mode 100644 index 000000000000..47491a5118b0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/__init__.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. +# -------------------------------------------------------------------------- + +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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..b660b59d7629 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/_models_py3.py @@ -0,0 +1,465 @@ +# 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 TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + :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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..750c79e0acf0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/_security_center_enums.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. +# 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 new file mode 100644 index 000000000000..a5ecd9bc7118 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/__init__.py @@ -0,0 +1,22 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..999c492cdbf2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_locations_operations.py @@ -0,0 +1,255 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_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") + + + @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. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AscLocationList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AscLocation] + + + request = build_get_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}"} # 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 new file mode 100644 index 000000000000..5f38eb843e05 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_operations.py @@ -0,0 +1,149 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + 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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.Operation"]: + """Exposes all available operations for discovery purposes. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/providers/Microsoft.Security/operations"} # type: ignore 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..9ed9f80265c7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_tasks_operations.py @@ -0,0 +1,850 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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( + 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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( + 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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( + 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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( + 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityTaskList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/tasks"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityTaskList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_home_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_home_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityTask] + + + 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, + template_url=self.get_subscription_level_task.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get_subscription_level_task.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.update_subscription_level_task_state.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + update_subscription_level_task_state.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}/{taskUpdateActionType}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityTaskList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityTask] + + + 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, + template_url=self.get_resource_group_level_task.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get_resource_group_level_task.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.update_resource_group_level_task_state.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + update_resource_group_level_task_state.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/tasks/{taskName}/{taskUpdateActionType}"} # 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 new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/py.typed @@ -0,0 +1 @@ +# 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 new file mode 100644 index 000000000000..a5eaeae6d251 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..b2b5163fc823 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_configuration.py @@ -0,0 +1,64 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2017-08-01") # type: str + + 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._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> 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.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") + 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 new file mode 100644 index 000000000000..809d36282025 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_metadata.json @@ -0,0 +1,90 @@ +{ + "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_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"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 + } + }, + "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=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "compliance_results": "ComplianceResultsOperations" + } +} \ No newline at end of file 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..018a0d49e1c4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +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) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.compliance_results = ComplianceResultsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SecurityCenter + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (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 new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) 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 new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" 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 new file mode 100644 index 000000000000..23906b4c7b04 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..6ddfc69bef23 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/_configuration.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. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-08-01") # type: str + + 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._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') + 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..a249f0a89191 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +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) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.compliance_results = ComplianceResultsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SecurityCenter": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> 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 new file mode 100644 index 000000000000..daac754c45c7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/operations/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..5f9b7df4071b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/operations/_compliance_results_operations.py @@ -0,0 +1,190 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComplianceResultList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/{scope}/providers/Microsoft.Security/complianceResults"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ComplianceResult or the result of cls(response) + :rtype: ~azure.mgmt.security.v2017_08_01.models.ComplianceResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComplianceResult] + + + request = build_get_request( + resource_id=resource_id, + compliance_result_name=compliance_result_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/complianceResults/{complianceResultName}"} # 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..637810ad8562 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/models/__init__.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..3730065dbfce --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/models/_models_py3.py @@ -0,0 +1,206 @@ +# 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 List + +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.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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + """ + 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 Azure. + + :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 + ): + """ + :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 + ): + """ + """ + 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..49629f384a80 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/models/_security_center_enums.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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. + """ + + #: This assessment on the resource is healthy + HEALTHY = "Healthy" + #: This assessment is not applicable to this resource + NOT_APPLICABLE = "NotApplicable" + #: This assessment is turned off by policy on this subscription + OFF_BY_POLICY = "OffByPolicy" + #: This assessment on the resource is not healthy + NOT_HEALTHY = "NotHealthy" 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 new file mode 100644 index 000000000000..daac754c45c7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/operations/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..48f38882b8b1 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/operations/_compliance_results_operations.py @@ -0,0 +1,259 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComplianceResultList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/{scope}/providers/Microsoft.Security/complianceResults"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ComplianceResult or the result of cls(response) + :rtype: ~azure.mgmt.security.v2017_08_01.models.ComplianceResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComplianceResult] + + + request = build_get_request( + resource_id=resource_id, + compliance_result_name=compliance_result_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/complianceResults/{complianceResultName}"} # 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/py.typed @@ -0,0 +1 @@ +# 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 new file mode 100644 index 000000000000..a5eaeae6d251 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..46043a171d74 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_configuration.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2017-08-01-preview") # type: str + + 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._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> 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.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") + 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 new file mode 100644 index 000000000000..f2bc142b961c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_metadata.json @@ -0,0 +1,106 @@ +{ + "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_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"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 + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Azure subscription ID. Required.", + "docstring_type": "str", + "required": true + } + }, + "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=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "auto_provisioning_settings": "AutoProvisioningSettingsOperations", + "compliances": "CompliancesOperations", + "information_protection_policies": "InformationProtectionPoliciesOperations", + "security_contacts": "SecurityContactsOperations", + "workspace_settings": "WorkspaceSettingsOperations" + } +} \ No newline at end of file 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..d08c19685330 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +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) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.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.security_contacts = SecurityContactsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_settings = WorkspaceSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SecurityCenter + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (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 new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) 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 new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" 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 new file mode 100644 index 000000000000..23906b4c7b04 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..6cfca7b9e3ba --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/_configuration.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. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-08-01-preview") # type: str + + 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._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') + 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..c52e89f0a80e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/_security_center.py @@ -0,0 +1,118 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +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) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.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.security_contacts = SecurityContactsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.workspace_settings = WorkspaceSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SecurityCenter": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> 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 new file mode 100644 index 000000000000..0c6e7c9dfe53 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/__init__.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. +# -------------------------------------------------------------------------- + +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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..557dc2365853 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_auto_provisioning_settings_operations.py @@ -0,0 +1,309 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.AutoProvisioningSetting"]: + """Exposes the auto provisioning settings of the subscriptions. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoProvisioningSettingList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoProvisioningSetting] + + + request = build_get_request( + setting_name=setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings/{settingName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. Required. + :type setting: ~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AutoProvisioningSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoProvisioningSetting] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(setting, (IO, 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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings/{settingName}"} # 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 new file mode 100644 index 000000000000..31a5cbeb6b72 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_compliances_operations.py @@ -0,0 +1,192 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComplianceList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/{scope}/providers/Microsoft.Security/compliances"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Compliance] + + + request = build_get_request( + scope=scope, + compliance_name=compliance_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Security/compliances/{complianceName}"} # 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 new file mode 100644 index 000000000000..5f8878fac6d8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_information_protection_policies_operations.py @@ -0,0 +1,349 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.InformationProtectionPolicy] + + + request = build_get_request( + scope=scope, + information_protection_policy_name=information_protection_policy_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Security/informationProtectionPolicies/{informationProtectionPolicyName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or + a IO type. Required. + :type information_protection_policy: + ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: InformationProtectionPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.InformationProtectionPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(information_protection_policy, (IO, 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.Security/informationProtectionPolicies/{informationProtectionPolicyName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.InformationProtectionPolicyList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/{scope}/providers/Microsoft.Security/informationProtectionPolicies"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..e91c0d22a4f8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_security_contacts_operations.py @@ -0,0 +1,492 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.SecurityContact"]: + """Security contact configurations for the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityContactList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityContact] + + + request = build_get_request( + security_contact_name=security_contact_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type security_contact: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityContact or the result of cls(response) + :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityContact] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_contact, (IO, 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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + security_contact_name=security_contact_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type security_contact: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityContact or the result of cls(response) + :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityContact] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_contact, (IO, 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, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}"} # 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 new file mode 100644 index 000000000000..94dd7fa75816 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_workspace_settings_operations.py @@ -0,0 +1,495 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @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. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceSettingList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceSetting] + + + request = build_get_request( + workspace_setting_name=workspace_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type workspace_setting: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: WorkspaceSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceSetting] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workspace_setting, (IO, 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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type workspace_setting: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: WorkspaceSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceSetting] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workspace_setting, (IO, 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, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + workspace_setting_name=workspace_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}"} # 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 new file mode 100644 index 000000000000..842cce18826b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/models/__init__.py @@ -0,0 +1,60 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..eea34dc09365 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/models/_models_py3.py @@ -0,0 +1,794 @@ +# 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 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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..d66191663bca --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/models/_security_center_enums.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. +# -------------------------------------------------------------------------- + +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. + """ + + #: Get notifications on new alerts + ON = "On" + #: Don't get notifications on new alerts + OFF = "Off" + +class AlertsToAdmins(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether to send security alerts notifications to subscription admins. + """ + + #: Send notification on new alerts to the subscription's admins + ON = "On" + #: Don't send notification on new alerts to the subscription's admins + OFF = "Off" + +class AutoProvision(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Describes what kind of security agent provisioning action to take. + """ + + #: Install missing security agent on VMs automatically + ON = "On" + #: Do not install security agent on the VMs automatically + OFF = "Off" + +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 new file mode 100644 index 000000000000..0c6e7c9dfe53 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/__init__.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. +# -------------------------------------------------------------------------- + +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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..6bfb66df384e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_auto_provisioning_settings_operations.py @@ -0,0 +1,417 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.AutoProvisioningSetting"]: + """Exposes the auto provisioning settings of the subscriptions. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoProvisioningSettingList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoProvisioningSetting] + + + request = build_get_request( + setting_name=setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings/{settingName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. Required. + :type setting: ~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AutoProvisioningSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.AutoProvisioningSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutoProvisioningSetting] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(setting, (IO, 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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/autoProvisioningSettings/{settingName}"} # 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 new file mode 100644 index 000000000000..029240934e42 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_compliances_operations.py @@ -0,0 +1,262 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComplianceList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/{scope}/providers/Microsoft.Security/compliances"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Compliance] + + + request = build_get_request( + scope=scope, + compliance_name=compliance_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Security/compliances/{complianceName}"} # 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 new file mode 100644 index 000000000000..06614355b8e3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_information_protection_policies_operations.py @@ -0,0 +1,457 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.InformationProtectionPolicy] + + + request = build_get_request( + scope=scope, + information_protection_policy_name=information_protection_policy_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Security/informationProtectionPolicies/{informationProtectionPolicyName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or + a IO type. Required. + :type information_protection_policy: + ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: InformationProtectionPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.InformationProtectionPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.InformationProtectionPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(information_protection_policy, (IO, 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.Security/informationProtectionPolicies/{informationProtectionPolicyName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.InformationProtectionPolicyList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/{scope}/providers/Microsoft.Security/informationProtectionPolicies"} # type: ignore 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..64b0df76f8a2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_security_contacts_operations.py @@ -0,0 +1,673 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.SecurityContact"]: + """Security contact configurations for the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityContactList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityContact] + + + request = build_get_request( + security_contact_name=security_contact_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type security_contact: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityContact or the result of cls(response) + :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityContact] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_contact, (IO, 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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + security_contact_name=security_contact_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type security_contact: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityContact or the result of cls(response) + :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.SecurityContact + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityContact] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_contact, (IO, 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, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}"} # 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 new file mode 100644 index 000000000000..6c6aa07563c2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_workspace_settings_operations.py @@ -0,0 +1,676 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @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. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceSettingList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceSetting] + + + request = build_get_request( + workspace_setting_name=workspace_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type workspace_setting: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: WorkspaceSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceSetting] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workspace_setting, (IO, 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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type workspace_setting: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: WorkspaceSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2017_08_01_preview.models.WorkspaceSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.WorkspaceSetting] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workspace_setting, (IO, 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, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + workspace_setting_name=workspace_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/workspaceSettings/{workspaceSettingName}"} # 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 new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/py.typed @@ -0,0 +1 @@ +# 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 new file mode 100644 index 000000000000..a5eaeae6d251 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..0281c36f13a3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_configuration.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2018-06-01") # type: str + + 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._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> 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.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") + 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 new file mode 100644 index 000000000000..d7403e5aa6ae --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_metadata.json @@ -0,0 +1,102 @@ +{ + "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_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"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 + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Azure subscription ID. Required.", + "docstring_type": "str", + "required": true + } + }, + "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=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "pricings": "PricingsOperations" + } +} \ No newline at end of file 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..e0d6757c1d68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +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) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.pricings = PricingsOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SecurityCenter + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (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 new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) 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 new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" 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 new file mode 100644 index 000000000000..23906b4c7b04 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..97de7f3864d2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/_configuration.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. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-06-01") # type: str + + 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._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') + 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..9dd758e9e5a6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/_security_center.py @@ -0,0 +1,93 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +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) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.pricings = PricingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SecurityCenter": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> 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 new file mode 100644 index 000000000000..ec8f4dcf5c8a --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/operations/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..c8ff4dcf24ba --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/operations/_pricings_operations.py @@ -0,0 +1,285 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Optional, 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 +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") + + + @distributed_trace_async + async def list( + self, + **kwargs: Any + ) -> _models.PricingList: + """Lists Microsoft Defender for Cloud pricing configurations in the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PricingList or the result of cls(response) + :rtype: ~azure.mgmt.security.v2018_06_01.models.PricingList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PricingList] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Pricing or the result of cls(response) + :rtype: ~azure.mgmt.security.v2018_06_01.models.Pricing + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Pricing] + + + request = build_get_request( + pricing_name=pricing_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. Required. + :type pricing: ~azure.mgmt.security.v2018_06_01.models.Pricing or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Pricing or the result of cls(response) + :rtype: ~azure.mgmt.security.v2018_06_01.models.Pricing + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Pricing] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(pricing, (IO, 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, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}"} # 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 new file mode 100644 index 000000000000..72ae86b58378 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/models/__init__.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..4a720af36fbd --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/models/_models_py3.py @@ -0,0 +1,217 @@ +# 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 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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..3a3bb1f34505 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/models/_security_center_enums.py @@ -0,0 +1,22 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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. + """ + + #: Get free Microsoft Defender for Cloud experience with basic security features + FREE = "Free" + #: Get the standard Microsoft Defender for Cloud experience with advanced security features + STANDARD = "Standard" 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 new file mode 100644 index 000000000000..ec8f4dcf5c8a --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/operations/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..c234e0882c43 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/operations/_pricings_operations.py @@ -0,0 +1,394 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Optional, 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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> _models.PricingList: + """Lists Microsoft Defender for Cloud pricing configurations in the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PricingList or the result of cls(response) + :rtype: ~azure.mgmt.security.v2018_06_01.models.PricingList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PricingList] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Pricing or the result of cls(response) + :rtype: ~azure.mgmt.security.v2018_06_01.models.Pricing + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Pricing] + + + request = build_get_request( + pricing_name=pricing_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. Required. + :type pricing: ~azure.mgmt.security.v2018_06_01.models.Pricing or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Pricing or the result of cls(response) + :rtype: ~azure.mgmt.security.v2018_06_01.models.Pricing + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Pricing] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(pricing, (IO, 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, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/pricings/{pricingName}"} # 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 new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/py.typed @@ -0,0 +1 @@ +# 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 new file mode 100644 index 000000000000..a5eaeae6d251 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..3ea0c3b424ca --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_configuration.py @@ -0,0 +1,64 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2019-01-01") # type: str + + 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._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> 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.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") + 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 new file mode 100644 index 000000000000..1354c53972c1 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_metadata.json @@ -0,0 +1,90 @@ +{ + "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_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"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 + } + }, + "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=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "advanced_threat_protection": "AdvancedThreatProtectionOperations" + } +} \ No newline at end of file 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..ccfc826e7e45 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +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) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.advanced_threat_protection = AdvancedThreatProtectionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SecurityCenter + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (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 new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) 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 new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" 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 new file mode 100644 index 000000000000..23906b4c7b04 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..8d1611e44b5f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/_configuration.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. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-01-01") # type: str + + 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._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') + 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..5436f38b757e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +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) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.advanced_threat_protection = AdvancedThreatProtectionOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SecurityCenter": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> 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 new file mode 100644 index 000000000000..a3172fd46d49 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/operations/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..a103298d956c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/operations/_advanced_threat_protection_operations.py @@ -0,0 +1,246 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Optional, 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 +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") + + + @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 + :keyword setting_name: Advanced Threat Protection setting name. Default value is "current". + Note that overriding this default value may result in unsupported behavior. + :paramtype setting_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AdvancedThreatProtectionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_01_01.models.AdvancedThreatProtectionSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01")) # type: str + setting_name = kwargs.pop('setting_name', "current") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AdvancedThreatProtectionSetting] + + + request = build_get_request( + resource_id=resource_id, + api_version=api_version, + setting_name=setting_name, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/advancedThreatProtectionSettings/{settingName}"} # 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 + :keyword setting_name: Advanced Threat Protection setting name. Default value is "current". + Note that overriding this default value may result in unsupported behavior. + :paramtype setting_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword setting_name: Advanced Threat Protection setting name. Default value is "current". + Note that overriding this default value may result in unsupported behavior. + :paramtype setting_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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], + **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 + model type or a IO type. Required. + :type advanced_threat_protection_setting: + ~azure.mgmt.security.v2019_01_01.models.AdvancedThreatProtectionSetting or IO + :keyword setting_name: Advanced Threat Protection setting name. Default value is "current". + Note that overriding this default value may result in unsupported behavior. + :paramtype setting_name: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AdvancedThreatProtectionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_01_01.models.AdvancedThreatProtectionSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01")) # type: str + setting_name = kwargs.pop('setting_name', "current") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AdvancedThreatProtectionSetting] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(advanced_threat_protection_setting, (IO, 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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + create.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/advancedThreatProtectionSettings/{settingName}"} # 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..9627b6e83292 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/models/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..5e144b7f25bc --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/models/_models_py3.py @@ -0,0 +1,170 @@ +# 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 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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + """ + 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..a3172fd46d49 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/operations/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..9b9e8460fc0b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/operations/_advanced_threat_protection_operations.py @@ -0,0 +1,322 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Optional, 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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01")) # type: str + setting_name = kwargs.pop('setting_name', "current") # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01")) # type: str + setting_name = kwargs.pop('setting_name', "current") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @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 + :keyword setting_name: Advanced Threat Protection setting name. Default value is "current". + Note that overriding this default value may result in unsupported behavior. + :paramtype setting_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AdvancedThreatProtectionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_01_01.models.AdvancedThreatProtectionSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01")) # type: str + setting_name = kwargs.pop('setting_name', "current") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AdvancedThreatProtectionSetting] + + + request = build_get_request( + resource_id=resource_id, + api_version=api_version, + setting_name=setting_name, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/advancedThreatProtectionSettings/{settingName}"} # 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 + :keyword setting_name: Advanced Threat Protection setting name. Default value is "current". + Note that overriding this default value may result in unsupported behavior. + :paramtype setting_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword setting_name: Advanced Threat Protection setting name. Default value is "current". + Note that overriding this default value may result in unsupported behavior. + :paramtype setting_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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], + **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 + model type or a IO type. Required. + :type advanced_threat_protection_setting: + ~azure.mgmt.security.v2019_01_01.models.AdvancedThreatProtectionSetting or IO + :keyword setting_name: Advanced Threat Protection setting name. Default value is "current". + Note that overriding this default value may result in unsupported behavior. + :paramtype setting_name: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AdvancedThreatProtectionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_01_01.models.AdvancedThreatProtectionSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01")) # type: str + setting_name = kwargs.pop('setting_name', "current") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AdvancedThreatProtectionSetting] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(advanced_threat_protection_setting, (IO, 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, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + create.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/advancedThreatProtectionSettings/{settingName}"} # 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/py.typed @@ -0,0 +1 @@ +# 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 new file mode 100644 index 000000000000..a5eaeae6d251 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..e84e5e718ea9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_configuration.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2019-01-01-preview") # type: str + + 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._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> 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.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") + 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 new file mode 100644 index 000000000000..ff1244d9151c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_metadata.json @@ -0,0 +1,107 @@ +{ + "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_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"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 + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Azure subscription ID. Required.", + "docstring_type": "str", + "required": true + } + }, + "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=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "regulatory_compliance_standards": "RegulatoryComplianceStandardsOperations", + "regulatory_compliance_controls": "RegulatoryComplianceControlsOperations", + "regulatory_compliance_assessments": "RegulatoryComplianceAssessmentsOperations", + "sub_assessments": "SubAssessmentsOperations", + "automations": "AutomationsOperations", + "alerts_suppression_rules": "AlertsSuppressionRulesOperations" + } +} \ No newline at end of file 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..a5196bde8981 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_security_center.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 copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +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 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 + :ivar automations: AutomationsOperations operations + :vartype automations: azure.mgmt.security.v2019_01_01_preview.operations.AutomationsOperations + :ivar alerts_suppression_rules: AlertsSuppressionRulesOperations operations + :vartype alerts_suppression_rules: + azure.mgmt.security.v2019_01_01_preview.operations.AlertsSuppressionRulesOperations + :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) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.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.automations = AutomationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.alerts_suppression_rules = AlertsSuppressionRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SecurityCenter + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (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 new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) 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 new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" 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 new file mode 100644 index 000000000000..23906b4c7b04 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..e64e3eefe8ce --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/_configuration.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. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-01-01-preview") # type: str + + 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._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') + 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..a251064339ba --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +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 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 + :ivar automations: AutomationsOperations operations + :vartype automations: + azure.mgmt.security.v2019_01_01_preview.aio.operations.AutomationsOperations + :ivar alerts_suppression_rules: AlertsSuppressionRulesOperations operations + :vartype alerts_suppression_rules: + azure.mgmt.security.v2019_01_01_preview.aio.operations.AlertsSuppressionRulesOperations + :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) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.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.automations = AutomationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.alerts_suppression_rules = AlertsSuppressionRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SecurityCenter": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> 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 new file mode 100644 index 000000000000..473ea251987e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/__init__.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +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 ._automations_operations import AutomationsOperations +from ._alerts_suppression_rules_operations import AlertsSuppressionRulesOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'RegulatoryComplianceStandardsOperations', + 'RegulatoryComplianceControlsOperations', + 'RegulatoryComplianceAssessmentsOperations', + 'SubAssessmentsOperations', + 'AutomationsOperations', + 'AlertsSuppressionRulesOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 new file mode 100644 index 000000000000..01e2dbf049f6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_alerts_suppression_rules_operations.py @@ -0,0 +1,372 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertsSuppressionRulesList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + alert_type=alert_type, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertsSuppressionRule] + + + request = build_get_request( + alerts_suppression_rule_name=alerts_suppression_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type alerts_suppression_rule: + ~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AlertsSuppressionRule or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertsSuppressionRule] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(alerts_suppression_rule, (IO, 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, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + alerts_suppression_rule_name=alerts_suppression_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}"} # 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 new file mode 100644 index 000000000000..c01d57ba00ca --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_automations_operations.py @@ -0,0 +1,621 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @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. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutomationList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/automations"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutomationList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Automation] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_name=automation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type automation: ~azure.mgmt.security.v2019_01_01_preview.models.Automation or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Automation or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.Automation + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Automation] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(automation, (IO, 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type automation: ~azure.mgmt.security.v2019_01_01_preview.models.Automation or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AutomationValidationStatus or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.AutomationValidationStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutomationValidationStatus] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(automation, (IO, 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, + template_url=self.validate.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}/validate"} # 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..b8cc1168e79c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_assessments_operations.py @@ -0,0 +1,208 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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 +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class RegulatoryComplianceAssessmentsOperations: + """ + .. 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RegulatoryComplianceAssessmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + 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, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}/regulatoryComplianceAssessments"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RegulatoryComplianceAssessment] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}/regulatoryComplianceAssessments/{regulatoryComplianceAssessmentName}"} # 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 new file mode 100644 index 000000000000..09a2e1c1bba2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_controls_operations.py @@ -0,0 +1,198 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RegulatoryComplianceControlList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + regulatory_compliance_standard_name=regulatory_compliance_standard_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RegulatoryComplianceControl] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}"} # 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 new file mode 100644 index 000000000000..ac34948a7826 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_standards_operations.py @@ -0,0 +1,188 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RegulatoryComplianceStandardList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RegulatoryComplianceStandard] + + + request = build_get_request( + regulatory_compliance_standard_name=regulatory_compliance_standard_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}"} # 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 new file mode 100644 index 000000000000..b6732b5a0c7c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_sub_assessments_operations.py @@ -0,0 +1,284 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecuritySubAssessmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_all_request( + scope=scope, + api_version=api_version, + template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_all.metadata = {'url': "/{scope}/providers/Microsoft.Security/subAssessments"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecuritySubAssessmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + assessment_name=assessment_name, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/subAssessments"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecuritySubAssessment] + + + request = build_get_request( + scope=scope, + assessment_name=assessment_name, + sub_assessment_name=sub_assessment_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/subAssessments/{subAssessmentName}"} # 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 new file mode 100644 index 000000000000..f41207c55adb --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/models/__init__.py @@ -0,0 +1,122 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..7c41482d8b8b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/models/_models_py3.py @@ -0,0 +1,2018 @@ +# 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 Azure. + + :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 + ): + """ + """ + super().__init__(**kwargs) + self.assessed_resource_type = None # type: Optional[str] + + +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 + ): + """ + """ + 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 this field will default to the maximum allowed expiration date. + :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 + ): + """ + :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 this field will default to the maximum allowed expiration date. + :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 Azure. + + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + """ + super().__init__(**kwargs) + self.action_type = None # type: Optional[str] + + +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 Azure. + + :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 + ): + """ + :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 = 'EventHub' # type: str + 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 Azure. + + :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 + ): + """ + :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 = 'LogicApp' # type: str + 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 Azure. + + :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 + ): + """ + :keyword workspace_resource_id: The fully qualified Log Analytics Workspace Azure Resource ID. + :paramtype workspace_resource_id: str + """ + super().__init__(**kwargs) + self.action_type = 'Workspace' # type: str + 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 Azure. + + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + """ + super().__init__(**kwargs) + self.source = None # type: Optional[str] + + +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 Azure. + + :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 + ): + """ + """ + super().__init__(**kwargs) + self.source = 'Azure' # type: str + 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 + ): + """ + """ + 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 Azure. + + :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 + ): + """ + """ + super().__init__(**kwargs) + self.assessed_resource_type = 'ContainerRegistryVulnerability' # type: str + 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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + """ + 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 Azure. + + :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 + ): + """ + :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 = 'OnPremise' # type: str + 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 Azure. + + :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 + ): + """ + :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 = 'OnPremiseSql' # type: str + 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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + """ + 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 Azure. + + :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 + ): + """ + """ + super().__init__(**kwargs) + self.assessed_resource_type = 'ServerVulnerabilityAssessment' # type: str + 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 Azure. + + :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 + ): + """ + """ + super().__init__(**kwargs) + self.assessed_resource_type = 'SqlServerVulnerability' # type: str + 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 + ): + """ + """ + 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 Azure. + + :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 + ): + """ + :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 + ): + """ + """ + 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..a05758aecdd4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/models/_security_center_enums.py @@ -0,0 +1,129 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) 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. + """ + + #: Applies for decimal and non-decimal operands + EQUALS = "Equals" + #: Applies only for 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 for decimal and non-decimal operands + NOT_EQUALS = "NotEquals" + #: Applies only for non-decimal operands + CONTAINS = "Contains" + #: Applies only for non-decimal operands + STARTS_WITH = "StartsWith" + #: Applies only for non-decimal operands + ENDS_WITH = "EndsWith" + +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. + """ + + #: Resource is in Azure + AZURE = "Azure" + #: Resource in an on premise machine connected to Azure cloud + ON_PREMISE = "OnPremise" + #: SQL Resource in an on premise machine connected to Azure cloud + ON_PREMISE_SQL = "OnPremiseSql" + +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Aggregative state based on the standard's supported controls states. + """ + + #: All supported regulatory compliance controls in the given standard have a passed state + PASSED = "Passed" + #: At least one supported regulatory compliance control in the given standard has a state of + #: failed + FAILED = "Failed" + #: All supported regulatory compliance controls in the given standard have a state of skipped + SKIPPED = "Skipped" + #: No supported regulatory compliance data for the given standard + UNSUPPORTED = "Unsupported" + +class SubAssessmentStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Programmatic code for the status of the assessment. + """ + + #: The resource is healthy + HEALTHY = "Healthy" + #: The resource has a security issue that needs to be addressed + UNHEALTHY = "Unhealthy" + #: Assessment for this resource did not happen + NOT_APPLICABLE = "NotApplicable" 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 new file mode 100644 index 000000000000..473ea251987e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/__init__.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +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 ._automations_operations import AutomationsOperations +from ._alerts_suppression_rules_operations import AlertsSuppressionRulesOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'RegulatoryComplianceStandardsOperations', + 'RegulatoryComplianceControlsOperations', + 'RegulatoryComplianceAssessmentsOperations', + 'SubAssessmentsOperations', + 'AutomationsOperations', + 'AlertsSuppressionRulesOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 new file mode 100644 index 000000000000..c9b394df481b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_alerts_suppression_rules_operations.py @@ -0,0 +1,519 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertsSuppressionRulesList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + alert_type=alert_type, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertsSuppressionRule] + + + request = build_get_request( + alerts_suppression_rule_name=alerts_suppression_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type alerts_suppression_rule: + ~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AlertsSuppressionRule or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.AlertsSuppressionRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertsSuppressionRule] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(alerts_suppression_rule, (IO, 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, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + alerts_suppression_rule_name=alerts_suppression_rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alertsSuppressionRules/{alertsSuppressionRuleName}"} # 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 new file mode 100644 index 000000000000..743c581573db --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_automations_operations.py @@ -0,0 +1,845 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @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. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutomationList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/automations"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutomationList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Automation] + + + request = build_get_request( + resource_group_name=resource_group_name, + automation_name=automation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type automation: ~azure.mgmt.security.v2019_01_01_preview.models.Automation or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Automation or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.Automation + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Automation] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(automation, (IO, 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type automation: ~azure.mgmt.security.v2019_01_01_preview.models.Automation or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AutomationValidationStatus or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_01_01_preview.models.AutomationValidationStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AutomationValidationStatus] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(automation, (IO, 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, + template_url=self.validate.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + validate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/automations/{automationName}/validate"} # 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..01cd58164f3d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_assessments_operations.py @@ -0,0 +1,290 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_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: + """ + .. 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RegulatoryComplianceAssessmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + 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, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}/regulatoryComplianceAssessments"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RegulatoryComplianceAssessment] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}/regulatoryComplianceAssessments/{regulatoryComplianceAssessmentName}"} # 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 new file mode 100644 index 000000000000..369277501850 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_controls_operations.py @@ -0,0 +1,276 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RegulatoryComplianceControlList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + regulatory_compliance_standard_name=regulatory_compliance_standard_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RegulatoryComplianceControl] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}/regulatoryComplianceControls/{regulatoryComplianceControlName}"} # 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 new file mode 100644 index 000000000000..176bb4f7a5e1 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_standards_operations.py @@ -0,0 +1,262 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RegulatoryComplianceStandardList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RegulatoryComplianceStandard] + + + request = build_get_request( + regulatory_compliance_standard_name=regulatory_compliance_standard_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/regulatoryComplianceStandards/{regulatoryComplianceStandardName}"} # 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 new file mode 100644 index 000000000000..037ed71825a2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_sub_assessments_operations.py @@ -0,0 +1,391 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecuritySubAssessmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_all_request( + scope=scope, + api_version=api_version, + template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_all.metadata = {'url': "/{scope}/providers/Microsoft.Security/subAssessments"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecuritySubAssessmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + assessment_name=assessment_name, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/subAssessments"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecuritySubAssessment] + + + request = build_get_request( + scope=scope, + assessment_name=assessment_name, + sub_assessment_name=sub_assessment_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Security/assessments/{assessmentName}/subAssessments/{subAssessmentName}"} # 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 new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/py.typed @@ -0,0 +1 @@ +# 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 new file mode 100644 index 000000000000..a5eaeae6d251 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..a4a64b1c590f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_configuration.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2019-08-01") # type: str + + 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._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> 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.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") + 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 new file mode 100644 index 000000000000..043490fe1983 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_metadata.json @@ -0,0 +1,106 @@ +{ + "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_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"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 + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Azure subscription ID. Required.", + "docstring_type": "str", + "required": true + } + }, + "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=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"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" + } +} \ No newline at end of file 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..355a95c07258 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_security_center.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 copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +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) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.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 + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SecurityCenter + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (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 new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) 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 new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" 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 new file mode 100644 index 000000000000..23906b4c7b04 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..115f47e1a837 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/_configuration.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. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-08-01") # type: str + + 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._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') + 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..6a17bc8bb52f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +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) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.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 + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SecurityCenter": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> 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 new file mode 100644 index 000000000000..5d8d6c30d198 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/__init__.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. +# -------------------------------------------------------------------------- + +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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..11221ce38565 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_device_security_groups_operations.py @@ -0,0 +1,395 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceSecurityGroupList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceSecurityGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceSecurityGroup] + + + request = build_get_request( + resource_id=resource_id, + device_security_group_name=device_security_group_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type device_security_group: ~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceSecurityGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceSecurityGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(device_security_group, (IO, 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_id=resource_id, + device_security_group_name=device_security_group_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}"} # 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 new file mode 100644 index 000000000000..be295e9f5ea0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solution_analytics_operations.py @@ -0,0 +1,173 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, 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 +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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IoTSecuritySolutionAnalyticsModelList or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionAnalyticsModelList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecuritySolutionAnalyticsModelList] + + + request = build_list_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IoTSecuritySolutionAnalyticsModel or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionAnalyticsModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecuritySolutionAnalyticsModel] + + + request = build_get_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default"} # 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 new file mode 100644 index 000000000000..aac0b7acdfb2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solution_operations.py @@ -0,0 +1,632 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecuritySolutionsList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/iotSecuritySolutions"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecuritySolutionsList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecuritySolutionModel] + + + request = build_get_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO + type. Required. + :type iot_security_solution_data: + ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecuritySolutionModel] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_security_solution_data, (IO, 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or + a IO type. Required. + :type update_iot_security_solution_data: + ~azure.mgmt.security.v2019_08_01.models.UpdateIotSecuritySolutionData or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecuritySolutionModel] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_iot_security_solution_data, (IO, 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, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}"} # 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 new file mode 100644 index 000000000000..008bf12ddeb2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py @@ -0,0 +1,271 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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 +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class IotSecuritySolutionsAnalyticsAggregatedAlertOperations: + """ + .. 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecurityAggregatedAlertList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IoTSecurityAggregatedAlert or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecurityAggregatedAlert + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecurityAggregatedAlert] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts/{aggregatedAlertName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.dismiss.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_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, {}) + + dismiss.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts/{aggregatedAlertName}/dismiss"} # 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 new file mode 100644 index 000000000000..e98c7b281afe --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solutions_analytics_recommendation_operations.py @@ -0,0 +1,208 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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 +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class IotSecuritySolutionsAnalyticsRecommendationOperations: + """ + .. 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IoTSecurityAggregatedRecommendation or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecurityAggregatedRecommendation + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecurityAggregatedRecommendation] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedRecommendations/{aggregatedRecommendationName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecurityAggregatedRecommendationList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedRecommendations"} # type: ignore 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..892b2218145e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/models/__init__.py @@ -0,0 +1,140 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..61e8cb021854 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/models/_models_py3.py @@ -0,0 +1,3015 @@ +# 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 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 Azure. + + :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 + ): + """ + :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 = None # type: Optional[str] + + +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 Azure. + + :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 + ): + """ + :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 = 'ThresholdCustomAlertRule' # type: str + 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 Azure. + + :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 + ): + """ + :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 = 'TimeWindowCustomAlertRule' # type: str + 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 Azure. + + :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 + ): + """ + :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 = 'ActiveConnectionsNotInAllowedRange' # type: str + + +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 + ): + """ + :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 Azure. + + :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 + ): + """ + :keyword is_enabled: Status of the custom alert. Required. + :paramtype is_enabled: bool + """ + super().__init__(is_enabled=is_enabled, **kwargs) + self.rule_type = 'ListCustomAlertRule' # type: str + 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 Azure. + + :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 + ): + """ + :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 = 'AllowlistCustomAlertRule' # type: str + 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 Azure. + + :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 + ): + """ + :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 = 'AmqpC2DMessagesNotInAllowedRange' # type: str + + +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 Azure. + + :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 + ): + """ + :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 = 'AmqpC2DRejectedMessagesNotInAllowedRange' # type: str + + +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 Azure. + + :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 + ): + """ + :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 = 'AmqpD2CMessagesNotInAllowedRange' # type: str + + +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 + ): + """ + """ + 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 Azure. + + :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 + ): + """ + :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 = 'ConnectionFromIpNotAllowed' # type: str + + +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 Azure. + + :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 + ): + """ + :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 = 'ConnectionToIpNotAllowed' # type: str + + +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 Azure. + + :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 + ): + """ + :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 = 'DenylistCustomAlertRule' # type: str + 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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 = 'DirectMethodInvokesNotInAllowedRange' # type: str + + +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 + ): + """ + """ + 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 Azure. + + :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 + ): + """ + :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 = 'FailedLocalLoginsNotInAllowedRange' # type: str + + +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 Azure. + + :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 + ): + """ + :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 = 'FileUploadsNotInAllowedRange' # type: str + + +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 Azure. + + :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 + ): + """ + :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 = 'HttpC2DMessagesNotInAllowedRange' # type: str + + +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 Azure. + + :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 + ): + """ + :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 = 'HttpC2DRejectedMessagesNotInAllowedRange' # type: str + + +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 Azure. + + :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 + ): + """ + :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 = 'HttpD2CMessagesNotInAllowedRange' # type: str + + +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 + ): + """ + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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): + """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 + ): + """ + """ + 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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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): + """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 + ): + """ + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 = 'LocalUserNotAllowed' # type: str + + +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 Azure. + + :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 + ): + """ + :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 = 'MqttC2DMessagesNotInAllowedRange' # type: str + + +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 Azure. + + :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 + ): + """ + :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 = 'MqttC2DRejectedMessagesNotInAllowedRange' # type: str + + +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 Azure. + + :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 + ): + """ + :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 = 'MqttD2CMessagesNotInAllowedRange' # type: str + + +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 Azure. + + :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 + ): + """ + :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 = 'ProcessNotAllowed' # type: str + + +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 Azure. + + :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 + ): + """ + :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 = 'QueuePurgesNotInAllowedRange' # type: str + + +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 Azure. + + :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 + ): + """ + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 = 'TwinUpdatesNotInAllowedRange' # type: str + + +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 Azure. + + :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 + ): + """ + :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 = 'UnauthorizedOperationsNotInAllowedRange' # type: str + + +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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..3b36779a74c7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/models/_security_center_enums.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. +# -------------------------------------------------------------------------- + +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. + """ + + #: Devices twin data + TWIN_DATA = "TwinData" + +class ExportData(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ExportData. + """ + + #: Agent raw events + RAW_EVENTS = "RawEvents" + +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. + """ + + #: Authentication schema used for pull an edge module from an ACR repository does not use Service + #: Principal Authentication. + IO_T_ACRAUTHENTICATION = "IoT_ACRAuthentication" + #: 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_AGENT_SENDS_UNUTILIZED_MESSAGES = "IoT_AgentSendsUnutilizedMessages" + #: Identified security related system configuration issues. + IO_T_BASELINE = "IoT_Baseline" + #: 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_HUB_MEM_OPTIMIZE = "IoT_EdgeHubMemOptimize" + #: Logging is disabled for this edge module. + IO_T_EDGE_LOGGING_OPTIONS = "IoT_EdgeLoggingOptions" + #: A minority within a device security group has inconsistent Edge Module settings with the rest + #: of their group. + IO_T_INCONSISTENT_MODULE_SETTINGS = "IoT_InconsistentModuleSettings" + #: Install the Azure Security of Things Agent. + IO_T_INSTALL_AGENT = "IoT_InstallAgent" + #: IP Filter Configuration should have rules defined for allowed traffic and should deny all other + #: traffic by default. + IO_T_IPFILTER_DENY_ALL = "IoT_IPFilter_DenyAll" + #: An Allow IP Filter rules source IP range is too large. Overly permissive rules might expose + #: your IoT hub to malicious intenders. + IO_T_IPFILTER_PERMISSIVE_RULE = "IoT_IPFilter_PermissiveRule" + #: A listening endpoint was found on the device. + IO_T_OPEN_PORTS = "IoT_OpenPorts" + #: 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_FIREWALL_POLICY = "IoT_PermissiveFirewallPolicy" + #: 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_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" + #: 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_PRIVILEGED_DOCKER_OPTIONS = "IoT_PrivilegedDockerOptions" + #: 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_SHARED_CREDENTIALS = "IoT_SharedCredentials" + #: Insecure TLS configurations detected. Immediate upgrade recommended. + IO_T_VULNERABLE_TLS_CIPHER_SUITE = "IoT_VulnerableTLSCipherSuite" + +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. + """ + + #: Unmasked IP logging is disabled + DISABLED = "Disabled" + #: Unmasked IP logging is enabled + ENABLED = "Enabled" + +class ValueType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The value type of the items in the list. + """ + + #: An IP range in CIDR format (e.g. '192.168.0.1/8'). + IP_CIDR = "IpCidr" + #: Any string value. + STRING = "String" 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 new file mode 100644 index 000000000000..5d8d6c30d198 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/__init__.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. +# -------------------------------------------------------------------------- + +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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..c874937b0dca --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_device_security_groups_operations.py @@ -0,0 +1,538 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceSecurityGroupList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_id=resource_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceSecurityGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceSecurityGroup] + + + request = build_get_request( + resource_id=resource_id, + device_security_group_name=device_security_group_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type device_security_group: ~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeviceSecurityGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_08_01.models.DeviceSecurityGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeviceSecurityGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(device_security_group, (IO, 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_id=resource_id, + device_security_group_name=device_security_group_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}"} # 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 new file mode 100644 index 000000000000..1d65656bbd77 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solution_analytics_operations.py @@ -0,0 +1,250 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, 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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IoTSecuritySolutionAnalyticsModelList or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionAnalyticsModelList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecuritySolutionAnalyticsModelList] + + + request = build_list_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IoTSecuritySolutionAnalyticsModel or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionAnalyticsModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecuritySolutionAnalyticsModel] + + + request = build_get_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default"} # 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 new file mode 100644 index 000000000000..ef11c3102b79 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solution_operations.py @@ -0,0 +1,864 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecuritySolutionsList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/iotSecuritySolutions"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecuritySolutionsList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecuritySolutionModel] + + + request = build_get_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO + type. Required. + :type iot_security_solution_data: + ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecuritySolutionModel] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_security_solution_data, (IO, 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or + a IO type. Required. + :type update_iot_security_solution_data: + ~azure.mgmt.security.v2019_08_01.models.UpdateIotSecuritySolutionData or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IoTSecuritySolutionModel or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecuritySolutionModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecuritySolutionModel] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_iot_security_solution_data, (IO, 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, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}"} # 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 new file mode 100644 index 000000000000..a11158879806 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py @@ -0,0 +1,392 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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: + """ + .. 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecurityAggregatedAlertList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IoTSecurityAggregatedAlert or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecurityAggregatedAlert + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecurityAggregatedAlert] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts/{aggregatedAlertName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.dismiss.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_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, {}) + + dismiss.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedAlerts/{aggregatedAlertName}/dismiss"} # 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 new file mode 100644 index 000000000000..6985994a93d2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solutions_analytics_recommendation_operations.py @@ -0,0 +1,290 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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: + """ + .. 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IoTSecurityAggregatedRecommendation or the result of cls(response) + :rtype: ~azure.mgmt.security.v2019_08_01.models.IoTSecurityAggregatedRecommendation + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecurityAggregatedRecommendation] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedRecommendations/{aggregatedRecommendationName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2019-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IoTSecurityAggregatedRecommendationList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + solution_name=solution_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/iotSecuritySolutions/{solutionName}/analyticsModels/default/aggregatedRecommendations"} # type: ignore 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/py.typed @@ -0,0 +1 @@ +# 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 new file mode 100644 index 000000000000..a5eaeae6d251 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..8a0246a8f30f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_configuration.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2020-01-01") # type: str + + 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._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> 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.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") + 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 new file mode 100644 index 000000000000..be1c5d7c93ef --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_metadata.json @@ -0,0 +1,116 @@ +{ + "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_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"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 + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Azure subscription ID. Required.", + "docstring_type": "str", + "required": true + } + }, + "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=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "server_vulnerability_assessment": "ServerVulnerabilityAssessmentOperations", + "assessments_metadata": "AssessmentsMetadataOperations", + "assessments": "AssessmentsOperations", + "adaptive_application_controls": "AdaptiveApplicationControlsOperations", + "adaptive_network_hardenings": "AdaptiveNetworkHardeningsOperations", + "allowed_connections": "AllowedConnectionsOperations", + "topology": "TopologyOperations", + "jit_network_access_policies": "JitNetworkAccessPoliciesOperations", + "discovered_security_solutions": "DiscoveredSecuritySolutionsOperations", + "security_solutions_reference_data": "SecuritySolutionsReferenceDataOperations", + "external_security_solutions": "ExternalSecuritySolutionsOperations", + "secure_scores": "SecureScoresOperations", + "secure_score_controls": "SecureScoreControlsOperations", + "secure_score_control_definitions": "SecureScoreControlDefinitionsOperations", + "security_solutions": "SecuritySolutionsOperations" + } +} \ No newline at end of file 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..cfe27e5eb433 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_security_center.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 copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +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 server_vulnerability_assessment: ServerVulnerabilityAssessmentOperations operations + :vartype server_vulnerability_assessment: + azure.mgmt.security.v2020_01_01.operations.ServerVulnerabilityAssessmentOperations + :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 adaptive_application_controls: AdaptiveApplicationControlsOperations operations + :vartype adaptive_application_controls: + azure.mgmt.security.v2020_01_01.operations.AdaptiveApplicationControlsOperations + :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 topology: TopologyOperations operations + :vartype topology: azure.mgmt.security.v2020_01_01.operations.TopologyOperations + :ivar jit_network_access_policies: JitNetworkAccessPoliciesOperations operations + :vartype jit_network_access_policies: + azure.mgmt.security.v2020_01_01.operations.JitNetworkAccessPoliciesOperations + :ivar discovered_security_solutions: DiscoveredSecuritySolutionsOperations operations + :vartype discovered_security_solutions: + azure.mgmt.security.v2020_01_01.operations.DiscoveredSecuritySolutionsOperations + :ivar security_solutions_reference_data: SecuritySolutionsReferenceDataOperations operations + :vartype security_solutions_reference_data: + azure.mgmt.security.v2020_01_01.operations.SecuritySolutionsReferenceDataOperations + :ivar external_security_solutions: ExternalSecuritySolutionsOperations operations + :vartype external_security_solutions: + azure.mgmt.security.v2020_01_01.operations.ExternalSecuritySolutionsOperations + :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 + :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) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.server_vulnerability_assessment = ServerVulnerabilityAssessmentOperations( + 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.adaptive_application_controls = AdaptiveApplicationControlsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.adaptive_network_hardenings = AdaptiveNetworkHardeningsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.allowed_connections = AllowedConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.topology = TopologyOperations(self._client, self._config, self._serialize, self._deserialize) + self.jit_network_access_policies = JitNetworkAccessPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.discovered_security_solutions = DiscoveredSecuritySolutionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.security_solutions_reference_data = SecuritySolutionsReferenceDataOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.external_security_solutions = ExternalSecuritySolutionsOperations( + 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 + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SecurityCenter + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (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 new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) 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 new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" 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 new file mode 100644 index 000000000000..23906b4c7b04 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..f75520bf25ea --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/_configuration.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. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-01-01") # type: str + + 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._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') + 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..d115f7348c5d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/_security_center.py @@ -0,0 +1,177 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +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 server_vulnerability_assessment: ServerVulnerabilityAssessmentOperations operations + :vartype server_vulnerability_assessment: + azure.mgmt.security.v2020_01_01.aio.operations.ServerVulnerabilityAssessmentOperations + :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 adaptive_application_controls: AdaptiveApplicationControlsOperations operations + :vartype adaptive_application_controls: + azure.mgmt.security.v2020_01_01.aio.operations.AdaptiveApplicationControlsOperations + :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 topology: TopologyOperations operations + :vartype topology: azure.mgmt.security.v2020_01_01.aio.operations.TopologyOperations + :ivar jit_network_access_policies: JitNetworkAccessPoliciesOperations operations + :vartype jit_network_access_policies: + azure.mgmt.security.v2020_01_01.aio.operations.JitNetworkAccessPoliciesOperations + :ivar discovered_security_solutions: DiscoveredSecuritySolutionsOperations operations + :vartype discovered_security_solutions: + azure.mgmt.security.v2020_01_01.aio.operations.DiscoveredSecuritySolutionsOperations + :ivar security_solutions_reference_data: SecuritySolutionsReferenceDataOperations operations + :vartype security_solutions_reference_data: + azure.mgmt.security.v2020_01_01.aio.operations.SecuritySolutionsReferenceDataOperations + :ivar external_security_solutions: ExternalSecuritySolutionsOperations operations + :vartype external_security_solutions: + azure.mgmt.security.v2020_01_01.aio.operations.ExternalSecuritySolutionsOperations + :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 + :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) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.server_vulnerability_assessment = ServerVulnerabilityAssessmentOperations( + 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.adaptive_application_controls = AdaptiveApplicationControlsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.adaptive_network_hardenings = AdaptiveNetworkHardeningsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.allowed_connections = AllowedConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.topology = TopologyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.jit_network_access_policies = JitNetworkAccessPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.discovered_security_solutions = DiscoveredSecuritySolutionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.security_solutions_reference_data = SecuritySolutionsReferenceDataOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.external_security_solutions = ExternalSecuritySolutionsOperations( + 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 + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SecurityCenter": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> 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 new file mode 100644 index 000000000000..97fd501f9bb3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/__init__.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. +# -------------------------------------------------------------------------- + +from ._server_vulnerability_assessment_operations import ServerVulnerabilityAssessmentOperations +from ._assessments_metadata_operations import AssessmentsMetadataOperations +from ._assessments_operations import AssessmentsOperations +from ._adaptive_application_controls_operations import AdaptiveApplicationControlsOperations +from ._adaptive_network_hardenings_operations import AdaptiveNetworkHardeningsOperations +from ._allowed_connections_operations import AllowedConnectionsOperations +from ._topology_operations import TopologyOperations +from ._jit_network_access_policies_operations import JitNetworkAccessPoliciesOperations +from ._discovered_security_solutions_operations import DiscoveredSecuritySolutionsOperations +from ._security_solutions_reference_data_operations import SecuritySolutionsReferenceDataOperations +from ._external_security_solutions_operations import ExternalSecuritySolutionsOperations +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 ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ServerVulnerabilityAssessmentOperations', + 'AssessmentsMetadataOperations', + 'AssessmentsOperations', + 'AdaptiveApplicationControlsOperations', + 'AdaptiveNetworkHardeningsOperations', + 'AllowedConnectionsOperations', + 'TopologyOperations', + 'JitNetworkAccessPoliciesOperations', + 'DiscoveredSecuritySolutionsOperations', + 'SecuritySolutionsReferenceDataOperations', + 'ExternalSecuritySolutionsOperations', + 'SecureScoresOperations', + 'SecureScoreControlsOperations', + 'SecureScoreControlDefinitionsOperations', + 'SecuritySolutionsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 new file mode 100644 index 000000000000..fc559163caef --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_adaptive_application_controls_operations.py @@ -0,0 +1,372 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Optional, 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 +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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AdaptiveApplicationControlGroups or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroups + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AdaptiveApplicationControlGroups] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + include_path_recommendations=include_path_recommendations, + summary=summary, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/applicationWhitelistings"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AdaptiveApplicationControlGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AdaptiveApplicationControlGroup] + + + request = build_get_request( + asc_location=asc_location, + group_name=group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. Required. + :type body: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AdaptiveApplicationControlGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AdaptiveApplicationControlGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, 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, + template_url=self.put.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + put.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + asc_location=asc_location, + group_name=group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}"} # 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 new file mode 100644 index 000000000000..c29732ca7356 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_adaptive_network_hardenings_operations.py @@ -0,0 +1,490 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AdaptiveNetworkHardeningsList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_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, + template_url=self.list_by_extended_resource.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_extended_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AdaptiveNetworkHardening or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveNetworkHardening + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AdaptiveNetworkHardening] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}"} # 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], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + adaptive_network_hardening_enforce_action = kwargs.pop('adaptive_network_hardening_enforce_action', "enforce") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, 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, + template_url=self._enforce_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + _enforce_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}/{adaptiveNetworkHardeningEnforceAction}"} # 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 + :keyword adaptive_network_hardening_enforce_action: Enforces the given rules on the NSG(s) + listed in the request. Default value is "enforce". Note that overriding this default value may + result in unsupported behavior. + :paramtype adaptive_network_hardening_enforce_action: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword adaptive_network_hardening_enforce_action: Enforces the given rules on the NSG(s) + listed in the request. Default value is "enforce". Note that overriding this default value may + result in unsupported behavior. + :paramtype adaptive_network_hardening_enforce_action: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + + @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], + **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 model type or a IO type. Required. + :type body: ~azure.mgmt.security.v2020_01_01.models.AdaptiveNetworkHardeningEnforceRequest or + IO + :keyword adaptive_network_hardening_enforce_action: Enforces the given rules on the NSG(s) + listed in the request. Default value is "enforce". Note that overriding this default value may + result in unsupported behavior. + :paramtype adaptive_network_hardening_enforce_action: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either 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 = kwargs.pop('adaptive_network_hardening_enforce_action', "enforce") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_enforce.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}/{adaptiveNetworkHardeningEnforceAction}"} # 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 new file mode 100644 index 000000000000..1bbcf7642e24 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_allowed_connections_operations.py @@ -0,0 +1,277 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.AllowedConnectionsResource"]: + """Gets the list of all possible traffic between resources for the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AllowedConnectionsList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/allowedConnections"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AllowedConnectionsList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_home_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_home_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AllowedConnectionsResource or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.AllowedConnectionsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AllowedConnectionsResource] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections/{connectionType}"} # 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 new file mode 100644 index 000000000000..3dd61c6048f0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_assessments_metadata_operations.py @@ -0,0 +1,509 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.SecurityAssessmentMetadata"]: + """Get metadata information on all assessment types. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadataList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/providers/Microsoft.Security/assessmentMetadata"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessmentMetadata or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadata] + + + request = build_get_request( + assessment_metadata_name=assessment_metadata_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # 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. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadataList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessmentMetadata or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadata] + + + request = build_get_in_subscription_request( + assessment_metadata_name=assessment_metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_in_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get_in_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type assessment_metadata: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessmentMetadata or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadata] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(assessment_metadata, (IO, 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, + template_url=self.create_in_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + create_in_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_in_subscription_request( + assessment_metadata_name=assessment_metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_in_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_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, {}) + + delete_in_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # 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 new file mode 100644 index 000000000000..0de36619a20d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_assessments_operations.py @@ -0,0 +1,398 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/{scope}/providers/Microsoft.Security/assessments"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessment or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessment] + + + request = build_get_request( + resource_id=resource_id, + assessment_name=assessment_name, + expand=expand, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 + model type or a IO type. Required. + :type assessment: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessment or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(assessment, (IO, 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_id=resource_id, + assessment_name=assessment_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}"} # 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 new file mode 100644 index 000000000000..0263981579d4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_discovered_security_solutions_operations.py @@ -0,0 +1,275 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.DiscoveredSecuritySolution"]: + """Gets a list of discovered Security Solutions for the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiscoveredSecuritySolutionList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/discoveredSecuritySolutions"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiscoveredSecuritySolutionList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_home_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_home_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/discoveredSecuritySolutions"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiscoveredSecuritySolution or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.DiscoveredSecuritySolution + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiscoveredSecuritySolution] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/discoveredSecuritySolutions/{discoveredSecuritySolutionName}"} # 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 new file mode 100644 index 000000000000..6eaf733532d9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_external_security_solutions_operations.py @@ -0,0 +1,275 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ExternalSecuritySolution"]: + """Gets a list of external security solutions for the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ExternalSecuritySolutionList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/externalSecuritySolutions"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ExternalSecuritySolutionList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_home_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_home_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/ExternalSecuritySolutions"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ExternalSecuritySolution or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolution + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ExternalSecuritySolution] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/ExternalSecuritySolutions/{externalSecuritySolutionsName}"} # 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 new file mode 100644 index 000000000000..127b7b4b143c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_jit_network_access_policies_operations.py @@ -0,0 +1,840 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.JitNetworkAccessPolicy"]: + """Policies for protecting resources using Just-in-Time access control. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessPoliciesList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/jitNetworkAccessPolicies"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessPoliciesList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessPoliciesList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/jitNetworkAccessPolicies"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessPoliciesList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_and_region_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group_and_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_resource_group_and_region.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitNetworkAccessPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessPolicy] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. Required. + :type body: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitNetworkAccessPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}"} # 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 + :keyword jit_network_access_policy_initiate_type: Type of the action to do on the Just-in-Time + access policy. Default value is "initiate". Note that overriding this default value may result + in unsupported behavior. + :paramtype jit_network_access_policy_initiate_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword jit_network_access_policy_initiate_type: Type of the action to do on the Just-in-Time + access policy. Default value is "initiate". Note that overriding this default value may result + in unsupported behavior. + :paramtype jit_network_access_policy_initiate_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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], + **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 model type or a IO type. Required. + :type body: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicyInitiateRequest or IO + :keyword jit_network_access_policy_initiate_type: Type of the action to do on the Just-in-Time + access policy. Default value is "initiate". Note that overriding this default value may result + in unsupported behavior. + :paramtype jit_network_access_policy_initiate_type: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitNetworkAccessRequest or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessRequest + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + jit_network_access_policy_initiate_type = kwargs.pop('jit_network_access_policy_initiate_type', "initiate") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessRequest] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, 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, + template_url=self.initiate.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + return deserialized + + initiate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}/{jitNetworkAccessPolicyInitiateType}"} # 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..09e4ee7643bc --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_score_control_definitions_operations.py @@ -0,0 +1,199 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.SecureScoreControlDefinitionItem"]: + """List the available security controls, their assessments, and the max score. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecureScoreControlDefinitionList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/providers/Microsoft.Security/secureScoreControlDefinitions"} # type: ignore + + @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. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecureScoreControlDefinitionList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScoreControlDefinitions"} # type: ignore 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 new file mode 100644 index 000000000000..11b70f0f3e80 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_score_controls_operations.py @@ -0,0 +1,212 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecureScoreControlList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_secure_score_request( + secure_score_name=secure_score_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list_by_secure_score.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_secure_score.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores/{secureScoreName}/secureScoreControls"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecureScoreControlList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScoreControls"} # type: ignore 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 new file mode 100644 index 000000000000..ff02b070d169 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_scores_operations.py @@ -0,0 +1,185 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @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. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecureScoresList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecureScoreItem or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.SecureScoreItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecureScoreItem] + + + request = build_get_request( + secure_score_name=secure_score_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores/{secureScoreName}"} # 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 new file mode 100644 index 000000000000..e41e91e22dc0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_security_solutions_operations.py @@ -0,0 +1,192 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.SecuritySolution"]: + """Gets a list of Security Solutions for the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecuritySolutionList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutions"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecuritySolution or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.SecuritySolution + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecuritySolution] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutions/{securitySolutionName}"} # 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 new file mode 100644 index 000000000000..2f61757b1815 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_security_solutions_reference_data_operations.py @@ -0,0 +1,160 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, 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 +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") + + + @distributed_trace_async + async def list( + self, + **kwargs: Any + ) -> _models.SecuritySolutionsReferenceDataList: + """Gets a list of all supported Security Solutions for the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecuritySolutionsReferenceDataList or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.SecuritySolutionsReferenceDataList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecuritySolutionsReferenceDataList] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutionsReferenceData"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecuritySolutionsReferenceDataList or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.SecuritySolutionsReferenceDataList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecuritySolutionsReferenceDataList] + + + request = build_list_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_home_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + list_by_home_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutionsReferenceData"} # 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 new file mode 100644 index 000000000000..6a978f394a08 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_server_vulnerability_assessment_operations.py @@ -0,0 +1,419 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, 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 +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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServerVulnerabilityAssessmentsList or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.ServerVulnerabilityAssessmentsList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServerVulnerabilityAssessmentsList] + + + 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, + template_url=self.list_by_extended_resource.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + list_by_extended_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments"} # 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 + :keyword server_vulnerability_assessment: ServerVulnerabilityAssessment status. only a + 'default' value is supported. Default value is "default". Note that overriding this default + value may result in unsupported behavior. + :paramtype server_vulnerability_assessment: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServerVulnerabilityAssessment or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.ServerVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + server_vulnerability_assessment = kwargs.pop('server_vulnerability_assessment', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServerVulnerabilityAssessment] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}"} # 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 + :keyword server_vulnerability_assessment: ServerVulnerabilityAssessment status. only a + 'default' value is supported. Default value is "default". Note that overriding this default + value may result in unsupported behavior. + :paramtype server_vulnerability_assessment: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServerVulnerabilityAssessment or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.ServerVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + server_vulnerability_assessment = kwargs.pop('server_vulnerability_assessment', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServerVulnerabilityAssessment] + + + 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}"} # 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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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 = kwargs.pop('server_vulnerability_assessment', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}"} # 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 + :keyword server_vulnerability_assessment: ServerVulnerabilityAssessment status. only a + 'default' value is supported. Default value is "default". Note that overriding this default + value may result in unsupported behavior. + :paramtype server_vulnerability_assessment: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + server_vulnerability_assessment = kwargs.pop('server_vulnerability_assessment', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}"} # 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 new file mode 100644 index 000000000000..7996a058582c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_topology_operations.py @@ -0,0 +1,273 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.TopologyResource"]: + """Gets a list that allows to build a topology view of a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TopologyList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/topologies"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TopologyList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_home_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_home_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/topologies"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TopologyResource or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.TopologyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TopologyResource] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/topologies/{topologyResourceName}"} # 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 new file mode 100644 index 000000000000..04e9256c865f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/__init__.py @@ -0,0 +1,236 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..358bbf9b07db --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_models_py3.py @@ -0,0 +1,3907 @@ +# 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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + """ + 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 Azure. + + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + """ + super().__init__(**kwargs) + self.source = None # type: Optional[str] + + +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 Azure. + + :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 + ): + """ + """ + super().__init__(**kwargs) + self.source = 'Azure' # type: str + 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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + """ + 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, # pylint: disable=redefined-builtin + **kwargs + ): + """ + :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 Azure. + + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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): + """JitNetworkAccessPolicyInitiateVirtualMachine. + + All required parameters must be populated in order to send to Azure. + + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 = 'OnPremise' # type: str + 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 Azure. + + :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 + ): + """ + :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 = 'OnPremiseSql' # type: str + 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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + """ + 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 Azure. + + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + :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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..c66b5e0d8b5e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_security_center_enums.py @@ -0,0 +1,294 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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. + """ + + #: The resource is healthy + HEALTHY = "Healthy" + #: The resource has a security issue that needs to be addressed + UNHEALTHY = "Unhealthy" + #: Assessment for this resource did not happen + NOT_APPLICABLE = "NotApplicable" + +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. + """ + + #: Microsoft Defender for Cloud managed assessments + BUILT_IN = "BuiltIn" + #: User defined policies that are automatically ingested from Azure Policy to Microsoft Defender + #: for Cloud + CUSTOM_POLICY = "CustomPolicy" + #: User assessments pushed directly by the user or other third party to Microsoft Defender for + #: Cloud + CUSTOMER_MANAGED = "CustomerManaged" + #: An assessment that was created by a verified 3rd party if the user connected it to ASC + VERIFIED_PARTNER = "VerifiedPartner" + +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). + """ + + #: Microsoft Defender for Cloud managed assessments + BUILT_IN = "BuiltIn" + #: Non Microsoft Defender for Cloud managed assessments + CUSTOM = "Custom" + +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. + """ + + #: Add definition object for each control + DEFINITION = "definition" + +class ExpandEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ExpandEnum. + """ + + #: All links associated with an assessment + LINKS = "links" + #: Assessment metadata + METADATA = "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. + """ + + #: Resource is in Azure + AZURE = "Azure" + #: Resource in an on premise machine connected to Azure cloud + ON_PREMISE = "OnPremise" + #: SQL Resource in an on premise machine connected to Azure cloud + ON_PREMISE_SQL = "OnPremiseSql" + +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 new file mode 100644 index 000000000000..97fd501f9bb3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/__init__.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. +# -------------------------------------------------------------------------- + +from ._server_vulnerability_assessment_operations import ServerVulnerabilityAssessmentOperations +from ._assessments_metadata_operations import AssessmentsMetadataOperations +from ._assessments_operations import AssessmentsOperations +from ._adaptive_application_controls_operations import AdaptiveApplicationControlsOperations +from ._adaptive_network_hardenings_operations import AdaptiveNetworkHardeningsOperations +from ._allowed_connections_operations import AllowedConnectionsOperations +from ._topology_operations import TopologyOperations +from ._jit_network_access_policies_operations import JitNetworkAccessPoliciesOperations +from ._discovered_security_solutions_operations import DiscoveredSecuritySolutionsOperations +from ._security_solutions_reference_data_operations import SecuritySolutionsReferenceDataOperations +from ._external_security_solutions_operations import ExternalSecuritySolutionsOperations +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 ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ServerVulnerabilityAssessmentOperations', + 'AssessmentsMetadataOperations', + 'AssessmentsOperations', + 'AdaptiveApplicationControlsOperations', + 'AdaptiveNetworkHardeningsOperations', + 'AllowedConnectionsOperations', + 'TopologyOperations', + 'JitNetworkAccessPoliciesOperations', + 'DiscoveredSecuritySolutionsOperations', + 'SecuritySolutionsReferenceDataOperations', + 'ExternalSecuritySolutionsOperations', + 'SecureScoresOperations', + 'SecureScoreControlsOperations', + 'SecureScoreControlDefinitionsOperations', + 'SecuritySolutionsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 new file mode 100644 index 000000000000..ee23a88554c2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_adaptive_application_controls_operations.py @@ -0,0 +1,529 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Optional, 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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AdaptiveApplicationControlGroups or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroups + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AdaptiveApplicationControlGroups] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + include_path_recommendations=include_path_recommendations, + summary=summary, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/applicationWhitelistings"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AdaptiveApplicationControlGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AdaptiveApplicationControlGroup] + + + request = build_get_request( + asc_location=asc_location, + group_name=group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. Required. + :type body: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AdaptiveApplicationControlGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AdaptiveApplicationControlGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, 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, + template_url=self.put.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + put.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + asc_location=asc_location, + group_name=group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}"} # 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 new file mode 100644 index 000000000000..d0d2802d21e1 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_adaptive_network_hardenings_operations.py @@ -0,0 +1,624 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('adaptive_network_hardening_enforce_action', "enforce") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AdaptiveNetworkHardeningsList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_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, + template_url=self.list_by_extended_resource.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_extended_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AdaptiveNetworkHardening or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.AdaptiveNetworkHardening + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AdaptiveNetworkHardening] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}"} # 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], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + adaptive_network_hardening_enforce_action = kwargs.pop('adaptive_network_hardening_enforce_action', "enforce") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, 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, + template_url=self._enforce_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + _enforce_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}/{adaptiveNetworkHardeningEnforceAction}"} # 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 + :keyword adaptive_network_hardening_enforce_action: Enforces the given rules on the NSG(s) + listed in the request. Default value is "enforce". Note that overriding this default value may + result in unsupported behavior. + :paramtype adaptive_network_hardening_enforce_action: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword adaptive_network_hardening_enforce_action: Enforces the given rules on the NSG(s) + listed in the request. Default value is "enforce". Note that overriding this default value may + result in unsupported behavior. + :paramtype adaptive_network_hardening_enforce_action: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + + @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], + **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 model type or a IO type. Required. + :type body: ~azure.mgmt.security.v2020_01_01.models.AdaptiveNetworkHardeningEnforceRequest or + IO + :keyword adaptive_network_hardening_enforce_action: Enforces the given rules on the NSG(s) + listed in the request. Default value is "enforce". Note that overriding this default value may + result in unsupported behavior. + :paramtype adaptive_network_hardening_enforce_action: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either 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 = kwargs.pop('adaptive_network_hardening_enforce_action', "enforce") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_enforce.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}/{adaptiveNetworkHardeningEnforceAction}"} # 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 new file mode 100644 index 000000000000..f8b7fd276c96 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_allowed_connections_operations.py @@ -0,0 +1,386 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.AllowedConnectionsResource"]: + """Gets the list of all possible traffic between resources for the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AllowedConnectionsList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/allowedConnections"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AllowedConnectionsList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_home_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_home_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AllowedConnectionsResource or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.AllowedConnectionsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AllowedConnectionsResource] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections/{connectionType}"} # 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 new file mode 100644 index 000000000000..81abc8935a4f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_assessments_metadata_operations.py @@ -0,0 +1,712 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.SecurityAssessmentMetadata"]: + """Get metadata information on all assessment types. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadataList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/providers/Microsoft.Security/assessmentMetadata"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessmentMetadata or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadata] + + + request = build_get_request( + assessment_metadata_name=assessment_metadata_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # 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. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadataList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessmentMetadata or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadata] + + + request = build_get_in_subscription_request( + assessment_metadata_name=assessment_metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_in_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get_in_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type assessment_metadata: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata + or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessmentMetadata or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessmentMetadata + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadata] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(assessment_metadata, (IO, 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, + template_url=self.create_in_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + create_in_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_in_subscription_request( + assessment_metadata_name=assessment_metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_in_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_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, {}) + + delete_in_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # 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 new file mode 100644 index 000000000000..4520e9d149f8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_assessments_operations.py @@ -0,0 +1,545 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/{scope}/providers/Microsoft.Security/assessments"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessment or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessment] + + + request = build_get_request( + resource_id=resource_id, + assessment_name=assessment_name, + expand=expand, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 + model type or a IO type. Required. + :type assessment: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessment or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.SecurityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(assessment, (IO, 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_id=resource_id, + assessment_name=assessment_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}"} # 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 new file mode 100644 index 000000000000..49dfd0caeae2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_discovered_security_solutions_operations.py @@ -0,0 +1,384 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.DiscoveredSecuritySolution"]: + """Gets a list of discovered Security Solutions for the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiscoveredSecuritySolutionList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/discoveredSecuritySolutions"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiscoveredSecuritySolutionList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_home_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_home_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/discoveredSecuritySolutions"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiscoveredSecuritySolution or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.DiscoveredSecuritySolution + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiscoveredSecuritySolution] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/discoveredSecuritySolutions/{discoveredSecuritySolutionName}"} # 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 new file mode 100644 index 000000000000..d27f196bc08e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_external_security_solutions_operations.py @@ -0,0 +1,384 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.ExternalSecuritySolution"]: + """Gets a list of external security solutions for the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ExternalSecuritySolutionList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/externalSecuritySolutions"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ExternalSecuritySolutionList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_home_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_home_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/ExternalSecuritySolutions"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ExternalSecuritySolution or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolution + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ExternalSecuritySolution] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/ExternalSecuritySolutions/{externalSecuritySolutionsName}"} # 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 new file mode 100644 index 000000000000..a8fd79b5e257 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_jit_network_access_policies_operations.py @@ -0,0 +1,1146 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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( + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('jit_network_access_policy_initiate_type', "initiate") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.JitNetworkAccessPolicy"]: + """Policies for protecting resources using Just-in-Time access control. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessPoliciesList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/jitNetworkAccessPolicies"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessPoliciesList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessPoliciesList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/jitNetworkAccessPolicies"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessPoliciesList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_and_region_request( + resource_group_name=resource_group_name, + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group_and_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_resource_group_and_region.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitNetworkAccessPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessPolicy] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. Required. + :type body: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitNetworkAccessPolicy or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}"} # 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 + :keyword jit_network_access_policy_initiate_type: Type of the action to do on the Just-in-Time + access policy. Default value is "initiate". Note that overriding this default value may result + in unsupported behavior. + :paramtype jit_network_access_policy_initiate_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword jit_network_access_policy_initiate_type: Type of the action to do on the Just-in-Time + access policy. Default value is "initiate". Note that overriding this default value may result + in unsupported behavior. + :paramtype jit_network_access_policy_initiate_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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], + **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 model type or a IO type. Required. + :type body: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicyInitiateRequest or IO + :keyword jit_network_access_policy_initiate_type: Type of the action to do on the Just-in-Time + access policy. Default value is "initiate". Note that overriding this default value may result + in unsupported behavior. + :paramtype jit_network_access_policy_initiate_type: str + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JitNetworkAccessRequest or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessRequest + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + jit_network_access_policy_initiate_type = kwargs.pop('jit_network_access_policy_initiate_type', "initiate") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessRequest] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, 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, + template_url=self.initiate.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + return deserialized + + initiate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}/{jitNetworkAccessPolicyInitiateType}"} # 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..6305d345081f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_score_control_definitions_operations.py @@ -0,0 +1,262 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.SecureScoreControlDefinitionItem"]: + """List the available security controls, their assessments, and the max score. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecureScoreControlDefinitionList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/providers/Microsoft.Security/secureScoreControlDefinitions"} # type: ignore + + @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. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecureScoreControlDefinitionList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScoreControlDefinitions"} # type: ignore 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 new file mode 100644 index 000000000000..36b1cf5e2f36 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_score_controls_operations.py @@ -0,0 +1,291 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecureScoreControlList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_secure_score_request( + secure_score_name=secure_score_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list_by_secure_score.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_secure_score.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores/{secureScoreName}/secureScoreControls"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecureScoreControlList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScoreControls"} # type: ignore 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 new file mode 100644 index 000000000000..24c3c11e173b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_scores_operations.py @@ -0,0 +1,254 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_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") + + + @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. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecureScoresList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecureScoreItem or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.SecureScoreItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecureScoreItem] + + + request = build_get_request( + secure_score_name=secure_score_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores/{secureScoreName}"} # 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 new file mode 100644 index 000000000000..cfc8a01c5ec3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_security_solutions_operations.py @@ -0,0 +1,265 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.SecuritySolution"]: + """Gets a list of Security Solutions for the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecuritySolutionList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutions"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecuritySolution or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.SecuritySolution + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecuritySolution] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutions/{securitySolutionName}"} # 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 new file mode 100644 index 000000000000..d71e205d5499 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_security_solutions_reference_data_operations.py @@ -0,0 +1,231 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, 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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> _models.SecuritySolutionsReferenceDataList: + """Gets a list of all supported Security Solutions for the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecuritySolutionsReferenceDataList or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.SecuritySolutionsReferenceDataList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecuritySolutionsReferenceDataList] + + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutionsReferenceData"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecuritySolutionsReferenceDataList or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.SecuritySolutionsReferenceDataList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecuritySolutionsReferenceDataList] + + + request = build_list_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_home_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + list_by_home_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutionsReferenceData"} # 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 new file mode 100644 index 000000000000..fc34f2354c44 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_server_vulnerability_assessment_operations.py @@ -0,0 +1,592 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, 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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('server_vulnerability_assessment', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('server_vulnerability_assessment', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('server_vulnerability_assessment', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServerVulnerabilityAssessmentsList or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.ServerVulnerabilityAssessmentsList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServerVulnerabilityAssessmentsList] + + + 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, + template_url=self.list_by_extended_resource.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + list_by_extended_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments"} # 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 + :keyword server_vulnerability_assessment: ServerVulnerabilityAssessment status. only a + 'default' value is supported. Default value is "default". Note that overriding this default + value may result in unsupported behavior. + :paramtype server_vulnerability_assessment: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServerVulnerabilityAssessment or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.ServerVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + server_vulnerability_assessment = kwargs.pop('server_vulnerability_assessment', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServerVulnerabilityAssessment] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}"} # 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 + :keyword server_vulnerability_assessment: ServerVulnerabilityAssessment status. only a + 'default' value is supported. Default value is "default". Note that overriding this default + value may result in unsupported behavior. + :paramtype server_vulnerability_assessment: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServerVulnerabilityAssessment or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.ServerVulnerabilityAssessment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + server_vulnerability_assessment = kwargs.pop('server_vulnerability_assessment', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ServerVulnerabilityAssessment] + + + 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}"} # 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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: 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 = kwargs.pop('server_vulnerability_assessment', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}"} # 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 + :keyword server_vulnerability_assessment: ServerVulnerabilityAssessment status. only a + 'default' value is supported. Default value is "default". Note that overriding this default + value may result in unsupported behavior. + :paramtype server_vulnerability_assessment: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + server_vulnerability_assessment = kwargs.pop('server_vulnerability_assessment', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}"} # 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 new file mode 100644 index 000000000000..f7561fea8cc8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_topology_operations.py @@ -0,0 +1,380 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.TopologyResource"]: + """Gets a list that allows to build a topology view of a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TopologyList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/topologies"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TopologyList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_home_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_home_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_home_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/topologies"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TopologyResource or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01.models.TopologyResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TopologyResource] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/topologies/{topologyResourceName}"} # 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 new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/py.typed @@ -0,0 +1 @@ +# 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 new file mode 100644 index 000000000000..a5eaeae6d251 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..ae35f0fad6a3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_configuration.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2020-01-01-preview") # type: str + + 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._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> 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.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") + 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 new file mode 100644 index 000000000000..047d717b391b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_metadata.json @@ -0,0 +1,102 @@ +{ + "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_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"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 + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Azure subscription ID. Required.", + "docstring_type": "str", + "required": true + } + }, + "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=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "connectors": "ConnectorsOperations" + } +} \ No newline at end of file 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..c2ef228454d9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from .._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import ConnectorsOperations + +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 + :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) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.connectors = ConnectorsOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SecurityCenter + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (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 new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) 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 new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" 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 new file mode 100644 index 000000000000..23906b4c7b04 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..954856784769 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_configuration.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. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-01-01-preview") # type: str + + 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._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') + 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..fa0a5e2b3f88 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ..._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import ConnectorsOperations + +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 + :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) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.connectors = ConnectorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SecurityCenter": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> 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 new file mode 100644 index 000000000000..1d6239b35b09 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ConnectorsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 new file mode 100644 index 000000000000..faeb687dcc68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_connectors_operations.py @@ -0,0 +1,371 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ConnectorSetting"]: + """Cloud accounts connectors of a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectorSettingList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectorSetting] + + + request = build_get_request( + connector_name=connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a + IO type. Required. + :type connector_setting: ~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectorSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectorSetting] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connector_setting, (IO, 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + connector_name=connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}"} # 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/__init__.py new file mode 100644 index 000000000000..0fb2cfc7e30d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/__init__.py @@ -0,0 +1,50 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 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 PermissionProperty +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # 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', + 'ServicePrincipalProperties', + 'AuthenticationProvisioningState', + 'AuthenticationType', + 'AutoProvision', + 'HybridComputeProvisioningState', + 'PermissionProperty', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 new file mode 100644 index 000000000000..f9aa761a4a4c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_models_py3.py @@ -0,0 +1,695 @@ +# 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 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 Azure. + + :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 + ): + """ + """ + super().__init__(**kwargs) + self.authentication_provisioning_state = None + self.granted_permissions = None + self.authentication_type = None # type: Optional[str] + + +class AwAssumeRoleAuthenticationDetailsProperties(AuthenticationDetailsProperties): + """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 Azure. + + :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 + ): + """ + :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 = 'awsAssumeRole' # type: str + 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 Azure. + + :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 + ): + """ + :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 = 'awsCreds' # type: str + 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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + :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 + ): + """ + """ + 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 Azure. + + :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 + ): + """ + :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 = 'gcpCredentials' # type: str + 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 Azure. + + :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 + ): + """ + :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 + ): + """ + :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 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 + ): + """ + :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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..ae512c2bd2e8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_security_center_enums.py @@ -0,0 +1,70 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 connector + VALID = "Valid" + #: Invalid connector + INVALID = "Invalid" + #: the connection has expired + EXPIRED = "Expired" + #: Incorrect policy of the connector + INCORRECT_POLICY = "IncorrectPolicy" + +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 cloud account connector user credentials authentication + AWS_CREDS = "awsCreds" + #: AWS account connector assume role authentication + AWS_ASSUME_ROLE = "awsAssumeRole" + #: GCP account connector service to service authentication + GCP_CREDENTIALS = "gcpCredentials" + +class AutoProvision(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether or not to automatically install Azure Arc (hybrid compute) agents on machines. + """ + + #: Install missing Azure Arc agents on machines automatically + ON = "On" + #: Do not install Azure Arc agent on the machines automatically + OFF = "Off" + +class HybridComputeProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the service principal and its secret. + """ + + #: Valid service principal details. + VALID = "Valid" + #: Invalid service principal details. + INVALID = "Invalid" + #: the service principal details are expired + EXPIRED = "Expired" + +class PermissionProperty(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A permission detected in the cloud account. + """ + + #: This permission provides read only access to AWS Security Hub resources. + AWS_AWS_SECURITY_HUB_READ_ONLY_ACCESS = "AWS::AWSSecurityHubReadOnlyAccess" + #: This permission grants access to read security configuration metadata. + AWS_SECURITY_AUDIT = "AWS::SecurityAudit" + #: The permission provides for EC2 Automation service to execute activities defined within + #: Automation documents. + AWS_AMAZON_SSM_AUTOMATION_ROLE = "AWS::AmazonSSMAutomationRole" + #: This permission provides read only access to GCP Security Command Center. + GCP_SECURITY_CENTER_ADMIN_VIEWER = "GCP::Security Center Admin Viewer" 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 new file mode 100644 index 000000000000..1d6239b35b09 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'ConnectorsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 new file mode 100644 index 000000000000..4f61e8839d8f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_connectors_operations.py @@ -0,0 +1,514 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.ConnectorSetting"]: + """Cloud accounts connectors of a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectorSettingList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectorSetting] + + + request = build_get_request( + connector_name=connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a + IO type. Required. + :type connector_setting: ~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectorSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectorSetting] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(connector_setting, (IO, 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}"} # type: ignore + + + @distributed_trace + 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + connector_name=connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}"} # 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/py.typed @@ -0,0 +1 @@ +# 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 new file mode 100644 index 000000000000..a5eaeae6d251 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..baa6932f44d6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_configuration.py @@ -0,0 +1,64 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2020-07-01-preview") # type: str + + 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._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> 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.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") + 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 new file mode 100644 index 000000000000..c06f42250e5b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_metadata.json @@ -0,0 +1,92 @@ +{ + "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_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"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 + } + }, + "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=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "sql_vulnerability_assessment_scans": "SqlVulnerabilityAssessmentScansOperations", + "sql_vulnerability_assessment_scan_results": "SqlVulnerabilityAssessmentScanResultsOperations", + "sql_vulnerability_assessment_baseline_rules": "SqlVulnerabilityAssessmentBaselineRulesOperations" + } +} \ No newline at end of file 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..fd77680bb793 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +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_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 + :ivar sql_vulnerability_assessment_baseline_rules: + SqlVulnerabilityAssessmentBaselineRulesOperations operations + :vartype sql_vulnerability_assessment_baseline_rules: + azure.mgmt.security.v2020_07_01_preview.operations.SqlVulnerabilityAssessmentBaselineRulesOperations + :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) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.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.sql_vulnerability_assessment_baseline_rules = SqlVulnerabilityAssessmentBaselineRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SecurityCenter + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (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 new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) 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 new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" 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 new file mode 100644 index 000000000000..23906b4c7b04 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..85ced0759a51 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/_configuration.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. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-07-01-preview") # type: str + + 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._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') + 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..025c50ba7092 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +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_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 + :ivar sql_vulnerability_assessment_baseline_rules: + SqlVulnerabilityAssessmentBaselineRulesOperations operations + :vartype sql_vulnerability_assessment_baseline_rules: + azure.mgmt.security.v2020_07_01_preview.aio.operations.SqlVulnerabilityAssessmentBaselineRulesOperations + :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) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.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.sql_vulnerability_assessment_baseline_rules = SqlVulnerabilityAssessmentBaselineRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SecurityCenter": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> 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 new file mode 100644 index 000000000000..e5841c5ea101 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/__init__.py @@ -0,0 +1,22 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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_scans_operations import SqlVulnerabilityAssessmentScansOperations +from ._sql_vulnerability_assessment_scan_results_operations import SqlVulnerabilityAssessmentScanResultsOperations +from ._sql_vulnerability_assessment_baseline_rules_operations import SqlVulnerabilityAssessmentBaselineRulesOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'SqlVulnerabilityAssessmentScansOperations', + 'SqlVulnerabilityAssessmentScanResultsOperations', + 'SqlVulnerabilityAssessmentBaselineRulesOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..fb12a10cf1d1 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_baseline_rules_operations.py @@ -0,0 +1,541 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Optional, 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 +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SqlVulnerabilityAssessmentBaselineRulesOperations: + """ + .. 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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]] = 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 model type or a IO type. Default + value is None. + :type body: ~azure.mgmt.security.v2020_07_01_preview.models.RuleResultsInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RuleResults or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RuleResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleResults] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleResults] + + + request = build_get_request( + rule_id=rule_id, + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + rule_id=rule_id, + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RulesResults] + + + request = build_list_request( + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + list.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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]] = 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 model type or a IO type. Default value is None. + :type body: ~azure.mgmt.security.v2020_07_01_preview.models.RulesResultsInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RulesResults or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RulesResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RulesResults] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, 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, + template_url=self.add.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + add.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules"} # 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 new file mode 100644 index 000000000000..beadd7dc32a5 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_scan_results_operations.py @@ -0,0 +1,187 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, 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 +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SqlVulnerabilityAssessmentScanResultsOperations: + """ + .. 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ScanResult] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}/scanResults/{scanResultId}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ScanResults] + + + request = build_list_request( + scan_id=scan_id, + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + list.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}/scanResults"} # 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 new file mode 100644 index 000000000000..dec9388d59fa --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_scans_operations.py @@ -0,0 +1,178 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, 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 +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SqlVulnerabilityAssessmentScansOperations: + """ + .. 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Scan] + + + request = build_get_request( + scan_id=scan_id, + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Scans] + + + request = build_list_request( + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + list.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans"} # 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 new file mode 100644 index 000000000000..110d42c8e814 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/models/__init__.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. +# -------------------------------------------------------------------------- + +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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..02d788d9e66e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/models/_models_py3.py @@ -0,0 +1,901 @@ +# 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 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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..a44b157a7222 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/models/_security_center_enums.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. +# -------------------------------------------------------------------------- + +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. + """ + + #: NonFinding + NON_FINDING = "NonFinding" + #: Finding + FINDING = "Finding" + #: InternalError + INTERNAL_ERROR = "InternalError" + +class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The rule type. + """ + + #: Binary + BINARY = "Binary" + #: BaselineExpected + BASELINE_EXPECTED = "BaselineExpected" + #: PositiveList + POSITIVE_LIST = "PositiveList" + #: NegativeList + NEGATIVE_LIST = "NegativeList" + +class ScanState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The scan status. + """ + + #: Failed + FAILED = "Failed" + #: FailedToRun + FAILED_TO_RUN = "FailedToRun" + #: InProgress + IN_PROGRESS = "InProgress" + #: Passed + PASSED = "Passed" + +class ScanTriggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The scan trigger type. + """ + + #: OnDemand + ON_DEMAND = "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 new file mode 100644 index 000000000000..e5841c5ea101 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/__init__.py @@ -0,0 +1,22 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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_scans_operations import SqlVulnerabilityAssessmentScansOperations +from ._sql_vulnerability_assessment_scan_results_operations import SqlVulnerabilityAssessmentScanResultsOperations +from ._sql_vulnerability_assessment_baseline_rules_operations import SqlVulnerabilityAssessmentBaselineRulesOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'SqlVulnerabilityAssessmentScansOperations', + 'SqlVulnerabilityAssessmentScanResultsOperations', + 'SqlVulnerabilityAssessmentBaselineRulesOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..2cd19395b145 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_baseline_rules_operations.py @@ -0,0 +1,736 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Optional, 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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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: + """ + .. 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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]] = 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 model type or a IO type. Default + value is None. + :type body: ~azure.mgmt.security.v2020_07_01_preview.models.RuleResultsInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RuleResults or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RuleResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleResults] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RuleResults] + + + request = build_get_request( + rule_id=rule_id, + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + rule_id=rule_id, + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules/{ruleId}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RulesResults] + + + request = build_list_request( + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + list.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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] = 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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]] = 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 model type or a IO type. Default value is None. + :type body: ~azure.mgmt.security.v2020_07_01_preview.models.RulesResultsInput or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RulesResults or the result of cls(response) + :rtype: ~azure.mgmt.security.v2020_07_01_preview.models.RulesResults + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RulesResults] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, 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, + template_url=self.add.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + add.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/baselineRules"} # 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 new file mode 100644 index 000000000000..5fbb81a20ad8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_scan_results_operations.py @@ -0,0 +1,268 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, 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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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: + """ + .. 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ScanResult] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}/scanResults/{scanResultId}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ScanResults] + + + request = build_list_request( + scan_id=scan_id, + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + list.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}/scanResults"} # 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 new file mode 100644 index 000000000000..8ca3f504e402 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_scans_operations.py @@ -0,0 +1,255 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, 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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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: + """ + .. 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Scan] + + + request = build_get_request( + scan_id=scan_id, + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans/{scanId}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Scans] + + + request = build_list_request( + resource_id=resource_id, + workspace_id=workspace_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + list.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/sqlVulnerabilityAssessments/default/scans"} # 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 new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/py.typed @@ -0,0 +1 @@ +# 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 new file mode 100644 index 000000000000..a5eaeae6d251 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..dd390ea69d5f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_configuration.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2021-01-01") # type: str + + 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._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> 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.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") + 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 new file mode 100644 index 000000000000..70bd35c11acc --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_metadata.json @@ -0,0 +1,102 @@ +{ + "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_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"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 + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Azure subscription ID. Required.", + "docstring_type": "str", + "required": true + } + }, + "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=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "alerts": "AlertsOperations" + } +} \ No newline at end of file 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..3c5681588d3a --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_security_center.py @@ -0,0 +1,92 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +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) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SecurityCenter + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (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 new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) 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 new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" 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 new file mode 100644 index 000000000000..23906b4c7b04 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..eab8575660e3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/_configuration.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. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-01-01") # type: str + + 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._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') + 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..628573e5ca0f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/_security_center.py @@ -0,0 +1,95 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +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) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.alerts = AlertsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SecurityCenter": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> 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 new file mode 100644 index 000000000000..13b6e37a8a16 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/operations/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..c3c66d969962 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/operations/_alerts_operations.py @@ -0,0 +1,1091 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.Alert"]: + """List all the alerts that are associated with the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alerts"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/alerts"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_subscription_level_by_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_subscription_level_by_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_subscription_level_by_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_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, + template_url=self.list_resource_group_level_by_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_resource_group_level_by_region.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Alert or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_01_01.models.Alert + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Alert] + + + request = build_get_subscription_level_request( + asc_location=asc_location, + alert_name=alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_subscription_level.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get_subscription_level.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Alert or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_01_01.models.Alert + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Alert] + + + 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, + template_url=self.get_resource_group_level.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}"} # type: ignore + + + @distributed_trace_async + async def update_subscription_level_state_to_dismiss( # pylint: disable=inconsistent-return-statements + 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.update_subscription_level_state_to_dismiss.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + update_subscription_level_state_to_dismiss.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss"} # type: ignore + + + @distributed_trace_async + async def update_subscription_level_state_to_resolve( # pylint: disable=inconsistent-return-statements + 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.update_subscription_level_state_to_resolve.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + update_subscription_level_state_to_resolve.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/resolve"} # type: ignore + + + @distributed_trace_async + async def update_subscription_level_state_to_activate( # pylint: disable=inconsistent-return-statements + 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.update_subscription_level_state_to_activate.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + update_subscription_level_state_to_activate.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/activate"} # type: ignore + + + @distributed_trace_async + async def update_resource_group_level_state_to_resolve( # pylint: disable=inconsistent-return-statements + 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.update_resource_group_level_state_to_resolve.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + update_resource_group_level_state_to_resolve.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/resolve"} # type: ignore + + + @distributed_trace_async + async def update_resource_group_level_state_to_dismiss( # pylint: disable=inconsistent-return-statements + 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.update_resource_group_level_state_to_dismiss.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + update_resource_group_level_state_to_dismiss.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss"} # type: ignore + + + @distributed_trace_async + async def update_resource_group_level_state_to_activate( # pylint: disable=inconsistent-return-statements + 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.update_resource_group_level_state_to_activate.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + update_resource_group_level_state_to_activate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/activate"} # type: ignore + + + async def _simulate_initial( # pylint: disable=inconsistent-return-statements + self, + asc_location: str, + alert_simulator_request_body: Union[_models.AlertSimulatorRequestBody, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(alert_simulator_request_body, (IO, 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, + template_url=self._simulate_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + _simulate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/default/simulate"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_simulate( + self, + asc_location: str, + alert_simulator_request_body: IO, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either 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], + **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 model type + or a IO type. Required. + :type alert_simulator_request_body: + ~azure.mgmt.security.v2021_01_01.models.AlertSimulatorRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'original-uri'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_simulate.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/default/simulate"} # 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..10344df27460 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/__init__.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. +# -------------------------------------------------------------------------- + +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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..a7318aea62f1 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/_models_py3.py @@ -0,0 +1,614 @@ +# 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 TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 = None # type: Optional[str] + + +class AlertSimulatorBundlesRequestProperties(AlertSimulatorRequestProperties): + """Simulate alerts according to this bundles. + + All required parameters must be populated in order to send to Azure. + + :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 + ): + """ + :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 = 'Bundles' # type: str + 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 + ): + """ + :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 Azure. + + :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 + ): + """ + """ + super().__init__(**kwargs) + self.type = None # type: Optional[str] + + +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 Azure. + + :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 + ): + """ + """ + super().__init__(**kwargs) + self.type = 'AzureResource' # type: str + 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 + ): + """ + """ + 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 + ): + """ + """ + 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 Azure. + + :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 + ): + """ + """ + super().__init__(**kwargs) + self.type = 'LogAnalytics' # type: str + 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..9253dbf091ec --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/_security_center_enums.py @@ -0,0 +1,122 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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. + """ + + #: An alert which doesn't specify a value is assigned the status 'Active' + ACTIVE = "Active" + #: Alert closed after handling + RESOLVED = "Resolved" + #: Alert dismissed as false positive + DISMISSED = "Dismissed" + +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" + #: 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 `_. + PRE_ATTACK = "PreAttack" + #: InitialAccess is the stage where an attacker manages to get foothold on the attacked resource. + INITIAL_ACCESS = "InitialAccess" + #: Persistence is any access, action, or configuration change to a system that gives a threat + #: actor a persistent presence on that system. + PERSISTENCE = "Persistence" + #: Privilege escalation is the result of actions that allow an adversary to obtain a higher level + #: of permissions on a system or network. + PRIVILEGE_ESCALATION = "PrivilegeEscalation" + #: Defense evasion consists of techniques an adversary may use to evade detection or avoid other + #: defenses. + DEFENSE_EVASION = "DefenseEvasion" + #: Credential access represents techniques resulting in access to or control over system, domain, + #: or service credentials that are used within an enterprise environment. + CREDENTIAL_ACCESS = "CredentialAccess" + #: Discovery consists of techniques that allow the adversary to gain knowledge about the system + #: and internal network. + DISCOVERY = "Discovery" + #: 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. + LATERAL_MOVEMENT = "LateralMovement" + #: The execution tactic represents techniques that result in execution of adversary-controlled + #: code on a local or remote system. + EXECUTION = "Execution" + #: Collection consists of techniques used to identify and gather information, such as sensitive + #: files, from a target network prior to exfiltration. + COLLECTION = "Collection" + #: Exfiltration refers to techniques and attributes that result or aid in the adversary removing + #: files and information from a target network. + EXFILTRATION = "Exfiltration" + #: The command and control tactic represents how adversaries communicate with systems under their + #: control within a target network. + COMMAND_AND_CONTROL = "CommandAndControl" + #: 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. + IMPACT = "Impact" + #: 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. + PROBING = "Probing" + #: 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. + EXPLOITATION = "Exploitation" + +class KindEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The kind of alert simulation. + """ + + #: Simulate alerts according to bundles + BUNDLES = "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 new file mode 100644 index 000000000000..13b6e37a8a16 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/operations/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..eaadd8ae917f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/operations/_alerts_operations.py @@ -0,0 +1,1575 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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( + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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( + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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( + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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( + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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( + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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( + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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( + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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( + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.Alert"]: + """List all the alerts that are associated with the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/alerts"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/alerts"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_subscription_level_by_region_request( + asc_location=asc_location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_subscription_level_by_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_subscription_level_by_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AlertList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_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, + template_url=self.list_resource_group_level_by_region.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_resource_group_level_by_region.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Alert or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_01_01.models.Alert + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Alert] + + + request = build_get_subscription_level_request( + asc_location=asc_location, + alert_name=alert_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_subscription_level.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get_subscription_level.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Alert or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_01_01.models.Alert + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Alert] + + + 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, + template_url=self.get_resource_group_level.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get_resource_group_level.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}"} # type: ignore + + + @distributed_trace + def update_subscription_level_state_to_dismiss( # pylint: disable=inconsistent-return-statements + 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.update_subscription_level_state_to_dismiss.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + update_subscription_level_state_to_dismiss.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss"} # type: ignore + + + @distributed_trace + def update_subscription_level_state_to_resolve( # pylint: disable=inconsistent-return-statements + 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.update_subscription_level_state_to_resolve.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + update_subscription_level_state_to_resolve.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/resolve"} # type: ignore + + + @distributed_trace + def update_subscription_level_state_to_activate( # pylint: disable=inconsistent-return-statements + 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.update_subscription_level_state_to_activate.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + update_subscription_level_state_to_activate.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/activate"} # type: ignore + + + @distributed_trace + def update_resource_group_level_state_to_resolve( # pylint: disable=inconsistent-return-statements + 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.update_resource_group_level_state_to_resolve.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + update_resource_group_level_state_to_resolve.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/resolve"} # type: ignore + + + @distributed_trace + def update_resource_group_level_state_to_dismiss( # pylint: disable=inconsistent-return-statements + 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.update_resource_group_level_state_to_dismiss.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + update_resource_group_level_state_to_dismiss.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/dismiss"} # type: ignore + + + @distributed_trace + def update_resource_group_level_state_to_activate( # pylint: disable=inconsistent-return-statements + 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[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, + template_url=self.update_resource_group_level_state_to_activate.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + update_resource_group_level_state_to_activate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/alerts/{alertName}/activate"} # type: ignore + + + def _simulate_initial( # pylint: disable=inconsistent-return-statements + self, + asc_location: str, + alert_simulator_request_body: Union[_models.AlertSimulatorRequestBody, IO], + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(alert_simulator_request_body, (IO, 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, + template_url=self._simulate_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + _simulate_initial.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/default/simulate"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_simulate( + self, + asc_location: str, + alert_simulator_request_body: IO, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either 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], + **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 model type + or a IO type. Required. + :type alert_simulator_request_body: + ~azure.mgmt.security.v2021_01_01.models.AlertSimulatorRequestBody or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + 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, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'original-uri'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_simulate.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/alerts/default/simulate"} # 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/__init__.py new file mode 100644 index 000000000000..a5eaeae6d251 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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_15_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_configuration.py new file mode 100644 index 000000000000..ce9e3f3e8007 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_configuration.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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-15-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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2021-01-15-preview") # type: str + + 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._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> 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.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") + 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_15_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_metadata.json new file mode 100644 index 000000000000..bd9228fe81da --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_metadata.json @@ -0,0 +1,102 @@ +{ + "chosen_version": "2021-01-15-preview", + "total_api_version_list": ["2021-01-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_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"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 + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Azure subscription ID. Required.", + "docstring_type": "str", + "required": true + } + }, + "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=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "ingestion_settings": "IngestionSettingsOperations" + } +} \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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_15_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_security_center.py new file mode 100644 index 000000000000..4aa5c10b58ce --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_security_center.py @@ -0,0 +1,93 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from .._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import IngestionSettingsOperations + +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 ingestion_settings: IngestionSettingsOperations operations + :vartype ingestion_settings: + azure.mgmt.security.v2021_01_15_preview.operations.IngestionSettingsOperations + :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-15-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) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.ingestion_settings = IngestionSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SecurityCenter + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/__init__.py new file mode 100644 index 000000000000..23906b4c7b04 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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_15_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/_configuration.py new file mode 100644 index 000000000000..a46aae05520d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/_configuration.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. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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-15-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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-01-15-preview") # type: str + + 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._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') + 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_15_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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_15_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/_security_center.py new file mode 100644 index 000000000000..1a2f72de0754 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ..._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import IngestionSettingsOperations + +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 ingestion_settings: IngestionSettingsOperations operations + :vartype ingestion_settings: + azure.mgmt.security.v2021_01_15_preview.aio.operations.IngestionSettingsOperations + :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-15-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) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.ingestion_settings = IngestionSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SecurityCenter": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..b27ec5f74715 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/operations/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._ingestion_settings_operations import IngestionSettingsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'IngestionSettingsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/operations/_ingestion_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/operations/_ingestion_settings_operations.py new file mode 100644 index 000000000000..7a8aa3e60d97 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/operations/_ingestion_settings_operations.py @@ -0,0 +1,491 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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._ingestion_settings_operations import build_create_request, build_delete_request, build_get_request, build_list_connection_strings_request, build_list_request, build_list_tokens_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class IngestionSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2021_01_15_preview.aio.SecurityCenter`'s + :attr:`ingestion_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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.IngestionSetting"]: + """Settings for ingesting security data and logs to correlate with resources associated with the + subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IngestionSetting or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2021_01_15_preview.models.IngestionSetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-15-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IngestionSettingList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("IngestionSettingList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings"} # type: ignore + + @distributed_trace_async + async def get( + self, + ingestion_setting_name: str, + **kwargs: Any + ) -> _models.IngestionSetting: + """Settings for ingesting security data and logs to correlate with resources associated with the + subscription. + + :param ingestion_setting_name: Name of the ingestion setting. Required. + :type ingestion_setting_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IngestionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_01_15_preview.models.IngestionSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-15-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IngestionSetting] + + + request = build_get_request( + ingestion_setting_name=ingestion_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('IngestionSetting', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}"} # type: ignore + + + @overload + async def create( + self, + ingestion_setting_name: str, + ingestion_setting: _models.IngestionSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IngestionSetting: + """Create setting for ingesting security data and logs to correlate with resources associated with + the subscription. + + :param ingestion_setting_name: Name of the ingestion setting. Required. + :type ingestion_setting_name: str + :param ingestion_setting: Ingestion setting object. Required. + :type ingestion_setting: ~azure.mgmt.security.v2021_01_15_preview.models.IngestionSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IngestionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_01_15_preview.models.IngestionSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + ingestion_setting_name: str, + ingestion_setting: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IngestionSetting: + """Create setting for ingesting security data and logs to correlate with resources associated with + the subscription. + + :param ingestion_setting_name: Name of the ingestion setting. Required. + :type ingestion_setting_name: str + :param ingestion_setting: Ingestion setting object. Required. + :type ingestion_setting: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IngestionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_01_15_preview.models.IngestionSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + + @distributed_trace_async + async def create( + self, + ingestion_setting_name: str, + ingestion_setting: Union[_models.IngestionSetting, IO], + **kwargs: Any + ) -> _models.IngestionSetting: + """Create setting for ingesting security data and logs to correlate with resources associated with + the subscription. + + :param ingestion_setting_name: Name of the ingestion setting. Required. + :type ingestion_setting_name: str + :param ingestion_setting: Ingestion setting object. Is either a model type or a IO type. + Required. + :type ingestion_setting: ~azure.mgmt.security.v2021_01_15_preview.models.IngestionSetting or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IngestionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_01_15_preview.models.IngestionSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-15-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.IngestionSetting] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(ingestion_setting, (IO, bytes)): + _content = ingestion_setting + else: + _json = self._serialize.body(ingestion_setting, 'IngestionSetting') + + request = build_create_request( + ingestion_setting_name=ingestion_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('IngestionSetting', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + ingestion_setting_name: str, + **kwargs: Any + ) -> None: + """Deletes the ingestion settings for this subscription. + + :param ingestion_setting_name: Name of the ingestion setting. Required. + :type ingestion_setting_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-15-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + ingestion_setting_name=ingestion_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}"} # type: ignore + + + @distributed_trace_async + async def list_tokens( + self, + ingestion_setting_name: str, + **kwargs: Any + ) -> _models.IngestionSettingToken: + """Returns the token that is used for correlating ingested telemetry with the resources in the + subscription. + + :param ingestion_setting_name: Name of the ingestion setting. Required. + :type ingestion_setting_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IngestionSettingToken or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_01_15_preview.models.IngestionSettingToken + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-15-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IngestionSettingToken] + + + request = build_list_tokens_request( + ingestion_setting_name=ingestion_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_tokens.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('IngestionSettingToken', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_tokens.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}/listTokens"} # type: ignore + + + @distributed_trace_async + async def list_connection_strings( + self, + ingestion_setting_name: str, + **kwargs: Any + ) -> _models.ConnectionStrings: + """Connection strings for ingesting security scan logs and data. + + :param ingestion_setting_name: Name of the ingestion setting. Required. + :type ingestion_setting_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectionStrings or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_01_15_preview.models.ConnectionStrings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-15-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectionStrings] + + + request = build_list_connection_strings_request( + ingestion_setting_name=ingestion_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_connection_strings.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConnectionStrings', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_connection_strings.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}/listConnectionStrings"} # type: ignore + diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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_15_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/models/__init__.py new file mode 100644 index 000000000000..560a1f7f2a84 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/models/__init__.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. +# -------------------------------------------------------------------------- + +from ._models_py3 import CloudErrorBody +from ._models_py3 import ConnectionStrings +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import IngestionConnectionString +from ._models_py3 import IngestionSetting +from ._models_py3 import IngestionSettingList +from ._models_py3 import IngestionSettingToken +from ._models_py3 import Resource +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'CloudErrorBody', + 'ConnectionStrings', + 'ErrorAdditionalInfo', + 'IngestionConnectionString', + 'IngestionSetting', + 'IngestionSettingList', + 'IngestionSettingToken', + 'Resource', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/models/_models_py3.py new file mode 100644 index 000000000000..aaac49589c85 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/models/_models_py3.py @@ -0,0 +1,301 @@ +# 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 + +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 +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.v2021_01_15_preview.models.CloudErrorBody] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.security.v2021_01_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 + ): + """ + """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ConnectionStrings(_serialization.Model): + """Connection string for ingesting security data and logs. + + All required parameters must be populated in order to send to Azure. + + :ivar value: Connection strings. Required. + :vartype value: list[~azure.mgmt.security.v2021_01_15_preview.models.IngestionConnectionString] + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[IngestionConnectionString]"}, + } + + def __init__( + self, + *, + value: List["_models.IngestionConnectionString"], + **kwargs + ): + """ + :keyword value: Connection strings. Required. + :paramtype value: + list[~azure.mgmt.security.v2021_01_15_preview.models.IngestionConnectionString] + """ + super().__init__(**kwargs) + self.value = value + + +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 + ): + """ + """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class IngestionConnectionString(_serialization.Model): + """Connection string for ingesting security data and logs. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location: The region where ingested logs and data resides. + :vartype location: str + :ivar value: Connection string value. + :vartype value: str + """ + + _validation = { + 'location': {'readonly': True}, + 'value': {'readonly': True}, + } + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super().__init__(**kwargs) + self.location = None + self.value = 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 + ): + """ + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class IngestionSetting(Resource): + """Configures how to correlate scan data and logs with resources associated with the subscription. + + 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: Ingestion setting data. + :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 + ): + """ + :keyword properties: Ingestion setting data. + :paramtype properties: JSON + """ + super().__init__(**kwargs) + self.properties = properties + + +class IngestionSettingList(_serialization.Model): + """List of ingestion settings. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of ingestion settings. + :vartype value: list[~azure.mgmt.security.v2021_01_15_preview.models.IngestionSetting] + :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": "[IngestionSetting]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class IngestionSettingToken(_serialization.Model): + """Configures how to correlate scan data and logs with resources associated with the subscription. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar token: The token is used for correlating security data and logs with the resources in the + subscription. + :vartype token: str + """ + + _validation = { + 'token': {'readonly': True}, + } + + _attribute_map = { + "token": {"key": "token", "type": "str"}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super().__init__(**kwargs) + self.token = None diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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_15_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/operations/__init__.py new file mode 100644 index 000000000000..b27ec5f74715 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/operations/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._ingestion_settings_operations import IngestionSettingsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'IngestionSettingsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/operations/_ingestion_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/operations/_ingestion_settings_operations.py new file mode 100644 index 000000000000..df97d2123aef --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/operations/_ingestion_settings_operations.py @@ -0,0 +1,704 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-15-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings") + path_format_arguments = { + "subscriptionId": _SERIALIZER.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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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( + ingestion_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-15-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}") # 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}$'), + "ingestionSettingName": _SERIALIZER.url("ingestion_setting_name", ingestion_setting_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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( + ingestion_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-15-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}") # 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}$'), + "ingestionSettingName": _SERIALIZER.url("ingestion_setting_name", ingestion_setting_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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( + ingestion_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-15-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}") # 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}$'), + "ingestionSettingName": _SERIALIZER.url("ingestion_setting_name", ingestion_setting_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_tokens_request( + ingestion_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-15-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}/listTokens") # 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}$'), + "ingestionSettingName": _SERIALIZER.url("ingestion_setting_name", ingestion_setting_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_connection_strings_request( + ingestion_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-15-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}/listConnectionStrings") # 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}$'), + "ingestionSettingName": _SERIALIZER.url("ingestion_setting_name", ingestion_setting_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 IngestionSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2021_01_15_preview.SecurityCenter`'s + :attr:`ingestion_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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.IngestionSetting"]: + """Settings for ingesting security data and logs to correlate with resources associated with the + subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IngestionSetting or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2021_01_15_preview.models.IngestionSetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-15-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IngestionSettingList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("IngestionSettingList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings"} # type: ignore + + @distributed_trace + def get( + self, + ingestion_setting_name: str, + **kwargs: Any + ) -> _models.IngestionSetting: + """Settings for ingesting security data and logs to correlate with resources associated with the + subscription. + + :param ingestion_setting_name: Name of the ingestion setting. Required. + :type ingestion_setting_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IngestionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_01_15_preview.models.IngestionSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-15-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IngestionSetting] + + + request = build_get_request( + ingestion_setting_name=ingestion_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('IngestionSetting', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}"} # type: ignore + + + @overload + def create( + self, + ingestion_setting_name: str, + ingestion_setting: _models.IngestionSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IngestionSetting: + """Create setting for ingesting security data and logs to correlate with resources associated with + the subscription. + + :param ingestion_setting_name: Name of the ingestion setting. Required. + :type ingestion_setting_name: str + :param ingestion_setting: Ingestion setting object. Required. + :type ingestion_setting: ~azure.mgmt.security.v2021_01_15_preview.models.IngestionSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IngestionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_01_15_preview.models.IngestionSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + ingestion_setting_name: str, + ingestion_setting: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IngestionSetting: + """Create setting for ingesting security data and logs to correlate with resources associated with + the subscription. + + :param ingestion_setting_name: Name of the ingestion setting. Required. + :type ingestion_setting_name: str + :param ingestion_setting: Ingestion setting object. Required. + :type ingestion_setting: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IngestionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_01_15_preview.models.IngestionSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + + @distributed_trace + def create( + self, + ingestion_setting_name: str, + ingestion_setting: Union[_models.IngestionSetting, IO], + **kwargs: Any + ) -> _models.IngestionSetting: + """Create setting for ingesting security data and logs to correlate with resources associated with + the subscription. + + :param ingestion_setting_name: Name of the ingestion setting. Required. + :type ingestion_setting_name: str + :param ingestion_setting: Ingestion setting object. Is either a model type or a IO type. + Required. + :type ingestion_setting: ~azure.mgmt.security.v2021_01_15_preview.models.IngestionSetting or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IngestionSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_01_15_preview.models.IngestionSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-15-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.IngestionSetting] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(ingestion_setting, (IO, bytes)): + _content = ingestion_setting + else: + _json = self._serialize.body(ingestion_setting, 'IngestionSetting') + + request = build_create_request( + ingestion_setting_name=ingestion_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('IngestionSetting', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + ingestion_setting_name: str, + **kwargs: Any + ) -> None: + """Deletes the ingestion settings for this subscription. + + :param ingestion_setting_name: Name of the ingestion setting. Required. + :type ingestion_setting_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-15-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + ingestion_setting_name=ingestion_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}"} # type: ignore + + + @distributed_trace + def list_tokens( + self, + ingestion_setting_name: str, + **kwargs: Any + ) -> _models.IngestionSettingToken: + """Returns the token that is used for correlating ingested telemetry with the resources in the + subscription. + + :param ingestion_setting_name: Name of the ingestion setting. Required. + :type ingestion_setting_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IngestionSettingToken or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_01_15_preview.models.IngestionSettingToken + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-15-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.IngestionSettingToken] + + + request = build_list_tokens_request( + ingestion_setting_name=ingestion_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_tokens.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('IngestionSettingToken', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_tokens.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}/listTokens"} # type: ignore + + + @distributed_trace + def list_connection_strings( + self, + ingestion_setting_name: str, + **kwargs: Any + ) -> _models.ConnectionStrings: + """Connection strings for ingesting security scan logs and data. + + :param ingestion_setting_name: Name of the ingestion setting. Required. + :type ingestion_setting_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectionStrings or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_01_15_preview.models.ConnectionStrings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-15-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectionStrings] + + + request = build_list_connection_strings_request( + ingestion_setting_name=ingestion_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_connection_strings.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConnectionStrings', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_connection_strings.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/ingestionSettings/{ingestionSettingName}/listConnectionStrings"} # type: ignore + diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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_15_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/py.typed @@ -0,0 +1 @@ +# 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 new file mode 100644 index 000000000000..a5eaeae6d251 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..2edeed7e1a4a --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_configuration.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2021-05-01-preview") # type: str + + 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._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> 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.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") + 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 new file mode 100644 index 000000000000..fc7aa567b217 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_metadata.json @@ -0,0 +1,102 @@ +{ + "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_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"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 + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Azure subscription ID. Required.", + "docstring_type": "str", + "required": true + } + }, + "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=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "software_inventories": "SoftwareInventoriesOperations" + } +} \ No newline at end of file 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..b8f322040926 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_security_center.py @@ -0,0 +1,93 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +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) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.software_inventories = SoftwareInventoriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SecurityCenter + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (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 new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) 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 new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" 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 new file mode 100644 index 000000000000..23906b4c7b04 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..d563dafbe3c4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/_configuration.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. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-05-01-preview") # type: str + + 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._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') + 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..2339858549b4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +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) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.software_inventories = SoftwareInventoriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SecurityCenter": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> 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 new file mode 100644 index 000000000000..458214931ad3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/operations/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..07e4900b58d6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/operations/_software_inventories_operations.py @@ -0,0 +1,292 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SoftwaresList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_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, + template_url=self.list_by_extended_resource.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_extended_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/softwareInventories"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable["_models.Software"]: + """Gets the software inventory of all virtual machines in the subscriptions. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SoftwaresList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/softwareInventories"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Software] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/softwareInventories/{softwareName}"} # 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 new file mode 100644 index 000000000000..d78bc3accdc9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/models/__init__.py @@ -0,0 +1,28 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..1371fb72e8a8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/models/_models_py3.py @@ -0,0 +1,274 @@ +# 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 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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + """ + 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 + ): + """ + :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 + ): + """ + :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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..2fa440c1a76c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/models/_security_center_enums.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. +# 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 new file mode 100644 index 000000000000..458214931ad3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/operations/__init__.py @@ -0,0 +1,18 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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() \ No newline at end of file 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..d2735d65802f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/operations/_software_inventories_operations.py @@ -0,0 +1,409 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SoftwaresList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_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, + template_url=self.list_by_extended_resource.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_extended_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/softwareInventories"} # type: ignore + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable["_models.Software"]: + """Gets the software inventory of all virtual machines in the subscriptions. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SoftwaresList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/softwareInventories"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-05-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Software] + + + 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, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/softwareInventories/{softwareName}"} # 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 new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/py.typed @@ -0,0 +1 @@ +# 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 new file mode 100644 index 000000000000..a5eaeae6d251 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..2c64b122657d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_configuration.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2021-06-01") # type: str + + 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._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> 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.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") + 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 new file mode 100644 index 000000000000..81f23729b9f8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_metadata.json @@ -0,0 +1,104 @@ +{ + "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_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"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 + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Azure subscription ID. Required.", + "docstring_type": "str", + "required": true + } + }, + "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=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "settings": "SettingsOperations", + "assessments_metadata": "AssessmentsMetadataOperations", + "assessments": "AssessmentsOperations" + } +} \ No newline at end of file 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..f665df89b9c3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_security_center.py @@ -0,0 +1,99 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +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 settings: SettingsOperations operations + :vartype settings: azure.mgmt.security.v2021_06_01.operations.SettingsOperations + :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 + :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) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.settings = SettingsOperations(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) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SecurityCenter + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (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 new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) 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 new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" 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 new file mode 100644 index 000000000000..23906b4c7b04 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..3c212a95a106 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/_configuration.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. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-06-01") # type: str + + 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._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') + 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..c278919218a5 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +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 settings: SettingsOperations operations + :vartype settings: azure.mgmt.security.v2021_06_01.aio.operations.SettingsOperations + :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 + :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) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.settings = SettingsOperations( + 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 + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SecurityCenter": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> 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 new file mode 100644 index 000000000000..f35e0b28c63b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/__init__.py @@ -0,0 +1,22 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 ._assessments_metadata_operations import AssessmentsMetadataOperations +from ._assessments_operations import AssessmentsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'SettingsOperations', + 'AssessmentsMetadataOperations', + 'AssessmentsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 new file mode 100644 index 000000000000..45b86b5bb5ed --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_assessments_metadata_operations.py @@ -0,0 +1,510 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.SecurityAssessmentMetadataResponse"]: + """Get metadata information on all assessment types. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadataResponseList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/providers/Microsoft.Security/assessmentMetadata"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessmentMetadataResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadataResponse] + + + request = build_get_request( + assessment_metadata_name=assessment_metadata_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # 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. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadataResponseList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessmentMetadataResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadataResponse] + + + request = build_get_in_subscription_request( + assessment_metadata_name=assessment_metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_in_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get_in_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type assessment_metadata: + ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessmentMetadataResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadataResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(assessment_metadata, (IO, 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, + template_url=self.create_in_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + create_in_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_in_subscription_request( + assessment_metadata_name=assessment_metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_in_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_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, {}) + + delete_in_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # 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 new file mode 100644 index 000000000000..4753e2e9adf5 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_assessments_operations.py @@ -0,0 +1,399 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/{scope}/providers/Microsoft.Security/assessments"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessmentResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentResponse] + + + request = build_get_request( + resource_id=resource_id, + assessment_name=assessment_name, + expand=expand, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 + model type or a IO type. Required. + :type assessment: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessmentResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(assessment, (IO, 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_id=resource_id, + assessment_name=assessment_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}"} # 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 new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..fb472f192e2b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_settings_operations.py @@ -0,0 +1,312 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 +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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.Setting"]: + """Settings about different configurations in Microsoft Defender for Cloud. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SettingsList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings"} # type: ignore + + @distributed_trace_async + async def get( + self, + setting_name: Union[str, "_models.Enum1"], + **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.Enum1 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Setting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_06_01.models.Setting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Setting] + + + request = build_get_request( + setting_name=setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}"} # type: ignore + + + @overload + async def update( + self, + setting_name: Union[str, "_models.Enum1"], + 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.Enum1 + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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.Enum1"], + setting: IO, + *, + 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.Enum1 + :param setting: Setting object. Required. + :type setting: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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.Enum1"], + setting: Union[_models.Setting, IO], + **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.Enum1 + :param setting: Setting object. Is either a model type or a IO type. Required. + :type setting: ~azure.mgmt.security.v2021_06_01.models.Setting or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Setting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_06_01.models.Setting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Setting] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(setting, (IO, 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, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}"} # 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 new file mode 100644 index 000000000000..d26219dc4aaf --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/models/__init__.py @@ -0,0 +1,98 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 Enum1 +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 * # type: ignore # 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', + 'Enum1', + 'ExpandEnum', + 'ImplementationEffort', + 'SettingKind', + 'Severity', + 'Source', + 'Tactics', + 'Techniques', + 'Threats', + 'UserImpact', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 new file mode 100644 index 000000000000..9d5f2d84b723 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/models/_models_py3.py @@ -0,0 +1,1783 @@ +# 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 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 + ): + """ + """ + 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 Azure. + + :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 + ): + """ + """ + super().__init__(**kwargs) + self.kind = None # type: Optional[str] + + +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 Azure. + + :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 + ): + """ + :keyword enabled: Is the alert sync setting enabled. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.kind = 'AlertSyncSettings' # type: str + 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 + ): + """ + """ + 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 Azure. + + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + """ + super().__init__(**kwargs) + self.source = None # type: Optional[str] + + +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 Azure. + + :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 + ): + """ + """ + super().__init__(**kwargs) + self.source = 'Azure' # type: str + 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 + ): + """ + """ + 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 Azure. + + :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 + ): + """ + :keyword enabled: Is the data export setting enabled. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.kind = 'DataExportSettings' # type: str + 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 + ): + """ + """ + 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 Azure. + + :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 + ): + """ + :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 = 'OnPremise' # type: str + 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 Azure. + + :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 + ): + """ + :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 = 'OnPremiseSql' # type: str + 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 + ): + """ + :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 + ): + """ + """ + 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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 + """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 Azure. + + :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 + ): + """ + :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): + """SecurityAssessmentMetadataPropertiesResponsePublishDates. + + All required parameters must be populated in order to send to Azure. + + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + """ + 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 Azure. + + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 Azure. + + :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 + ): + """ + :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 + ): + """ + :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 + ): + """ + :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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..f79d68e80b7b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/models/_security_center_enums.py @@ -0,0 +1,249 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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. + """ + + #: The resource is healthy + HEALTHY = "Healthy" + #: The resource has a security issue that needs to be addressed + UNHEALTHY = "Unhealthy" + #: Assessment for this resource did not happen + NOT_APPLICABLE = "NotApplicable" + +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. + """ + + #: Microsoft Defender for Cloud managed assessments + BUILT_IN = "BuiltIn" + #: User defined policies that are automatically ingested from Azure Policy to Microsoft Defender + #: for Cloud + CUSTOM_POLICY = "CustomPolicy" + #: User assessments pushed directly by the user or other third party to Microsoft Defender for + #: Cloud + CUSTOMER_MANAGED = "CustomerManaged" + #: An assessment that was created by a verified 3rd party if the user connected it to ASC + VERIFIED_PARTNER = "VerifiedPartner" + +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 Enum1(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum1. + """ + + MCAS = "MCAS" + WDATP = "WDATP" + SENTINEL = "Sentinel" + +class ExpandEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ExpandEnum. + """ + + #: All links associated with an assessment + LINKS = "links" + #: Assessment metadata + METADATA = "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. + """ + + #: Resource is in Azure + AZURE = "Azure" + #: Resource in an on premise machine connected to Azure cloud + ON_PREMISE = "OnPremise" + #: SQL Resource in an on premise machine connected to Azure cloud + ON_PREMISE_SQL = "OnPremiseSql" + +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 new file mode 100644 index 000000000000..f35e0b28c63b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/__init__.py @@ -0,0 +1,22 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 ._assessments_metadata_operations import AssessmentsMetadataOperations +from ._assessments_operations import AssessmentsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'SettingsOperations', + 'AssessmentsMetadataOperations', + 'AssessmentsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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 new file mode 100644 index 000000000000..cce0445f9ba0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_assessments_metadata_operations.py @@ -0,0 +1,713 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.SecurityAssessmentMetadataResponse"]: + """Get metadata information on all assessment types. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadataResponseList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/providers/Microsoft.Security/assessmentMetadata"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessmentMetadataResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadataResponse] + + + request = build_get_request( + assessment_metadata_name=assessment_metadata_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # 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. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadataResponseList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessmentMetadataResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadataResponse] + + + request = build_get_in_subscription_request( + assessment_metadata_name=assessment_metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_in_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get_in_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 model type or a IO type. + Required. + :type assessment_metadata: + ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessmentMetadataResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentMetadataResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadataResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(assessment_metadata, (IO, 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, + template_url=self.create_in_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + create_in_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_in_subscription_request( + assessment_metadata_name=assessment_metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_in_subscription.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_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, {}) + + delete_in_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # 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 new file mode 100644 index 000000000000..699c423a12c5 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_assessments_operations.py @@ -0,0 +1,546 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + scope=scope, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/{scope}/providers/Microsoft.Security/assessments"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessmentResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentResponse] + + + request = build_get_request( + resource_id=resource_id, + assessment_name=assessment_name, + expand=expand, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], + **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 + model type or a IO type. Required. + :type assessment: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityAssessmentResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_06_01.models.SecurityAssessmentResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(assessment, (IO, 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, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + return deserialized + + create_or_update.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_id=resource_id, + assessment_name=assessment_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **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, {}) + + delete.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}"} # 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..7618ed0d80f9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_settings_operations.py @@ -0,0 +1,419 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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.Enum1"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_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.Enum1"], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.Setting"]: + """Settings about different configurations in Microsoft Defender for Cloud. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SettingsList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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 + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings"} # type: ignore + + @distributed_trace + def get( + self, + setting_name: Union[str, "_models.Enum1"], + **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.Enum1 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Setting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_06_01.models.Setting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Setting] + + + request = build_get_request( + setting_name=setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}"} # type: ignore + + + @overload + def update( + self, + setting_name: Union[str, "_models.Enum1"], + 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.Enum1 + :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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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.Enum1"], + setting: IO, + *, + 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.Enum1 + :param setting: Setting object. Required. + :type setting: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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.Enum1"], + setting: Union[_models.Setting, IO], + **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.Enum1 + :param setting: Setting object. Is either a model type or a IO type. Required. + :type setting: ~azure.mgmt.security.v2021_06_01.models.Setting or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Setting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_06_01.models.Setting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Setting] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(setting, (IO, 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, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}"} # 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 new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/py.typed @@ -0,0 +1 @@ +# 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 new file mode 100644 index 000000000000..a5eaeae6d251 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/__init__.py @@ -0,0 +1,24 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..155cb1fc508d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_configuration.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2021-07-01") # type: str + + 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._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> 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.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") + 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 new file mode 100644 index 000000000000..7af577e25640 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_metadata.json @@ -0,0 +1,102 @@ +{ + "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_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"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 + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Azure subscription ID. Required.", + "docstring_type": "str", + "required": true + } + }, + "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=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "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 + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "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\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "settings": "SettingsOperations" + } +} \ No newline at end of file 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..3dc330c4f3f9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +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) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.settings = SettingsOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SecurityCenter + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (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 new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) 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 new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" 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 new file mode 100644 index 000000000000..17bf2c4a484a --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/__init__.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. +# 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 * # type: ignore # 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 new file mode 100644 index 000000000000..20758d43dca3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_configuration.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. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenterConfiguration(Configuration): # 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: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2021-07-01") # type: str + + 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._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") + 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..de5852103e68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +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) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.settings = SettingsOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SecurityCenter": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> 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 new file mode 100644 index 000000000000..0b0925b026d7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..9045e6c3043c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/_settings_operations.py @@ -0,0 +1,308 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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 + +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") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Setting"]: + """Settings about different configurations in Microsoft Defender for Cloud. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SettingsList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Setting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_07_01.models.Setting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Setting] + + request = build_get_request( + setting_name=setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], **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 model type or a IO type. Required. + :type setting: ~azure.mgmt.security.v2021_07_01.models.Setting or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Setting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_07_01.models.Setting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Setting] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(setting, (IO, 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, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}"} # 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 new file mode 100644 index 000000000000..63e5f8c91733 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/__init__.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. +# -------------------------------------------------------------------------- + +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 * # type: ignore # 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 new file mode 100644 index 000000000000..614e2db39baa --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_models_py3.py @@ -0,0 +1,279 @@ +# 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 List, 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): + """ """ + 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 Azure. + + :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): + """ """ + super().__init__(**kwargs) + self.kind = None # type: Optional[str] + + +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 Azure. + + :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): + """ + :keyword enabled: Is the alert sync setting enabled. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.kind = "AlertSyncSettings" # type: str + 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): + """ """ + 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 Azure. + + :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): + """ + :keyword enabled: Is the data export setting enabled. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.kind = "DataExportSettings" # type: str + 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): + """ """ + 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): + """ + :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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..a8c079d4a92a --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_security_center_enums.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. +# -------------------------------------------------------------------------- + +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 new file mode 100644 index 000000000000..0b0925b026d7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 * # type: ignore # 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 new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# 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 new file mode 100644 index 000000000000..6f5f9119dac7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/_settings_operations.py @@ -0,0 +1,400 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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, _format_url_section + +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 = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + 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 = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_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 = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + 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 = _format_url_section(_url, **path_format_arguments) + + # 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") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Setting"]: + """Settings about different configurations in Microsoft Defender for Cloud. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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 = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SettingsList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings"} # type: ignore + + @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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Setting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_07_01.models.Setting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Setting] + + request = build_get_request( + setting_name=setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}"} # 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :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, + *, + 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 + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: 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], **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 model type or a IO type. Required. + :type setting: ~azure.mgmt.security.v2021_07_01.models.Setting or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Setting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2021_07_01.models.Setting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Setting] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(setting, (IO, 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, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [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, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}"} # 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 new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file