diff --git a/sdk/security/azure-mgmt-security/_meta.json b/sdk/security/azure-mgmt-security/_meta.json index d2dee5a74e00..dd3ed4fbbbbc 100644 --- a/sdk/security/azure-mgmt-security/_meta.json +++ b/sdk/security/azure-mgmt-security/_meta.json @@ -1,11 +1,46 @@ { - "commit": "a3974594e96506c6fa921be80f349d67b555e534", + "commit": "461b25f6a3b0fc701678204c930a32be540b306f", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.9.7", "use": [ - "@autorest/python@6.4.7", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.7.1", + "@autorest/modelerfour@4.26.2" ], - "autorest_command": "autorest specification/security/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.4.7 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", - "readme": "specification/security/resource-manager/readme.md" + "autorest_command": "autorest specification/security/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", + "readme": "specification/security/resource-manager/readme.md", + "package-2023-11-15": "2023-09-12 12:04:57 -0700 32c178f2467f792a322f56174be244135d2c907f Microsoft.Security/stable/2023-11-15/apiCollections.json", + "package-preview-2023-10": "2023-10-27 04:43:14 +0300 2eb036ae2fcf0dab9bbc49f3aeadb7847c953f9a Microsoft.Security/preview/2023-10-01-preview/securityConnectors.json", + "package-preview-2023-09": "fatal: invalid object name 'from'. from: securityConnectorsDevOps.json", + "package-2023-05": "2023-06-07 22:07:01 -0700 483cdd30332340a14e3d09eafdc1a18f3ba4324c Microsoft.Security/stable/2023-05-01/ServerVulnerabilityAssessmentsSettings.json", + "package-preview-2023-05": "2023-05-29 05:03:56 +0300 be02493774ad6450166fa3383c109027658567b4 Microsoft.Security/preview/2023-05-01-preview/healthReports.json", + "package-preview-2023-03-only": "2023-03-23 11:34:42 +0200 2db2beee2fed67b08d273fdac7a51aba02ac2f80 Microsoft.Security/preview/2023-03-01-preview/securityConnectors.json", + "package-preview-2023-02-15-only": "2023-04-20 09:04:12 +0300 e60df62e9e0d88462e6abba81a76d94eab000f0d Microsoft.Security/preview/2023-02-15-preview/sensitivitySettings.json", + "package-preview-2023-02-only": "2023-03-10 09:31:28 +0200 a2e2617050e68ae1c445db565076c5a7f42ebad4 Microsoft.Security/preview/2023-02-01-preview/healthReports.json", + "package-preview-2023-01-only": "2023-03-28 11:35:29 +0300 0e2c3d175e126284c5db1d3099b61e46e462fb74 Microsoft.Security/preview/2023-01-01-preview/securityOperators.json", + "package-2023-01": "2023-03-27 17:16:35 +0300 efd2b52bcf2b06e174f7008b2728f70ee7f972bd Microsoft.Security/stable/2023-01-01/pricings.json", + "package-preview-2022-12": "2023-09-12 22:01:54 +0300 b09b155f738b4178bcfe820f54f8702a94eb9d90 Microsoft.Security/preview/2022-12-01-preview/defenderForStorageSettings.json", + "package-preview-2022-08": "2022-09-20 03:45:43 +0300 9000eea3aa90071c2814f663dd763d7fc1668bed Microsoft.Security/preview/2022-08-01-preview/securityConnectors.json", + "package-preview-2022-07": "2022-11-01 04:47:16 +0200 312544c27464f61bf9639924099d4238bdfa1d71 Microsoft.Security/preview/2022-07-01-preview/applications.json", + "package-2022-05": "2022-06-09 12:47:24 +0300 d006e1d15d8fe19a6c558861dd5bba6b7baa8dd8 Microsoft.Security/stable/2022-05-01/settings.json", + "package-preview-2022-11": "2022-11-14 21:43:58 -0800 38995aeb1e63c781ae7c2cd176ea444480638093 Microsoft.Security/preview/2022-11-20-preview/apiCollections.json", + "package-preview-2022-05": "2022-06-24 06:02:22 +0300 0f8b747471c2bcae823c874e24e1b54726673a3a Microsoft.Security/preview/2022-05-01-preview/securityConnectors.json", + "package-2022-03": "2022-08-08 05:50:55 +0300 63312d0231ed57559b7f85548137cde356b98e57 Microsoft.Security/stable/2022-03-01/pricings.json", + "package-2022-01-only": "2023-03-02 10:05:39 +0800 c287c0fb1c00df4bb1812acec050d178fa969cb6 Microsoft.Security/stable/2022-01-01/alerts.json", + "package-2022-01-preview-only": "2023-01-24 09:46:27 +0200 9eb9c45842ba2932eee57326189019adc3018397 Microsoft.Security/preview/2022-01-01-preview/governanceRules.json", + "package-2021-10-preview-only": "2021-10-22 08:18:20 +0300 32652d34b63d39b2c9ca52cf97e2f805b881dd4a Microsoft.Security/preview/2021-10-01-preview/mdeOnboardings.json", + "package-2021-07-preview-only": "2022-02-16 05:25:20 +0200 72808f0e1bef87104ed97735158547422acb3d17 Microsoft.Security/preview/2021-07-01-preview/customAssessmentAutomation.json", + "package-2021-07-only": "2022-04-13 06:23:26 +0300 880394b28e0f4e7925f4ecb3edc46b651ab58129 Microsoft.Security/stable/2021-07-01/settings.json", + "package-2021-06-only": "2022-04-13 06:23:26 +0300 880394b28e0f4e7925f4ecb3edc46b651ab58129 Microsoft.Security/stable/2021-06-01/settings.json", + "package-2021-05-preview-only": "2021-05-20 10:54:13 +0300 5fcc6854765009e891052653b304cfe80353430a Microsoft.Security/preview/2021-05-01-preview/softwareInventories.json", + "package-2021-01-only": "2021-02-23 03:48:25 +0200 605f17bf33f419ee5cd3899f3ff799318a7caeb1 Microsoft.Security/stable/2021-01-01/alerts.json", + "package-2020-07-preview-only": "2020-10-28 04:54:24 +0200 f8440e900cea52b8347f63f9a755d1feeae6f161 Microsoft.Security/preview/2020-07-01-preview/sqlVulnerabilityAssessmentsScanResultsOperations.json", + "package-2020-01-python-only": "2022-05-17 18:32:46 +0300 9896393247d4098e6ff91944d2471385efaac804 Microsoft.Security/stable/2020-01-01/topologies.json", + "package-2020-01-preview-python-only": "2022-04-13 06:23:26 +0300 880394b28e0f4e7925f4ecb3edc46b651ab58129 Microsoft.Security/preview/2020-01-01-preview/securityContacts.json", + "package-2019-08-python-only": "2021-01-04 04:26:12 +0200 e5c779c267ed9d5ae7115ca71e16f3a6e6152bdd Microsoft.Security/stable/2019-08-01/iotSecuritySolutions.json", + "package-2019-01-python-only": "2022-02-23 11:14:18 +0800 8aa184e00b5314f9e293db0401e002cb99c85a91 Microsoft.Security/stable/2019-01-01/advancedThreatProtectionSettings.json", + "package-2019-01-preview-python-only": "2023-11-16 21:07:47 +0200 21d0c31470784c5765166f508c2892bdc6299444 Microsoft.Security/preview/2019-01-01-preview/alertsSuppressionRules.json", + "package-2018-06-only": "2022-04-13 06:23:26 +0300 880394b28e0f4e7925f4ecb3edc46b651ab58129 Microsoft.Security/stable/2018-06-01/pricings.json", + "package-2017-08-only": "2022-04-13 06:23:26 +0300 880394b28e0f4e7925f4ecb3edc46b651ab58129 Microsoft.Security/stable/2017-08-01/complianceResults.json", + "package-2017-08-preview-python-only": "2022-04-13 06:23:26 +0300 880394b28e0f4e7925f4ecb3edc46b651ab58129 Microsoft.Security/preview/2017-08-01-preview/securityContacts.json", + "package-2015-06-preview-python-only": "2022-04-13 06:23:26 +0300 880394b28e0f4e7925f4ecb3edc46b651ab58129 Microsoft.Security/preview/2015-06-01-preview/tasks.json" } \ No newline at end of file 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 0bfeac5dfa1e..bfbed8980d47 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/_configuration.py @@ -28,7 +28,7 @@ class SecurityCenterConfiguration(Configuration): :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. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str """ diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/_operations_mixin.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/_operations_mixin.py new file mode 100644 index 000000000000..8ba5c25a391d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/_operations_mixin.py @@ -0,0 +1,76 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +from ._serialization import Serializer, Deserializer +from io import IOBase +from typing import Any, IO, Optional, Union + +from . import models as _models + + +class SecurityCenterOperationsMixin(object): + + def get_sensitivity_settings( + self, + **kwargs: Any + ) -> _models.GetSensitivitySettingsResponse: + """Gets data sensitivity settings for sensitive data discovery. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + api_version = self._get_api_version('get_sensitivity_settings') + if api_version == '2023-02-15-preview': + from .v2023_02_15_preview.operations import SecurityCenterOperationsMixin as OperationClass + else: + raise ValueError("API version {} does not have operation 'get_sensitivity_settings'".format(api_version)) + mixin_instance = OperationClass() + mixin_instance._client = self._client + mixin_instance._config = self._config + mixin_instance._config.api_version = api_version + mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False + mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) + return mixin_instance.get_sensitivity_settings(**kwargs) + + def update_sensitivity_settings( + self, + sensitivity_settings: Union[_models.UpdateSensitivitySettingsRequest, IO], + **kwargs: Any + ) -> _models.GetSensitivitySettingsResponse: + """Updates data sensitivity settings for sensitive data discovery. + + :param sensitivity_settings: The data sensitivity settings to update. Is either a + UpdateSensitivitySettingsRequest type or a IO type. Required. + :type sensitivity_settings: + ~azure.mgmt.security.v2023_02_15_preview.models.UpdateSensitivitySettingsRequest 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: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + api_version = self._get_api_version('update_sensitivity_settings') + if api_version == '2023-02-15-preview': + from .v2023_02_15_preview.operations import SecurityCenterOperationsMixin as OperationClass + else: + raise ValueError("API version {} does not have operation 'update_sensitivity_settings'".format(api_version)) + mixin_instance = OperationClass() + mixin_instance._client = self._client + mixin_instance._config = self._config + mixin_instance._config.api_version = api_version + mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False + mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) + return mixin_instance.update_sensitivity_settings(sensitivity_settings, **kwargs) 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 264dbd194175..da76bc438581 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 @@ -29,7 +29,7 @@ def __init__(self, *args, **kwargs): """ pass -class SecurityCenter(MultiApiClientMixin, _SDKClient): +class SecurityCenter(SecurityCenterOperationsMixin, MultiApiClientMixin, _SDKClient): """API spec for Microsoft.Security (Azure Security Center) resource provider. This ready contains multiple API versions, to help you deal with all of the Azure clouds @@ -42,7 +42,7 @@ class SecurityCenter(MultiApiClientMixin, _SDKClient): :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. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -53,7 +53,7 @@ class SecurityCenter(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2023-01-01' + DEFAULT_API_VERSION = '2023-11-15' _PROFILE_TAG = "azure.mgmt.security.SecurityCenter" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -73,16 +73,30 @@ class SecurityCenter(MultiApiClientMixin, _SDKClient): 'assessments_metadata': '2021-06-01', 'auto_provisioning_settings': '2017-08-01-preview', 'automations': '2019-01-01-preview', + 'azure_dev_ops_orgs': '2023-09-01-preview', + 'azure_dev_ops_projects': '2023-09-01-preview', + 'azure_dev_ops_repos': '2023-09-01-preview', 'compliance_results': '2017-08-01', 'compliances': '2017-08-01-preview', 'connectors': '2020-01-01-preview', 'custom_assessment_automations': '2021-07-01-preview', 'custom_entity_store_assignments': '2021-07-01-preview', + 'defender_for_storage': '2022-12-01-preview', + 'dev_ops_configurations': '2023-09-01-preview', + 'dev_ops_operation_results': '2023-09-01-preview', 'device_security_groups': '2019-08-01', 'discovered_security_solutions': '2020-01-01', 'external_security_solutions': '2020-01-01', + 'get_sensitivity_settings': '2023-02-15-preview', + 'git_hub_owners': '2023-09-01-preview', + 'git_hub_repos': '2023-09-01-preview', + 'git_lab_groups': '2023-09-01-preview', + 'git_lab_projects': '2023-09-01-preview', + 'git_lab_subgroups': '2023-09-01-preview', 'governance_assignments': '2022-01-01-preview', 'governance_rules': '2022-01-01-preview', + 'health_report': '2023-02-01-preview', + 'health_reports': '2023-05-01-preview', 'information_protection_policies': '2017-08-01-preview', 'ingestion_settings': '2021-01-15-preview', 'iot_security_solution': '2019-08-01', @@ -93,6 +107,7 @@ class SecurityCenter(MultiApiClientMixin, _SDKClient): 'locations': '2015-06-01-preview', 'mde_onboardings': '2021-10-01-preview', 'operations': '2015-06-01-preview', + 'pricings': '2023-01-01', 'regulatory_compliance_assessments': '2019-01-01-preview', 'regulatory_compliance_controls': '2019-01-01-preview', 'regulatory_compliance_standards': '2019-01-01-preview', @@ -101,15 +116,23 @@ class SecurityCenter(MultiApiClientMixin, _SDKClient): 'secure_scores': '2020-01-01', 'security_connector_application': '2022-07-01-preview', 'security_connector_applications': '2022-07-01-preview', - 'security_contacts': '2017-08-01-preview', + 'security_connectors': '2023-10-01-preview', + 'security_contacts': '2020-01-01-preview', + 'security_operators': '2023-01-01-preview', 'security_solutions': '2020-01-01', 'security_solutions_reference_data': '2020-01-01', + 'sensitivity_settings': '2023-02-15-preview', 'server_vulnerability_assessment': '2020-01-01', + 'server_vulnerability_assessments_settings': '2023-05-01', 'settings': '2022-05-01', 'software_inventories': '2021-05-01-preview', + 'sql_vulnerability_assessment_baseline_rules': '2023-02-01-preview', + 'sql_vulnerability_assessment_scan_results': '2023-02-01-preview', + 'sql_vulnerability_assessment_scans': '2023-02-01-preview', 'sub_assessments': '2019-01-01-preview', 'tasks': '2015-06-01-preview', 'topology': '2020-01-01', + 'update_sensitivity_settings': '2023-02-15-preview', 'workspace_settings': '2017-08-01-preview', }}, _PROFILE_TAG + " latest" @@ -124,6 +147,8 @@ def __init__( profile: KnownProfiles=KnownProfiles.default, **kwargs: Any ): + if api_version: + kwargs.setdefault('api_version', api_version) self._config = SecurityCenterConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(SecurityCenter, self).__init__( @@ -164,10 +189,17 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2022-07-01-preview: :mod:`v2022_07_01_preview.models` * 2022-08-01-preview: :mod:`v2022_08_01_preview.models` * 2022-11-20-preview: :mod:`v2022_11_20_preview.models` + * 2022-12-01-preview: :mod:`v2022_12_01_preview.models` * 2023-01-01: :mod:`v2023_01_01.models` * 2023-01-01-preview: :mod:`v2023_01_01_preview.models` * 2023-02-01-preview: :mod:`v2023_02_01_preview.models` + * 2023-02-15-preview: :mod:`v2023_02_15_preview.models` * 2023-03-01-preview: :mod:`v2023_03_01_preview.models` + * 2023-05-01: :mod:`v2023_05_01.models` + * 2023-05-01-preview: :mod:`v2023_05_01_preview.models` + * 2023-09-01-preview: :mod:`v2023_09_01_preview.models` + * 2023-10-01-preview: :mod:`v2023_10_01_preview.models` + * 2023-11-15: :mod:`v2023_11_15.models` """ if api_version == '2015-06-01-preview': from .v2015_06_01_preview import models @@ -244,6 +276,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-11-20-preview': from .v2022_11_20_preview import models return models + elif api_version == '2022-12-01-preview': + from .v2022_12_01_preview import models + return models elif api_version == '2023-01-01': from .v2023_01_01 import models return models @@ -253,9 +288,27 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2023-02-01-preview': from .v2023_02_01_preview import models return models + elif api_version == '2023-02-15-preview': + from .v2023_02_15_preview import models + return models elif api_version == '2023-03-01-preview': from .v2023_03_01_preview import models return models + elif api_version == '2023-05-01': + from .v2023_05_01 import models + return models + elif api_version == '2023-05-01-preview': + from .v2023_05_01_preview import models + return models + elif api_version == '2023-09-01-preview': + from .v2023_09_01_preview import models + return models + elif api_version == '2023-10-01-preview': + from .v2023_10_01_preview import models + return models + elif api_version == '2023-11-15': + from .v2023_11_15 import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -270,7 +323,7 @@ def adaptive_application_controls(self): else: raise ValueError("API version {} does not have operation group 'adaptive_application_controls'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def adaptive_network_hardenings(self): @@ -284,7 +337,7 @@ def adaptive_network_hardenings(self): else: raise ValueError("API version {} does not have operation group 'adaptive_network_hardenings'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def advanced_threat_protection(self): @@ -298,7 +351,7 @@ def advanced_threat_protection(self): else: raise ValueError("API version {} does not have operation group 'advanced_threat_protection'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def alerts(self): @@ -315,7 +368,7 @@ def alerts(self): else: raise ValueError("API version {} does not have operation group 'alerts'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def alerts_suppression_rules(self): @@ -329,7 +382,7 @@ def alerts_suppression_rules(self): else: raise ValueError("API version {} does not have operation group 'alerts_suppression_rules'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def allowed_connections(self): @@ -343,7 +396,7 @@ def allowed_connections(self): else: raise ValueError("API version {} does not have operation group 'allowed_connections'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def api_collection(self): @@ -357,7 +410,7 @@ def api_collection(self): else: raise ValueError("API version {} does not have operation group 'api_collection'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def api_collection_offboarding(self): @@ -371,7 +424,7 @@ def api_collection_offboarding(self): else: raise ValueError("API version {} does not have operation group 'api_collection_offboarding'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def api_collection_onboarding(self): @@ -385,7 +438,21 @@ def api_collection_onboarding(self): else: raise ValueError("API version {} does not have operation group 'api_collection_onboarding'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def api_collections(self): + """Instance depends on the API version: + + * 2023-11-15: :class:`APICollectionsOperations` + """ + api_version = self._get_api_version('api_collections') + if api_version == '2023-11-15': + from .v2023_11_15.operations import APICollectionsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'api_collections'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def application(self): @@ -399,7 +466,7 @@ def application(self): else: raise ValueError("API version {} does not have operation group 'application'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def applications(self): @@ -413,7 +480,7 @@ def applications(self): else: raise ValueError("API version {} does not have operation group 'applications'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def assessments(self): @@ -430,7 +497,7 @@ def assessments(self): else: raise ValueError("API version {} does not have operation group 'assessments'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def assessments_metadata(self): @@ -447,7 +514,7 @@ def assessments_metadata(self): else: raise ValueError("API version {} does not have operation group 'assessments_metadata'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def auto_provisioning_settings(self): @@ -461,7 +528,7 @@ def auto_provisioning_settings(self): else: raise ValueError("API version {} does not have operation group 'auto_provisioning_settings'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def automations(self): @@ -475,7 +542,49 @@ def automations(self): else: raise ValueError("API version {} does not have operation group 'automations'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def azure_dev_ops_orgs(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`AzureDevOpsOrgsOperations` + """ + api_version = self._get_api_version('azure_dev_ops_orgs') + if api_version == '2023-09-01-preview': + from .v2023_09_01_preview.operations import AzureDevOpsOrgsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'azure_dev_ops_orgs'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def azure_dev_ops_projects(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`AzureDevOpsProjectsOperations` + """ + api_version = self._get_api_version('azure_dev_ops_projects') + if api_version == '2023-09-01-preview': + from .v2023_09_01_preview.operations import AzureDevOpsProjectsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'azure_dev_ops_projects'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def azure_dev_ops_repos(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`AzureDevOpsReposOperations` + """ + api_version = self._get_api_version('azure_dev_ops_repos') + if api_version == '2023-09-01-preview': + from .v2023_09_01_preview.operations import AzureDevOpsReposOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'azure_dev_ops_repos'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def compliance_results(self): @@ -489,7 +598,7 @@ def compliance_results(self): else: raise ValueError("API version {} does not have operation group 'compliance_results'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def compliances(self): @@ -503,7 +612,7 @@ def compliances(self): else: raise ValueError("API version {} does not have operation group 'compliances'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def connectors(self): @@ -517,7 +626,7 @@ def connectors(self): else: raise ValueError("API version {} does not have operation group 'connectors'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def custom_assessment_automations(self): @@ -531,7 +640,7 @@ def custom_assessment_automations(self): else: raise ValueError("API version {} does not have operation group 'custom_assessment_automations'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def custom_entity_store_assignments(self): @@ -545,7 +654,49 @@ def custom_entity_store_assignments(self): else: raise ValueError("API version {} does not have operation group 'custom_entity_store_assignments'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def defender_for_storage(self): + """Instance depends on the API version: + + * 2022-12-01-preview: :class:`DefenderForStorageOperations` + """ + api_version = self._get_api_version('defender_for_storage') + if api_version == '2022-12-01-preview': + from .v2022_12_01_preview.operations import DefenderForStorageOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'defender_for_storage'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def dev_ops_configurations(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`DevOpsConfigurationsOperations` + """ + api_version = self._get_api_version('dev_ops_configurations') + if api_version == '2023-09-01-preview': + from .v2023_09_01_preview.operations import DevOpsConfigurationsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'dev_ops_configurations'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def dev_ops_operation_results(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`DevOpsOperationResultsOperations` + """ + api_version = self._get_api_version('dev_ops_operation_results') + if api_version == '2023-09-01-preview': + from .v2023_09_01_preview.operations import DevOpsOperationResultsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'dev_ops_operation_results'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def device_security_groups(self): @@ -559,7 +710,7 @@ def device_security_groups(self): else: raise ValueError("API version {} does not have operation group 'device_security_groups'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def discovered_security_solutions(self): @@ -573,7 +724,7 @@ def discovered_security_solutions(self): else: raise ValueError("API version {} does not have operation group 'discovered_security_solutions'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def external_security_solutions(self): @@ -587,7 +738,77 @@ def external_security_solutions(self): else: raise ValueError("API version {} does not have operation group 'external_security_solutions'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def git_hub_owners(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`GitHubOwnersOperations` + """ + api_version = self._get_api_version('git_hub_owners') + if api_version == '2023-09-01-preview': + from .v2023_09_01_preview.operations import GitHubOwnersOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'git_hub_owners'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def git_hub_repos(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`GitHubReposOperations` + """ + api_version = self._get_api_version('git_hub_repos') + if api_version == '2023-09-01-preview': + from .v2023_09_01_preview.operations import GitHubReposOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'git_hub_repos'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def git_lab_groups(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`GitLabGroupsOperations` + """ + api_version = self._get_api_version('git_lab_groups') + if api_version == '2023-09-01-preview': + from .v2023_09_01_preview.operations import GitLabGroupsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'git_lab_groups'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def git_lab_projects(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`GitLabProjectsOperations` + """ + api_version = self._get_api_version('git_lab_projects') + if api_version == '2023-09-01-preview': + from .v2023_09_01_preview.operations import GitLabProjectsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'git_lab_projects'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def git_lab_subgroups(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`GitLabSubgroupsOperations` + """ + api_version = self._get_api_version('git_lab_subgroups') + if api_version == '2023-09-01-preview': + from .v2023_09_01_preview.operations import GitLabSubgroupsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'git_lab_subgroups'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def governance_assignments(self): @@ -601,7 +822,7 @@ def governance_assignments(self): else: raise ValueError("API version {} does not have operation group 'governance_assignments'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def governance_rules(self): @@ -615,7 +836,7 @@ def governance_rules(self): else: raise ValueError("API version {} does not have operation group 'governance_rules'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def health_report(self): @@ -629,21 +850,24 @@ def health_report(self): else: raise ValueError("API version {} does not have operation group 'health_report'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def health_reports(self): """Instance depends on the API version: * 2023-02-01-preview: :class:`HealthReportsOperations` + * 2023-05-01-preview: :class:`HealthReportsOperations` """ api_version = self._get_api_version('health_reports') if api_version == '2023-02-01-preview': from .v2023_02_01_preview.operations import HealthReportsOperations as OperationClass + elif api_version == '2023-05-01-preview': + from .v2023_05_01_preview.operations import HealthReportsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'health_reports'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def information_protection_policies(self): @@ -657,7 +881,7 @@ def information_protection_policies(self): else: raise ValueError("API version {} does not have operation group 'information_protection_policies'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def ingestion_settings(self): @@ -671,7 +895,7 @@ def ingestion_settings(self): else: raise ValueError("API version {} does not have operation group 'ingestion_settings'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def iot_security_solution(self): @@ -685,7 +909,7 @@ def iot_security_solution(self): else: raise ValueError("API version {} does not have operation group 'iot_security_solution'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def iot_security_solution_analytics(self): @@ -699,7 +923,7 @@ def iot_security_solution_analytics(self): else: raise ValueError("API version {} does not have operation group 'iot_security_solution_analytics'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def iot_security_solutions_analytics_aggregated_alert(self): @@ -713,7 +937,7 @@ def iot_security_solutions_analytics_aggregated_alert(self): else: raise ValueError("API version {} does not have operation group 'iot_security_solutions_analytics_aggregated_alert'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def iot_security_solutions_analytics_recommendation(self): @@ -727,7 +951,7 @@ def iot_security_solutions_analytics_recommendation(self): else: raise ValueError("API version {} does not have operation group 'iot_security_solutions_analytics_recommendation'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def jit_network_access_policies(self): @@ -741,7 +965,7 @@ def jit_network_access_policies(self): else: raise ValueError("API version {} does not have operation group 'jit_network_access_policies'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def locations(self): @@ -755,7 +979,7 @@ def locations(self): else: raise ValueError("API version {} does not have operation group 'locations'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def mde_onboardings(self): @@ -769,7 +993,7 @@ def mde_onboardings(self): else: raise ValueError("API version {} does not have operation group 'mde_onboardings'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def operations(self): @@ -783,7 +1007,7 @@ def operations(self): else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def pricings(self): @@ -803,7 +1027,7 @@ def pricings(self): else: raise ValueError("API version {} does not have operation group 'pricings'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def regulatory_compliance_assessments(self): @@ -817,7 +1041,7 @@ def regulatory_compliance_assessments(self): else: raise ValueError("API version {} does not have operation group 'regulatory_compliance_assessments'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def regulatory_compliance_controls(self): @@ -831,7 +1055,7 @@ def regulatory_compliance_controls(self): else: raise ValueError("API version {} does not have operation group 'regulatory_compliance_controls'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def regulatory_compliance_standards(self): @@ -845,7 +1069,7 @@ def regulatory_compliance_standards(self): else: raise ValueError("API version {} does not have operation group 'regulatory_compliance_standards'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def secure_score_control_definitions(self): @@ -859,7 +1083,7 @@ def secure_score_control_definitions(self): else: raise ValueError("API version {} does not have operation group 'secure_score_control_definitions'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def secure_score_controls(self): @@ -873,7 +1097,7 @@ def secure_score_controls(self): else: raise ValueError("API version {} does not have operation group 'secure_score_controls'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def secure_scores(self): @@ -887,7 +1111,7 @@ def secure_scores(self): else: raise ValueError("API version {} does not have operation group 'secure_scores'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def security_connector_application(self): @@ -901,7 +1125,7 @@ def security_connector_application(self): else: raise ValueError("API version {} does not have operation group 'security_connector_application'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def security_connector_applications(self): @@ -915,7 +1139,7 @@ def security_connector_applications(self): else: raise ValueError("API version {} does not have operation group 'security_connector_applications'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def security_connectors(self): @@ -925,6 +1149,7 @@ def security_connectors(self): * 2022-05-01-preview: :class:`SecurityConnectorsOperations` * 2022-08-01-preview: :class:`SecurityConnectorsOperations` * 2023-03-01-preview: :class:`SecurityConnectorsOperations` + * 2023-10-01-preview: :class:`SecurityConnectorsOperations` """ api_version = self._get_api_version('security_connectors') if api_version == '2021-07-01-preview': @@ -935,24 +1160,29 @@ def security_connectors(self): from .v2022_08_01_preview.operations import SecurityConnectorsOperations as OperationClass elif api_version == '2023-03-01-preview': from .v2023_03_01_preview.operations import SecurityConnectorsOperations as OperationClass + elif api_version == '2023-10-01-preview': + from .v2023_10_01_preview.operations import SecurityConnectorsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_connectors'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def security_contacts(self): """Instance depends on the API version: * 2017-08-01-preview: :class:`SecurityContactsOperations` + * 2020-01-01-preview: :class:`SecurityContactsOperations` """ api_version = self._get_api_version('security_contacts') if api_version == '2017-08-01-preview': from .v2017_08_01_preview.operations import SecurityContactsOperations as OperationClass + elif api_version == '2020-01-01-preview': + from .v2020_01_01_preview.operations import SecurityContactsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_contacts'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def security_operators(self): @@ -966,7 +1196,7 @@ def security_operators(self): else: raise ValueError("API version {} does not have operation group 'security_operators'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def security_solutions(self): @@ -980,7 +1210,7 @@ def security_solutions(self): else: raise ValueError("API version {} does not have operation group 'security_solutions'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def security_solutions_reference_data(self): @@ -994,7 +1224,21 @@ def security_solutions_reference_data(self): else: raise ValueError("API version {} does not have operation group 'security_solutions_reference_data'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def sensitivity_settings(self): + """Instance depends on the API version: + + * 2023-02-15-preview: :class:`SensitivitySettingsOperations` + """ + api_version = self._get_api_version('sensitivity_settings') + if api_version == '2023-02-15-preview': + from .v2023_02_15_preview.operations import SensitivitySettingsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'sensitivity_settings'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def server_vulnerability_assessment(self): @@ -1008,7 +1252,21 @@ def server_vulnerability_assessment(self): else: raise ValueError("API version {} does not have operation group 'server_vulnerability_assessment'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def server_vulnerability_assessments_settings(self): + """Instance depends on the API version: + + * 2023-05-01: :class:`ServerVulnerabilityAssessmentsSettingsOperations` + """ + api_version = self._get_api_version('server_vulnerability_assessments_settings') + if api_version == '2023-05-01': + from .v2023_05_01.operations import ServerVulnerabilityAssessmentsSettingsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'server_vulnerability_assessments_settings'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def settings(self): @@ -1028,7 +1286,7 @@ def settings(self): else: raise ValueError("API version {} does not have operation group 'settings'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def software_inventories(self): @@ -1042,7 +1300,7 @@ def software_inventories(self): else: raise ValueError("API version {} does not have operation group 'software_inventories'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def sql_vulnerability_assessment_baseline_rules(self): @@ -1059,7 +1317,7 @@ def sql_vulnerability_assessment_baseline_rules(self): else: raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_baseline_rules'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def sql_vulnerability_assessment_scan_results(self): @@ -1076,7 +1334,7 @@ def sql_vulnerability_assessment_scan_results(self): else: raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_scan_results'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def sql_vulnerability_assessment_scans(self): @@ -1093,7 +1351,7 @@ def sql_vulnerability_assessment_scans(self): else: raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_scans'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def sub_assessments(self): @@ -1107,7 +1365,7 @@ def sub_assessments(self): else: raise ValueError("API version {} does not have operation group 'sub_assessments'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def tasks(self): @@ -1121,7 +1379,7 @@ def tasks(self): else: raise ValueError("API version {} does not have operation group 'tasks'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def topology(self): @@ -1135,7 +1393,7 @@ def topology(self): else: raise ValueError("API version {} does not have operation group 'topology'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def workspace_settings(self): @@ -1149,7 +1407,7 @@ def workspace_settings(self): else: raise ValueError("API version {} does not have operation group 'workspace_settings'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) def close(self): self._client.close() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/_serialization.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/_serialization.py index e3cc6ce6ed6f..a00658b1fc19 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/_serialization.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/_serialization.py @@ -664,8 +664,9 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) @@ -743,6 +744,8 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. :rtype: str :raises: TypeError if serialization fails. :raises: ValueError if data is None @@ -751,10 +754,8 @@ def query(self, name, data, data_type, **kwargs): # 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)) + do_quote = not kwargs.get('skip_quote', False) + return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -893,6 +894,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -905,9 +908,18 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get('do_quote', False): + serialized = [ + '' if s is None else quote(str(s), safe='') + for s + in serialized + ] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -952,7 +964,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: 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 f085bcc1fe5d..20921f2a85f8 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 @@ -28,7 +28,7 @@ class SecurityCenterConfiguration(Configuration): :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. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str """ diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/_operations_mixin.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/_operations_mixin.py new file mode 100644 index 000000000000..a1412419444b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/_operations_mixin.py @@ -0,0 +1,76 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +from .._serialization import Serializer, Deserializer +from io import IOBase +from typing import Any, IO, Optional, Union + +from .. import models as _models + + +class SecurityCenterOperationsMixin(object): + + async def get_sensitivity_settings( + self, + **kwargs: Any + ) -> _models.GetSensitivitySettingsResponse: + """Gets data sensitivity settings for sensitive data discovery. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + api_version = self._get_api_version('get_sensitivity_settings') + if api_version == '2023-02-15-preview': + from ..v2023_02_15_preview.aio.operations import SecurityCenterOperationsMixin as OperationClass + else: + raise ValueError("API version {} does not have operation 'get_sensitivity_settings'".format(api_version)) + mixin_instance = OperationClass() + mixin_instance._client = self._client + mixin_instance._config = self._config + mixin_instance._config.api_version = api_version + mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False + mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) + return await mixin_instance.get_sensitivity_settings(**kwargs) + + async def update_sensitivity_settings( + self, + sensitivity_settings: Union[_models.UpdateSensitivitySettingsRequest, IO], + **kwargs: Any + ) -> _models.GetSensitivitySettingsResponse: + """Updates data sensitivity settings for sensitive data discovery. + + :param sensitivity_settings: The data sensitivity settings to update. Is either a + UpdateSensitivitySettingsRequest type or a IO type. Required. + :type sensitivity_settings: + ~azure.mgmt.security.v2023_02_15_preview.models.UpdateSensitivitySettingsRequest 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: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + api_version = self._get_api_version('update_sensitivity_settings') + if api_version == '2023-02-15-preview': + from ..v2023_02_15_preview.aio.operations import SecurityCenterOperationsMixin as OperationClass + else: + raise ValueError("API version {} does not have operation 'update_sensitivity_settings'".format(api_version)) + mixin_instance = OperationClass() + mixin_instance._client = self._client + mixin_instance._config = self._config + mixin_instance._config.api_version = api_version + mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False + mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) + return await mixin_instance.update_sensitivity_settings(sensitivity_settings, **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 96a0e28100b5..d0fd0206abd4 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 @@ -29,7 +29,7 @@ def __init__(self, *args, **kwargs): """ pass -class SecurityCenter(MultiApiClientMixin, _SDKClient): +class SecurityCenter(SecurityCenterOperationsMixin, MultiApiClientMixin, _SDKClient): """API spec for Microsoft.Security (Azure Security Center) resource provider. This ready contains multiple API versions, to help you deal with all of the Azure clouds @@ -42,7 +42,7 @@ class SecurityCenter(MultiApiClientMixin, _SDKClient): :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. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -53,7 +53,7 @@ class SecurityCenter(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2023-01-01' + DEFAULT_API_VERSION = '2023-11-15' _PROFILE_TAG = "azure.mgmt.security.SecurityCenter" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -73,16 +73,30 @@ class SecurityCenter(MultiApiClientMixin, _SDKClient): 'assessments_metadata': '2021-06-01', 'auto_provisioning_settings': '2017-08-01-preview', 'automations': '2019-01-01-preview', + 'azure_dev_ops_orgs': '2023-09-01-preview', + 'azure_dev_ops_projects': '2023-09-01-preview', + 'azure_dev_ops_repos': '2023-09-01-preview', 'compliance_results': '2017-08-01', 'compliances': '2017-08-01-preview', 'connectors': '2020-01-01-preview', 'custom_assessment_automations': '2021-07-01-preview', 'custom_entity_store_assignments': '2021-07-01-preview', + 'defender_for_storage': '2022-12-01-preview', + 'dev_ops_configurations': '2023-09-01-preview', + 'dev_ops_operation_results': '2023-09-01-preview', 'device_security_groups': '2019-08-01', 'discovered_security_solutions': '2020-01-01', 'external_security_solutions': '2020-01-01', + 'get_sensitivity_settings': '2023-02-15-preview', + 'git_hub_owners': '2023-09-01-preview', + 'git_hub_repos': '2023-09-01-preview', + 'git_lab_groups': '2023-09-01-preview', + 'git_lab_projects': '2023-09-01-preview', + 'git_lab_subgroups': '2023-09-01-preview', 'governance_assignments': '2022-01-01-preview', 'governance_rules': '2022-01-01-preview', + 'health_report': '2023-02-01-preview', + 'health_reports': '2023-05-01-preview', 'information_protection_policies': '2017-08-01-preview', 'ingestion_settings': '2021-01-15-preview', 'iot_security_solution': '2019-08-01', @@ -93,6 +107,7 @@ class SecurityCenter(MultiApiClientMixin, _SDKClient): 'locations': '2015-06-01-preview', 'mde_onboardings': '2021-10-01-preview', 'operations': '2015-06-01-preview', + 'pricings': '2023-01-01', 'regulatory_compliance_assessments': '2019-01-01-preview', 'regulatory_compliance_controls': '2019-01-01-preview', 'regulatory_compliance_standards': '2019-01-01-preview', @@ -101,15 +116,23 @@ class SecurityCenter(MultiApiClientMixin, _SDKClient): 'secure_scores': '2020-01-01', 'security_connector_application': '2022-07-01-preview', 'security_connector_applications': '2022-07-01-preview', - 'security_contacts': '2017-08-01-preview', + 'security_connectors': '2023-10-01-preview', + 'security_contacts': '2020-01-01-preview', + 'security_operators': '2023-01-01-preview', 'security_solutions': '2020-01-01', 'security_solutions_reference_data': '2020-01-01', + 'sensitivity_settings': '2023-02-15-preview', 'server_vulnerability_assessment': '2020-01-01', + 'server_vulnerability_assessments_settings': '2023-05-01', 'settings': '2022-05-01', 'software_inventories': '2021-05-01-preview', + 'sql_vulnerability_assessment_baseline_rules': '2023-02-01-preview', + 'sql_vulnerability_assessment_scan_results': '2023-02-01-preview', + 'sql_vulnerability_assessment_scans': '2023-02-01-preview', 'sub_assessments': '2019-01-01-preview', 'tasks': '2015-06-01-preview', 'topology': '2020-01-01', + 'update_sensitivity_settings': '2023-02-15-preview', 'workspace_settings': '2017-08-01-preview', }}, _PROFILE_TAG + " latest" @@ -124,6 +147,8 @@ def __init__( profile: KnownProfiles = KnownProfiles.default, **kwargs: Any ) -> None: + if api_version: + kwargs.setdefault('api_version', api_version) self._config = SecurityCenterConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(SecurityCenter, self).__init__( @@ -164,10 +189,17 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2022-07-01-preview: :mod:`v2022_07_01_preview.models` * 2022-08-01-preview: :mod:`v2022_08_01_preview.models` * 2022-11-20-preview: :mod:`v2022_11_20_preview.models` + * 2022-12-01-preview: :mod:`v2022_12_01_preview.models` * 2023-01-01: :mod:`v2023_01_01.models` * 2023-01-01-preview: :mod:`v2023_01_01_preview.models` * 2023-02-01-preview: :mod:`v2023_02_01_preview.models` + * 2023-02-15-preview: :mod:`v2023_02_15_preview.models` * 2023-03-01-preview: :mod:`v2023_03_01_preview.models` + * 2023-05-01: :mod:`v2023_05_01.models` + * 2023-05-01-preview: :mod:`v2023_05_01_preview.models` + * 2023-09-01-preview: :mod:`v2023_09_01_preview.models` + * 2023-10-01-preview: :mod:`v2023_10_01_preview.models` + * 2023-11-15: :mod:`v2023_11_15.models` """ if api_version == '2015-06-01-preview': from ..v2015_06_01_preview import models @@ -244,6 +276,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-11-20-preview': from ..v2022_11_20_preview import models return models + elif api_version == '2022-12-01-preview': + from ..v2022_12_01_preview import models + return models elif api_version == '2023-01-01': from ..v2023_01_01 import models return models @@ -253,9 +288,27 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2023-02-01-preview': from ..v2023_02_01_preview import models return models + elif api_version == '2023-02-15-preview': + from ..v2023_02_15_preview import models + return models elif api_version == '2023-03-01-preview': from ..v2023_03_01_preview import models return models + elif api_version == '2023-05-01': + from ..v2023_05_01 import models + return models + elif api_version == '2023-05-01-preview': + from ..v2023_05_01_preview import models + return models + elif api_version == '2023-09-01-preview': + from ..v2023_09_01_preview import models + return models + elif api_version == '2023-10-01-preview': + from ..v2023_10_01_preview import models + return models + elif api_version == '2023-11-15': + from ..v2023_11_15 import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -270,7 +323,7 @@ def adaptive_application_controls(self): else: raise ValueError("API version {} does not have operation group 'adaptive_application_controls'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def adaptive_network_hardenings(self): @@ -284,7 +337,7 @@ def adaptive_network_hardenings(self): else: raise ValueError("API version {} does not have operation group 'adaptive_network_hardenings'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def advanced_threat_protection(self): @@ -298,7 +351,7 @@ def advanced_threat_protection(self): else: raise ValueError("API version {} does not have operation group 'advanced_threat_protection'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def alerts(self): @@ -315,7 +368,7 @@ def alerts(self): else: raise ValueError("API version {} does not have operation group 'alerts'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def alerts_suppression_rules(self): @@ -329,7 +382,7 @@ def alerts_suppression_rules(self): else: raise ValueError("API version {} does not have operation group 'alerts_suppression_rules'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def allowed_connections(self): @@ -343,7 +396,7 @@ def allowed_connections(self): else: raise ValueError("API version {} does not have operation group 'allowed_connections'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def api_collection(self): @@ -357,7 +410,7 @@ def api_collection(self): else: raise ValueError("API version {} does not have operation group 'api_collection'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def api_collection_offboarding(self): @@ -371,7 +424,7 @@ def api_collection_offboarding(self): else: raise ValueError("API version {} does not have operation group 'api_collection_offboarding'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def api_collection_onboarding(self): @@ -385,7 +438,21 @@ def api_collection_onboarding(self): else: raise ValueError("API version {} does not have operation group 'api_collection_onboarding'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def api_collections(self): + """Instance depends on the API version: + + * 2023-11-15: :class:`APICollectionsOperations` + """ + api_version = self._get_api_version('api_collections') + if api_version == '2023-11-15': + from ..v2023_11_15.aio.operations import APICollectionsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'api_collections'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def application(self): @@ -399,7 +466,7 @@ def application(self): else: raise ValueError("API version {} does not have operation group 'application'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def applications(self): @@ -413,7 +480,7 @@ def applications(self): else: raise ValueError("API version {} does not have operation group 'applications'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def assessments(self): @@ -430,7 +497,7 @@ def assessments(self): else: raise ValueError("API version {} does not have operation group 'assessments'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def assessments_metadata(self): @@ -447,7 +514,7 @@ def assessments_metadata(self): else: raise ValueError("API version {} does not have operation group 'assessments_metadata'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def auto_provisioning_settings(self): @@ -461,7 +528,7 @@ def auto_provisioning_settings(self): else: raise ValueError("API version {} does not have operation group 'auto_provisioning_settings'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def automations(self): @@ -475,7 +542,49 @@ def automations(self): else: raise ValueError("API version {} does not have operation group 'automations'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def azure_dev_ops_orgs(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`AzureDevOpsOrgsOperations` + """ + api_version = self._get_api_version('azure_dev_ops_orgs') + if api_version == '2023-09-01-preview': + from ..v2023_09_01_preview.aio.operations import AzureDevOpsOrgsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'azure_dev_ops_orgs'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def azure_dev_ops_projects(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`AzureDevOpsProjectsOperations` + """ + api_version = self._get_api_version('azure_dev_ops_projects') + if api_version == '2023-09-01-preview': + from ..v2023_09_01_preview.aio.operations import AzureDevOpsProjectsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'azure_dev_ops_projects'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def azure_dev_ops_repos(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`AzureDevOpsReposOperations` + """ + api_version = self._get_api_version('azure_dev_ops_repos') + if api_version == '2023-09-01-preview': + from ..v2023_09_01_preview.aio.operations import AzureDevOpsReposOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'azure_dev_ops_repos'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def compliance_results(self): @@ -489,7 +598,7 @@ def compliance_results(self): else: raise ValueError("API version {} does not have operation group 'compliance_results'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def compliances(self): @@ -503,7 +612,7 @@ def compliances(self): else: raise ValueError("API version {} does not have operation group 'compliances'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def connectors(self): @@ -517,7 +626,7 @@ def connectors(self): else: raise ValueError("API version {} does not have operation group 'connectors'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def custom_assessment_automations(self): @@ -531,7 +640,7 @@ def custom_assessment_automations(self): else: raise ValueError("API version {} does not have operation group 'custom_assessment_automations'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def custom_entity_store_assignments(self): @@ -545,7 +654,49 @@ def custom_entity_store_assignments(self): else: raise ValueError("API version {} does not have operation group 'custom_entity_store_assignments'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def defender_for_storage(self): + """Instance depends on the API version: + + * 2022-12-01-preview: :class:`DefenderForStorageOperations` + """ + api_version = self._get_api_version('defender_for_storage') + if api_version == '2022-12-01-preview': + from ..v2022_12_01_preview.aio.operations import DefenderForStorageOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'defender_for_storage'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def dev_ops_configurations(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`DevOpsConfigurationsOperations` + """ + api_version = self._get_api_version('dev_ops_configurations') + if api_version == '2023-09-01-preview': + from ..v2023_09_01_preview.aio.operations import DevOpsConfigurationsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'dev_ops_configurations'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def dev_ops_operation_results(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`DevOpsOperationResultsOperations` + """ + api_version = self._get_api_version('dev_ops_operation_results') + if api_version == '2023-09-01-preview': + from ..v2023_09_01_preview.aio.operations import DevOpsOperationResultsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'dev_ops_operation_results'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def device_security_groups(self): @@ -559,7 +710,7 @@ def device_security_groups(self): else: raise ValueError("API version {} does not have operation group 'device_security_groups'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def discovered_security_solutions(self): @@ -573,7 +724,7 @@ def discovered_security_solutions(self): else: raise ValueError("API version {} does not have operation group 'discovered_security_solutions'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def external_security_solutions(self): @@ -587,7 +738,77 @@ def external_security_solutions(self): else: raise ValueError("API version {} does not have operation group 'external_security_solutions'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def git_hub_owners(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`GitHubOwnersOperations` + """ + api_version = self._get_api_version('git_hub_owners') + if api_version == '2023-09-01-preview': + from ..v2023_09_01_preview.aio.operations import GitHubOwnersOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'git_hub_owners'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def git_hub_repos(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`GitHubReposOperations` + """ + api_version = self._get_api_version('git_hub_repos') + if api_version == '2023-09-01-preview': + from ..v2023_09_01_preview.aio.operations import GitHubReposOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'git_hub_repos'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def git_lab_groups(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`GitLabGroupsOperations` + """ + api_version = self._get_api_version('git_lab_groups') + if api_version == '2023-09-01-preview': + from ..v2023_09_01_preview.aio.operations import GitLabGroupsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'git_lab_groups'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def git_lab_projects(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`GitLabProjectsOperations` + """ + api_version = self._get_api_version('git_lab_projects') + if api_version == '2023-09-01-preview': + from ..v2023_09_01_preview.aio.operations import GitLabProjectsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'git_lab_projects'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def git_lab_subgroups(self): + """Instance depends on the API version: + + * 2023-09-01-preview: :class:`GitLabSubgroupsOperations` + """ + api_version = self._get_api_version('git_lab_subgroups') + if api_version == '2023-09-01-preview': + from ..v2023_09_01_preview.aio.operations import GitLabSubgroupsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'git_lab_subgroups'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def governance_assignments(self): @@ -601,7 +822,7 @@ def governance_assignments(self): else: raise ValueError("API version {} does not have operation group 'governance_assignments'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def governance_rules(self): @@ -615,7 +836,7 @@ def governance_rules(self): else: raise ValueError("API version {} does not have operation group 'governance_rules'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def health_report(self): @@ -629,21 +850,24 @@ def health_report(self): else: raise ValueError("API version {} does not have operation group 'health_report'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def health_reports(self): """Instance depends on the API version: * 2023-02-01-preview: :class:`HealthReportsOperations` + * 2023-05-01-preview: :class:`HealthReportsOperations` """ api_version = self._get_api_version('health_reports') if api_version == '2023-02-01-preview': from ..v2023_02_01_preview.aio.operations import HealthReportsOperations as OperationClass + elif api_version == '2023-05-01-preview': + from ..v2023_05_01_preview.aio.operations import HealthReportsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'health_reports'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def information_protection_policies(self): @@ -657,7 +881,7 @@ def information_protection_policies(self): else: raise ValueError("API version {} does not have operation group 'information_protection_policies'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def ingestion_settings(self): @@ -671,7 +895,7 @@ def ingestion_settings(self): else: raise ValueError("API version {} does not have operation group 'ingestion_settings'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def iot_security_solution(self): @@ -685,7 +909,7 @@ def iot_security_solution(self): else: raise ValueError("API version {} does not have operation group 'iot_security_solution'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def iot_security_solution_analytics(self): @@ -699,7 +923,7 @@ def iot_security_solution_analytics(self): else: raise ValueError("API version {} does not have operation group 'iot_security_solution_analytics'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def iot_security_solutions_analytics_aggregated_alert(self): @@ -713,7 +937,7 @@ def iot_security_solutions_analytics_aggregated_alert(self): else: raise ValueError("API version {} does not have operation group 'iot_security_solutions_analytics_aggregated_alert'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def iot_security_solutions_analytics_recommendation(self): @@ -727,7 +951,7 @@ def iot_security_solutions_analytics_recommendation(self): else: raise ValueError("API version {} does not have operation group 'iot_security_solutions_analytics_recommendation'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def jit_network_access_policies(self): @@ -741,7 +965,7 @@ def jit_network_access_policies(self): else: raise ValueError("API version {} does not have operation group 'jit_network_access_policies'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def locations(self): @@ -755,7 +979,7 @@ def locations(self): else: raise ValueError("API version {} does not have operation group 'locations'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def mde_onboardings(self): @@ -769,7 +993,7 @@ def mde_onboardings(self): else: raise ValueError("API version {} does not have operation group 'mde_onboardings'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def operations(self): @@ -783,7 +1007,7 @@ def operations(self): else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def pricings(self): @@ -803,7 +1027,7 @@ def pricings(self): else: raise ValueError("API version {} does not have operation group 'pricings'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def regulatory_compliance_assessments(self): @@ -817,7 +1041,7 @@ def regulatory_compliance_assessments(self): else: raise ValueError("API version {} does not have operation group 'regulatory_compliance_assessments'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def regulatory_compliance_controls(self): @@ -831,7 +1055,7 @@ def regulatory_compliance_controls(self): else: raise ValueError("API version {} does not have operation group 'regulatory_compliance_controls'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def regulatory_compliance_standards(self): @@ -845,7 +1069,7 @@ def regulatory_compliance_standards(self): else: raise ValueError("API version {} does not have operation group 'regulatory_compliance_standards'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def secure_score_control_definitions(self): @@ -859,7 +1083,7 @@ def secure_score_control_definitions(self): else: raise ValueError("API version {} does not have operation group 'secure_score_control_definitions'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def secure_score_controls(self): @@ -873,7 +1097,7 @@ def secure_score_controls(self): else: raise ValueError("API version {} does not have operation group 'secure_score_controls'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def secure_scores(self): @@ -887,7 +1111,7 @@ def secure_scores(self): else: raise ValueError("API version {} does not have operation group 'secure_scores'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def security_connector_application(self): @@ -901,7 +1125,7 @@ def security_connector_application(self): else: raise ValueError("API version {} does not have operation group 'security_connector_application'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def security_connector_applications(self): @@ -915,7 +1139,7 @@ def security_connector_applications(self): else: raise ValueError("API version {} does not have operation group 'security_connector_applications'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def security_connectors(self): @@ -925,6 +1149,7 @@ def security_connectors(self): * 2022-05-01-preview: :class:`SecurityConnectorsOperations` * 2022-08-01-preview: :class:`SecurityConnectorsOperations` * 2023-03-01-preview: :class:`SecurityConnectorsOperations` + * 2023-10-01-preview: :class:`SecurityConnectorsOperations` """ api_version = self._get_api_version('security_connectors') if api_version == '2021-07-01-preview': @@ -935,24 +1160,29 @@ def security_connectors(self): from ..v2022_08_01_preview.aio.operations import SecurityConnectorsOperations as OperationClass elif api_version == '2023-03-01-preview': from ..v2023_03_01_preview.aio.operations import SecurityConnectorsOperations as OperationClass + elif api_version == '2023-10-01-preview': + from ..v2023_10_01_preview.aio.operations import SecurityConnectorsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_connectors'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def security_contacts(self): """Instance depends on the API version: * 2017-08-01-preview: :class:`SecurityContactsOperations` + * 2020-01-01-preview: :class:`SecurityContactsOperations` """ api_version = self._get_api_version('security_contacts') if api_version == '2017-08-01-preview': from ..v2017_08_01_preview.aio.operations import SecurityContactsOperations as OperationClass + elif api_version == '2020-01-01-preview': + from ..v2020_01_01_preview.aio.operations import SecurityContactsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_contacts'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def security_operators(self): @@ -966,7 +1196,7 @@ def security_operators(self): else: raise ValueError("API version {} does not have operation group 'security_operators'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def security_solutions(self): @@ -980,7 +1210,7 @@ def security_solutions(self): else: raise ValueError("API version {} does not have operation group 'security_solutions'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def security_solutions_reference_data(self): @@ -994,7 +1224,21 @@ def security_solutions_reference_data(self): else: raise ValueError("API version {} does not have operation group 'security_solutions_reference_data'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def sensitivity_settings(self): + """Instance depends on the API version: + + * 2023-02-15-preview: :class:`SensitivitySettingsOperations` + """ + api_version = self._get_api_version('sensitivity_settings') + if api_version == '2023-02-15-preview': + from ..v2023_02_15_preview.aio.operations import SensitivitySettingsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'sensitivity_settings'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def server_vulnerability_assessment(self): @@ -1008,7 +1252,21 @@ def server_vulnerability_assessment(self): else: raise ValueError("API version {} does not have operation group 'server_vulnerability_assessment'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) + + @property + def server_vulnerability_assessments_settings(self): + """Instance depends on the API version: + + * 2023-05-01: :class:`ServerVulnerabilityAssessmentsSettingsOperations` + """ + api_version = self._get_api_version('server_vulnerability_assessments_settings') + if api_version == '2023-05-01': + from ..v2023_05_01.aio.operations import ServerVulnerabilityAssessmentsSettingsOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'server_vulnerability_assessments_settings'".format(api_version)) + self._config.api_version = api_version + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def settings(self): @@ -1028,7 +1286,7 @@ def settings(self): else: raise ValueError("API version {} does not have operation group 'settings'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def software_inventories(self): @@ -1042,7 +1300,7 @@ def software_inventories(self): else: raise ValueError("API version {} does not have operation group 'software_inventories'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def sql_vulnerability_assessment_baseline_rules(self): @@ -1059,7 +1317,7 @@ def sql_vulnerability_assessment_baseline_rules(self): else: raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_baseline_rules'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def sql_vulnerability_assessment_scan_results(self): @@ -1076,7 +1334,7 @@ def sql_vulnerability_assessment_scan_results(self): else: raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_scan_results'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def sql_vulnerability_assessment_scans(self): @@ -1093,7 +1351,7 @@ def sql_vulnerability_assessment_scans(self): else: raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_scans'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def sub_assessments(self): @@ -1107,7 +1365,7 @@ def sub_assessments(self): else: raise ValueError("API version {} does not have operation group 'sub_assessments'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def tasks(self): @@ -1121,7 +1379,7 @@ def tasks(self): else: raise ValueError("API version {} does not have operation group 'tasks'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def topology(self): @@ -1135,7 +1393,7 @@ def topology(self): else: raise ValueError("API version {} does not have operation group 'topology'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) @property def workspace_settings(self): @@ -1149,7 +1407,7 @@ def workspace_settings(self): else: raise ValueError("API version {} does not have operation group 'workspace_settings'".format(api_version)) self._config.api_version = api_version - return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)), api_version) async def close(self): await self._client.close() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/models.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/models.py index 47d82a3301e2..78992a9d9405 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/models.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/models.py @@ -22,4 +22,13 @@ from .v2022_05_01.models import * from .v2022_07_01_preview.models import * from .v2022_11_20_preview.models import * +from .v2022_12_01_preview.models import * from .v2023_01_01.models import * +from .v2023_01_01_preview.models import * +from .v2023_02_01_preview.models import * +from .v2023_02_15_preview.models import * +from .v2023_05_01.models import * +from .v2023_05_01_preview.models import * +from .v2023_09_01_preview.models import * +from .v2023_10_01_preview.models import * +from .v2023_11_15.models import * 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 index b7a9f475da5c..de0d8c74879d 100644 --- 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 @@ -56,9 +56,15 @@ def __init__( 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) + self.locations = LocationsOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-06-01-preview" + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2015-06-01-preview" + ) + self.tasks = TasksOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-06-01-preview" + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. 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 index bd0df84f5319..0dafe0e287ff 100644 --- 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 @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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 index 34ea7990c4b4..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" 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 index 3323fcd39041..aa5a656dd4de 100644 --- 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 @@ -56,9 +56,15 @@ def __init__( 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) + self.locations = LocationsOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-06-01-preview" + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize, "2015-06-01-preview" + ) + self.tasks = TasksOperations( + self._client, self._config, self._serialize, self._deserialize, "2015-06-01-preview" + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. 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 index 48c8c6dc1f06..fe3c820bab51 100644 --- 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 @@ -52,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.AscLocation"]: @@ -68,7 +69,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.AscLocation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[_models.AscLocationList] = kwargs.pop("cls", None) error_map = { @@ -159,7 +162,9 @@ async def get(self, asc_location: str, **kwargs: Any) -> _models.AscLocation: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[_models.AscLocation] = kwargs.pop("cls", None) request = build_get_request( 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 index baebf823e6b1..566e8428f790 100644 --- 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 @@ -51,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: @@ -65,7 +66,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) error_map = { 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 index db91a87098bc..1bad47c7712c 100644 --- 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 @@ -60,6 +60,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.SecurityTask"]: @@ -76,7 +77,9 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[_models.SecurityTaskList] = kwargs.pop("cls", None) error_map = { @@ -165,7 +168,9 @@ def list_by_home_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[_models.SecurityTaskList] = kwargs.pop("cls", None) error_map = { @@ -264,7 +269,9 @@ async def get_subscription_level_task( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[_models.SecurityTask] = kwargs.pop("cls", None) request = build_get_subscription_level_task_request( @@ -336,7 +343,9 @@ async def update_subscription_level_task_state( # pylint: disable=inconsistent- _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_subscription_level_task_state_request( @@ -393,7 +402,9 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[_models.SecurityTaskList] = kwargs.pop("cls", None) error_map = { @@ -496,7 +507,9 @@ async def get_resource_group_level_task( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[_models.SecurityTask] = kwargs.pop("cls", None) request = build_get_resource_group_level_task_request( @@ -573,7 +586,9 @@ async def update_resource_group_level_task_state( # pylint: disable=inconsisten _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_resource_group_level_task_state_request( 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 index 9c2d20dbebdb..8e0822713da3 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +51,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +80,7 @@ def build_get_request(asc_location: str, subscription_id: str, **kwargs: Any) -> "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -109,6 +109,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.AscLocation"]: @@ -125,7 +126,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.AscLocation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[_models.AscLocationList] = kwargs.pop("cls", None) error_map = { @@ -216,7 +219,9 @@ def get(self, asc_location: str, **kwargs: Any) -> _models.AscLocation: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[_models.AscLocation] = kwargs.pop("cls", None) request = build_get_request( 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 index 5fec409b01e5..ce4a9e8934d7 100644 --- 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 @@ -73,6 +73,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: @@ -86,7 +87,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[_models.OperationList] = kwargs.pop("cls", None) error_map = { 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 index 7958a48f535f..7d4854774fc3 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +51,7 @@ def build_list_request(subscription_id: str, *, filter: Optional[str] = None, ** ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -84,7 +84,7 @@ def build_list_by_home_region_request( "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -119,7 +119,7 @@ def build_get_subscription_level_task_request( "taskName": _SERIALIZER.url("task_name", task_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -157,7 +157,7 @@ def build_update_subscription_level_task_state_request( "taskUpdateActionType": _SERIALIZER.url("task_update_action_type", task_update_action_type, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -192,7 +192,7 @@ def build_list_by_resource_group_request( "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -230,7 +230,7 @@ def build_get_resource_group_level_task_request( "taskName": _SERIALIZER.url("task_name", task_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -272,7 +272,7 @@ def build_update_resource_group_level_task_state_request( "taskUpdateActionType": _SERIALIZER.url("task_update_action_type", task_update_action_type, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -301,6 +301,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.SecurityTask"]: @@ -317,7 +318,9 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[_models.SecurityTaskList] = kwargs.pop("cls", None) error_map = { @@ -406,7 +409,9 @@ def list_by_home_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[_models.SecurityTaskList] = kwargs.pop("cls", None) error_map = { @@ -503,7 +508,9 @@ def get_subscription_level_task(self, asc_location: str, task_name: str, **kwarg _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[_models.SecurityTask] = kwargs.pop("cls", None) request = build_get_subscription_level_task_request( @@ -575,7 +582,9 @@ def update_subscription_level_task_state( # pylint: disable=inconsistent-return _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_subscription_level_task_state_request( @@ -632,7 +641,9 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[_models.SecurityTaskList] = kwargs.pop("cls", None) error_map = { @@ -735,7 +746,9 @@ def get_resource_group_level_task( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[_models.SecurityTask] = kwargs.pop("cls", None) request = build_get_resource_group_level_task_request( @@ -812,7 +825,9 @@ def update_resource_group_level_task_state( # pylint: disable=inconsistent-retu _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2015-06-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_resource_group_level_task_state_request( 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 index 62bc54c3d345..f933c3e773aa 100644 --- 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 @@ -48,7 +48,7 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.compliance_results = ComplianceResultsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2017-08-01" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: 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 index bd0df84f5319..0dafe0e287ff 100644 --- 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 @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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 index 34ea7990c4b4..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" 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 index 82ae1259e6d5..12d27877d42c 100644 --- 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 @@ -48,7 +48,7 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.compliance_results = ComplianceResultsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2017-08-01" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: 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 index f01a643f0a60..22b79d79d070 100644 --- 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 @@ -52,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.ComplianceResult"]: @@ -70,7 +71,7 @@ def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.ComplianceRe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-08-01")) cls: ClsType[_models.ComplianceResultList] = kwargs.pop("cls", None) error_map = { @@ -162,7 +163,7 @@ async def get(self, resource_id: str, compliance_result_name: str, **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-08-01")) cls: ClsType[_models.ComplianceResult] = kwargs.pop("cls", None) request = build_get_request( 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 index 94ec12f61e8f..ddb8747005e0 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +49,7 @@ def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +76,7 @@ def build_get_request(resource_id: str, compliance_result_name: str, **kwargs: A "complianceResultName": _SERIALIZER.url("compliance_result_name", compliance_result_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -105,6 +105,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, scope: str, **kwargs: Any) -> Iterable["_models.ComplianceResult"]: @@ -122,7 +123,7 @@ def list(self, scope: str, **kwargs: Any) -> Iterable["_models.ComplianceResult" _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-08-01")) cls: ClsType[_models.ComplianceResultList] = kwargs.pop("cls", None) error_map = { @@ -214,7 +215,7 @@ def get(self, resource_id: str, compliance_result_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-08-01")) cls: ClsType[_models.ComplianceResult] = kwargs.pop("cls", None) request = build_get_request( 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 index 4044f96477f0..12bb01198393 100644 --- 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 @@ -71,17 +71,19 @@ def __init__( 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._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" + ) + self.compliances = CompliancesOperations( + self._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" ) - self.compliances = CompliancesOperations(self._client, self._config, self._serialize, self._deserialize) self.information_protection_policies = InformationProtectionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" ) self.security_contacts = SecurityContactsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" ) self.workspace_settings = WorkspaceSettingsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: 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 index bd0df84f5319..0dafe0e287ff 100644 --- 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 @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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 index 34ea7990c4b4..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" 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 index 831356ffee4d..8c6a1769fa50 100644 --- 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 @@ -72,17 +72,19 @@ def __init__( 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._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" + ) + self.compliances = CompliancesOperations( + self._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" ) - self.compliances = CompliancesOperations(self._client, self._config, self._serialize, self._deserialize) self.information_protection_policies = InformationProtectionPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" ) self.security_contacts = SecurityContactsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" ) self.workspace_settings = WorkspaceSettingsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2017-08-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: 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 index 4b19b1ff3f37..9a9936976d04 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -56,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.AutoProvisioningSetting"]: @@ -71,7 +73,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.AutoProvisioningSetting" _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.AutoProvisioningSettingList] = kwargs.pop("cls", None) error_map = { @@ -161,7 +165,9 @@ async def get(self, setting_name: str, **kwargs: Any) -> _models.AutoProvisionin _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.AutoProvisioningSetting] = kwargs.pop("cls", None) request = build_get_request( @@ -270,14 +276,16 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AutoProvisioningSetting] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(setting, (IO, bytes)): + if isinstance(setting, (IOBase, bytes)): _content = setting else: _json = self._serialize.body(setting, "AutoProvisioningSetting") 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 index cfb3bcaa1690..6ba0491d312d 100644 --- 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 @@ -52,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Compliance"]: @@ -70,7 +71,9 @@ def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Compliance"] _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.ComplianceList] = kwargs.pop("cls", None) error_map = { @@ -164,7 +167,9 @@ async def get(self, scope: str, compliance_name: str, **kwargs: Any) -> _models. _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.Compliance] = kwargs.pop("cls", None) request = build_get_request( 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 index 8d5d4c0f1afe..0eee792b027a 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -56,6 +57,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( @@ -90,7 +92,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.InformationProtectionPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -230,14 +234,16 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.InformationProtectionPolicy] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(information_protection_policy, (IO, bytes)): + if isinstance(information_protection_policy, (IOBase, bytes)): _content = information_protection_policy else: _json = self._serialize.body(information_protection_policy, "InformationProtectionPolicy") @@ -300,7 +306,9 @@ def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.InformationP _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.InformationProtectionPolicyList] = kwargs.pop("cls", None) error_map = { 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 index 0825a84f7770..562aded9d26a 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -58,6 +59,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityContact"]: @@ -72,7 +74,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityContact"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.SecurityContactList] = kwargs.pop("cls", None) error_map = { @@ -162,7 +166,9 @@ async def get(self, security_contact_name: str, **kwargs: Any) -> _models.Securi _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) request = build_get_request( @@ -271,14 +277,16 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_contact, (IO, bytes)): + if isinstance(security_contact, (IOBase, bytes)): _content = security_contact else: _json = self._serialize.body(security_contact, "SecurityContact") @@ -343,7 +351,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -448,14 +458,16 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_contact, (IO, bytes)): + if isinstance(security_contact, (IOBase, bytes)): _content = security_contact else: _json = self._serialize.body(security_contact, "SecurityContact") 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 index 6c2b27d78f67..2e4f1317db1d 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -58,6 +59,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.WorkspaceSetting"]: @@ -73,7 +75,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.WorkspaceSetting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.WorkspaceSettingList] = kwargs.pop("cls", None) error_map = { @@ -164,7 +168,9 @@ async def get(self, workspace_setting_name: str, **kwargs: Any) -> _models.Works _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.WorkspaceSetting] = kwargs.pop("cls", None) request = build_get_request( @@ -278,14 +284,16 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkspaceSetting] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workspace_setting, (IO, bytes)): + if isinstance(workspace_setting, (IOBase, bytes)): _content = workspace_setting else: _json = self._serialize.body(workspace_setting, "WorkspaceSetting") @@ -404,14 +412,16 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkspaceSetting] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workspace_setting, (IO, bytes)): + if isinstance(workspace_setting, (IOBase, bytes)): _content = workspace_setting else: _json = self._serialize.body(workspace_setting, "WorkspaceSetting") @@ -477,7 +487,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 index 85442edc4a61..a92052cf058a 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +54,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +84,7 @@ def build_get_request(setting_name: str, subscription_id: str, **kwargs: Any) -> "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +115,7 @@ def build_create_request(setting_name: str, subscription_id: str, **kwargs: Any) "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -145,6 +146,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.AutoProvisioningSetting"]: @@ -160,7 +162,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.AutoProvisioningSetting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.AutoProvisioningSettingList] = kwargs.pop("cls", None) error_map = { @@ -250,7 +254,9 @@ def get(self, setting_name: str, **kwargs: Any) -> _models.AutoProvisioningSetti _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.AutoProvisioningSetting] = kwargs.pop("cls", None) request = build_get_request( @@ -359,14 +365,16 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AutoProvisioningSetting] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(setting, (IO, bytes)): + if isinstance(setting, (IOBase, bytes)): _content = setting else: _json = self._serialize.body(setting, "AutoProvisioningSetting") 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 index c4cdcd9ebb7e..5349d94671be 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +49,7 @@ def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -74,7 +74,7 @@ def build_get_request(scope: str, compliance_name: str, **kwargs: Any) -> HttpRe "complianceName": _SERIALIZER.url("compliance_name", compliance_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -103,6 +103,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, scope: str, **kwargs: Any) -> Iterable["_models.Compliance"]: @@ -121,7 +122,9 @@ def list(self, scope: str, **kwargs: Any) -> Iterable["_models.Compliance"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.ComplianceList] = kwargs.pop("cls", None) error_map = { @@ -215,7 +218,9 @@ def get(self, scope: str, compliance_name: str, **kwargs: Any) -> _models.Compli _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.Compliance] = kwargs.pop("cls", None) request = build_get_request( 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 index cd5e6e5f5b24..5173e239bd52 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +58,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -90,7 +91,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +117,7 @@ def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -145,6 +146,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get( @@ -179,7 +181,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.InformationProtectionPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -319,14 +323,16 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.InformationProtectionPolicy] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(information_protection_policy, (IO, bytes)): + if isinstance(information_protection_policy, (IOBase, bytes)): _content = information_protection_policy else: _json = self._serialize.body(information_protection_policy, "InformationProtectionPolicy") @@ -389,7 +395,9 @@ def list(self, scope: str, **kwargs: Any) -> Iterable["_models.InformationProtec _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.InformationProtectionPolicyList] = kwargs.pop("cls", None) error_map = { 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 index d7068bf2e8d4..a3a788c2d823 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +52,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,7 +82,7 @@ def build_get_request(security_contact_name: str, subscription_id: str, **kwargs "securityContactName": _SERIALIZER.url("security_contact_name", security_contact_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -112,7 +113,7 @@ def build_create_request(security_contact_name: str, subscription_id: str, **kwa "securityContactName": _SERIALIZER.url("security_contact_name", security_contact_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -144,7 +145,7 @@ def build_delete_request(security_contact_name: str, subscription_id: str, **kwa "securityContactName": _SERIALIZER.url("security_contact_name", security_contact_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -175,7 +176,7 @@ def build_update_request(security_contact_name: str, subscription_id: str, **kwa "securityContactName": _SERIALIZER.url("security_contact_name", security_contact_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -206,6 +207,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.SecurityContact"]: @@ -220,7 +222,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.SecurityContact"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.SecurityContactList] = kwargs.pop("cls", None) error_map = { @@ -310,7 +314,9 @@ def get(self, security_contact_name: str, **kwargs: Any) -> _models.SecurityCont _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) request = build_get_request( @@ -419,14 +425,16 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_contact, (IO, bytes)): + if isinstance(security_contact, (IOBase, bytes)): _content = security_contact else: _json = self._serialize.body(security_contact, "SecurityContact") @@ -491,7 +499,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -596,14 +606,16 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_contact, (IO, bytes)): + if isinstance(security_contact, (IOBase, bytes)): _content = security_contact else: _json = self._serialize.body(security_contact, "SecurityContact") 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 index 8387549138c9..8ef9970f0388 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +52,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,7 +82,7 @@ def build_get_request(workspace_setting_name: str, subscription_id: str, **kwarg "workspaceSettingName": _SERIALIZER.url("workspace_setting_name", workspace_setting_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -112,7 +113,7 @@ def build_create_request(workspace_setting_name: str, subscription_id: str, **kw "workspaceSettingName": _SERIALIZER.url("workspace_setting_name", workspace_setting_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -145,7 +146,7 @@ def build_update_request(workspace_setting_name: str, subscription_id: str, **kw "workspaceSettingName": _SERIALIZER.url("workspace_setting_name", workspace_setting_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -177,7 +178,7 @@ def build_delete_request(workspace_setting_name: str, subscription_id: str, **kw "workspaceSettingName": _SERIALIZER.url("workspace_setting_name", workspace_setting_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -206,6 +207,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.WorkspaceSetting"]: @@ -221,7 +223,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.WorkspaceSetting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.WorkspaceSettingList] = kwargs.pop("cls", None) error_map = { @@ -312,7 +316,9 @@ def get(self, workspace_setting_name: str, **kwargs: Any) -> _models.WorkspaceSe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[_models.WorkspaceSetting] = kwargs.pop("cls", None) request = build_get_request( @@ -426,14 +432,16 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkspaceSetting] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workspace_setting, (IO, bytes)): + if isinstance(workspace_setting, (IOBase, bytes)): _content = workspace_setting else: _json = self._serialize.body(workspace_setting, "WorkspaceSetting") @@ -552,14 +560,16 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WorkspaceSetting] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(workspace_setting, (IO, bytes)): + if isinstance(workspace_setting, (IOBase, bytes)): _content = workspace_setting else: _json = self._serialize.body(workspace_setting, "WorkspaceSetting") @@ -625,7 +635,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2017-08-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 index 0aac90f41d53..a60e6c0a7add 100644 --- 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 @@ -52,7 +52,7 @@ def __init__( 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) + self.pricings = PricingsOperations(self._client, self._config, self._serialize, self._deserialize, "2018-06-01") def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. 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 index bd0df84f5319..0dafe0e287ff 100644 --- 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 @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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 index 34ea7990c4b4..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" 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 index 6dceef464990..d456f9afb79b 100644 --- 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 @@ -52,7 +52,7 @@ def __init__( 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) + self.pricings = PricingsOperations(self._client, self._config, self._serialize, self._deserialize, "2018-06-01") def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. 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 index a8e7a631b4e2..81db9919e1e2 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -49,6 +50,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, **kwargs: Any) -> _models.PricingList: @@ -70,7 +72,7 @@ async def list(self, **kwargs: Any) -> _models.PricingList: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-06-01")) cls: ClsType[_models.PricingList] = kwargs.pop("cls", None) request = build_list_request( @@ -125,7 +127,7 @@ async def get(self, pricing_name: str, **kwargs: Any) -> _models.Pricing: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-06-01")) cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) request = build_get_request( @@ -224,14 +226,14 @@ async def update(self, pricing_name: str, pricing: Union[_models.Pricing, IO], * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(pricing, (IO, bytes)): + if isinstance(pricing, (IOBase, bytes)): _content = pricing else: _json = self._serialize.body(pricing, "Pricing") 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 index a064d5d5418a..7d772ad5dae9 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -25,7 +26,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +50,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +79,7 @@ def build_get_request(pricing_name: str, subscription_id: str, **kwargs: Any) -> "pricingName": _SERIALIZER.url("pricing_name", pricing_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -108,7 +109,7 @@ def build_update_request(pricing_name: str, subscription_id: str, **kwargs: Any) "pricingName": _SERIALIZER.url("pricing_name", pricing_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -139,6 +140,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> _models.PricingList: @@ -160,7 +162,7 @@ def list(self, **kwargs: Any) -> _models.PricingList: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-06-01")) cls: ClsType[_models.PricingList] = kwargs.pop("cls", None) request = build_list_request( @@ -215,7 +217,7 @@ def get(self, pricing_name: str, **kwargs: Any) -> _models.Pricing: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-06-01")) cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) request = build_get_request( @@ -314,14 +316,14 @@ def update(self, pricing_name: str, pricing: Union[_models.Pricing, IO], **kwarg _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(pricing, (IO, bytes)): + if isinstance(pricing, (IOBase, bytes)): _content = pricing else: _json = self._serialize.body(pricing, "Pricing") 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 index 9e10b5e73cb1..23e4a7eb8d95 100644 --- 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 @@ -48,7 +48,7 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.advanced_threat_protection = AdvancedThreatProtectionOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-01-01" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: 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 index bd0df84f5319..0dafe0e287ff 100644 --- 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 @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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 index 34ea7990c4b4..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" 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 index 8317dd34122f..a94c165dc751 100644 --- 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 @@ -48,7 +48,7 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.advanced_threat_protection = AdvancedThreatProtectionOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-01-01" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: 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 index 67965a676dcb..ae02b83b184c 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -54,6 +55,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, resource_id: str, **kwargs: Any) -> _models.AdvancedThreatProtectionSetting: @@ -80,7 +82,7 @@ async def get(self, resource_id: str, **kwargs: Any) -> _models.AdvancedThreatPr _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-01-01")) setting_name: Literal["current"] = kwargs.pop("setting_name", "current") cls: ClsType[_models.AdvancedThreatProtectionSetting] = kwargs.pop("cls", None) @@ -207,7 +209,7 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-01-01")) setting_name: Literal["current"] = kwargs.pop("setting_name", "current") content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AdvancedThreatProtectionSetting] = kwargs.pop("cls", None) @@ -215,7 +217,7 @@ async def create( content_type = content_type or "application/json" _json = None _content = None - if isinstance(advanced_threat_protection_setting, (IO, bytes)): + if isinstance(advanced_threat_protection_setting, (IOBase, bytes)): _content = advanced_threat_protection_setting else: _json = self._serialize.body(advanced_threat_protection_setting, "AdvancedThreatProtectionSetting") 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 index 11b42500dd6d..65658e4c8fa2 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload @@ -26,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request if sys.version_info >= (3, 8): from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports @@ -56,7 +57,7 @@ def build_get_request(resource_id: str, **kwargs: Any) -> HttpRequest: "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -85,7 +86,7 @@ def build_create_request(resource_id: str, **kwargs: Any) -> HttpRequest: "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,6 +117,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, resource_id: str, **kwargs: Any) -> _models.AdvancedThreatProtectionSetting: @@ -142,7 +144,7 @@ def get(self, resource_id: str, **kwargs: Any) -> _models.AdvancedThreatProtecti _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-01-01")) setting_name: Literal["current"] = kwargs.pop("setting_name", "current") cls: ClsType[_models.AdvancedThreatProtectionSetting] = kwargs.pop("cls", None) @@ -269,7 +271,7 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-01-01")) setting_name: Literal["current"] = kwargs.pop("setting_name", "current") content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AdvancedThreatProtectionSetting] = kwargs.pop("cls", None) @@ -277,7 +279,7 @@ def create( content_type = content_type or "application/json" _json = None _content = None - if isinstance(advanced_threat_protection_setting, (IO, bytes)): + if isinstance(advanced_threat_protection_setting, (IOBase, bytes)): _content = advanced_threat_protection_setting else: _json = self._serialize.body(advanced_threat_protection_setting, "AdvancedThreatProtectionSetting") 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 index ca506ebfd9e8..203d3b7683d4 100644 --- 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 @@ -75,18 +75,22 @@ def __init__( 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._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" ) self.regulatory_compliance_controls = RegulatoryComplianceControlsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" ) self.regulatory_compliance_assessments = RegulatoryComplianceAssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" + ) + self.sub_assessments = SubAssessmentsOperations( + self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" + ) + self.automations = AutomationsOperations( + self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" ) - 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._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: 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 index bd0df84f5319..0dafe0e287ff 100644 --- 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 @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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 index 34ea7990c4b4..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" 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 index 19da659b35a0..e5d1df822219 100644 --- 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 @@ -76,18 +76,22 @@ def __init__( 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._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" ) self.regulatory_compliance_controls = RegulatoryComplianceControlsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" ) self.regulatory_compliance_assessments = RegulatoryComplianceAssessmentsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" + ) + self.sub_assessments = SubAssessmentsOperations( + self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" + ) + self.automations = AutomationsOperations( + self._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" ) - 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._client, self._config, self._serialize, self._deserialize, "2019-01-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: 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 index 354fa9fc9971..e8f15f2a06c8 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -57,6 +58,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, alert_type: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_models.AlertsSuppressionRule"]: @@ -74,7 +76,9 @@ def list(self, alert_type: Optional[str] = None, **kwargs: Any) -> AsyncIterable _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.AlertsSuppressionRulesList] = kwargs.pop("cls", None) error_map = { @@ -165,7 +169,9 @@ async def get(self, alerts_suppression_rule_name: str, **kwargs: Any) -> _models _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.AlertsSuppressionRule] = kwargs.pop("cls", None) request = build_get_request( @@ -284,14 +290,16 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AlertsSuppressionRule] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(alerts_suppression_rule, (IO, bytes)): + if isinstance(alerts_suppression_rule, (IOBase, bytes)): _content = alerts_suppression_rule else: _json = self._serialize.body(alerts_suppression_rule, "AlertsSuppressionRule") @@ -356,7 +364,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 index aab4c404e7ac..9d02ddfb61d3 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -59,6 +60,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Automation"]: @@ -74,7 +76,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Automation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.AutomationList] = kwargs.pop("cls", None) error_map = { @@ -159,7 +163,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.AutomationList] = kwargs.pop("cls", None) error_map = { @@ -255,7 +261,9 @@ async def get(self, resource_group_name: str, automation_name: str, **kwargs: An _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.Automation] = kwargs.pop("cls", None) request = build_get_request( @@ -384,14 +392,16 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Automation] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(automation, (IO, bytes)): + if isinstance(automation, (IOBase, bytes)): _content = automation else: _json = self._serialize.body(automation, "Automation") @@ -464,7 +474,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -589,14 +601,16 @@ async def validate( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AutomationValidationStatus] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(automation, (IO, bytes)): + if isinstance(automation, (IOBase, bytes)): _content = automation else: _json = self._serialize.body(automation, "Automation") 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 index 1cf03b28c025..5ff2891c05d4 100644 --- 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 @@ -52,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -81,7 +82,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.RegulatoryComplianceAssessmentList] = kwargs.pop("cls", None) error_map = { @@ -189,7 +192,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.RegulatoryComplianceAssessment] = kwargs.pop("cls", None) request = build_get_request( 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 index 591b1d5a8d27..b62da0e9ec8c 100644 --- 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 @@ -52,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -74,7 +75,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.RegulatoryComplianceControlList] = kwargs.pop("cls", None) error_map = { @@ -174,7 +177,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.RegulatoryComplianceControl] = kwargs.pop("cls", None) request = build_get_request( 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 index 69db69ae0684..37aeaf3fab7a 100644 --- 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 @@ -52,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -71,7 +72,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.RegulatoryComplianceStandardList] = kwargs.pop("cls", None) error_map = { @@ -167,7 +170,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.RegulatoryComplianceStandard] = kwargs.pop("cls", None) request = build_get_request( 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 index 86b56fffb508..df47e3b664c8 100644 --- 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 @@ -52,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_all(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.SecuritySubAssessment"]: @@ -71,7 +72,9 @@ def list_all(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Security _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.SecuritySubAssessmentList] = kwargs.pop("cls", None) error_map = { @@ -159,7 +162,9 @@ def list(self, scope: str, assessment_name: str, **kwargs: Any) -> AsyncIterable _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.SecuritySubAssessmentList] = kwargs.pop("cls", None) error_map = { @@ -259,7 +264,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.SecuritySubAssessment] = kwargs.pop("cls", None) request = build_get_request( 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 index 2aec4b3ea73f..302c745bfb42 100644 --- 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 @@ -103,7 +103,7 @@ class AlertsSuppressionRule(Resource): :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. + null there will no expiration at all. :vartype expiration_date_utc: ~datetime.datetime :ivar reason: The reason for dismissing the alert. :vartype reason: str @@ -152,7 +152,7 @@ def __init__( :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. + as null there will no expiration at all. :paramtype expiration_date_utc: ~datetime.datetime :keyword reason: The reason for dismissing the alert. :paramtype reason: str 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 index 6e82c4210bac..e883801efcf4 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +54,7 @@ def build_list_request(subscription_id: str, *, alert_type: Optional[str] = None ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -87,7 +88,7 @@ def build_get_request(alerts_suppression_rule_name: str, subscription_id: str, * ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,7 +121,7 @@ def build_update_request(alerts_suppression_rule_name: str, subscription_id: str ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,7 +155,7 @@ def build_delete_request(alerts_suppression_rule_name: str, subscription_id: str ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -183,6 +184,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, alert_type: Optional[str] = None, **kwargs: Any) -> Iterable["_models.AlertsSuppressionRule"]: @@ -200,7 +202,9 @@ def list(self, alert_type: Optional[str] = None, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.AlertsSuppressionRulesList] = kwargs.pop("cls", None) error_map = { @@ -291,7 +295,9 @@ def get(self, alerts_suppression_rule_name: str, **kwargs: Any) -> _models.Alert _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.AlertsSuppressionRule] = kwargs.pop("cls", None) request = build_get_request( @@ -410,14 +416,16 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AlertsSuppressionRule] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(alerts_suppression_rule, (IO, bytes)): + if isinstance(alerts_suppression_rule, (IOBase, bytes)): _content = alerts_suppression_rule else: _json = self._serialize.body(alerts_suppression_rule, "AlertsSuppressionRule") @@ -482,7 +490,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 index e8b2672620ef..3f8dc2e1c754 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +52,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +84,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -118,7 +119,7 @@ def build_get_request( "automationName": _SERIALIZER.url("automation_name", automation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,7 +155,7 @@ def build_create_or_update_request( "automationName": _SERIALIZER.url("automation_name", automation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -191,7 +192,7 @@ def build_delete_request( "automationName": _SERIALIZER.url("automation_name", automation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -227,7 +228,7 @@ def build_validate_request( "automationName": _SERIALIZER.url("automation_name", automation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -258,6 +259,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Automation"]: @@ -273,7 +275,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.Automation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.AutomationList] = kwargs.pop("cls", None) error_map = { @@ -358,7 +362,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.AutomationList] = kwargs.pop("cls", None) error_map = { @@ -454,7 +460,9 @@ def get(self, resource_group_name: str, automation_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.Automation] = kwargs.pop("cls", None) request = build_get_request( @@ -583,14 +591,16 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Automation] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(automation, (IO, bytes)): + if isinstance(automation, (IOBase, bytes)): _content = automation else: _json = self._serialize.body(automation, "Automation") @@ -663,7 +673,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -788,14 +800,16 @@ def validate( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AutomationValidationStatus] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(automation, (IO, bytes)): + if isinstance(automation, (IOBase, bytes)): _content = automation else: _json = self._serialize.body(automation, "Automation") 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 index d8cba4a4062e..3b021fc0b87f 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -67,7 +67,7 @@ def build_list_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -113,7 +113,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -142,6 +142,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -171,7 +172,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.RegulatoryComplianceAssessmentList] = kwargs.pop("cls", None) error_map = { @@ -279,7 +282,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.RegulatoryComplianceAssessment] = kwargs.pop("cls", None) request = build_get_request( 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 index 0d23417a27fc..c7ffa10b4f8f 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -59,7 +59,7 @@ def build_list_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -101,7 +101,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -130,6 +130,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -152,7 +153,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.RegulatoryComplianceControlList] = kwargs.pop("cls", None) error_map = { @@ -252,7 +255,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.RegulatoryComplianceControl] = kwargs.pop("cls", None) request = build_get_request( 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 index 1f4c98bb0d24..d945c4040d48 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +53,7 @@ def build_list_request(subscription_id: str, *, filter: Optional[str] = None, ** ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -87,7 +87,7 @@ def build_get_request(regulatory_compliance_standard_name: str, subscription_id: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,6 +116,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models.RegulatoryComplianceStandard"]: @@ -133,7 +134,9 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.RegulatoryComplianceStandardList] = kwargs.pop("cls", None) error_map = { @@ -227,7 +230,9 @@ def get(self, regulatory_compliance_standard_name: str, **kwargs: Any) -> _model _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.RegulatoryComplianceStandard] = kwargs.pop("cls", None) request = build_get_request( 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 index 76f3e023f130..8ccd12ae3e78 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +49,7 @@ def build_list_all_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +76,7 @@ def build_list_request(scope: str, assessment_name: str, **kwargs: Any) -> HttpR "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -105,7 +105,7 @@ def build_get_request(scope: str, assessment_name: str, sub_assessment_name: str "subAssessmentName": _SERIALIZER.url("sub_assessment_name", sub_assessment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -134,6 +134,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_all(self, scope: str, **kwargs: Any) -> Iterable["_models.SecuritySubAssessment"]: @@ -153,7 +154,9 @@ def list_all(self, scope: str, **kwargs: Any) -> Iterable["_models.SecuritySubAs _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.SecuritySubAssessmentList] = kwargs.pop("cls", None) error_map = { @@ -241,7 +244,9 @@ def list(self, scope: str, assessment_name: str, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.SecuritySubAssessmentList] = kwargs.pop("cls", None) error_map = { @@ -341,7 +346,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2019-01-01-preview") + ) cls: ClsType[_models.SecuritySubAssessment] = kwargs.pop("cls", None) request = build_get_request( 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 index 0982481520ae..77bc3079f37e 100644 --- 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 @@ -74,19 +74,19 @@ def __init__( 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._client, self._config, self._serialize, self._deserialize, "2019-08-01" ) self.iot_security_solution_analytics = IotSecuritySolutionAnalyticsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-08-01" ) self.iot_security_solutions_analytics_aggregated_alert = IotSecuritySolutionsAnalyticsAggregatedAlertOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-08-01" ) self.iot_security_solutions_analytics_recommendation = IotSecuritySolutionsAnalyticsRecommendationOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-08-01" ) self.iot_security_solution = IotSecuritySolutionOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-08-01" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: 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 index bd0df84f5319..0dafe0e287ff 100644 --- 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 @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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 index 34ea7990c4b4..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" 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 index 5946015da3fc..2a947e21df9d 100644 --- 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 @@ -74,19 +74,19 @@ def __init__( 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._client, self._config, self._serialize, self._deserialize, "2019-08-01" ) self.iot_security_solution_analytics = IotSecuritySolutionAnalyticsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-08-01" ) self.iot_security_solutions_analytics_aggregated_alert = IotSecuritySolutionsAnalyticsAggregatedAlertOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-08-01" ) self.iot_security_solutions_analytics_recommendation = IotSecuritySolutionsAnalyticsRecommendationOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-08-01" ) self.iot_security_solution = IotSecuritySolutionOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2019-08-01" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: 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 index df7bfc973b84..5b49cd654a83 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -57,6 +58,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, resource_id: str, **kwargs: Any) -> AsyncIterable["_models.DeviceSecurityGroup"]: @@ -73,7 +75,7 @@ def list(self, resource_id: str, **kwargs: Any) -> AsyncIterable["_models.Device _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.DeviceSecurityGroupList] = kwargs.pop("cls", None) error_map = { @@ -168,7 +170,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.DeviceSecurityGroup] = kwargs.pop("cls", None) request = build_get_request( @@ -298,14 +300,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DeviceSecurityGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(device_security_group, (IO, bytes)): + if isinstance(device_security_group, (IOBase, bytes)): _content = device_security_group else: _json = self._serialize.body(device_security_group, "DeviceSecurityGroup") @@ -377,7 +379,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 index f0a7bec020ac..0bb90d3d4f34 100644 --- 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 @@ -49,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list( @@ -77,7 +78,7 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.IoTSecuritySolutionAnalyticsModelList] = kwargs.pop("cls", None) request = build_list_request( @@ -141,7 +142,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.IoTSecuritySolutionAnalyticsModel] = kwargs.pop("cls", None) request = build_get_request( 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 index 6cccf016e767..56dc2031ab07 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -59,6 +60,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription( @@ -79,7 +81,7 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.IoTSecuritySolutionsList] = kwargs.pop("cls", None) error_map = { @@ -172,7 +174,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.IoTSecuritySolutionsList] = kwargs.pop("cls", None) error_map = { @@ -271,7 +273,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.IoTSecuritySolutionModel] = kwargs.pop("cls", None) request = build_get_request( @@ -403,14 +405,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IoTSecuritySolutionModel] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_security_solution_data, (IO, bytes)): + if isinstance(iot_security_solution_data, (IOBase, bytes)): _content = iot_security_solution_data else: _json = self._serialize.body(iot_security_solution_data, "IoTSecuritySolutionModel") @@ -554,14 +556,14 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IoTSecuritySolutionModel] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(update_iot_security_solution_data, (IO, bytes)): + if isinstance(update_iot_security_solution_data, (IOBase, bytes)): _content = update_iot_security_solution_data else: _json = self._serialize.body(update_iot_security_solution_data, "UpdateIotSecuritySolutionData") @@ -630,7 +632,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 index 4e133bf57dd4..30061f0c1812 100644 --- 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 @@ -56,6 +56,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -80,7 +81,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.IoTSecurityAggregatedAlertList] = kwargs.pop("cls", None) error_map = { @@ -183,7 +184,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.IoTSecurityAggregatedAlert] = kwargs.pop("cls", None) request = build_get_request( @@ -250,7 +251,7 @@ async def dismiss( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_dismiss_request( 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 index 747c3f884dbd..b3813f4437d4 100644 --- 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 @@ -55,6 +55,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( @@ -87,7 +88,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.IoTSecurityAggregatedRecommendation] = kwargs.pop("cls", None) request = build_get_request( @@ -149,7 +150,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.IoTSecurityAggregatedRecommendationList] = kwargs.pop("cls", None) error_map = { 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 index eb0a0197bce3..4e8770a7c570 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +50,7 @@ def build_list_request(resource_id: str, **kwargs: Any) -> HttpRequest: "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +77,7 @@ def build_get_request(resource_id: str, device_security_group_name: str, **kwarg "deviceSecurityGroupName": _SERIALIZER.url("device_security_group_name", device_security_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -104,7 +105,7 @@ def build_create_or_update_request(resource_id: str, device_security_group_name: "deviceSecurityGroupName": _SERIALIZER.url("device_security_group_name", device_security_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -133,7 +134,7 @@ def build_delete_request(resource_id: str, device_security_group_name: str, **kw "deviceSecurityGroupName": _SERIALIZER.url("device_security_group_name", device_security_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -162,6 +163,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, resource_id: str, **kwargs: Any) -> Iterable["_models.DeviceSecurityGroup"]: @@ -178,7 +180,7 @@ def list(self, resource_id: str, **kwargs: Any) -> Iterable["_models.DeviceSecur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.DeviceSecurityGroupList] = kwargs.pop("cls", None) error_map = { @@ -271,7 +273,7 @@ def get(self, resource_id: str, device_security_group_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.DeviceSecurityGroup] = kwargs.pop("cls", None) request = build_get_request( @@ -401,14 +403,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.DeviceSecurityGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(device_security_group, (IO, bytes)): + if isinstance(device_security_group, (IOBase, bytes)): _content = device_security_group else: _json = self._serialize.body(device_security_group, "DeviceSecurityGroup") @@ -480,7 +482,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 index 96e688e02cad..77c4dd2c308c 100644 --- 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 @@ -25,7 +25,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -58,7 +58,7 @@ def build_list_request( "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -91,7 +91,7 @@ def build_get_request(resource_group_name: str, solution_name: str, subscription "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,6 +120,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -148,7 +149,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.IoTSecuritySolutionAnalyticsModelList] = kwargs.pop("cls", None) request = build_list_request( @@ -212,7 +213,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.IoTSecuritySolutionAnalyticsModel] = kwargs.pop("cls", None) request = build_get_request( 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 index 84932d448a3e..f6b6f600d945 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +56,7 @@ def build_list_by_subscription_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -91,7 +92,7 @@ def build_list_by_resource_group_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -126,7 +127,7 @@ def build_get_request(resource_group_name: str, solution_name: str, subscription "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -162,7 +163,7 @@ def build_create_or_update_request( "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -200,7 +201,7 @@ def build_update_request( "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -237,7 +238,7 @@ def build_delete_request( "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -266,6 +267,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_subscription( @@ -286,7 +288,7 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.IoTSecuritySolutionsList] = kwargs.pop("cls", None) error_map = { @@ -379,7 +381,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.IoTSecuritySolutionsList] = kwargs.pop("cls", None) error_map = { @@ -476,7 +478,7 @@ def get(self, resource_group_name: str, solution_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.IoTSecuritySolutionModel] = kwargs.pop("cls", None) request = build_get_request( @@ -608,14 +610,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IoTSecuritySolutionModel] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(iot_security_solution_data, (IO, bytes)): + if isinstance(iot_security_solution_data, (IOBase, bytes)): _content = iot_security_solution_data else: _json = self._serialize.body(iot_security_solution_data, "IoTSecuritySolutionModel") @@ -759,14 +761,14 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.IoTSecuritySolutionModel] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(update_iot_security_solution_data, (IO, bytes)): + if isinstance(update_iot_security_solution_data, (IOBase, bytes)): _content = update_iot_security_solution_data else: _json = self._serialize.body(update_iot_security_solution_data, "UpdateIotSecuritySolutionData") @@ -835,7 +837,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 index 49569ea37c2b..e1f5e9246db2 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -60,7 +60,7 @@ def build_list_request( "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -98,7 +98,7 @@ def build_get_request( "aggregatedAlertName": _SERIALIZER.url("aggregated_alert_name", aggregated_alert_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -134,7 +134,7 @@ def build_dismiss_request( "aggregatedAlertName": _SERIALIZER.url("aggregated_alert_name", aggregated_alert_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -163,6 +163,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -187,7 +188,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.IoTSecurityAggregatedAlertList] = kwargs.pop("cls", None) error_map = { @@ -290,7 +291,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.IoTSecurityAggregatedAlert] = kwargs.pop("cls", None) request = build_get_request( @@ -357,7 +358,7 @@ def dismiss( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_dismiss_request( 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 index 50840665537d..4450d45877fe 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -67,7 +67,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -102,7 +102,7 @@ def build_list_request( "solutionName": _SERIALIZER.url("solution_name", solution_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -133,6 +133,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get( @@ -165,7 +166,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.IoTSecurityAggregatedRecommendation] = kwargs.pop("cls", None) request = build_get_request( @@ -227,7 +228,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-08-01")) cls: ClsType[_models.IoTSecurityAggregatedRecommendationList] = kwargs.pop("cls", None) error_map = { 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 index 41a478432613..30f987fdc20a 100644 --- 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 @@ -111,43 +111,47 @@ def __init__( 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._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) self.assessments_metadata = AssessmentsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" + ) + self.assessments = AssessmentsOperations( + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) - self.assessments = AssessmentsOperations(self._client, self._config, self._serialize, self._deserialize) self.adaptive_application_controls = AdaptiveApplicationControlsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) self.adaptive_network_hardenings = AdaptiveNetworkHardeningsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) self.allowed_connections = AllowedConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) - self.topology = TopologyOperations(self._client, self._config, self._serialize, self._deserialize) + self.topology = TopologyOperations(self._client, self._config, self._serialize, self._deserialize, "2020-01-01") self.jit_network_access_policies = JitNetworkAccessPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) self.discovered_security_solutions = DiscoveredSecuritySolutionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) self.security_solutions_reference_data = SecuritySolutionsReferenceDataOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) self.external_security_solutions = ExternalSecuritySolutionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" + ) + self.secure_scores = SecureScoresOperations( + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) - self.secure_scores = SecureScoresOperations(self._client, self._config, self._serialize, self._deserialize) self.secure_score_controls = SecureScoreControlsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) self.secure_score_control_definitions = SecureScoreControlDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) self.security_solutions = SecuritySolutionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: 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 index bd0df84f5319..0dafe0e287ff 100644 --- 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 @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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 index 34ea7990c4b4..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" 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 index f2b86b65f4df..6bf93a7eb23d 100644 --- 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 @@ -111,43 +111,47 @@ def __init__( 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._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) self.assessments_metadata = AssessmentsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" + ) + self.assessments = AssessmentsOperations( + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) - self.assessments = AssessmentsOperations(self._client, self._config, self._serialize, self._deserialize) self.adaptive_application_controls = AdaptiveApplicationControlsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) self.adaptive_network_hardenings = AdaptiveNetworkHardeningsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) self.allowed_connections = AllowedConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) - self.topology = TopologyOperations(self._client, self._config, self._serialize, self._deserialize) + self.topology = TopologyOperations(self._client, self._config, self._serialize, self._deserialize, "2020-01-01") self.jit_network_access_policies = JitNetworkAccessPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) self.discovered_security_solutions = DiscoveredSecuritySolutionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) self.security_solutions_reference_data = SecuritySolutionsReferenceDataOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) self.external_security_solutions = ExternalSecuritySolutionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" + ) + self.secure_scores = SecureScoresOperations( + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) - self.secure_scores = SecureScoresOperations(self._client, self._config, self._serialize, self._deserialize) self.secure_score_controls = SecureScoreControlsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) self.secure_score_control_definitions = SecureScoreControlDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) self.security_solutions = SecuritySolutionsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-01-01" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: 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 index 0c893005cfe1..7005a2ed6b0d 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -54,6 +55,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list( @@ -81,7 +83,7 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.AdaptiveApplicationControlGroups] = kwargs.pop("cls", None) request = build_list_request( @@ -141,7 +143,7 @@ async def get(self, asc_location: str, group_name: str, **kwargs: Any) -> _model _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.AdaptiveApplicationControlGroup] = kwargs.pop("cls", None) request = build_get_request( @@ -264,14 +266,14 @@ async def put( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AdaptiveApplicationControlGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "AdaptiveApplicationControlGroup") @@ -340,7 +342,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 index a738d754b02e..c7d49a27eace 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -63,6 +64,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_extended_resource( @@ -89,7 +91,7 @@ def list_by_extended_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.AdaptiveNetworkHardeningsList] = kwargs.pop("cls", None) error_map = { @@ -203,7 +205,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.AdaptiveNetworkHardening] = kwargs.pop("cls", None) request = build_get_request( @@ -267,14 +269,14 @@ async def _enforce_initial( # pylint: disable=inconsistent-return-statements adaptive_network_hardening_enforce_action: Literal["enforce"] = kwargs.pop( "adaptive_network_hardening_enforce_action", "enforce" ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "AdaptiveNetworkHardeningEnforceRequest") @@ -467,7 +469,7 @@ async def begin_enforce( adaptive_network_hardening_enforce_action: Literal["enforce"] = kwargs.pop( "adaptive_network_hardening_enforce_action", "enforce" ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) 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 index 106b9ee6f22f..6ad84d5199cc 100644 --- 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 @@ -56,6 +56,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.AllowedConnectionsResource"]: @@ -71,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.AllowedConnectionsResour _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.AllowedConnectionsList] = kwargs.pop("cls", None) error_map = { @@ -158,7 +159,7 @@ def list_by_home_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.AllowedConnectionsList] = kwargs.pop("cls", None) error_map = { @@ -265,7 +266,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.AllowedConnectionsResource] = kwargs.pop("cls", None) request = build_get_request( 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 index e3d360c8822c..a5a00682c814 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -59,6 +60,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityAssessmentMetadata"]: @@ -74,7 +76,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityAssessmentMetada _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecurityAssessmentMetadataList] = kwargs.pop("cls", None) error_map = { @@ -164,7 +166,7 @@ async def get(self, assessment_metadata_name: str, **kwargs: Any) -> _models.Sec _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecurityAssessmentMetadata] = kwargs.pop("cls", None) request = build_get_request( @@ -211,7 +213,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Security _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecurityAssessmentMetadataList] = kwargs.pop("cls", None) error_map = { @@ -306,7 +308,7 @@ async def get_in_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecurityAssessmentMetadata] = kwargs.pop("cls", None) request = build_get_in_subscription_request( @@ -427,14 +429,14 @@ async def create_in_subscription( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityAssessmentMetadata] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(assessment_metadata, (IO, bytes)): + if isinstance(assessment_metadata, (IOBase, bytes)): _content = assessment_metadata else: _json = self._serialize.body(assessment_metadata, "SecurityAssessmentMetadata") @@ -501,7 +503,7 @@ async def delete_in_subscription( # pylint: disable=inconsistent-return-stateme _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_in_subscription_request( 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 index a673b4fe0361..a8731ec0ff84 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -57,6 +58,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.SecurityAssessment"]: @@ -75,7 +77,7 @@ def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.SecurityAsse _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecurityAssessmentList] = kwargs.pop("cls", None) error_map = { @@ -176,7 +178,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecurityAssessment] = kwargs.pop("cls", None) request = build_get_request( @@ -300,14 +302,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityAssessment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(assessment, (IO, bytes)): + if isinstance(assessment, (IOBase, bytes)): _content = assessment else: _json = self._serialize.body(assessment, "SecurityAssessment") @@ -377,7 +379,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 index 5c40d7e74d87..6b082f82ff07 100644 --- 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 @@ -56,6 +56,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.DiscoveredSecuritySolution"]: @@ -71,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DiscoveredSecuritySoluti _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.DiscoveredSecuritySolutionList] = kwargs.pop("cls", None) error_map = { @@ -158,7 +159,7 @@ def list_by_home_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.DiscoveredSecuritySolutionList] = kwargs.pop("cls", None) error_map = { @@ -259,7 +260,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.DiscoveredSecuritySolution] = kwargs.pop("cls", None) request = build_get_request( 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 index 13f835a5e00d..6703e51b921f 100644 --- 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 @@ -56,6 +56,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.ExternalSecuritySolution"]: @@ -71,7 +72,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ExternalSecuritySolution _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.ExternalSecuritySolutionList] = kwargs.pop("cls", None) error_map = { @@ -158,7 +159,7 @@ def list_by_home_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.ExternalSecuritySolutionList] = kwargs.pop("cls", None) error_map = { @@ -259,7 +260,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.ExternalSecuritySolution] = kwargs.pop("cls", None) request = build_get_request( 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 index 0386c9bd8ecd..e9de36187f50 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -66,6 +67,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.JitNetworkAccessPolicy"]: @@ -81,7 +83,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.JitNetworkAccessPolicy"] _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.JitNetworkAccessPoliciesList] = kwargs.pop("cls", None) error_map = { @@ -167,7 +169,7 @@ def list_by_region(self, asc_location: str, **kwargs: Any) -> AsyncIterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.JitNetworkAccessPoliciesList] = kwargs.pop("cls", None) error_map = { @@ -258,7 +260,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.JitNetworkAccessPoliciesList] = kwargs.pop("cls", None) error_map = { @@ -352,7 +354,7 @@ def list_by_resource_group_and_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.JitNetworkAccessPoliciesList] = kwargs.pop("cls", None) error_map = { @@ -456,7 +458,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.JitNetworkAccessPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -601,14 +603,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JitNetworkAccessPolicy] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "JitNetworkAccessPolicy") @@ -682,7 +684,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -838,14 +840,14 @@ async def initiate( jit_network_access_policy_initiate_type: Literal["initiate"] = kwargs.pop( "jit_network_access_policy_initiate_type", "initiate" ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JitNetworkAccessRequest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "JitNetworkAccessPolicyInitiateRequest") 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 index 35941e80a86f..c26123577f2e 100644 --- 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 @@ -54,6 +54,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.SecureScoreControlDefinitionItem"]: @@ -69,7 +70,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SecureScoreControlDefini _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecureScoreControlDefinitionList] = kwargs.pop("cls", None) error_map = { @@ -151,7 +152,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.SecureSc _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecureScoreControlDefinitionList] = kwargs.pop("cls", None) error_map = { 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 index b65ef6415121..71a7e2bb60f5 100644 --- 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 @@ -51,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_secure_score( @@ -73,7 +74,7 @@ def list_by_secure_score( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecureScoreControlList] = kwargs.pop("cls", None) error_map = { @@ -163,7 +164,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecureScoreControlList] = kwargs.pop("cls", None) error_map = { 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 index ac360aac1c88..fa072107ccd8 100644 --- 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 @@ -52,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.SecureScoreItem"]: @@ -67,7 +68,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SecureScoreItem"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecureScoresList] = kwargs.pop("cls", None) error_map = { @@ -159,7 +160,7 @@ async def get(self, secure_score_name: str, **kwargs: Any) -> _models.SecureScor _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecureScoreItem] = kwargs.pop("cls", None) request = build_get_request( 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 index fe48cc1fe819..0ba42bd86ff2 100644 --- 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 @@ -52,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.SecuritySolution"]: @@ -66,7 +67,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SecuritySolution"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecuritySolutionList] = kwargs.pop("cls", None) error_map = { @@ -164,7 +165,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecuritySolution] = kwargs.pop("cls", None) request = build_get_request( 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 index d00599027088..84e1b45a3206 100644 --- 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 @@ -52,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, **kwargs: Any) -> _models.SecuritySolutionsReferenceDataList: @@ -73,7 +74,7 @@ async def list(self, **kwargs: Any) -> _models.SecuritySolutionsReferenceDataLis _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecuritySolutionsReferenceDataList] = kwargs.pop("cls", None) request = build_list_request( @@ -131,7 +132,7 @@ async def list_by_home_region(self, asc_location: str, **kwargs: Any) -> _models _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecuritySolutionsReferenceDataList] = kwargs.pop("cls", None) request = build_list_by_home_region_request( 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 index 3c45c2f1f8aa..c17ed397796d 100644 --- 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 @@ -61,6 +61,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list_by_extended_resource( @@ -93,7 +94,7 @@ async def list_by_extended_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.ServerVulnerabilityAssessmentsList] = kwargs.pop("cls", None) request = build_list_by_extended_resource_request( @@ -168,7 +169,7 @@ async def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) request = build_get_request( @@ -245,7 +246,7 @@ async def create_or_update( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) request = build_create_or_update_request( @@ -300,7 +301,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -371,7 +372,7 @@ async def begin_delete( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 index b55ba2f85e0f..0ec0d1a6238c 100644 --- 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 @@ -52,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.TopologyResource"]: @@ -66,7 +67,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.TopologyResource"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.TopologyList] = kwargs.pop("cls", None) error_map = { @@ -150,7 +151,7 @@ def list_by_home_region(self, asc_location: str, **kwargs: Any) -> AsyncIterable _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.TopologyList] = kwargs.pop("cls", None) error_map = { @@ -251,7 +252,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.TopologyResource] = kwargs.pop("cls", None) request = build_get_request( 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 index a9ccdc63be3d..3931e141c886 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -25,7 +26,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -57,7 +58,7 @@ def build_list_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -94,7 +95,7 @@ def build_get_request(asc_location: str, group_name: str, subscription_id: str, "groupName": _SERIALIZER.url("group_name", group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -126,7 +127,7 @@ def build_put_request(asc_location: str, group_name: str, subscription_id: str, "groupName": _SERIALIZER.url("group_name", group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -159,7 +160,7 @@ def build_delete_request(asc_location: str, group_name: str, subscription_id: st "groupName": _SERIALIZER.url("group_name", group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -188,6 +189,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -215,7 +217,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.AdaptiveApplicationControlGroups] = kwargs.pop("cls", None) request = build_list_request( @@ -275,7 +277,7 @@ def get(self, asc_location: str, group_name: str, **kwargs: Any) -> _models.Adap _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.AdaptiveApplicationControlGroup] = kwargs.pop("cls", None) request = build_get_request( @@ -398,14 +400,14 @@ def put( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.AdaptiveApplicationControlGroup] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "AdaptiveApplicationControlGroup") @@ -474,7 +476,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 index 43c3b47b2057..48dd7c718856 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,7 +31,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request if sys.version_info >= (3, 8): from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports @@ -74,7 +75,7 @@ def build_list_by_extended_resource_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,7 +121,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -173,7 +174,7 @@ def build_enforce_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -204,6 +205,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_extended_resource( @@ -230,7 +232,7 @@ def list_by_extended_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.AdaptiveNetworkHardeningsList] = kwargs.pop("cls", None) error_map = { @@ -344,7 +346,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.AdaptiveNetworkHardening] = kwargs.pop("cls", None) request = build_get_request( @@ -408,14 +410,14 @@ def _enforce_initial( # pylint: disable=inconsistent-return-statements adaptive_network_hardening_enforce_action: Literal["enforce"] = kwargs.pop( "adaptive_network_hardening_enforce_action", "enforce" ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "AdaptiveNetworkHardeningEnforceRequest") @@ -608,7 +610,7 @@ def begin_enforce( adaptive_network_hardening_enforce_action: Literal["enforce"] = kwargs.pop( "adaptive_network_hardening_enforce_action", "enforce" ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) 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 index e80d0643446d..693db100e653 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +51,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,7 +81,7 @@ def build_list_by_home_region_request(asc_location: str, subscription_id: str, * "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -121,7 +121,7 @@ def build_get_request( "connectionType": _SERIALIZER.url("connection_type", connection_type, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -150,6 +150,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.AllowedConnectionsResource"]: @@ -165,7 +166,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.AllowedConnectionsResource"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.AllowedConnectionsList] = kwargs.pop("cls", None) error_map = { @@ -250,7 +251,7 @@ def list_by_home_region(self, asc_location: str, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.AllowedConnectionsList] = kwargs.pop("cls", None) error_map = { @@ -357,7 +358,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.AllowedConnectionsResource] = kwargs.pop("cls", None) request = build_get_request( 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 index b2cad32e0228..d5ce76282167 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +69,7 @@ def build_get_request(assessment_metadata_name: str, **kwargs: Any) -> HttpReque "assessmentMetadataName": _SERIALIZER.url("assessment_metadata_name", assessment_metadata_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -94,7 +95,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -126,7 +127,7 @@ def build_get_in_subscription_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -159,7 +160,7 @@ def build_create_in_subscription_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -193,7 +194,7 @@ def build_delete_in_subscription_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -222,6 +223,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.SecurityAssessmentMetadata"]: @@ -237,7 +239,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SecurityAssessmentMetadata"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecurityAssessmentMetadataList] = kwargs.pop("cls", None) error_map = { @@ -327,7 +329,7 @@ def get(self, assessment_metadata_name: str, **kwargs: Any) -> _models.SecurityA _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecurityAssessmentMetadata] = kwargs.pop("cls", None) request = build_get_request( @@ -374,7 +376,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SecurityAsses _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecurityAssessmentMetadataList] = kwargs.pop("cls", None) error_map = { @@ -467,7 +469,7 @@ def get_in_subscription(self, assessment_metadata_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecurityAssessmentMetadata] = kwargs.pop("cls", None) request = build_get_in_subscription_request( @@ -588,14 +590,14 @@ def create_in_subscription( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityAssessmentMetadata] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(assessment_metadata, (IO, bytes)): + if isinstance(assessment_metadata, (IOBase, bytes)): _content = assessment_metadata else: _json = self._serialize.body(assessment_metadata, "SecurityAssessmentMetadata") @@ -662,7 +664,7 @@ def delete_in_subscription( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_in_subscription_request( 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 index 306cc0337040..1cdbfda01b54 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +50,7 @@ def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +77,7 @@ def build_get_request( "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -104,7 +105,7 @@ def build_create_or_update_request(resource_id: str, assessment_name: str, **kwa "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -131,7 +132,7 @@ def build_delete_request(resource_id: str, assessment_name: str, **kwargs: Any) "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -160,6 +161,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, scope: str, **kwargs: Any) -> Iterable["_models.SecurityAssessment"]: @@ -178,7 +180,7 @@ def list(self, scope: str, **kwargs: Any) -> Iterable["_models.SecurityAssessmen _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecurityAssessmentList] = kwargs.pop("cls", None) error_map = { @@ -279,7 +281,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecurityAssessment] = kwargs.pop("cls", None) request = build_get_request( @@ -403,14 +405,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityAssessment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(assessment, (IO, bytes)): + if isinstance(assessment, (IOBase, bytes)): _content = assessment else: _json = self._serialize.body(assessment, "SecurityAssessment") @@ -480,7 +482,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 index 924a93438a11..20e737947be8 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +53,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +83,7 @@ def build_list_by_home_region_request(asc_location: str, subscription_id: str, * "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -125,7 +125,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,6 +154,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.DiscoveredSecuritySolution"]: @@ -169,7 +170,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.DiscoveredSecuritySolution"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.DiscoveredSecuritySolutionList] = kwargs.pop("cls", None) error_map = { @@ -254,7 +255,7 @@ def list_by_home_region(self, asc_location: str, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.DiscoveredSecuritySolutionList] = kwargs.pop("cls", None) error_map = { @@ -355,7 +356,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.DiscoveredSecuritySolution] = kwargs.pop("cls", None) request = build_get_request( 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 index 06d8f746b57c..1f1490a551e1 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +53,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +83,7 @@ def build_list_by_home_region_request(asc_location: str, subscription_id: str, * "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -125,7 +125,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,6 +154,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.ExternalSecuritySolution"]: @@ -169,7 +170,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.ExternalSecuritySolution"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.ExternalSecuritySolutionList] = kwargs.pop("cls", None) error_map = { @@ -254,7 +255,7 @@ def list_by_home_region(self, asc_location: str, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.ExternalSecuritySolutionList] = kwargs.pop("cls", None) error_map = { @@ -355,7 +356,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.ExternalSecuritySolution] = kwargs.pop("cls", None) request = build_get_request( 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 index bcf3c5da7047..f9f1fe5d728f 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -28,7 +29,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request if sys.version_info >= (3, 8): from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports @@ -58,7 +59,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -88,7 +89,7 @@ def build_list_by_region_request(asc_location: str, subscription_id: str, **kwar "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -120,7 +121,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -155,7 +156,7 @@ def build_list_by_resource_group_and_region_request( "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -197,7 +198,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -240,7 +241,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -284,7 +285,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -333,7 +334,7 @@ def build_initiate_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -364,6 +365,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.JitNetworkAccessPolicy"]: @@ -379,7 +381,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.JitNetworkAccessPolicy"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.JitNetworkAccessPoliciesList] = kwargs.pop("cls", None) error_map = { @@ -465,7 +467,7 @@ def list_by_region(self, asc_location: str, **kwargs: Any) -> Iterable["_models. _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.JitNetworkAccessPoliciesList] = kwargs.pop("cls", None) error_map = { @@ -556,7 +558,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.JitNetworkAccessPoliciesList] = kwargs.pop("cls", None) error_map = { @@ -650,7 +652,7 @@ def list_by_resource_group_and_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.JitNetworkAccessPoliciesList] = kwargs.pop("cls", None) error_map = { @@ -754,7 +756,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.JitNetworkAccessPolicy] = kwargs.pop("cls", None) request = build_get_request( @@ -899,14 +901,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JitNetworkAccessPolicy] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "JitNetworkAccessPolicy") @@ -980,7 +982,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -1136,14 +1138,14 @@ def initiate( jit_network_access_policy_initiate_type: Literal["initiate"] = kwargs.pop( "jit_network_access_policy_initiate_type", "initiate" ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.JitNetworkAccessRequest] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: _json = self._serialize.body(body, "JitNetworkAccessPolicyInitiateRequest") 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 index a71e28ae3369..4cfb91541f45 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -72,7 +72,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -101,6 +101,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.SecureScoreControlDefinitionItem"]: @@ -116,7 +117,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SecureScoreControlDefinitionI _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecureScoreControlDefinitionList] = kwargs.pop("cls", None) error_map = { @@ -198,7 +199,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SecureScoreCo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecureScoreControlDefinitionList] = kwargs.pop("cls", None) error_map = { 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 index cd4e410b809e..27d39df5e03d 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -61,7 +61,7 @@ def build_list_by_secure_score_request( "secureScoreName": _SERIALIZER.url("secure_score_name", secure_score_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,7 +93,7 @@ def build_list_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -124,6 +124,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_secure_score( @@ -146,7 +147,7 @@ def list_by_secure_score( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecureScoreControlList] = kwargs.pop("cls", None) error_map = { @@ -236,7 +237,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecureScoreControlList] = kwargs.pop("cls", None) error_map = { 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 index 086f693eb890..31685cdff01a 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +51,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +80,7 @@ def build_get_request(secure_score_name: str, subscription_id: str, **kwargs: An "secureScoreName": _SERIALIZER.url("secure_score_name", secure_score_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -109,6 +109,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.SecureScoreItem"]: @@ -123,7 +124,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SecureScoreItem"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecureScoresList] = kwargs.pop("cls", None) error_map = { @@ -215,7 +216,7 @@ def get(self, secure_score_name: str, **kwargs: Any) -> _models.SecureScoreItem: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecureScoreItem] = kwargs.pop("cls", None) request = build_get_request( 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 index 597fd7e3a763..bd172567efa5 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +51,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -87,7 +87,7 @@ def build_get_request( "securitySolutionName": _SERIALIZER.url("security_solution_name", security_solution_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,6 +116,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.SecuritySolution"]: @@ -129,7 +130,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SecuritySolution"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecuritySolutionList] = kwargs.pop("cls", None) error_map = { @@ -227,7 +228,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecuritySolution] = kwargs.pop("cls", None) request = build_get_request( 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 index 5f006c66799c..cd3253dcc51e 100644 --- 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 @@ -25,7 +25,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +51,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,7 +81,7 @@ def build_list_by_home_region_request(asc_location: str, subscription_id: str, * "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -110,6 +110,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> _models.SecuritySolutionsReferenceDataList: @@ -131,7 +132,7 @@ def list(self, **kwargs: Any) -> _models.SecuritySolutionsReferenceDataList: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecuritySolutionsReferenceDataList] = kwargs.pop("cls", None) request = build_list_request( @@ -189,7 +190,7 @@ def list_by_home_region(self, asc_location: str, **kwargs: Any) -> _models.Secur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.SecuritySolutionsReferenceDataList] = kwargs.pop("cls", None) request = build_list_by_home_region_request( 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 index dfe4efc03713..99288deca58c 100644 --- 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 @@ -28,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request if sys.version_info >= (3, 8): from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports @@ -72,7 +72,7 @@ def build_list_by_extended_resource_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -118,7 +118,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -164,7 +164,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -210,7 +210,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -239,6 +239,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_extended_resource( @@ -271,7 +272,7 @@ def list_by_extended_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.ServerVulnerabilityAssessmentsList] = kwargs.pop("cls", None) request = build_list_by_extended_resource_request( @@ -346,7 +347,7 @@ def get( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) request = build_get_request( @@ -423,7 +424,7 @@ def create_or_update( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.ServerVulnerabilityAssessment] = kwargs.pop("cls", None) request = build_create_or_update_request( @@ -478,7 +479,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -549,7 +550,7 @@ def begin_delete( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) server_vulnerability_assessment: Literal["default"] = kwargs.pop("server_vulnerability_assessment", "default") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) 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 index 1c554e6f5a4e..440b0ea85186 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +51,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,7 +81,7 @@ def build_list_by_home_region_request(asc_location: str, subscription_id: str, * "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -117,7 +117,7 @@ def build_get_request( "topologyResourceName": _SERIALIZER.url("topology_resource_name", topology_resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -146,6 +146,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.TopologyResource"]: @@ -159,7 +160,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.TopologyResource"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.TopologyList] = kwargs.pop("cls", None) error_map = { @@ -242,7 +243,7 @@ def list_by_home_region(self, asc_location: str, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.TopologyList] = kwargs.pop("cls", None) error_map = { @@ -343,7 +344,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2020-01-01")) cls: ClsType[_models.TopologyResource] = kwargs.pop("cls", None) request = build_get_request( 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 index 202fd18686be..16927e0eb702 100644 --- 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 @@ -105,6 +105,7 @@ "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" + "connectors": "ConnectorsOperations", + "security_contacts": "SecurityContactsOperations" } } 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 index 37ebc0e8f327..d21f9abf87ca 100644 --- 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 @@ -15,7 +15,7 @@ from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import SecurityCenterConfiguration -from .operations import ConnectorsOperations +from .operations import ConnectorsOperations, SecurityContactsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -27,6 +27,9 @@ class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword :ivar connectors: ConnectorsOperations operations :vartype connectors: azure.mgmt.security.v2020_01_01_preview.operations.ConnectorsOperations + :ivar security_contacts: SecurityContactsOperations operations + :vartype security_contacts: + azure.mgmt.security.v2020_01_01_preview.operations.SecurityContactsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Azure subscription ID. Required. @@ -52,7 +55,12 @@ def __init__( 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) + self.connectors = ConnectorsOperations( + self._client, self._config, self._serialize, self._deserialize, "2020-01-01-preview" + ) + self.security_contacts = SecurityContactsOperations( + self._client, self._config, self._serialize, self._deserialize, "2020-01-01-preview" + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. 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 index bd0df84f5319..0dafe0e287ff 100644 --- 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 @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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 index 34ea7990c4b4..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" 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 index 47854abe0a1f..6109899f868d 100644 --- 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 @@ -15,7 +15,7 @@ from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import SecurityCenterConfiguration -from .operations import ConnectorsOperations +from .operations import ConnectorsOperations, SecurityContactsOperations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -28,6 +28,9 @@ class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword :ivar connectors: ConnectorsOperations operations :vartype connectors: azure.mgmt.security.v2020_01_01_preview.aio.operations.ConnectorsOperations + :ivar security_contacts: SecurityContactsOperations operations + :vartype security_contacts: + azure.mgmt.security.v2020_01_01_preview.aio.operations.SecurityContactsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Azure subscription ID. Required. @@ -53,7 +56,12 @@ def __init__( 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) + self.connectors = ConnectorsOperations( + self._client, self._config, self._serialize, self._deserialize, "2020-01-01-preview" + ) + self.security_contacts = SecurityContactsOperations( + self._client, self._config, self._serialize, self._deserialize, "2020-01-01-preview" + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. 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 index 28d52bdd565d..48244779e87d 100644 --- 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from ._connectors_operations import ConnectorsOperations +from ._security_contacts_operations import SecurityContactsOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -14,6 +15,7 @@ __all__ = [ "ConnectorsOperations", + "SecurityContactsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_connectors_operations.py index 66cb59276b43..408a35505d9b 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -57,6 +58,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.ConnectorSetting"]: @@ -71,7 +73,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ConnectorSetting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") + ) cls: ClsType[_models.ConnectorSettingList] = kwargs.pop("cls", None) error_map = { @@ -161,7 +165,9 @@ async def get(self, connector_name: str, **kwargs: Any) -> _models.ConnectorSett _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") + ) cls: ClsType[_models.ConnectorSetting] = kwargs.pop("cls", None) request = build_get_request( @@ -274,14 +280,16 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ConnectorSetting] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(connector_setting, (IO, bytes)): + if isinstance(connector_setting, (IOBase, bytes)): _content = connector_setting else: _json = self._serialize.body(connector_setting, "ConnectorSetting") @@ -346,7 +354,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_security_contacts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_security_contacts_operations.py new file mode 100644 index 000000000000..80731f8bb1b8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_security_contacts_operations.py @@ -0,0 +1,389 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._security_contacts_operations import ( + build_create_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 SecurityContactsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2020_01_01_preview.aio.SecurityCenter`'s + :attr:`security_contacts` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityContact"]: + """List all security contact configurations for the subscription. + + :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.v2020_01_01_preview.models.SecurityContact] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") + ) + cls: ClsType[_models.SecurityContactList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityContactList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts"} + + @distributed_trace_async + async def get(self, security_contact_name: str, **kwargs: Any) -> _models.SecurityContact: + """Get Default Security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. Required. + :type security_contact_name: str + :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.v2020_01_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: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") + ) + cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) + + request = build_get_request( + security_contact_name=security_contact_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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}" + } + + @overload + async def create( + self, + security_contact_name: str, + security_contact: _models.SecurityContact, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityContact: + """Create security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. Required. + :type security_contact_name: str + :param security_contact: Security contact object. Required. + :type security_contact: ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContact + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2020_01_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: + """Create security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. Required. + :type security_contact_name: str + :param security_contact: Security contact object. Required. + :type security_contact: IO + :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.v2020_01_01_preview.models.SecurityContact + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, security_contact_name: str, security_contact: Union[_models.SecurityContact, IO], **kwargs: Any + ) -> _models.SecurityContact: + """Create security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. Required. + :type security_contact_name: str + :param security_contact: Security contact object. Is either a SecurityContact type or a IO + type. Required. + :type security_contact: ~azure.mgmt.security.v2020_01_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.v2020_01_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: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_contact, (IOBase, bytes)): + _content = security_contact + else: + _json = self._serialize.body(security_contact, "SecurityContact") + + request = build_create_request( + security_contact_name=security_contact_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SecurityContact", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SecurityContact", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, security_contact_name: str, **kwargs: Any + ) -> None: + """Delete security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. Required. + :type security_contact_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + security_contact_name=security_contact_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}" + } 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 index ddfe12e9e53d..02d587c315da 100644 --- 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 @@ -17,13 +17,20 @@ from ._models_py3 import HybridComputeSettingsProperties from ._models_py3 import ProxyServerProperties from ._models_py3 import Resource +from ._models_py3 import SecurityContact +from ._models_py3 import SecurityContactList +from ._models_py3 import SecurityContactPropertiesAlertNotifications +from ._models_py3 import SecurityContactPropertiesNotificationsByRole from ._models_py3 import ServicePrincipalProperties from ._security_center_enums import AuthenticationProvisioningState from ._security_center_enums import AuthenticationType from ._security_center_enums import AutoProvision from ._security_center_enums import HybridComputeProvisioningState +from ._security_center_enums import MinimalSeverity from ._security_center_enums import PermissionProperty +from ._security_center_enums import Roles +from ._security_center_enums import State from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk @@ -40,12 +47,19 @@ "HybridComputeSettingsProperties", "ProxyServerProperties", "Resource", + "SecurityContact", + "SecurityContactList", + "SecurityContactPropertiesAlertNotifications", + "SecurityContactPropertiesNotificationsByRole", "ServicePrincipalProperties", "AuthenticationProvisioningState", "AuthenticationType", "AutoProvision", "HybridComputeProvisioningState", + "MinimalSeverity", "PermissionProperty", + "Roles", + "State", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_models_py3.py index 6723a290455e..213bdb1f8aaf 100644 --- 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 @@ -641,6 +641,188 @@ def __init__(self, *, ip: Optional[str] = None, port: Optional[str] = None, **kw self.port = port +class SecurityContact(Resource): + """Contact details and configurations for notifications coming from Microsoft Defender for Cloud. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar emails: List of email addresses which will get notifications from Microsoft Defender for + Cloud by the configurations defined in this security contact. + :vartype emails: str + :ivar phone: The security contact's phone number. + :vartype phone: str + :ivar alert_notifications: Defines whether to send email notifications about new security + alerts. + :vartype alert_notifications: + ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContactPropertiesAlertNotifications + :ivar notifications_by_role: Defines whether to send email notifications from Microsoft + Defender for Cloud to persons with specific RBAC roles on the subscription. + :vartype notifications_by_role: + ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContactPropertiesNotificationsByRole + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "emails": {"key": "properties.emails", "type": "str"}, + "phone": {"key": "properties.phone", "type": "str"}, + "alert_notifications": { + "key": "properties.alertNotifications", + "type": "SecurityContactPropertiesAlertNotifications", + }, + "notifications_by_role": { + "key": "properties.notificationsByRole", + "type": "SecurityContactPropertiesNotificationsByRole", + }, + } + + def __init__( + self, + *, + emails: Optional[str] = None, + phone: Optional[str] = None, + alert_notifications: Optional["_models.SecurityContactPropertiesAlertNotifications"] = None, + notifications_by_role: Optional["_models.SecurityContactPropertiesNotificationsByRole"] = None, + **kwargs: Any + ) -> None: + """ + :keyword emails: List of email addresses which will get notifications from Microsoft Defender + for Cloud by the configurations defined in this security contact. + :paramtype emails: str + :keyword phone: The security contact's phone number. + :paramtype phone: str + :keyword alert_notifications: Defines whether to send email notifications about new security + alerts. + :paramtype alert_notifications: + ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContactPropertiesAlertNotifications + :keyword notifications_by_role: Defines whether to send email notifications from Microsoft + Defender for Cloud to persons with specific RBAC roles on the subscription. + :paramtype notifications_by_role: + ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContactPropertiesNotificationsByRole + """ + super().__init__(**kwargs) + self.emails = emails + self.phone = phone + self.alert_notifications = alert_notifications + self.notifications_by_role = notifications_by_role + + +class SecurityContactList(_serialization.Model): + """List of security contacts response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of security contacts. + :vartype value: list[~azure.mgmt.security.v2020_01_01_preview.models.SecurityContact] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SecurityContact]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class SecurityContactPropertiesAlertNotifications(_serialization.Model): + """Defines whether to send email notifications about new security alerts. + + :ivar state: Defines if email notifications will be sent about new security alerts. Known + values are: "On" and "Off". + :vartype state: str or ~azure.mgmt.security.v2020_01_01_preview.models.State + :ivar minimal_severity: Defines the minimal alert severity which will be sent as email + notifications. Known values are: "High", "Medium", and "Low". + :vartype minimal_severity: str or + ~azure.mgmt.security.v2020_01_01_preview.models.MinimalSeverity + """ + + _attribute_map = { + "state": {"key": "state", "type": "str"}, + "minimal_severity": {"key": "minimalSeverity", "type": "str"}, + } + + def __init__( + self, + *, + state: Optional[Union[str, "_models.State"]] = None, + minimal_severity: Optional[Union[str, "_models.MinimalSeverity"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword state: Defines if email notifications will be sent about new security alerts. Known + values are: "On" and "Off". + :paramtype state: str or ~azure.mgmt.security.v2020_01_01_preview.models.State + :keyword minimal_severity: Defines the minimal alert severity which will be sent as email + notifications. Known values are: "High", "Medium", and "Low". + :paramtype minimal_severity: str or + ~azure.mgmt.security.v2020_01_01_preview.models.MinimalSeverity + """ + super().__init__(**kwargs) + self.state = state + self.minimal_severity = minimal_severity + + +class SecurityContactPropertiesNotificationsByRole(_serialization.Model): + """Defines whether to send email notifications from Microsoft Defender for Cloud to persons with + specific RBAC roles on the subscription. + + :ivar state: Defines whether to send email notifications from AMicrosoft Defender for Cloud to + persons with specific RBAC roles on the subscription. Known values are: "On" and "Off". + :vartype state: str or ~azure.mgmt.security.v2020_01_01_preview.models.State + :ivar roles: Defines which RBAC roles will get email notifications from Microsoft Defender for + Cloud. List of allowed RBAC roles:. + :vartype roles: list[str or ~azure.mgmt.security.v2020_01_01_preview.models.Roles] + """ + + _attribute_map = { + "state": {"key": "state", "type": "str"}, + "roles": {"key": "roles", "type": "[str]"}, + } + + def __init__( + self, + *, + state: Optional[Union[str, "_models.State"]] = None, + roles: Optional[List[Union[str, "_models.Roles"]]] = None, + **kwargs: Any + ) -> None: + """ + :keyword state: Defines whether to send email notifications from AMicrosoft Defender for Cloud + to persons with specific RBAC roles on the subscription. Known values are: "On" and "Off". + :paramtype state: str or ~azure.mgmt.security.v2020_01_01_preview.models.State + :keyword roles: Defines which RBAC roles will get email notifications from Microsoft Defender + for Cloud. List of allowed RBAC roles:. + :paramtype roles: list[str or ~azure.mgmt.security.v2020_01_01_preview.models.Roles] + """ + super().__init__(**kwargs) + self.state = state + self.roles = roles + + class ServicePrincipalProperties(_serialization.Model): """Details of the service principal. 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 index ba41abf7907c..b07acd420f4f 100644 --- 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 @@ -56,6 +56,17 @@ class HybridComputeProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMet """the service principal details are expired""" +class MinimalSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the minimal alert severity which will be sent as email notifications.""" + + HIGH = "High" + """Get notifications on new alerts with High severity""" + MEDIUM = "Medium" + """Get notifications on new alerts with medium or high severity""" + LOW = "Low" + """Don't get notifications on new alerts with low, medium or high severity""" + + class PermissionProperty(str, Enum, metaclass=CaseInsensitiveEnumMeta): """A permission detected in the cloud account.""" @@ -68,3 +79,25 @@ class PermissionProperty(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: Automation documents.""" GCP_SECURITY_CENTER_ADMIN_VIEWER = "GCP::Security Center Admin Viewer" """This permission provides read only access to GCP Security Command Center.""" + + +class Roles(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """A possible role to configure sending security notification alerts to.""" + + ACCOUNT_ADMIN = "AccountAdmin" + """If enabled, send notification on new alerts to the account admins""" + SERVICE_ADMIN = "ServiceAdmin" + """If enabled, send notification on new alerts to the service admins""" + OWNER = "Owner" + """If enabled, send notification on new alerts to the subscription owners""" + CONTRIBUTOR = "Contributor" + """If enabled, send notification on new alerts to the subscription contributors""" + + +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines if email notifications will be sent about new security alerts.""" + + ON = "On" + """Get notifications on new alerts""" + OFF = "Off" + """Don't get notifications on new alerts""" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/__init__.py index 28d52bdd565d..48244779e87d 100644 --- 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from ._connectors_operations import ConnectorsOperations +from ._security_contacts_operations import SecurityContactsOperations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -14,6 +15,7 @@ __all__ = [ "ConnectorsOperations", + "SecurityContactsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_connectors_operations.py index 5e0b4a07df98..8d84b416ce2d 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +52,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +81,7 @@ def build_get_request(connector_name: str, subscription_id: str, **kwargs: Any) "connectorName": _SERIALIZER.url("connector_name", connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -110,7 +111,7 @@ def build_create_or_update_request(connector_name: str, subscription_id: str, ** "connectorName": _SERIALIZER.url("connector_name", connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -141,7 +142,7 @@ def build_delete_request(connector_name: str, subscription_id: str, **kwargs: An "connectorName": _SERIALIZER.url("connector_name", connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -170,6 +171,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.ConnectorSetting"]: @@ -184,7 +186,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.ConnectorSetting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") + ) cls: ClsType[_models.ConnectorSettingList] = kwargs.pop("cls", None) error_map = { @@ -274,7 +278,9 @@ def get(self, connector_name: str, **kwargs: Any) -> _models.ConnectorSetting: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") + ) cls: ClsType[_models.ConnectorSetting] = kwargs.pop("cls", None) request = build_get_request( @@ -387,14 +393,16 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.ConnectorSetting] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(connector_setting, (IO, bytes)): + if isinstance(connector_setting, (IOBase, bytes)): _content = connector_setting else: _json = self._serialize.body(connector_setting, "ConnectorSetting") @@ -457,7 +465,9 @@ def delete(self, connector_name: str, **kwargs: Any) -> None: # pylint: disable _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_security_contacts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_security_contacts_operations.py new file mode 100644 index 000000000000..6c4118858433 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_security_contacts_operations.py @@ -0,0 +1,505 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _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(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(security_contact_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "securityContactName": _SERIALIZER.url("security_contact_name", security_contact_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request(security_contact_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "securityContactName": _SERIALIZER.url("security_contact_name", security_contact_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(security_contact_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "securityContactName": _SERIALIZER.url("security_contact_name", security_contact_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class SecurityContactsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2020_01_01_preview.SecurityCenter`'s + :attr:`security_contacts` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.SecurityContact"]: + """List all security contact configurations for the subscription. + + :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.v2020_01_01_preview.models.SecurityContact] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") + ) + cls: ClsType[_models.SecurityContactList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityContactList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts"} + + @distributed_trace + def get(self, security_contact_name: str, **kwargs: Any) -> _models.SecurityContact: + """Get Default Security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. Required. + :type security_contact_name: str + :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.v2020_01_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: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") + ) + cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) + + request = build_get_request( + security_contact_name=security_contact_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + 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}" + } + + @overload + def create( + self, + security_contact_name: str, + security_contact: _models.SecurityContact, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityContact: + """Create security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. Required. + :type security_contact_name: str + :param security_contact: Security contact object. Required. + :type security_contact: ~azure.mgmt.security.v2020_01_01_preview.models.SecurityContact + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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.v2020_01_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: + """Create security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. Required. + :type security_contact_name: str + :param security_contact: Security contact object. Required. + :type security_contact: IO + :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.v2020_01_01_preview.models.SecurityContact + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, security_contact_name: str, security_contact: Union[_models.SecurityContact, IO], **kwargs: Any + ) -> _models.SecurityContact: + """Create security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. Required. + :type security_contact_name: str + :param security_contact: Security contact object. Is either a SecurityContact type or a IO + type. Required. + :type security_contact: ~azure.mgmt.security.v2020_01_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.v2020_01_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: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityContact] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_contact, (IOBase, bytes)): + _content = security_contact + else: + _json = self._serialize.body(security_contact, "SecurityContact") + + request = build_create_request( + security_contact_name=security_contact_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SecurityContact", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SecurityContact", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, security_contact_name: str, **kwargs: Any + ) -> None: + """Delete security contact configurations for the subscription. + + :param security_contact_name: Name of the security contact object. Required. + :type security_contact_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + security_contact_name=security_contact_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityContacts/{securityContactName}" + } 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 index 9f6225154e67..68cfa262b59c 100644 --- 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 @@ -60,13 +60,13 @@ def __init__( 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._client, self._config, self._serialize, self._deserialize, "2020-07-01-preview" ) self.sql_vulnerability_assessment_scan_results = SqlVulnerabilityAssessmentScanResultsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-07-01-preview" ) self.sql_vulnerability_assessment_baseline_rules = SqlVulnerabilityAssessmentBaselineRulesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-07-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: 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 index bd0df84f5319..0dafe0e287ff 100644 --- 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 @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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 index 34ea7990c4b4..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" 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 index b59faaee9dad..416e83bd09b2 100644 --- 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 @@ -60,13 +60,13 @@ def __init__( 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._client, self._config, self._serialize, self._deserialize, "2020-07-01-preview" ) self.sql_vulnerability_assessment_scan_results = SqlVulnerabilityAssessmentScanResultsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-07-01-preview" ) self.sql_vulnerability_assessment_baseline_rules = SqlVulnerabilityAssessmentBaselineRulesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2020-07-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: 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 index 1db2c9c89b9c..4f52169a2a51 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -55,6 +56,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload async def create_or_update( @@ -161,14 +163,16 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: @@ -241,7 +245,9 @@ async def get(self, rule_id: str, workspace_id: str, resource_id: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") + ) cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) request = build_get_request( @@ -308,7 +314,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -367,7 +375,9 @@ async def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _mod _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") + ) cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) request = build_list_request( @@ -499,14 +509,16 @@ async def add( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: 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 index 667becc45360..cbc35a2e4876 100644 --- 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 @@ -49,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( @@ -83,7 +84,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") + ) cls: ClsType[_models.ScanResult] = kwargs.pop("cls", None) request = build_get_request( @@ -150,7 +153,9 @@ async def list(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") + ) cls: ClsType[_models.ScanResults] = kwargs.pop("cls", None) request = build_list_request( 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 index 16a64e40c567..f5e9772fd02d 100644 --- 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 @@ -49,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Scan: @@ -79,7 +80,9 @@ async def get(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") + ) cls: ClsType[_models.Scan] = kwargs.pop("cls", None) request = build_get_request( @@ -142,7 +145,9 @@ async def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _mod _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") + ) cls: ClsType[_models.Scans] = kwargs.pop("cls", None) request = build_list_request( 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 index f739e23204a9..2dbe14e24f6d 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -25,7 +26,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +53,7 @@ def build_create_or_update_request(rule_id: str, resource_id: str, *, workspace_ "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") @@ -83,7 +84,7 @@ def build_get_request(rule_id: str, resource_id: str, *, workspace_id: str, **kw "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") @@ -112,7 +113,7 @@ def build_delete_request(rule_id: str, resource_id: str, *, workspace_id: str, * "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") @@ -139,7 +140,7 @@ def build_list_request(resource_id: str, *, workspace_id: str, **kwargs: Any) -> "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") @@ -167,7 +168,7 @@ def build_add_request(resource_id: str, *, workspace_id: str, **kwargs: Any) -> "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") @@ -199,6 +200,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload def create_or_update( @@ -305,14 +307,16 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: @@ -385,7 +389,9 @@ def get(self, rule_id: str, workspace_id: str, resource_id: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") + ) cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) request = build_get_request( @@ -452,7 +458,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -511,7 +519,9 @@ def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Ru _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") + ) cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) request = build_list_request( @@ -643,14 +653,16 @@ def add( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: 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 index 84c89fcdc9ed..0303dab17f86 100644 --- 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 @@ -25,7 +25,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +54,7 @@ def build_get_request( "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") @@ -83,7 +83,7 @@ def build_list_request(scan_id: str, resource_id: str, *, workspace_id: str, **k "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") @@ -113,6 +113,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get( @@ -147,7 +148,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") + ) cls: ClsType[_models.ScanResult] = kwargs.pop("cls", None) request = build_get_request( @@ -214,7 +217,9 @@ def list(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") + ) cls: ClsType[_models.ScanResults] = kwargs.pop("cls", None) request = build_list_request( 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 index 349437506b57..42c7e607ab8e 100644 --- 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 @@ -25,7 +25,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +50,7 @@ def build_get_request(scan_id: str, resource_id: str, *, workspace_id: str, **kw "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") @@ -77,7 +77,7 @@ def build_list_request(resource_id: str, *, workspace_id: str, **kwargs: Any) -> "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") @@ -107,6 +107,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Scan: @@ -137,7 +138,9 @@ def get(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") + ) cls: ClsType[_models.Scan] = kwargs.pop("cls", None) request = build_get_request( @@ -200,7 +203,9 @@ def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Sc _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2020-07-01-preview") + ) cls: ClsType[_models.Scans] = kwargs.pop("cls", None) request = build_list_request( 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 index 2a0107428ab7..377858b32833 100644 --- 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 @@ -54,7 +54,7 @@ def __init__( 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) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize, "2021-01-01") def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. 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 index bd0df84f5319..0dafe0e287ff 100644 --- 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 @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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 index 34ea7990c4b4..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" 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 index 8ebe160cdf4f..feb2f0faa41b 100644 --- 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 @@ -54,7 +54,7 @@ def __init__( 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) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize, "2021-01-01") def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. 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 index e39d5f37ae0e..acdf741c8d34 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -68,6 +69,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Alert"]: @@ -81,7 +83,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Alert"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) error_map = { @@ -164,7 +166,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) error_map = { @@ -251,7 +253,7 @@ def list_subscription_level_by_region(self, asc_location: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) error_map = { @@ -343,7 +345,7 @@ def list_resource_group_level_by_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) error_map = { @@ -440,7 +442,7 @@ async def get_subscription_level(self, asc_location: str, alert_name: str, **kwa _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) request = build_get_subscription_level_request( @@ -507,7 +509,7 @@ async def get_resource_group_level( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) request = build_get_resource_group_level_request( @@ -572,7 +574,7 @@ async def update_subscription_level_state_to_dismiss( # pylint: disable=inconsi _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_subscription_level_state_to_dismiss_request( @@ -632,7 +634,7 @@ async def update_subscription_level_state_to_resolve( # pylint: disable=inconsi _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_subscription_level_state_to_resolve_request( @@ -692,7 +694,7 @@ async def update_subscription_level_state_to_activate( # pylint: disable=incons _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_subscription_level_state_to_activate_request( @@ -755,7 +757,7 @@ async def update_resource_group_level_state_to_resolve( # pylint: disable=incon _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_resource_group_level_state_to_resolve_request( @@ -819,7 +821,7 @@ async def update_resource_group_level_state_to_dismiss( # pylint: disable=incon _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_resource_group_level_state_to_dismiss_request( @@ -883,7 +885,7 @@ async def update_resource_group_level_state_to_activate( # pylint: disable=inco _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_resource_group_level_state_to_activate_request( @@ -934,14 +936,14 @@ async def _simulate_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(alert_simulator_request_body, (IO, bytes)): + if isinstance(alert_simulator_request_body, (IOBase, bytes)): _content = alert_simulator_request_body else: _json = self._serialize.body(alert_simulator_request_body, "AlertSimulatorRequestBody") @@ -1077,7 +1079,7 @@ async def begin_simulate( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) 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 index f12a1ef841c6..d1a43ef59ceb 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -29,7 +30,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +54,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -85,7 +86,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +117,7 @@ def build_list_subscription_level_by_region_request( "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -151,7 +152,7 @@ def build_list_resource_group_level_by_region_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -184,7 +185,7 @@ def build_get_subscription_level_request( "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -220,7 +221,7 @@ def build_get_resource_group_level_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -253,7 +254,7 @@ def build_update_subscription_level_state_to_dismiss_request( "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -286,7 +287,7 @@ def build_update_subscription_level_state_to_resolve_request( "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -319,7 +320,7 @@ def build_update_subscription_level_state_to_activate_request( "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -355,7 +356,7 @@ def build_update_resource_group_level_state_to_resolve_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -391,7 +392,7 @@ def build_update_resource_group_level_state_to_dismiss_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -427,7 +428,7 @@ def build_update_resource_group_level_state_to_activate_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -458,7 +459,7 @@ def build_simulate_request(asc_location: str, subscription_id: str, **kwargs: An "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -489,6 +490,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Alert"]: @@ -502,7 +504,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Alert"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) error_map = { @@ -585,7 +587,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) error_map = { @@ -672,7 +674,7 @@ def list_subscription_level_by_region(self, asc_location: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) error_map = { @@ -764,7 +766,7 @@ def list_resource_group_level_by_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) error_map = { @@ -861,7 +863,7 @@ def get_subscription_level(self, asc_location: str, alert_name: str, **kwargs: A _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) request = build_get_subscription_level_request( @@ -928,7 +930,7 @@ def get_resource_group_level( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) request = build_get_resource_group_level_request( @@ -993,7 +995,7 @@ def update_subscription_level_state_to_dismiss( # pylint: disable=inconsistent- _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_subscription_level_state_to_dismiss_request( @@ -1053,7 +1055,7 @@ def update_subscription_level_state_to_resolve( # pylint: disable=inconsistent- _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_subscription_level_state_to_resolve_request( @@ -1113,7 +1115,7 @@ def update_subscription_level_state_to_activate( # pylint: disable=inconsistent _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_subscription_level_state_to_activate_request( @@ -1176,7 +1178,7 @@ def update_resource_group_level_state_to_resolve( # pylint: disable=inconsisten _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_resource_group_level_state_to_resolve_request( @@ -1240,7 +1242,7 @@ def update_resource_group_level_state_to_dismiss( # pylint: disable=inconsisten _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_resource_group_level_state_to_dismiss_request( @@ -1304,7 +1306,7 @@ def update_resource_group_level_state_to_activate( # pylint: disable=inconsiste _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_resource_group_level_state_to_activate_request( @@ -1355,14 +1357,14 @@ def _simulate_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(alert_simulator_request_body, (IO, bytes)): + if isinstance(alert_simulator_request_body, (IOBase, bytes)): _content = alert_simulator_request_body else: _json = self._serialize.body(alert_simulator_request_body, "AlertSimulatorRequestBody") @@ -1498,7 +1500,7 @@ def begin_simulate( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) 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 index 27780ae9c76c..f0f08b4573ee 100644 --- 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 @@ -54,7 +54,7 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.software_inventories = SoftwareInventoriesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-05-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: 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 index bd0df84f5319..0dafe0e287ff 100644 --- 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 @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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 index 34ea7990c4b4..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" 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 index a0b8ce433c53..94742b63f8cd 100644 --- 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 @@ -54,7 +54,7 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.software_inventories = SoftwareInventoriesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-05-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: 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 index 55d9059512fc..addcebdab504 100644 --- 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 @@ -56,6 +56,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_extended_resource( @@ -81,7 +82,9 @@ def list_by_extended_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-05-01-preview") + ) cls: ClsType[_models.SoftwaresList] = kwargs.pop("cls", None) error_map = { @@ -168,7 +171,9 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Software _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-05-01-preview") + ) cls: ClsType[_models.SoftwaresList] = kwargs.pop("cls", None) error_map = { @@ -277,7 +282,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-05-01-preview") + ) cls: ClsType[_models.Software] = kwargs.pop("cls", None) request = build_get_request( 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 index 1e3401d56c93..9383e076aaf7 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -67,7 +67,7 @@ def build_list_by_extended_resource_request( "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -95,7 +95,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -139,7 +139,7 @@ def build_get_request( "softwareName": _SERIALIZER.url("software_name", software_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -168,6 +168,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list_by_extended_resource( @@ -192,7 +193,9 @@ def list_by_extended_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-05-01-preview") + ) cls: ClsType[_models.SoftwaresList] = kwargs.pop("cls", None) error_map = { @@ -278,7 +281,9 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Software"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-05-01-preview") + ) cls: ClsType[_models.SoftwaresList] = kwargs.pop("cls", None) error_map = { @@ -387,7 +392,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-05-01-preview") + ) cls: ClsType[_models.Software] = kwargs.pop("cls", None) request = build_get_request( 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 index 472f73f3bfb2..b8bcb4717fd8 100644 --- 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 @@ -57,11 +57,13 @@ def __init__( 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.settings = SettingsOperations(self._client, self._config, self._serialize, self._deserialize, "2021-06-01") self.assessments_metadata = AssessmentsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-06-01" + ) + self.assessments = AssessmentsOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-06-01" ) - self.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. 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 index bd0df84f5319..0dafe0e287ff 100644 --- 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 @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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 index 34ea7990c4b4..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" 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 index 816012d6b27b..0e59c51c1035 100644 --- 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 @@ -57,11 +57,13 @@ def __init__( 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.settings = SettingsOperations(self._client, self._config, self._serialize, self._deserialize, "2021-06-01") self.assessments_metadata = AssessmentsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-06-01" + ) + self.assessments = AssessmentsOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-06-01" ) - self.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. 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 index 07c54f8c18bd..c4fb79913196 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -59,6 +60,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityAssessmentMetadataResponse"]: @@ -74,7 +76,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityAssessmentMetada _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.SecurityAssessmentMetadataResponseList] = kwargs.pop("cls", None) error_map = { @@ -164,7 +166,7 @@ async def get(self, assessment_metadata_name: str, **kwargs: Any) -> _models.Sec _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.SecurityAssessmentMetadataResponse] = kwargs.pop("cls", None) request = build_get_request( @@ -211,7 +213,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Security _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.SecurityAssessmentMetadataResponseList] = kwargs.pop("cls", None) error_map = { @@ -306,7 +308,7 @@ async def get_in_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.SecurityAssessmentMetadataResponse] = kwargs.pop("cls", None) request = build_get_in_subscription_request( @@ -428,14 +430,14 @@ async def create_in_subscription( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityAssessmentMetadataResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(assessment_metadata, (IO, bytes)): + if isinstance(assessment_metadata, (IOBase, bytes)): _content = assessment_metadata else: _json = self._serialize.body(assessment_metadata, "SecurityAssessmentMetadataResponse") @@ -502,7 +504,7 @@ async def delete_in_subscription( # pylint: disable=inconsistent-return-stateme _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_in_subscription_request( 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 index 7fa59db0461c..036a252c9f19 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -57,6 +58,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.SecurityAssessmentResponse"]: @@ -76,7 +78,7 @@ def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.SecurityAsse _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.SecurityAssessmentList] = kwargs.pop("cls", None) error_map = { @@ -177,7 +179,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.SecurityAssessmentResponse] = kwargs.pop("cls", None) request = build_get_request( @@ -301,14 +303,14 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityAssessmentResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(assessment, (IO, bytes)): + if isinstance(assessment, (IOBase, bytes)): _content = assessment else: _json = self._serialize.body(assessment, "SecurityAssessment") @@ -378,7 +380,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 index 7647a22e665c..5a5719ba1f69 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -52,6 +53,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Setting"]: @@ -66,7 +68,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Setting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.SettingsList] = kwargs.pop("cls", None) error_map = { @@ -157,7 +159,7 @@ async def get(self, setting_name: Union[str, _models.Enum1], **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.Setting] = kwargs.pop("cls", None) request = build_get_request( @@ -271,14 +273,14 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Setting] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(setting, (IO, bytes)): + if isinstance(setting, (IOBase, bytes)): _content = setting else: _json = self._serialize.body(setting, "Setting") 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 index e56ee1a87d7f..2c286d023d43 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +69,7 @@ def build_get_request(assessment_metadata_name: str, **kwargs: Any) -> HttpReque "assessmentMetadataName": _SERIALIZER.url("assessment_metadata_name", assessment_metadata_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -94,7 +95,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -126,7 +127,7 @@ def build_get_in_subscription_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -159,7 +160,7 @@ def build_create_in_subscription_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -193,7 +194,7 @@ def build_delete_in_subscription_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -222,6 +223,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.SecurityAssessmentMetadataResponse"]: @@ -237,7 +239,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SecurityAssessmentMetadataRes _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.SecurityAssessmentMetadataResponseList] = kwargs.pop("cls", None) error_map = { @@ -327,7 +329,7 @@ def get(self, assessment_metadata_name: str, **kwargs: Any) -> _models.SecurityA _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.SecurityAssessmentMetadataResponse] = kwargs.pop("cls", None) request = build_get_request( @@ -374,7 +376,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SecurityAsses _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.SecurityAssessmentMetadataResponseList] = kwargs.pop("cls", None) error_map = { @@ -469,7 +471,7 @@ def get_in_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.SecurityAssessmentMetadataResponse] = kwargs.pop("cls", None) request = build_get_in_subscription_request( @@ -591,14 +593,14 @@ def create_in_subscription( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityAssessmentMetadataResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(assessment_metadata, (IO, bytes)): + if isinstance(assessment_metadata, (IOBase, bytes)): _content = assessment_metadata else: _json = self._serialize.body(assessment_metadata, "SecurityAssessmentMetadataResponse") @@ -665,7 +667,7 @@ def delete_in_subscription( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_in_subscription_request( 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 index ab971d6c63bd..5f5d9629341b 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +50,7 @@ def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +77,7 @@ def build_get_request( "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -104,7 +105,7 @@ def build_create_or_update_request(resource_id: str, assessment_name: str, **kwa "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -131,7 +132,7 @@ def build_delete_request(resource_id: str, assessment_name: str, **kwargs: Any) "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -160,6 +161,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, scope: str, **kwargs: Any) -> Iterable["_models.SecurityAssessmentResponse"]: @@ -179,7 +181,7 @@ def list(self, scope: str, **kwargs: Any) -> Iterable["_models.SecurityAssessmen _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.SecurityAssessmentList] = kwargs.pop("cls", None) error_map = { @@ -280,7 +282,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.SecurityAssessmentResponse] = kwargs.pop("cls", None) request = build_get_request( @@ -404,14 +406,14 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityAssessmentResponse] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(assessment, (IO, bytes)): + if isinstance(assessment, (IOBase, bytes)): _content = assessment else: _json = self._serialize.body(assessment, "SecurityAssessment") @@ -481,7 +483,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( 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 index 7daa51ca5a64..37cd35997a51 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +52,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +81,7 @@ def build_get_request(setting_name: Union[str, _models.Enum1], subscription_id: "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -110,7 +111,7 @@ def build_update_request(setting_name: Union[str, _models.Enum1], subscription_i "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -141,6 +142,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Setting"]: @@ -154,7 +156,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Setting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.SettingsList] = kwargs.pop("cls", None) error_map = { @@ -245,7 +247,7 @@ def get(self, setting_name: Union[str, _models.Enum1], **kwargs: Any) -> _models _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) cls: ClsType[_models.Setting] = kwargs.pop("cls", None) request = build_get_request( @@ -359,14 +361,14 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-06-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Setting] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(setting, (IO, bytes)): + if isinstance(setting, (IOBase, bytes)): _content = setting else: _json = self._serialize.body(setting, "Setting") 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 index d75ba09255ac..fe978e6cfebc 100644 --- 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 @@ -52,7 +52,7 @@ def __init__( 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.settings = SettingsOperations(self._client, self._config, self._serialize, self._deserialize, "2021-07-01") def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. 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 index bd0df84f5319..0dafe0e287ff 100644 --- 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 @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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 index 34ea7990c4b4..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" 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 index 0d23488186e4..6718d6473cf0 100644 --- 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 @@ -52,7 +52,7 @@ def __init__( 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.settings = SettingsOperations(self._client, self._config, self._serialize, self._deserialize, "2021-07-01") def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. 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 index 2766b2a31f5b..8f904625584c 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -52,6 +53,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Setting"]: @@ -66,7 +68,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Setting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.SettingsList] = kwargs.pop("cls", None) error_map = { @@ -157,7 +159,7 @@ async def get(self, setting_name: Union[str, _models.SettingName], **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.Setting] = kwargs.pop("cls", None) request = build_get_request( @@ -271,14 +273,14 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Setting] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(setting, (IO, bytes)): + if isinstance(setting, (IOBase, bytes)): _content = setting else: _json = self._serialize.body(setting, "Setting") 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 index 61ab019a4e4d..94ead7adbcd0 100644 --- 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 @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +52,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +83,7 @@ def build_get_request( "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +115,7 @@ def build_update_request( "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -145,6 +146,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Setting"]: @@ -158,7 +160,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Setting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.SettingsList] = kwargs.pop("cls", None) error_map = { @@ -249,7 +251,7 @@ def get(self, setting_name: Union[str, _models.SettingName], **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) cls: ClsType[_models.Setting] = kwargs.pop("cls", None) request = build_get_request( @@ -363,14 +365,14 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-07-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Setting] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(setting, (IO, bytes)): + if isinstance(setting, (IOBase, bytes)): _content = setting else: _json = self._serialize.body(setting, "Setting") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_security_center.py index 076ae5f77234..e28084e957a8 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_security_center.py @@ -64,13 +64,13 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.custom_assessment_automations = CustomAssessmentAutomationsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.custom_entity_store_assignments = CustomEntityStoreAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.security_connectors = SecurityConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_vendor.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_version.py index 34ea7990c4b4..e5754a47ce68 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/_security_center.py index 1f187e2beb83..8383f74a9846 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/_security_center.py @@ -64,13 +64,13 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.custom_assessment_automations = CustomAssessmentAutomationsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.custom_entity_store_assignments = CustomEntityStoreAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) self.security_connectors = SecurityConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2021-07-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_assessment_automations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_assessment_automations_operations.py index 849a0aeb23ee..663bac6619d2 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_assessment_automations_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_assessment_automations_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -58,6 +59,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( @@ -89,7 +91,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[_models.CustomAssessmentAutomation] = kwargs.pop("cls", None) request = build_get_request( @@ -230,14 +234,16 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CustomAssessmentAutomation] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(custom_assessment_automation_body, (IO, bytes)): + if isinstance(custom_assessment_automation_body, (IOBase, bytes)): _content = custom_assessment_automation_body else: _json = self._serialize.body(custom_assessment_automation_body, "CustomAssessmentAutomationRequest") @@ -312,7 +318,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -366,7 +374,9 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[_models.CustomAssessmentAutomationsListResult] = kwargs.pop("cls", None) error_map = { @@ -453,7 +463,9 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.CustomAs _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[_models.CustomAssessmentAutomationsListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_entity_store_assignments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_entity_store_assignments_operations.py index 83a2f00dc7a7..a9bdd2823d4a 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_entity_store_assignments_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_entity_store_assignments_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -58,6 +59,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( @@ -90,7 +92,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[_models.CustomEntityStoreAssignment] = kwargs.pop("cls", None) request = build_get_request( @@ -233,14 +237,16 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CustomEntityStoreAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(custom_entity_store_assignment_request_body, (IO, bytes)): + if isinstance(custom_entity_store_assignment_request_body, (IOBase, bytes)): _content = custom_entity_store_assignment_request_body else: _json = self._serialize.body( @@ -318,7 +324,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -372,7 +380,9 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[_models.CustomEntityStoreAssignmentsListResult] = kwargs.pop("cls", None) error_map = { @@ -459,7 +469,9 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.CustomEn _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[_models.CustomEntityStoreAssignmentsListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_security_connectors_operations.py index 7653233043d9..2a5d6bfd2f6f 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_security_connectors_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_security_connectors_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -59,6 +60,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityConnector"]: @@ -74,7 +76,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityConnector"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) error_map = { @@ -161,7 +165,9 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) error_map = { @@ -259,7 +265,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) request = build_get_request( @@ -393,14 +401,16 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_connector, (IO, bytes)): + if isinstance(security_connector, (IOBase, bytes)): _content = security_connector else: _json = self._serialize.body(security_connector, "SecurityConnector") @@ -540,14 +550,16 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_connector, (IO, bytes)): + if isinstance(security_connector, (IOBase, bytes)): _content = security_connector else: _json = self._serialize.body(security_connector, "SecurityConnector") @@ -616,7 +628,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/models/_models_py3.py index 2c8cfa075004..d2ca7f2d86e8 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/models/_models_py3.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/models/_models_py3.py @@ -290,8 +290,8 @@ def __init__( self, *, compressed_query: Optional[str] = None, - supported_cloud: Optional[Union[str, "_models.SupportedCloudEnum"]] = None, - severity: Optional[Union[str, "_models.SeverityEnum"]] = None, + supported_cloud: Union[str, "_models.SupportedCloudEnum"] = "AWS", + severity: Union[str, "_models.SeverityEnum"] = "Low", display_name: Optional[str] = None, description: Optional[str] = None, remediation_description: Optional[str] = None, @@ -387,8 +387,8 @@ def __init__( self, *, compressed_query: Optional[str] = None, - supported_cloud: Optional[Union[str, "_models.SupportedCloudEnum"]] = None, - severity: Optional[Union[str, "_models.SeverityEnum"]] = None, + supported_cloud: Union[str, "_models.SupportedCloudEnum"] = "AWS", + severity: Union[str, "_models.SeverityEnum"] = "Low", display_name: Optional[str] = None, description: Optional[str] = None, remediation_description: Optional[str] = None, diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_assessment_automations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_assessment_automations_operations.py index 29037afe1a80..a5496d7133c7 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_assessment_automations_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_assessment_automations_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -62,7 +63,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -100,7 +101,7 @@ def build_create_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -139,7 +140,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -171,7 +172,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -199,7 +200,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -228,6 +229,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get( @@ -259,7 +261,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[_models.CustomAssessmentAutomation] = kwargs.pop("cls", None) request = build_get_request( @@ -400,14 +404,16 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CustomAssessmentAutomation] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(custom_assessment_automation_body, (IO, bytes)): + if isinstance(custom_assessment_automation_body, (IOBase, bytes)): _content = custom_assessment_automation_body else: _json = self._serialize.body(custom_assessment_automation_body, "CustomAssessmentAutomationRequest") @@ -482,7 +488,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -536,7 +544,9 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[_models.CustomAssessmentAutomationsListResult] = kwargs.pop("cls", None) error_map = { @@ -623,7 +633,9 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.CustomAssessm _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[_models.CustomAssessmentAutomationsListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_entity_store_assignments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_entity_store_assignments_operations.py index 938668293774..3e15d0b0ac57 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_entity_store_assignments_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_entity_store_assignments_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -62,7 +63,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -100,7 +101,7 @@ def build_create_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -139,7 +140,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -171,7 +172,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -199,7 +200,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -228,6 +229,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get( @@ -260,7 +262,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[_models.CustomEntityStoreAssignment] = kwargs.pop("cls", None) request = build_get_request( @@ -403,14 +407,16 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CustomEntityStoreAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(custom_entity_store_assignment_request_body, (IO, bytes)): + if isinstance(custom_entity_store_assignment_request_body, (IOBase, bytes)): _content = custom_entity_store_assignment_request_body else: _json = self._serialize.body( @@ -488,7 +494,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -542,7 +550,9 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[_models.CustomEntityStoreAssignmentsListResult] = kwargs.pop("cls", None) error_map = { @@ -629,7 +639,9 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.CustomEntityS _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[_models.CustomEntityStoreAssignmentsListResult] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_security_connectors_operations.py index 7388f271da5e..b97c3759aaa6 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_security_connectors_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_security_connectors_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +52,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +84,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -118,7 +119,7 @@ def build_get_request( "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,7 +155,7 @@ def build_create_or_update_request( "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -192,7 +193,7 @@ def build_update_request( "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -229,7 +230,7 @@ def build_delete_request( "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -258,6 +259,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: @@ -273,7 +275,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) error_map = { @@ -358,7 +362,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) error_map = { @@ -454,7 +460,9 @@ def get(self, resource_group_name: str, security_connector_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) request = build_get_request( @@ -588,14 +596,16 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_connector, (IO, bytes)): + if isinstance(security_connector, (IOBase, bytes)): _content = security_connector else: _json = self._serialize.body(security_connector, "SecurityConnector") @@ -735,14 +745,16 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_connector, (IO, bytes)): + if isinstance(security_connector, (IOBase, bytes)): _content = security_connector else: _json = self._serialize.body(security_connector, "SecurityConnector") @@ -811,7 +823,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-07-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_security_center.py index df96282b2831..eea491791f89 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_security_center.py @@ -53,7 +53,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.mde_onboardings = MdeOnboardingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.mde_onboardings = MdeOnboardingsOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-10-01-preview" + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_vendor.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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_10_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_version.py index 34ea7990c4b4..e5754a47ce68 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/_security_center.py index 4ea8dcab55f6..c0c77c0be475 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/_security_center.py @@ -53,7 +53,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.mde_onboardings = MdeOnboardingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.mde_onboardings = MdeOnboardingsOperations( + self._client, self._config, self._serialize, self._deserialize, "2021-10-01-preview" + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/operations/_mde_onboardings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/operations/_mde_onboardings_operations.py index 9c9c80a643b1..627d9b829398 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/operations/_mde_onboardings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/operations/_mde_onboardings_operations.py @@ -49,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, **kwargs: Any) -> _models.MdeOnboardingDataList: @@ -70,7 +71,9 @@ async def list(self, **kwargs: Any) -> _models.MdeOnboardingDataList: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-10-01-preview") + ) cls: ClsType[_models.MdeOnboardingDataList] = kwargs.pop("cls", None) request = build_list_request( @@ -123,7 +126,9 @@ async def get(self, **kwargs: Any) -> _models.MdeOnboardingData: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-10-01-preview") + ) cls: ClsType[_models.MdeOnboardingData] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/operations/_mde_onboardings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/operations/_mde_onboardings_operations.py index 4f4b46057a3d..b009fd7d747e 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/operations/_mde_onboardings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/operations/_mde_onboardings_operations.py @@ -25,7 +25,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +49,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -77,7 +77,7 @@ def build_get_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -106,6 +106,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> _models.MdeOnboardingDataList: @@ -127,7 +128,9 @@ def list(self, **kwargs: Any) -> _models.MdeOnboardingDataList: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-10-01-preview") + ) cls: ClsType[_models.MdeOnboardingDataList] = kwargs.pop("cls", None) request = build_list_request( @@ -180,7 +183,9 @@ def get(self, **kwargs: Any) -> _models.MdeOnboardingData: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2021-10-01-preview") + ) cls: ClsType[_models.MdeOnboardingData] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_security_center.py index 78ee9ec8b55f..7674858ed412 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_security_center.py @@ -54,7 +54,7 @@ def __init__( 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) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize, "2022-01-01") def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_vendor.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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/v2022_01_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_version.py index 34ea7990c4b4..e5754a47ce68 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/_security_center.py index 70afb42bffb6..9c6b0a2a41b5 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/_security_center.py @@ -54,7 +54,7 @@ def __init__( 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) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize, "2022-01-01") def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/operations/_alerts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/operations/_alerts_operations.py index 602b5ed5c87d..582485286fec 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/operations/_alerts_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/operations/_alerts_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -70,6 +71,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Alert"]: @@ -83,7 +85,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Alert"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) error_map = { @@ -166,7 +168,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) error_map = { @@ -253,7 +255,7 @@ def list_subscription_level_by_region(self, asc_location: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) error_map = { @@ -345,7 +347,7 @@ def list_resource_group_level_by_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) error_map = { @@ -442,7 +444,7 @@ async def get_subscription_level(self, asc_location: str, alert_name: str, **kwa _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) request = build_get_subscription_level_request( @@ -509,7 +511,7 @@ async def get_resource_group_level( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) request = build_get_resource_group_level_request( @@ -574,7 +576,7 @@ async def update_subscription_level_state_to_dismiss( # pylint: disable=inconsi _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_subscription_level_state_to_dismiss_request( @@ -634,7 +636,7 @@ async def update_subscription_level_state_to_resolve( # pylint: disable=inconsi _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_subscription_level_state_to_resolve_request( @@ -694,7 +696,7 @@ async def update_subscription_level_state_to_activate( # pylint: disable=incons _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_subscription_level_state_to_activate_request( @@ -754,7 +756,7 @@ async def update_subscription_level_state_to_in_progress( # pylint: disable=inc _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_subscription_level_state_to_in_progress_request( @@ -817,7 +819,7 @@ async def update_resource_group_level_state_to_resolve( # pylint: disable=incon _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_resource_group_level_state_to_resolve_request( @@ -881,7 +883,7 @@ async def update_resource_group_level_state_to_dismiss( # pylint: disable=incon _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_resource_group_level_state_to_dismiss_request( @@ -945,7 +947,7 @@ async def update_resource_group_level_state_to_activate( # pylint: disable=inco _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_resource_group_level_state_to_activate_request( @@ -1009,7 +1011,7 @@ async def update_resource_group_level_state_to_in_progress( # pylint: disable=i _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_resource_group_level_state_to_in_progress_request( @@ -1060,14 +1062,14 @@ async def _simulate_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(alert_simulator_request_body, (IO, bytes)): + if isinstance(alert_simulator_request_body, (IOBase, bytes)): _content = alert_simulator_request_body else: _json = self._serialize.body(alert_simulator_request_body, "AlertSimulatorRequestBody") @@ -1203,7 +1205,7 @@ async def begin_simulate( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/operations/_alerts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/operations/_alerts_operations.py index a9003d2e03bd..6c177aabf93d 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/operations/_alerts_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/operations/_alerts_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -29,7 +30,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +54,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -85,7 +86,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +117,7 @@ def build_list_subscription_level_by_region_request( "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -151,7 +152,7 @@ def build_list_resource_group_level_by_region_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -184,7 +185,7 @@ def build_get_subscription_level_request( "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -220,7 +221,7 @@ def build_get_resource_group_level_request( "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -253,7 +254,7 @@ def build_update_subscription_level_state_to_dismiss_request( "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -286,7 +287,7 @@ def build_update_subscription_level_state_to_resolve_request( "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -319,7 +320,7 @@ def build_update_subscription_level_state_to_activate_request( "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -352,7 +353,7 @@ def build_update_subscription_level_state_to_in_progress_request( "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -388,7 +389,7 @@ def build_update_resource_group_level_state_to_resolve_request( "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -424,7 +425,7 @@ def build_update_resource_group_level_state_to_dismiss_request( "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -460,7 +461,7 @@ def build_update_resource_group_level_state_to_activate_request( "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -496,7 +497,7 @@ def build_update_resource_group_level_state_to_in_progress_request( "alertName": _SERIALIZER.url("alert_name", alert_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -527,7 +528,7 @@ def build_simulate_request(asc_location: str, subscription_id: str, **kwargs: An "ascLocation": _SERIALIZER.url("asc_location", asc_location, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -558,6 +559,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Alert"]: @@ -571,7 +573,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Alert"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) error_map = { @@ -654,7 +656,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) error_map = { @@ -741,7 +743,7 @@ def list_subscription_level_by_region(self, asc_location: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) error_map = { @@ -833,7 +835,7 @@ def list_resource_group_level_by_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[_models.AlertList] = kwargs.pop("cls", None) error_map = { @@ -930,7 +932,7 @@ def get_subscription_level(self, asc_location: str, alert_name: str, **kwargs: A _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) request = build_get_subscription_level_request( @@ -997,7 +999,7 @@ def get_resource_group_level( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[_models.Alert] = kwargs.pop("cls", None) request = build_get_resource_group_level_request( @@ -1062,7 +1064,7 @@ def update_subscription_level_state_to_dismiss( # pylint: disable=inconsistent- _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_subscription_level_state_to_dismiss_request( @@ -1122,7 +1124,7 @@ def update_subscription_level_state_to_resolve( # pylint: disable=inconsistent- _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_subscription_level_state_to_resolve_request( @@ -1182,7 +1184,7 @@ def update_subscription_level_state_to_activate( # pylint: disable=inconsistent _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_subscription_level_state_to_activate_request( @@ -1242,7 +1244,7 @@ def update_subscription_level_state_to_in_progress( # pylint: disable=inconsist _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_subscription_level_state_to_in_progress_request( @@ -1305,7 +1307,7 @@ def update_resource_group_level_state_to_resolve( # pylint: disable=inconsisten _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_resource_group_level_state_to_resolve_request( @@ -1369,7 +1371,7 @@ def update_resource_group_level_state_to_dismiss( # pylint: disable=inconsisten _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_resource_group_level_state_to_dismiss_request( @@ -1433,7 +1435,7 @@ def update_resource_group_level_state_to_activate( # pylint: disable=inconsiste _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_resource_group_level_state_to_activate_request( @@ -1497,7 +1499,7 @@ def update_resource_group_level_state_to_in_progress( # pylint: disable=inconsi _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) cls: ClsType[None] = kwargs.pop("cls", None) request = build_update_resource_group_level_state_to_in_progress_request( @@ -1548,14 +1550,14 @@ def _simulate_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(alert_simulator_request_body, (IO, bytes)): + if isinstance(alert_simulator_request_body, (IOBase, bytes)): _content = alert_simulator_request_body else: _json = self._serialize.body(alert_simulator_request_body, "AlertSimulatorRequestBody") @@ -1691,7 +1693,7 @@ def begin_simulate( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_security_center.py index 985797ba08f1..f6eff2f7d688 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_security_center.py @@ -53,10 +53,10 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.governance_rules = GovernanceRulesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-01-01-preview" ) self.governance_assignments = GovernanceAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-01-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_vendor.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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/v2022_01_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_version.py index 34ea7990c4b4..e5754a47ce68 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/_security_center.py index 51ff6579ebd2..496fc4e974f0 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/_security_center.py @@ -53,10 +53,10 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.governance_rules = GovernanceRulesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-01-01-preview" ) self.governance_assignments = GovernanceAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-01-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_assignments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_assignments_operations.py index 695aed426375..96ac0553906f 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_assignments_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_assignments_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -57,6 +58,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, scope: str, assessment_name: str, **kwargs: Any) -> AsyncIterable["_models.GovernanceAssignment"]: @@ -79,7 +81,9 @@ def list(self, scope: str, assessment_name: str, **kwargs: Any) -> AsyncIterable _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) cls: ClsType[_models.GovernanceAssignmentsList] = kwargs.pop("cls", None) error_map = { @@ -180,7 +184,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) cls: ClsType[_models.GovernanceAssignment] = kwargs.pop("cls", None) request = build_get_request( @@ -330,14 +336,16 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GovernanceAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(governance_assignment, (IO, bytes)): + if isinstance(governance_assignment, (IOBase, bytes)): _content = governance_assignment else: _json = self._serialize.body(governance_assignment, "GovernanceAssignment") @@ -415,7 +423,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_rules_operations.py index b9b49f624126..6eb478f81bdf 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_rules_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_rules_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -61,6 +62,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.GovernanceRule"]: @@ -81,7 +83,9 @@ def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.GovernanceRu _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) cls: ClsType[_models.GovernanceRuleList] = kwargs.pop("cls", None) error_map = { @@ -178,7 +182,9 @@ async def get(self, scope: str, rule_id: str, **kwargs: Any) -> _models.Governan _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) cls: ClsType[_models.GovernanceRule] = kwargs.pop("cls", None) request = build_get_request( @@ -307,14 +313,16 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GovernanceRule] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(governance_rule, (IO, bytes)): + if isinstance(governance_rule, (IOBase, bytes)): _content = governance_rule else: _json = self._serialize.body(governance_rule, "GovernanceRule") @@ -371,7 +379,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -433,7 +443,9 @@ async def begin_delete(self, scope: str, rule_id: str, **kwargs: Any) -> AsyncLR _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -491,14 +503,16 @@ async def _execute_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(execute_governance_rule_params, (IO, bytes)): + if isinstance(execute_governance_rule_params, (IOBase, bytes)): _content = execute_governance_rule_params else: if execute_governance_rule_params is not None: @@ -661,7 +675,9 @@ async def begin_execute( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -738,7 +754,9 @@ async def operation_results( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) cls: ClsType[Optional[_models.OperationResultAutoGenerated]] = kwargs.pop("cls", None) request = build_operation_results_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_assignments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_assignments_operations.py index e26965c74fcf..3ffee0a032c7 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_assignments_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_assignments_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +53,7 @@ def build_list_request(scope: str, assessment_name: str, **kwargs: Any) -> HttpR "assessmentName": _SERIALIZER.url("assessment_name", assessment_name, "str", pattern=r"^[-\w\._\(\)]+$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -81,7 +82,7 @@ def build_get_request(scope: str, assessment_name: str, assignment_key: str, **k "assignmentKey": _SERIALIZER.url("assignment_key", assignment_key, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -111,7 +112,7 @@ def build_create_or_update_request(scope: str, assessment_name: str, assignment_ "assignmentKey": _SERIALIZER.url("assignment_key", assignment_key, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -139,7 +140,7 @@ def build_delete_request(scope: str, assessment_name: str, assignment_key: str, "assignmentKey": _SERIALIZER.url("assignment_key", assignment_key, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -165,6 +166,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, scope: str, assessment_name: str, **kwargs: Any) -> Iterable["_models.GovernanceAssignment"]: @@ -187,7 +189,9 @@ def list(self, scope: str, assessment_name: str, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) cls: ClsType[_models.GovernanceAssignmentsList] = kwargs.pop("cls", None) error_map = { @@ -286,7 +290,9 @@ def get(self, scope: str, assessment_name: str, assignment_key: str, **kwargs: A _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) cls: ClsType[_models.GovernanceAssignment] = kwargs.pop("cls", None) request = build_get_request( @@ -436,14 +442,16 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GovernanceAssignment] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(governance_assignment, (IO, bytes)): + if isinstance(governance_assignment, (IOBase, bytes)): _content = governance_assignment else: _json = self._serialize.body(governance_assignment, "GovernanceAssignment") @@ -521,7 +529,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_rules_operations.py index 3921e077fcef..317b4f554313 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_rules_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_rules_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -29,7 +30,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +52,7 @@ def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +77,7 @@ def build_get_request(scope: str, rule_id: str, **kwargs: Any) -> HttpRequest: "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -102,7 +103,7 @@ def build_create_or_update_request(scope: str, rule_id: str, **kwargs: Any) -> H "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -126,7 +127,7 @@ def build_delete_request(scope: str, rule_id: str, **kwargs: Any) -> HttpRequest "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -149,7 +150,7 @@ def build_execute_request(scope: str, rule_id: str, **kwargs: Any) -> HttpReques "ruleId": _SERIALIZER.url("rule_id", rule_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -179,7 +180,7 @@ def build_operation_results_request(scope: str, rule_id: str, operation_id: str, "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -208,6 +209,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, scope: str, **kwargs: Any) -> Iterable["_models.GovernanceRule"]: @@ -228,7 +230,9 @@ def list(self, scope: str, **kwargs: Any) -> Iterable["_models.GovernanceRule"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) cls: ClsType[_models.GovernanceRuleList] = kwargs.pop("cls", None) error_map = { @@ -325,7 +329,9 @@ def get(self, scope: str, rule_id: str, **kwargs: Any) -> _models.GovernanceRule _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) cls: ClsType[_models.GovernanceRule] = kwargs.pop("cls", None) request = build_get_request( @@ -454,14 +460,16 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.GovernanceRule] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(governance_rule, (IO, bytes)): + if isinstance(governance_rule, (IOBase, bytes)): _content = governance_rule else: _json = self._serialize.body(governance_rule, "GovernanceRule") @@ -518,7 +526,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -580,7 +590,9 @@ def begin_delete(self, scope: str, rule_id: str, **kwargs: Any) -> LROPoller[Non _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) @@ -638,14 +650,16 @@ def _execute_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(execute_governance_rule_params, (IO, bytes)): + if isinstance(execute_governance_rule_params, (IOBase, bytes)): _content = execute_governance_rule_params else: if execute_governance_rule_params is not None: @@ -808,7 +822,9 @@ def begin_execute( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -885,7 +901,9 @@ def operation_results( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-01-01-preview") + ) cls: ClsType[Optional[_models.OperationResultAutoGenerated]] = kwargs.pop("cls", None) request = build_operation_results_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_security_center.py index def06d937af3..4083cb0402b0 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_security_center.py @@ -52,7 +52,7 @@ def __init__( 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) + self.pricings = PricingsOperations(self._client, self._config, self._serialize, self._deserialize, "2022-03-01") def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_vendor.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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/v2022_03_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_version.py index 34ea7990c4b4..e5754a47ce68 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/_security_center.py index 712cee16c5b3..d48089f9280a 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/_security_center.py @@ -52,7 +52,7 @@ def __init__( 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) + self.pricings = PricingsOperations(self._client, self._config, self._serialize, self._deserialize, "2022-03-01") def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/operations/_pricings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/operations/_pricings_operations.py index c126c362661b..3ad1b142a6e5 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/operations/_pricings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/operations/_pricings_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -49,6 +50,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, **kwargs: Any) -> _models.PricingList: @@ -70,7 +72,7 @@ async def list(self, **kwargs: Any) -> _models.PricingList: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-03-01")) cls: ClsType[_models.PricingList] = kwargs.pop("cls", None) request = build_list_request( @@ -125,7 +127,7 @@ async def get(self, pricing_name: str, **kwargs: Any) -> _models.Pricing: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-03-01")) cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) request = build_get_request( @@ -224,14 +226,14 @@ async def update(self, pricing_name: str, pricing: Union[_models.Pricing, IO], * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(pricing, (IO, bytes)): + if isinstance(pricing, (IOBase, bytes)): _content = pricing else: _json = self._serialize.body(pricing, "Pricing") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/operations/_pricings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/operations/_pricings_operations.py index 2cf57a8ea298..5f0c504c1fd4 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/operations/_pricings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/operations/_pricings_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -25,7 +26,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +50,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +79,7 @@ def build_get_request(pricing_name: str, subscription_id: str, **kwargs: Any) -> "pricingName": _SERIALIZER.url("pricing_name", pricing_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -108,7 +109,7 @@ def build_update_request(pricing_name: str, subscription_id: str, **kwargs: Any) "pricingName": _SERIALIZER.url("pricing_name", pricing_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -139,6 +140,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> _models.PricingList: @@ -160,7 +162,7 @@ def list(self, **kwargs: Any) -> _models.PricingList: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-03-01")) cls: ClsType[_models.PricingList] = kwargs.pop("cls", None) request = build_list_request( @@ -215,7 +217,7 @@ def get(self, pricing_name: str, **kwargs: Any) -> _models.Pricing: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-03-01")) cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) request = build_get_request( @@ -314,14 +316,14 @@ def update(self, pricing_name: str, pricing: Union[_models.Pricing, IO], **kwarg _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-03-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(pricing, (IO, bytes)): + if isinstance(pricing, (IOBase, bytes)): _content = pricing else: _json = self._serialize.body(pricing, "Pricing") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_security_center.py index fc68fa3ea9c2..e4082f27af75 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_security_center.py @@ -52,7 +52,7 @@ def __init__( 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.settings = SettingsOperations(self._client, self._config, self._serialize, self._deserialize, "2022-05-01") def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_vendor.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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/v2022_05_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_version.py index 34ea7990c4b4..e5754a47ce68 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/_security_center.py index 9cef09f45fab..d2daab4df997 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/_security_center.py @@ -52,7 +52,7 @@ def __init__( 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.settings = SettingsOperations(self._client, self._config, self._serialize, self._deserialize, "2022-05-01") def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/operations/_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/operations/_settings_operations.py index a37c42204d5b..6a14c636c1ce 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/operations/_settings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/operations/_settings_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -52,6 +53,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Setting"]: @@ -66,7 +68,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Setting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.SettingsList] = kwargs.pop("cls", None) error_map = { @@ -157,7 +159,7 @@ async def get(self, setting_name: Union[str, _models.SettingName], **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.Setting] = kwargs.pop("cls", None) request = build_get_request( @@ -271,14 +273,14 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Setting] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(setting, (IO, bytes)): + if isinstance(setting, (IOBase, bytes)): _content = setting else: _json = self._serialize.body(setting, "Setting") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/operations/_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/operations/_settings_operations.py index 3edb98d8fe85..a5de91380e59 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/operations/_settings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/operations/_settings_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +52,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +83,7 @@ def build_get_request( "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +115,7 @@ def build_update_request( "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -145,6 +146,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Setting"]: @@ -158,7 +160,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Setting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.SettingsList] = kwargs.pop("cls", None) error_map = { @@ -249,7 +251,7 @@ def get(self, setting_name: Union[str, _models.SettingName], **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) cls: ClsType[_models.Setting] = kwargs.pop("cls", None) request = build_get_request( @@ -363,14 +365,14 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-05-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Setting] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(setting, (IO, bytes)): + if isinstance(setting, (IOBase, bytes)): _content = setting else: _json = self._serialize.body(setting, "Setting") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_security_center.py index 9798db8a62eb..369935e63950 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_security_center.py @@ -54,7 +54,7 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.security_connectors = SecurityConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-05-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_vendor.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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/v2022_05_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_version.py index 34ea7990c4b4..e5754a47ce68 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/_security_center.py index 09cb6fa13cd8..a1832afc8928 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/_security_center.py @@ -54,7 +54,7 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.security_connectors = SecurityConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-05-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/operations/_security_connectors_operations.py index eb70b6199986..10753a742a8c 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/operations/_security_connectors_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/operations/_security_connectors_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -59,6 +60,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityConnector"]: @@ -74,7 +76,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityConnector"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") + ) cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) error_map = { @@ -161,7 +165,9 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") + ) cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) error_map = { @@ -259,7 +265,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") + ) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) request = build_get_request( @@ -393,14 +401,16 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_connector, (IO, bytes)): + if isinstance(security_connector, (IOBase, bytes)): _content = security_connector else: _json = self._serialize.body(security_connector, "SecurityConnector") @@ -540,14 +550,16 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_connector, (IO, bytes)): + if isinstance(security_connector, (IOBase, bytes)): _content = security_connector else: _json = self._serialize.body(security_connector, "SecurityConnector") @@ -616,7 +628,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/operations/_security_connectors_operations.py index 0e6fe0c8fe02..7ec1341d1589 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/operations/_security_connectors_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/operations/_security_connectors_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +52,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +84,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -118,7 +119,7 @@ def build_get_request( "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,7 +155,7 @@ def build_create_or_update_request( "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -192,7 +193,7 @@ def build_update_request( "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -229,7 +230,7 @@ def build_delete_request( "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -258,6 +259,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: @@ -273,7 +275,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") + ) cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) error_map = { @@ -358,7 +362,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") + ) cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) error_map = { @@ -454,7 +460,9 @@ def get(self, resource_group_name: str, security_connector_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") + ) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) request = build_get_request( @@ -588,14 +596,16 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_connector, (IO, bytes)): + if isinstance(security_connector, (IOBase, bytes)): _content = security_connector else: _json = self._serialize.body(security_connector, "SecurityConnector") @@ -735,14 +745,16 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_connector, (IO, bytes)): + if isinstance(security_connector, (IOBase, bytes)): _content = security_connector else: _json = self._serialize.body(security_connector, "SecurityConnector") @@ -811,7 +823,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-05-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_security_center.py index ea6e857630f7..42d57cb469bf 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_security_center.py @@ -66,13 +66,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.applications = ApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.application = ApplicationOperations(self._client, self._config, self._serialize, self._deserialize) + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-07-01-preview" + ) + self.application = ApplicationOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-07-01-preview" + ) self.security_connector_applications = SecurityConnectorApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-07-01-preview" ) self.security_connector_application = SecurityConnectorApplicationOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-07-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_vendor.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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/v2022_07_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_version.py index 34ea7990c4b4..e5754a47ce68 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/_security_center.py index 24f7a2c6a316..dc11d8583275 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/_security_center.py @@ -67,13 +67,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.applications = ApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.application = ApplicationOperations(self._client, self._config, self._serialize, self._deserialize) + self.applications = ApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-07-01-preview" + ) + self.application = ApplicationOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-07-01-preview" + ) self.security_connector_applications = SecurityConnectorApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-07-01-preview" ) self.security_connector_application = SecurityConnectorApplicationOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-07-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_application_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_application_operations.py index 216ee48f31f9..3c9baf78b8d9 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_application_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_application_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -53,6 +54,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, application_id: str, **kwargs: Any) -> _models.Application: @@ -77,7 +79,9 @@ async def get(self, application_id: str, **kwargs: Any) -> _models.Application: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") + ) cls: ClsType[_models.Application] = kwargs.pop("cls", None) request = build_get_request( @@ -187,14 +191,16 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Application] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(application, (IO, bytes)): + if isinstance(application, (IOBase, bytes)): _content = application else: _json = self._serialize.body(application, "Application") @@ -264,7 +270,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_applications_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_applications_operations.py index 8b8004c9733a..b95130f09afe 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_applications_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_applications_operations.py @@ -51,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Application"]: @@ -65,7 +66,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Application"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") + ) cls: ClsType[_models.ApplicationsList] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_application_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_application_operations.py index aa009610b627..b7aace553aac 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_application_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_application_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -53,6 +54,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( @@ -84,7 +86,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") + ) cls: ClsType[_models.Application] = kwargs.pop("cls", None) request = build_get_request( @@ -227,14 +231,16 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Application] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(application, (IO, bytes)): + if isinstance(application, (IOBase, bytes)): _content = application else: _json = self._serialize.body(application, "Application") @@ -311,7 +317,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_applications_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_applications_operations.py index 9ea9919210de..98da9bba7c05 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_applications_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_applications_operations.py @@ -51,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -72,7 +73,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") + ) cls: ClsType[_models.ApplicationsList] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_application_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_application_operations.py index b98a76ec6f6f..c1193a31e2ad 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_application_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_application_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -25,7 +26,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +53,7 @@ def build_get_request(application_id: str, subscription_id: str, **kwargs: Any) "applicationId": _SERIALIZER.url("application_id", application_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,7 +83,7 @@ def build_create_or_update_request(application_id: str, subscription_id: str, ** "applicationId": _SERIALIZER.url("application_id", application_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -110,7 +111,7 @@ def build_delete_request(application_id: str, subscription_id: str, **kwargs: An "applicationId": _SERIALIZER.url("application_id", application_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -136,6 +137,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, application_id: str, **kwargs: Any) -> _models.Application: @@ -160,7 +162,9 @@ def get(self, application_id: str, **kwargs: Any) -> _models.Application: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") + ) cls: ClsType[_models.Application] = kwargs.pop("cls", None) request = build_get_request( @@ -270,14 +274,16 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Application] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(application, (IO, bytes)): + if isinstance(application, (IOBase, bytes)): _content = application else: _json = self._serialize.body(application, "Application") @@ -345,7 +351,9 @@ def delete(self, application_id: str, **kwargs: Any) -> None: # pylint: disable _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_applications_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_applications_operations.py index 2ec7d9218cac..c68dc11c4b9f 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_applications_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_applications_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +51,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,6 +80,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Application"]: @@ -94,7 +95,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.Application"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") + ) cls: ClsType[_models.ApplicationsList] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_application_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_application_operations.py index 28489e7ed320..f34fd4f0b9fd 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_application_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_application_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -25,7 +26,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -59,7 +60,7 @@ def build_get_request( "applicationId": _SERIALIZER.url("application_id", application_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -96,7 +97,7 @@ def build_create_or_update_request( "applicationId": _SERIALIZER.url("application_id", application_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -131,7 +132,7 @@ def build_delete_request( "applicationId": _SERIALIZER.url("application_id", application_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -157,6 +158,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get( @@ -188,7 +190,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") + ) cls: ClsType[_models.Application] = kwargs.pop("cls", None) request = build_get_request( @@ -331,14 +335,16 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Application] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(application, (IO, bytes)): + if isinstance(application, (IOBase, bytes)): _content = application else: _json = self._serialize.body(application, "Application") @@ -415,7 +421,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_applications_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_applications_operations.py index c35eb33ea56d..e0b89955d63f 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_applications_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_applications_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -60,7 +60,7 @@ def build_list_request( "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -89,6 +89,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -110,7 +111,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-07-01-preview") + ) cls: ClsType[_models.ApplicationsList] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_security_center.py index d4bd92f40269..7d821368738f 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_security_center.py @@ -54,7 +54,7 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.security_connectors = SecurityConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_vendor.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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/v2022_08_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_version.py index 34ea7990c4b4..e5754a47ce68 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_security_center.py index 5cf32d6522ff..bcfc40864212 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_security_center.py @@ -54,7 +54,7 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.security_connectors = SecurityConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-08-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/_security_connectors_operations.py index 65ac800fbed9..33351b4668b6 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/_security_connectors_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/_security_connectors_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -59,6 +60,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityConnector"]: @@ -74,7 +76,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityConnector"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") + ) cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) error_map = { @@ -161,7 +165,9 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") + ) cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) error_map = { @@ -259,7 +265,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") + ) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) request = build_get_request( @@ -393,14 +401,16 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_connector, (IO, bytes)): + if isinstance(security_connector, (IOBase, bytes)): _content = security_connector else: _json = self._serialize.body(security_connector, "SecurityConnector") @@ -540,14 +550,16 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_connector, (IO, bytes)): + if isinstance(security_connector, (IOBase, bytes)): _content = security_connector else: _json = self._serialize.body(security_connector, "SecurityConnector") @@ -616,7 +628,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/_security_connectors_operations.py index a7993a553a70..be61fa384e5a 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/_security_connectors_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/_security_connectors_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +52,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +84,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -118,7 +119,7 @@ def build_get_request( "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,7 +155,7 @@ def build_create_or_update_request( "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -192,7 +193,7 @@ def build_update_request( "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -229,7 +230,7 @@ def build_delete_request( "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -258,6 +259,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: @@ -273,7 +275,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") + ) cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) error_map = { @@ -358,7 +362,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") + ) cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) error_map = { @@ -454,7 +460,9 @@ def get(self, resource_group_name: str, security_connector_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") + ) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) request = build_get_request( @@ -588,14 +596,16 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_connector, (IO, bytes)): + if isinstance(security_connector, (IOBase, bytes)): _content = security_connector else: _json = self._serialize.body(security_connector, "SecurityConnector") @@ -735,14 +745,16 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_connector, (IO, bytes)): + if isinstance(security_connector, (IOBase, bytes)): _content = security_connector else: _json = self._serialize.body(security_connector, "SecurityConnector") @@ -811,7 +823,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-08-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-08-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_security_center.py index b2a7260da2e9..118616922018 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_security_center.py @@ -59,12 +59,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.api_collection = APICollectionOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_collection = APICollectionOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-11-20-preview" + ) self.api_collection_onboarding = APICollectionOnboardingOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-11-20-preview" ) self.api_collection_offboarding = APICollectionOffboardingOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-11-20-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_vendor.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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/v2022_11_20_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_version.py index 34ea7990c4b4..e5754a47ce68 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/_security_center.py index 729482ac997b..be99fad4bca9 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/_security_center.py @@ -59,12 +59,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.api_collection = APICollectionOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_collection = APICollectionOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-11-20-preview" + ) self.api_collection_onboarding = APICollectionOnboardingOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-11-20-preview" ) self.api_collection_offboarding = APICollectionOffboardingOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2022-11-20-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_offboarding_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_offboarding_operations.py index 7901f3adf739..be671b18caf1 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_offboarding_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_offboarding_operations.py @@ -49,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -84,7 +85,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-20-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-20-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_onboarding_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_onboarding_operations.py index ef3e16f10f16..6cef03177e5a 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_onboarding_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_onboarding_operations.py @@ -49,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def create( @@ -85,7 +86,9 @@ async def create( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-20-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-20-preview") + ) cls: ClsType[_models.ApiCollectionResponse] = kwargs.pop("cls", None) request = build_create_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_operations.py index 7d95afcb3ff0..5e1d46bc73cb 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/aio/operations/_api_collection_operations.py @@ -52,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -79,7 +80,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-20-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-20-preview") + ) cls: ClsType[_models.ApiCollectionResponseList] = kwargs.pop("cls", None) error_map = { @@ -188,7 +191,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-20-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-20-preview") + ) cls: ClsType[_models.ApiCollectionResponse] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_offboarding_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_offboarding_operations.py index d82962b536fe..6c4d2f9c9f83 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_offboarding_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_offboarding_operations.py @@ -25,7 +25,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -64,7 +64,7 @@ def build_delete_request( "apiCollectionId": _SERIALIZER.url("api_collection_id", api_collection_id, "str", max_length=256, min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,6 +93,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -128,7 +129,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-20-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-20-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_onboarding_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_onboarding_operations.py index 024feb82531d..0e36d4dcfc90 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_onboarding_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_onboarding_operations.py @@ -25,7 +25,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -64,7 +64,7 @@ def build_create_request( "apiCollectionId": _SERIALIZER.url("api_collection_id", api_collection_id, "str", max_length=256, min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,6 +93,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def create( @@ -129,7 +130,9 @@ def create( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-20-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-20-preview") + ) cls: ClsType[_models.ApiCollectionResponse] = kwargs.pop("cls", None) request = build_create_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_operations.py index 9bc3b3c4af92..df3aea954011 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_11_20_preview/operations/_api_collection_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -63,7 +63,7 @@ def build_list_request(resource_group_name: str, service_name: str, subscription ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -104,7 +104,7 @@ def build_get_request( "apiCollectionId": _SERIALIZER.url("api_collection_id", api_collection_id, "str", max_length=256, min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -133,6 +133,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list( @@ -160,7 +161,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-20-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-20-preview") + ) cls: ClsType[_models.ApiCollectionResponseList] = kwargs.pop("cls", None) error_map = { @@ -269,7 +272,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-11-20-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-11-20-preview") + ) cls: ClsType[_models.ApiCollectionResponse] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/__init__.py new file mode 100644 index 000000000000..e95a015ca6b8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/__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 ._security_center import SecurityCenter +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenter", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_configuration.py new file mode 100644 index 000000000000..dfca6d53f681 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_configuration.py @@ -0,0 +1,61 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +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 "2022-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2022-12-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) + self._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.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/v2022_12_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_metadata.json new file mode 100644 index 000000000000..d6c404b0b69d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_metadata.json @@ -0,0 +1,97 @@ +{ + "chosen_version": "2022-12-01-preview", + "total_api_version_list": ["2022-12-01-preview"], + "client": { + "name": "SecurityCenter", + "filename": "_security_center", + "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_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, + "method_location": "positional" + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + } + }, + "constant": { + }, + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version: Optional[str]=None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"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": { + "defender_for_storage": "DefenderForStorageOperations" + } +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_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/v2022_12_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_security_center.py new file mode 100644 index 000000000000..10690360b47d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_security_center.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import DefenderForStorageOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword + """API spec for Microsoft.Security (Azure Security Center) resource provider. + + :ivar defender_for_storage: DefenderForStorageOperations operations + :vartype defender_for_storage: + azure.mgmt.security.v2022_12_01_preview.operations.DefenderForStorageOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any + ) -> None: + self._config = SecurityCenterConfiguration(credential=credential, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.defender_for_storage = DefenderForStorageOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-12-01-preview" + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "SecurityCenter": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_vendor.py new file mode 100644 index 000000000000..0dafe0e287ff --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_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/v2022_12_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/__init__.py new file mode 100644 index 000000000000..d9a53c22b3e6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/__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 ._security_center import SecurityCenter + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenter", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/_configuration.py new file mode 100644 index 000000000000..8990bf186cb8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/_configuration.py @@ -0,0 +1,61 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +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 "2022-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2022-12-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) + self._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/v2022_12_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_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/v2022_12_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/_security_center.py new file mode 100644 index 000000000000..c7a9ea71bd41 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/_security_center.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import DefenderForStorageOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword + """API spec for Microsoft.Security (Azure Security Center) resource provider. + + :ivar defender_for_storage: DefenderForStorageOperations operations + :vartype defender_for_storage: + azure.mgmt.security.v2022_12_01_preview.aio.operations.DefenderForStorageOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-12-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any + ) -> None: + self._config = SecurityCenterConfiguration(credential=credential, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.defender_for_storage = DefenderForStorageOperations( + self._client, self._config, self._serialize, self._deserialize, "2022-12-01-preview" + ) + + 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: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..70d5fc321c3b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/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 ._defender_for_storage_operations import DefenderForStorageOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DefenderForStorageOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/operations/_defender_for_storage_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/operations/_defender_for_storage_operations.py new file mode 100644 index 000000000000..ba06ea04f6c5 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/operations/_defender_for_storage_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 io import IOBase +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._defender_for_storage_operations import build_create_request, build_get_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DefenderForStorageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2022_12_01_preview.aio.SecurityCenter`'s + :attr:`defender_for_storage` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def get( + self, resource_id: str, setting_name: Union[str, _models.SettingName], **kwargs: Any + ) -> _models.DefenderForStorageSetting: + """Gets the Defender for Storage settings for the specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.v2022_12_01_preview.models.SettingName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DefenderForStorageSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-12-01-preview") + ) + cls: ClsType[_models.DefenderForStorageSetting] = kwargs.pop("cls", None) + + request = build_get_request( + resource_id=resource_id, + setting_name=setting_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DefenderForStorageSetting", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/{resourceId}/providers/Microsoft.Security/defenderForStorageSettings/{settingName}"} + + @overload + async def create( + self, + resource_id: str, + setting_name: Union[str, _models.SettingName], + defender_for_storage_setting: _models.DefenderForStorageSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForStorageSetting: + """Creates or updates the Defender for Storage settings on a specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.v2022_12_01_preview.models.SettingName + :param defender_for_storage_setting: Defender for Storage Settings. Required. + :type defender_for_storage_setting: + ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DefenderForStorageSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_id: str, + setting_name: Union[str, _models.SettingName], + defender_for_storage_setting: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForStorageSetting: + """Creates or updates the Defender for Storage settings on a specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.v2022_12_01_preview.models.SettingName + :param defender_for_storage_setting: Defender for Storage Settings. Required. + :type defender_for_storage_setting: IO + :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: DefenderForStorageSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_id: str, + setting_name: Union[str, _models.SettingName], + defender_for_storage_setting: Union[_models.DefenderForStorageSetting, IO], + **kwargs: Any + ) -> _models.DefenderForStorageSetting: + """Creates or updates the Defender for Storage settings on a specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.v2022_12_01_preview.models.SettingName + :param defender_for_storage_setting: Defender for Storage Settings. Is either a + DefenderForStorageSetting type or a IO type. Required. + :type defender_for_storage_setting: + ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting 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: DefenderForStorageSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DefenderForStorageSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(defender_for_storage_setting, (IOBase, bytes)): + _content = defender_for_storage_setting + else: + _json = self._serialize.body(defender_for_storage_setting, "DefenderForStorageSetting") + + request = build_create_request( + resource_id=resource_id, + setting_name=setting_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DefenderForStorageSetting", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("DefenderForStorageSetting", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create.metadata = {"url": "/{resourceId}/providers/Microsoft.Security/defenderForStorageSettings/{settingName}"} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/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/v2022_12_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/__init__.py new file mode 100644 index 000000000000..cdc4834354ce --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/__init__.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import CloudErrorBody +from ._models_py3 import DefenderForStorageSetting +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import OperationStatus +from ._models_py3 import Resource + +from ._security_center_enums import SettingName +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "CloudErrorBody", + "DefenderForStorageSetting", + "ErrorAdditionalInfo", + "OperationStatus", + "Resource", + "SettingName", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/_models_py3.py new file mode 100644 index 000000000000..c7f7f0eb8723 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/_models_py3.py @@ -0,0 +1,265 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional + +from ... import _serialization + + +class CloudErrorBody(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.security.v2022_12_01_preview.models.CloudErrorBody] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.security.v2022_12_01_preview.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class Resource(_serialization.Model): + """Describes an Azure resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class DefenderForStorageSetting(Resource): # pylint: disable=too-many-instance-attributes + """The Defender for Storage resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar is_enabled_properties_is_enabled: Indicates whether Defender for Storage is enabled on + this storage account. + :vartype is_enabled_properties_is_enabled: bool + :ivar override_subscription_level_settings: Indicates whether the settings defined for this + storage account should override the settings defined for the subscription. + :vartype override_subscription_level_settings: bool + :ivar is_enabled_properties_sensitive_data_discovery_is_enabled: Indicates whether Sensitive + Data Discovery should be enabled. + :vartype is_enabled_properties_sensitive_data_discovery_is_enabled: bool + :ivar operation_status_properties_sensitive_data_discovery_operation_status: Upon failure or + partial success. Additional data describing Sensitive Data Discovery enable/disable operation. + :vartype operation_status_properties_sensitive_data_discovery_operation_status: + ~azure.mgmt.security.v2022_12_01_preview.models.OperationStatus + :ivar scan_results_event_grid_topic_resource_id: Optional. Resource id of an Event Grid Topic + to send scan results to. + :vartype scan_results_event_grid_topic_resource_id: str + :ivar operation_status_properties_malware_scanning_operation_status: Upon failure or partial + success. Additional data describing Malware Scanning enable/disable operation. + :vartype operation_status_properties_malware_scanning_operation_status: + ~azure.mgmt.security.v2022_12_01_preview.models.OperationStatus + :ivar is_enabled_properties_malware_scanning_on_upload_is_enabled: Indicates whether On Upload + malware scanning should be enabled. + :vartype is_enabled_properties_malware_scanning_on_upload_is_enabled: bool + :ivar cap_gb_per_month: Defines the max GB to be scanned per Month. Set to -1 if no capping is + needed. + :vartype cap_gb_per_month: int + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "operation_status_properties_sensitive_data_discovery_operation_status": {"readonly": True}, + "operation_status_properties_malware_scanning_operation_status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "is_enabled_properties_is_enabled": {"key": "properties.isEnabled", "type": "bool"}, + "override_subscription_level_settings": {"key": "properties.overrideSubscriptionLevelSettings", "type": "bool"}, + "is_enabled_properties_sensitive_data_discovery_is_enabled": { + "key": "properties.sensitiveDataDiscovery.isEnabled", + "type": "bool", + }, + "operation_status_properties_sensitive_data_discovery_operation_status": { + "key": "properties.sensitiveDataDiscovery.operationStatus", + "type": "OperationStatus", + }, + "scan_results_event_grid_topic_resource_id": { + "key": "properties.malwareScanning.scanResultsEventGridTopicResourceId", + "type": "str", + }, + "operation_status_properties_malware_scanning_operation_status": { + "key": "properties.malwareScanning.operationStatus", + "type": "OperationStatus", + }, + "is_enabled_properties_malware_scanning_on_upload_is_enabled": { + "key": "properties.malwareScanning.onUpload.isEnabled", + "type": "bool", + }, + "cap_gb_per_month": {"key": "properties.malwareScanning.onUpload.capGBPerMonth", "type": "int"}, + } + + def __init__( + self, + *, + is_enabled_properties_is_enabled: Optional[bool] = None, + override_subscription_level_settings: Optional[bool] = None, + is_enabled_properties_sensitive_data_discovery_is_enabled: Optional[bool] = None, + scan_results_event_grid_topic_resource_id: Optional[str] = None, + is_enabled_properties_malware_scanning_on_upload_is_enabled: Optional[bool] = None, + cap_gb_per_month: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword is_enabled_properties_is_enabled: Indicates whether Defender for Storage is enabled on + this storage account. + :paramtype is_enabled_properties_is_enabled: bool + :keyword override_subscription_level_settings: Indicates whether the settings defined for this + storage account should override the settings defined for the subscription. + :paramtype override_subscription_level_settings: bool + :keyword is_enabled_properties_sensitive_data_discovery_is_enabled: Indicates whether Sensitive + Data Discovery should be enabled. + :paramtype is_enabled_properties_sensitive_data_discovery_is_enabled: bool + :keyword scan_results_event_grid_topic_resource_id: Optional. Resource id of an Event Grid + Topic to send scan results to. + :paramtype scan_results_event_grid_topic_resource_id: str + :keyword is_enabled_properties_malware_scanning_on_upload_is_enabled: Indicates whether On + Upload malware scanning should be enabled. + :paramtype is_enabled_properties_malware_scanning_on_upload_is_enabled: bool + :keyword cap_gb_per_month: Defines the max GB to be scanned per Month. Set to -1 if no capping + is needed. + :paramtype cap_gb_per_month: int + """ + super().__init__(**kwargs) + self.is_enabled_properties_is_enabled = is_enabled_properties_is_enabled + self.override_subscription_level_settings = override_subscription_level_settings + self.is_enabled_properties_sensitive_data_discovery_is_enabled = ( + is_enabled_properties_sensitive_data_discovery_is_enabled + ) + self.operation_status_properties_sensitive_data_discovery_operation_status = None + self.scan_results_event_grid_topic_resource_id = scan_results_event_grid_topic_resource_id + self.operation_status_properties_malware_scanning_operation_status = None + self.is_enabled_properties_malware_scanning_on_upload_is_enabled = ( + is_enabled_properties_malware_scanning_on_upload_is_enabled + ) + self.cap_gb_per_month = cap_gb_per_month + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class OperationStatus(_serialization.Model): + """A status describing the success/failure of the enablement/disablement operation. + + :ivar code: The operation status code. + :vartype code: str + :ivar message: Additional information regarding the success/failure of the operation. + :vartype message: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword code: The operation status code. + :paramtype code: str + :keyword message: Additional information regarding the success/failure of the operation. + :paramtype message: str + """ + super().__init__(**kwargs) + self.code = code + self.message = message diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_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/v2022_12_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/_security_center_enums.py new file mode 100644 index 000000000000..f15592b91e90 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/models/_security_center_enums.py @@ -0,0 +1,17 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class SettingName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """SettingName.""" + + CURRENT = "current" + """Name of the Defender for Storage Settings name.""" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/operations/__init__.py new file mode 100644 index 000000000000..70d5fc321c3b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/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 ._defender_for_storage_operations import DefenderForStorageOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DefenderForStorageOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/operations/_defender_for_storage_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/operations/_defender_for_storage_operations.py new file mode 100644 index 000000000000..d5afecf40a2c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/operations/_defender_for_storage_operations.py @@ -0,0 +1,319 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, 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 + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(resource_id: str, setting_name: Union[str, _models.SettingName], **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{resourceId}/providers/Microsoft.Security/defenderForStorageSettings/{settingName}" + ) + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request(resource_id: str, setting_name: Union[str, _models.SettingName], **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-12-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{resourceId}/providers/Microsoft.Security/defenderForStorageSettings/{settingName}" + ) + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +class DefenderForStorageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2022_12_01_preview.SecurityCenter`'s + :attr:`defender_for_storage` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def get( + self, resource_id: str, setting_name: Union[str, _models.SettingName], **kwargs: Any + ) -> _models.DefenderForStorageSetting: + """Gets the Defender for Storage settings for the specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.v2022_12_01_preview.models.SettingName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DefenderForStorageSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-12-01-preview") + ) + cls: ClsType[_models.DefenderForStorageSetting] = kwargs.pop("cls", None) + + request = build_get_request( + resource_id=resource_id, + setting_name=setting_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DefenderForStorageSetting", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/{resourceId}/providers/Microsoft.Security/defenderForStorageSettings/{settingName}"} + + @overload + def create( + self, + resource_id: str, + setting_name: Union[str, _models.SettingName], + defender_for_storage_setting: _models.DefenderForStorageSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForStorageSetting: + """Creates or updates the Defender for Storage settings on a specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.v2022_12_01_preview.models.SettingName + :param defender_for_storage_setting: Defender for Storage Settings. Required. + :type defender_for_storage_setting: + ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DefenderForStorageSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_id: str, + setting_name: Union[str, _models.SettingName], + defender_for_storage_setting: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DefenderForStorageSetting: + """Creates or updates the Defender for Storage settings on a specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.v2022_12_01_preview.models.SettingName + :param defender_for_storage_setting: Defender for Storage Settings. Required. + :type defender_for_storage_setting: IO + :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: DefenderForStorageSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_id: str, + setting_name: Union[str, _models.SettingName], + defender_for_storage_setting: Union[_models.DefenderForStorageSetting, IO], + **kwargs: Any + ) -> _models.DefenderForStorageSetting: + """Creates or updates the Defender for Storage settings on a specified storage account. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param setting_name: Defender for Storage setting name. "current" Required. + :type setting_name: str or ~azure.mgmt.security.v2022_12_01_preview.models.SettingName + :param defender_for_storage_setting: Defender for Storage Settings. Is either a + DefenderForStorageSetting type or a IO type. Required. + :type defender_for_storage_setting: + ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting 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: DefenderForStorageSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_12_01_preview.models.DefenderForStorageSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2022-12-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DefenderForStorageSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(defender_for_storage_setting, (IOBase, bytes)): + _content = defender_for_storage_setting + else: + _json = self._serialize.body(defender_for_storage_setting, "DefenderForStorageSetting") + + request = build_create_request( + resource_id=resource_id, + setting_name=setting_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DefenderForStorageSetting", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("DefenderForStorageSetting", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create.metadata = {"url": "/{resourceId}/providers/Microsoft.Security/defenderForStorageSettings/{settingName}"} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_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/v2022_12_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_12_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/v2023_01_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_security_center.py index b1fcc6238204..4a30327092ec 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_security_center.py @@ -52,7 +52,7 @@ def __init__( 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) + self.pricings = PricingsOperations(self._client, self._config, self._serialize, self._deserialize, "2023-01-01") def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_vendor.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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/v2023_01_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_version.py index 34ea7990c4b4..e5754a47ce68 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/_security_center.py index 01a5fef602d9..492709a1a213 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/_security_center.py @@ -52,7 +52,7 @@ def __init__( 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) + self.pricings = PricingsOperations(self._client, self._config, self._serialize, self._deserialize, "2023-01-01") def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/operations/_pricings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/operations/_pricings_operations.py index 180bd2169e0f..8f1142df39da 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/operations/_pricings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/aio/operations/_pricings_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -49,6 +50,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, **kwargs: Any) -> _models.PricingList: @@ -70,7 +72,7 @@ async def list(self, **kwargs: Any) -> _models.PricingList: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.PricingList] = kwargs.pop("cls", None) request = build_list_request( @@ -125,7 +127,7 @@ async def get(self, pricing_name: str, **kwargs: Any) -> _models.Pricing: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) request = build_get_request( @@ -224,14 +226,14 @@ async def update(self, pricing_name: str, pricing: Union[_models.Pricing, IO], * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(pricing, (IO, bytes)): + if isinstance(pricing, (IOBase, bytes)): _content = pricing else: _json = self._serialize.body(pricing, "Pricing") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/operations/_pricings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/operations/_pricings_operations.py index 469079d1e3d1..255fa244c8c4 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/operations/_pricings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01/operations/_pricings_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -25,7 +26,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +50,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +79,7 @@ def build_get_request(pricing_name: str, subscription_id: str, **kwargs: Any) -> "pricingName": _SERIALIZER.url("pricing_name", pricing_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -108,7 +109,7 @@ def build_update_request(pricing_name: str, subscription_id: str, **kwargs: Any) "pricingName": _SERIALIZER.url("pricing_name", pricing_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -139,6 +140,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> _models.PricingList: @@ -160,7 +162,7 @@ def list(self, **kwargs: Any) -> _models.PricingList: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.PricingList] = kwargs.pop("cls", None) request = build_list_request( @@ -215,7 +217,7 @@ def get(self, pricing_name: str, **kwargs: Any) -> _models.Pricing: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) request = build_get_request( @@ -314,14 +316,14 @@ def update(self, pricing_name: str, pricing: Union[_models.Pricing, IO], **kwarg _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Pricing] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(pricing, (IO, bytes)): + if isinstance(pricing, (IOBase, bytes)): _content = pricing else: _json = self._serialize.body(pricing, "Pricing") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_security_center.py index ac7601564ce0..1663c6a04734 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_security_center.py @@ -54,7 +54,7 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.security_operators = SecurityOperatorsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2023-01-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_vendor.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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/v2023_01_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_version.py index 34ea7990c4b4..e5754a47ce68 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/_security_center.py index c50e67d50cc7..070e9237a94e 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/_security_center.py @@ -54,7 +54,7 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.security_operators = SecurityOperatorsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2023-01-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/operations/_security_operators_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/operations/_security_operators_operations.py index 5e8981142f40..ad254b279884 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/operations/_security_operators_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/aio/operations/_security_operators_operations.py @@ -54,6 +54,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def list(self, pricing_name: str, **kwargs: Any) -> _models.SecurityOperatorList: @@ -77,7 +78,9 @@ async def list(self, pricing_name: str, **kwargs: Any) -> _models.SecurityOperat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-01-01-preview") + ) cls: ClsType[_models.SecurityOperatorList] = kwargs.pop("cls", None) request = build_list_request( @@ -137,7 +140,9 @@ async def get(self, pricing_name: str, security_operator_name: str, **kwargs: An _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-01-01-preview") + ) cls: ClsType[_models.SecurityOperator] = kwargs.pop("cls", None) request = build_get_request( @@ -200,7 +205,9 @@ async def create_or_update( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-01-01-preview") + ) cls: ClsType[_models.SecurityOperator] = kwargs.pop("cls", None) request = build_create_or_update_request( @@ -263,7 +270,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-01-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/operations/_security_operators_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/operations/_security_operators_operations.py index 88f474fb9ca6..92755345991c 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/operations/_security_operators_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_01_01_preview/operations/_security_operators_operations.py @@ -25,7 +25,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -55,7 +55,7 @@ def build_list_request(pricing_name: str, subscription_id: str, **kwargs: Any) - ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -97,7 +97,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -139,7 +139,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -181,7 +181,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -210,6 +210,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, pricing_name: str, **kwargs: Any) -> _models.SecurityOperatorList: @@ -233,7 +234,9 @@ def list(self, pricing_name: str, **kwargs: Any) -> _models.SecurityOperatorList _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-01-01-preview") + ) cls: ClsType[_models.SecurityOperatorList] = kwargs.pop("cls", None) request = build_list_request( @@ -293,7 +296,9 @@ def get(self, pricing_name: str, security_operator_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-01-01-preview") + ) cls: ClsType[_models.SecurityOperator] = kwargs.pop("cls", None) request = build_get_request( @@ -356,7 +361,9 @@ def create_or_update( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-01-01-preview") + ) cls: ClsType[_models.SecurityOperator] = kwargs.pop("cls", None) request = build_create_or_update_request( @@ -419,7 +426,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-01-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-01-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_security_center.py index 035e3016766b..43e7a075afa3 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_security_center.py @@ -68,16 +68,20 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.sql_vulnerability_assessment_baseline_rules = SqlVulnerabilityAssessmentBaselineRulesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" ) self.sql_vulnerability_assessment_scans = SqlVulnerabilityAssessmentScansOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" ) self.sql_vulnerability_assessment_scan_results = SqlVulnerabilityAssessmentScanResultsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" + ) + self.health_reports = HealthReportsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" + ) + self.health_report = HealthReportOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" ) - self.health_reports = HealthReportsOperations(self._client, self._config, self._serialize, self._deserialize) - self.health_report = HealthReportOperations(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. diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_vendor.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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/v2023_02_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_version.py index 34ea7990c4b4..e5754a47ce68 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/_security_center.py index 55f9e3c2d844..30c549e7c024 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/_security_center.py @@ -68,16 +68,20 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.sql_vulnerability_assessment_baseline_rules = SqlVulnerabilityAssessmentBaselineRulesOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" ) self.sql_vulnerability_assessment_scans = SqlVulnerabilityAssessmentScansOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" ) self.sql_vulnerability_assessment_scan_results = SqlVulnerabilityAssessmentScanResultsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" + ) + self.health_reports = HealthReportsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" + ) + self.health_report = HealthReportOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-02-01-preview" ) - self.health_reports = HealthReportsOperations(self._client, self._config, self._serialize, self._deserialize) - self.health_report = HealthReportOperations(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. diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_health_report_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_health_report_operations.py index 852329018d70..12acbd3fa508 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_health_report_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_health_report_operations.py @@ -49,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, resource_id: str, health_report_name: str, **kwargs: Any) -> _models.HealthReport: @@ -75,7 +76,9 @@ async def get(self, resource_id: str, health_report_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) cls: ClsType[_models.HealthReport] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_health_reports_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_health_reports_operations.py index dca763a5abab..9df07c928c38 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_health_reports_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_health_reports_operations.py @@ -51,6 +51,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.HealthReport"]: @@ -69,7 +70,9 @@ def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.HealthReport _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) cls: ClsType[_models.HealthReportsList] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_baseline_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_baseline_rules_operations.py index 02b232640a32..308c4b7fd1d7 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_baseline_rules_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_baseline_rules_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -55,6 +56,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload async def create_or_update( @@ -161,14 +163,16 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: @@ -241,7 +245,9 @@ async def get(self, rule_id: str, workspace_id: str, resource_id: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) request = build_get_request( @@ -308,7 +314,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -367,7 +375,9 @@ async def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _mod _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) request = build_list_request( @@ -499,14 +509,16 @@ async def add( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_scan_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_scan_results_operations.py index faf8e1678563..8ced3a5352ad 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_scan_results_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_scan_results_operations.py @@ -49,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get( @@ -83,7 +84,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) cls: ClsType[_models.ScanResult] = kwargs.pop("cls", None) request = build_get_request( @@ -150,7 +153,9 @@ async def list(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) cls: ClsType[_models.ScanResults] = kwargs.pop("cls", None) request = build_list_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_scans_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_scans_operations.py index 3adad361e900..9880755edec5 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_scans_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/aio/operations/_sql_vulnerability_assessment_scans_operations.py @@ -49,6 +49,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace_async async def get(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Scan: @@ -79,7 +80,9 @@ async def get(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) cls: ClsType[_models.Scan] = kwargs.pop("cls", None) request = build_get_request( @@ -142,7 +145,9 @@ async def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _mod _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) cls: ClsType[_models.Scans] = kwargs.pop("cls", None) request = build_list_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_health_report_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_health_report_operations.py index c8dcf4dbf55d..963d9b7c2a59 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_health_report_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_health_report_operations.py @@ -25,7 +25,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +53,7 @@ def build_get_request(resource_id: str, health_report_name: str, **kwargs: Any) ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -82,6 +82,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, resource_id: str, health_report_name: str, **kwargs: Any) -> _models.HealthReport: @@ -108,7 +109,9 @@ def get(self, resource_id: str, health_report_name: str, **kwargs: Any) -> _mode _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) cls: ClsType[_models.HealthReport] = kwargs.pop("cls", None) request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_health_reports_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_health_reports_operations.py index f87d7219a84e..0ed9e0024d1e 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_health_reports_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_health_reports_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +49,7 @@ def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True, max_length=90, min_length=1), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,6 +78,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, scope: str, **kwargs: Any) -> Iterable["_models.HealthReport"]: @@ -96,7 +97,9 @@ def list(self, scope: str, **kwargs: Any) -> Iterable["_models.HealthReport"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) cls: ClsType[_models.HealthReportsList] = kwargs.pop("cls", None) error_map = { diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_baseline_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_baseline_rules_operations.py index 5ed3ce4fed9b..7544d70c4208 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_baseline_rules_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_baseline_rules_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -25,7 +26,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +53,7 @@ def build_create_or_update_request(rule_id: str, resource_id: str, *, workspace_ "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") @@ -83,7 +84,7 @@ def build_get_request(rule_id: str, resource_id: str, *, workspace_id: str, **kw "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") @@ -112,7 +113,7 @@ def build_delete_request(rule_id: str, resource_id: str, *, workspace_id: str, * "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") @@ -139,7 +140,7 @@ def build_list_request(resource_id: str, *, workspace_id: str, **kwargs: Any) -> "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") @@ -167,7 +168,7 @@ def build_add_request(resource_id: str, *, workspace_id: str, **kwargs: Any) -> "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") @@ -199,6 +200,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @overload def create_or_update( @@ -305,14 +307,16 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: @@ -385,7 +389,9 @@ def get(self, rule_id: str, workspace_id: str, resource_id: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) cls: ClsType[_models.RuleResults] = kwargs.pop("cls", None) request = build_get_request( @@ -452,7 +458,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( @@ -511,7 +519,9 @@ def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Ru _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) request = build_list_request( @@ -643,14 +653,16 @@ def add( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.RulesResults] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(body, (IO, bytes)): + if isinstance(body, (IOBase, bytes)): _content = body else: if body is not None: diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_scan_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_scan_results_operations.py index 552d1b48ddf1..1698456df475 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_scan_results_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_scan_results_operations.py @@ -25,7 +25,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -54,7 +54,7 @@ def build_get_request( "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") @@ -83,7 +83,7 @@ def build_list_request(scan_id: str, resource_id: str, *, workspace_id: str, **k "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") @@ -113,6 +113,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get( @@ -147,7 +148,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) cls: ClsType[_models.ScanResult] = kwargs.pop("cls", None) request = build_get_request( @@ -214,7 +217,9 @@ def list(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) cls: ClsType[_models.ScanResults] = kwargs.pop("cls", None) request = build_list_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_scans_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_scans_operations.py index c51aca11e0e4..bc1a9e269e73 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_scans_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_01_preview/operations/_sql_vulnerability_assessment_scans_operations.py @@ -25,7 +25,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +50,7 @@ def build_get_request(scan_id: str, resource_id: str, *, workspace_id: str, **kw "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") @@ -77,7 +77,7 @@ def build_list_request(resource_id: str, *, workspace_id: str, **kwargs: Any) -> "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["workspaceId"] = _SERIALIZER.query("workspace_id", workspace_id, "str") @@ -107,6 +107,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def get(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Scan: @@ -137,7 +138,9 @@ def get(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) cls: ClsType[_models.Scan] = kwargs.pop("cls", None) request = build_get_request( @@ -200,7 +203,9 @@ def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Sc _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-01-preview") + ) cls: ClsType[_models.Scans] = kwargs.pop("cls", None) request = build_list_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/__init__.py new file mode 100644 index 000000000000..e95a015ca6b8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/__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 ._security_center import SecurityCenter +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenter", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_configuration.py new file mode 100644 index 000000000000..31286d72aa1c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_configuration.py @@ -0,0 +1,61 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +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 "2023-02-15-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-02-15-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) + self._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.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/v2023_02_15_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_metadata.json new file mode 100644 index 000000000000..1ff541faafd9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_metadata.json @@ -0,0 +1,131 @@ +{ + "chosen_version": "2023-02-15-preview", + "total_api_version_list": ["2023-02-15-preview"], + "client": { + "name": "SecurityCenter", + "filename": "_security_center", + "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_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\"], \"._operations_mixin\": [\"SecurityCenterOperationsMixin\"]}}, \"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\"], \"._operations_mixin\": [\"SecurityCenterOperationsMixin\"]}}, \"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, + "method_location": "positional" + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + } + }, + "constant": { + }, + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version: Optional[str]=None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"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": { + "sensitivity_settings": "SensitivitySettingsOperations" + }, + "operation_mixins": { + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"regular\": {\"local\": {\".\": [[\"models\", \"_models\"]]}, \"stdlib\": {\"typing\": [\"IO\", \"Optional\", \"Union\"], \"io\": [\"IOBase\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"regular\": {\"local\": {\"..\": [[\"models\", \"_models\"]]}, \"stdlib\": {\"typing\": [\"IO\", \"Optional\", \"Union\"], \"io\": [\"IOBase\"]}}}", + "sync_mixin_typing_definitions": "", + "async_mixin_typing_definitions": "", + "operations": { + "update_sensitivity_settings" : { + "sync": { + "signature": "def update_sensitivity_settings(\n self,\n sensitivity_settings: Union[_models.UpdateSensitivitySettingsRequest, IO],\n **kwargs: Any\n) -\u003e _models.GetSensitivitySettingsResponse:\n", + "doc": "\"\"\"Updates data sensitivity settings for sensitive data discovery.\n\n:param sensitivity_settings: The data sensitivity settings to update. Is either a\n UpdateSensitivitySettingsRequest type or a IO type. Required.\n:type sensitivity_settings:\n ~azure.mgmt.security.v2023_02_15_preview.models.UpdateSensitivitySettingsRequest or IO\n:keyword content_type: Body Parameter content-type. Known values are: \u0027application/json\u0027.\n Default value is None.\n:paramtype content_type: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: GetSensitivitySettingsResponse or the result of cls(response)\n:rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "sensitivity_settings, **kwargs" + }, + "async": { + "coroutine": true, + "signature": "async def update_sensitivity_settings(\n self,\n sensitivity_settings: Union[_models.UpdateSensitivitySettingsRequest, IO],\n **kwargs: Any\n) -\u003e _models.GetSensitivitySettingsResponse:\n", + "doc": "\"\"\"Updates data sensitivity settings for sensitive data discovery.\n\n:param sensitivity_settings: The data sensitivity settings to update. Is either a\n UpdateSensitivitySettingsRequest type or a IO type. Required.\n:type sensitivity_settings:\n ~azure.mgmt.security.v2023_02_15_preview.models.UpdateSensitivitySettingsRequest or IO\n:keyword content_type: Body Parameter content-type. Known values are: \u0027application/json\u0027.\n Default value is None.\n:paramtype content_type: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: GetSensitivitySettingsResponse or the result of cls(response)\n:rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "sensitivity_settings, **kwargs" + } + }, + "get_sensitivity_settings" : { + "sync": { + "signature": "def get_sensitivity_settings(\n self,\n **kwargs: Any\n) -\u003e _models.GetSensitivitySettingsResponse:\n", + "doc": "\"\"\"Gets data sensitivity settings for sensitive data discovery.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: GetSensitivitySettingsResponse or the result of cls(response)\n:rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "**kwargs" + }, + "async": { + "coroutine": true, + "signature": "async def get_sensitivity_settings(\n self,\n **kwargs: Any\n) -\u003e _models.GetSensitivitySettingsResponse:\n", + "doc": "\"\"\"Gets data sensitivity settings for sensitive data discovery.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: GetSensitivitySettingsResponse or the result of cls(response)\n:rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "call": "**kwargs" + } + } + } + } +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_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/v2023_02_15_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_security_center.py new file mode 100644 index 000000000000..7c859dbbc70a --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_security_center.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import SecurityCenterOperationsMixin, SensitivitySettingsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenter(SecurityCenterOperationsMixin): # pylint: disable=client-accepts-api-version-keyword + """API spec for Microsoft.Security (Azure Security Center) resource provider. + + :ivar sensitivity_settings: SensitivitySettingsOperations operations + :vartype sensitivity_settings: + azure.mgmt.security.v2023_02_15_preview.operations.SensitivitySettingsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-02-15-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any + ) -> None: + self._config = SecurityCenterConfiguration(credential=credential, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.sensitivity_settings = SensitivitySettingsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-02-15-preview" + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "SecurityCenter": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_vendor.py new file mode 100644 index 000000000000..3fb0610034d8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_vendor.py @@ -0,0 +1,36 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import SecurityCenterConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import PipelineClient + + from .._serialization import Deserializer, Serializer + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + +class SecurityCenterMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: SecurityCenterConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_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/v2023_02_15_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/__init__.py new file mode 100644 index 000000000000..d9a53c22b3e6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/__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 ._security_center import SecurityCenter + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenter", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/_configuration.py new file mode 100644 index 000000000000..042995ef6a63 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/_configuration.py @@ -0,0 +1,61 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +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 "2023-02-15-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-02-15-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) + self._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/v2023_02_15_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_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/v2023_02_15_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/_security_center.py new file mode 100644 index 000000000000..fcd60d91bfc1 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/_security_center.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import SecurityCenterOperationsMixin, SensitivitySettingsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenter(SecurityCenterOperationsMixin): # pylint: disable=client-accepts-api-version-keyword + """API spec for Microsoft.Security (Azure Security Center) resource provider. + + :ivar sensitivity_settings: SensitivitySettingsOperations operations + :vartype sensitivity_settings: + azure.mgmt.security.v2023_02_15_preview.aio.operations.SensitivitySettingsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-02-15-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any + ) -> None: + self._config = SecurityCenterConfiguration(credential=credential, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.sensitivity_settings = SensitivitySettingsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-02-15-preview" + ) + + 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: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/_vendor.py new file mode 100644 index 000000000000..b5f27b3e8331 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/_vendor.py @@ -0,0 +1,28 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import SecurityCenterConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core import AsyncPipelineClient + + from ..._serialization import Deserializer, Serializer + + +class SecurityCenterMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: SecurityCenterConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..90eb0802810d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/operations/__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_operations import SecurityCenterOperationsMixin +from ._sensitivity_settings_operations import SensitivitySettingsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenterOperationsMixin", + "SensitivitySettingsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/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/v2023_02_15_preview/aio/operations/_security_center_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/operations/_security_center_operations.py new file mode 100644 index 000000000000..853675ca3011 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/operations/_security_center_operations.py @@ -0,0 +1,214 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._security_center_operations import ( + build_get_sensitivity_settings_request, + build_update_sensitivity_settings_request, +) +from .._vendor import SecurityCenterMixinABC + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SecurityCenterOperationsMixin(SecurityCenterMixinABC): + def _api_version(self, op_name: str) -> str: # pylint: disable=unused-argument + try: + return self._config.api_version + except: # pylint: disable=bare-except + return "" + + @overload + async def update_sensitivity_settings( + self, + sensitivity_settings: _models.UpdateSensitivitySettingsRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GetSensitivitySettingsResponse: + """Updates data sensitivity settings for sensitive data discovery. + + :param sensitivity_settings: The data sensitivity settings to update. Required. + :type sensitivity_settings: + ~azure.mgmt.security.v2023_02_15_preview.models.UpdateSensitivitySettingsRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update_sensitivity_settings( + self, sensitivity_settings: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.GetSensitivitySettingsResponse: + """Updates data sensitivity settings for sensitive data discovery. + + :param sensitivity_settings: The data sensitivity settings to update. Required. + :type sensitivity_settings: 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: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update_sensitivity_settings( + self, sensitivity_settings: Union[_models.UpdateSensitivitySettingsRequest, IO], **kwargs: Any + ) -> _models.GetSensitivitySettingsResponse: + """Updates data sensitivity settings for sensitive data discovery. + + :param sensitivity_settings: The data sensitivity settings to update. Is either a + UpdateSensitivitySettingsRequest type or a IO type. Required. + :type sensitivity_settings: + ~azure.mgmt.security.v2023_02_15_preview.models.UpdateSensitivitySettingsRequest 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: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", + _params.pop("api-version", self._api_version("update_sensitivity_settings") or "2023-02-15-preview"), + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GetSensitivitySettingsResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sensitivity_settings, (IOBase, bytes)): + _content = sensitivity_settings + else: + _json = self._serialize.body(sensitivity_settings, "UpdateSensitivitySettingsRequest") + + request = build_update_sensitivity_settings_request( + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update_sensitivity_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GetSensitivitySettingsResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_sensitivity_settings.metadata = {"url": "/providers/Microsoft.Security/sensitivitySettings/current"} + + @distributed_trace_async + async def get_sensitivity_settings(self, **kwargs: Any) -> _models.GetSensitivitySettingsResponse: + """Gets data sensitivity settings for sensitive data discovery. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", + _params.pop("api-version", self._api_version("get_sensitivity_settings") or "2023-02-15-preview"), + ) + cls: ClsType[_models.GetSensitivitySettingsResponse] = kwargs.pop("cls", None) + + request = build_get_sensitivity_settings_request( + api_version=api_version, + template_url=self.get_sensitivity_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GetSensitivitySettingsResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_sensitivity_settings.metadata = {"url": "/providers/Microsoft.Security/sensitivitySettings/current"} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/operations/_sensitivity_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/operations/_sensitivity_settings_operations.py new file mode 100644 index 000000000000..adbbbaeb21da --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/aio/operations/_sensitivity_settings_operations.py @@ -0,0 +1,107 @@ +# 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._sensitivity_settings_operations import build_list_request +from .._vendor import SecurityCenterMixinABC + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SensitivitySettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_02_15_preview.aio.SecurityCenter`'s + :attr:`sensitivity_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def list(self, **kwargs: Any) -> _models.GetSensitivitySettingsListResponse: + """Gets a list with a single sensitivity settings resource. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GetSensitivitySettingsListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsListResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-15-preview") + ) + cls: ClsType[_models.GetSensitivitySettingsListResponse] = kwargs.pop("cls", None) + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GetSensitivitySettingsListResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/providers/Microsoft.Security/sensitivitySettings"} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/__init__.py new file mode 100644 index 000000000000..d4485df65317 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/__init__.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import BuiltInInfoType +from ._models_py3 import CloudErrorBody +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import GetSensitivitySettingsListResponse +from ._models_py3 import GetSensitivitySettingsResponse +from ._models_py3 import GetSensitivitySettingsResponseProperties +from ._models_py3 import GetSensitivitySettingsResponsePropertiesMipInformation +from ._models_py3 import InfoType +from ._models_py3 import Label +from ._models_py3 import UpdateSensitivitySettingsRequest + +from ._security_center_enums import MipIntegrationStatus +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "BuiltInInfoType", + "CloudErrorBody", + "ErrorAdditionalInfo", + "GetSensitivitySettingsListResponse", + "GetSensitivitySettingsResponse", + "GetSensitivitySettingsResponseProperties", + "GetSensitivitySettingsResponsePropertiesMipInformation", + "InfoType", + "Label", + "UpdateSensitivitySettingsRequest", + "MipIntegrationStatus", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/_models_py3.py new file mode 100644 index 000000000000..d70429d32f7e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/_models_py3.py @@ -0,0 +1,435 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class BuiltInInfoType(_serialization.Model): + """Pre-configured sensitive information type. + + :ivar name: Display name of the info type. + :vartype name: str + :ivar id: Id of the info type. + :vartype id: str + :ivar type: Category of the built-in info type. + :vartype type: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + type: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Display name of the info type. + :paramtype name: str + :keyword id: Id of the info type. + :paramtype id: str + :keyword type: Category of the built-in info type. + :paramtype type: str + """ + super().__init__(**kwargs) + self.name = name + self.id = id + self.type = type + + +class CloudErrorBody(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.security.v2023_02_15_preview.models.CloudErrorBody] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.security.v2023_02_15_preview.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class GetSensitivitySettingsListResponse(_serialization.Model): + """A list with a single sensitivity settings resource. + + :ivar value: + :vartype value: + list[~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GetSensitivitySettingsResponse]"}, + } + + def __init__( + self, *, value: Optional[List["_models.GetSensitivitySettingsResponse"]] = None, **kwargs: Any + ) -> None: + """ + :keyword value: + :paramtype value: + list[~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse] + """ + super().__init__(**kwargs) + self.value = value + + +class GetSensitivitySettingsResponse(_serialization.Model): + """Data sensitivity settings for sensitive data discovery. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ID of the sensitivity settings. + :vartype id: str + :ivar type: The type of the sensitivity settings. + :vartype type: str + :ivar name: The name of the sensitivity settings. + :vartype name: str + :ivar properties: The sensitivity settings properties. + :vartype properties: + ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponseProperties + """ + + _validation = { + "id": {"readonly": True}, + "type": {"readonly": True}, + "name": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "GetSensitivitySettingsResponseProperties"}, + } + + def __init__( + self, *, properties: Optional["_models.GetSensitivitySettingsResponseProperties"] = None, **kwargs: Any + ) -> None: + """ + :keyword properties: The sensitivity settings properties. + :paramtype properties: + ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponseProperties + """ + super().__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.properties = properties + + +class GetSensitivitySettingsResponseProperties(_serialization.Model): + """The sensitivity settings properties. + + :ivar sensitive_info_types_ids: List of selected sensitive info types' IDs. + :vartype sensitive_info_types_ids: list[str] + :ivar sensitivity_threshold_label_order: The order of the sensitivity threshold label. Any + label at or above this order will be considered sensitive. If set to -1, sensitivity by labels + is turned off. + :vartype sensitivity_threshold_label_order: float + :ivar sensitivity_threshold_label_id: The id of the sensitivity threshold label. Any label at + or above this rank will be considered sensitive. + :vartype sensitivity_threshold_label_id: str + :ivar mip_information: Microsoft information protection built-in and custom information types, + labels, and integration status. + :vartype mip_information: + ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponsePropertiesMipInformation + """ + + _attribute_map = { + "sensitive_info_types_ids": {"key": "sensitiveInfoTypesIds", "type": "[str]"}, + "sensitivity_threshold_label_order": {"key": "sensitivityThresholdLabelOrder", "type": "float"}, + "sensitivity_threshold_label_id": {"key": "sensitivityThresholdLabelId", "type": "str"}, + "mip_information": {"key": "mipInformation", "type": "GetSensitivitySettingsResponsePropertiesMipInformation"}, + } + + def __init__( + self, + *, + sensitive_info_types_ids: Optional[List[str]] = None, + sensitivity_threshold_label_order: Optional[float] = None, + sensitivity_threshold_label_id: Optional[str] = None, + mip_information: Optional["_models.GetSensitivitySettingsResponsePropertiesMipInformation"] = None, + **kwargs: Any + ) -> None: + """ + :keyword sensitive_info_types_ids: List of selected sensitive info types' IDs. + :paramtype sensitive_info_types_ids: list[str] + :keyword sensitivity_threshold_label_order: The order of the sensitivity threshold label. Any + label at or above this order will be considered sensitive. If set to -1, sensitivity by labels + is turned off. + :paramtype sensitivity_threshold_label_order: float + :keyword sensitivity_threshold_label_id: The id of the sensitivity threshold label. Any label + at or above this rank will be considered sensitive. + :paramtype sensitivity_threshold_label_id: str + :keyword mip_information: Microsoft information protection built-in and custom information + types, labels, and integration status. + :paramtype mip_information: + ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponsePropertiesMipInformation + """ + super().__init__(**kwargs) + self.sensitive_info_types_ids = sensitive_info_types_ids + self.sensitivity_threshold_label_order = sensitivity_threshold_label_order + self.sensitivity_threshold_label_id = sensitivity_threshold_label_id + self.mip_information = mip_information + + +class GetSensitivitySettingsResponsePropertiesMipInformation(_serialization.Model): + """Microsoft information protection built-in and custom information types, labels, and integration + status. + + :ivar mip_integration_status: Microsoft information protection integration status. Known values + are: "Ok", "noConsent", "noAutoLabelingRules", and "noMipLabels". + :vartype mip_integration_status: str or + ~azure.mgmt.security.v2023_02_15_preview.models.MipIntegrationStatus + :ivar labels: List of Microsoft information protection sensitivity labels. + :vartype labels: list[~azure.mgmt.security.v2023_02_15_preview.models.Label] + :ivar custom_info_types: List of custom user-defined information types. + :vartype custom_info_types: list[~azure.mgmt.security.v2023_02_15_preview.models.InfoType] + :ivar built_in_info_types: List of pre-configured sensitive information types. + :vartype built_in_info_types: + list[~azure.mgmt.security.v2023_02_15_preview.models.BuiltInInfoType] + """ + + _attribute_map = { + "mip_integration_status": {"key": "mipIntegrationStatus", "type": "str"}, + "labels": {"key": "labels", "type": "[Label]"}, + "custom_info_types": {"key": "customInfoTypes", "type": "[InfoType]"}, + "built_in_info_types": {"key": "builtInInfoTypes", "type": "[BuiltInInfoType]"}, + } + + def __init__( + self, + *, + mip_integration_status: Optional[Union[str, "_models.MipIntegrationStatus"]] = None, + labels: Optional[List["_models.Label"]] = None, + custom_info_types: Optional[List["_models.InfoType"]] = None, + built_in_info_types: Optional[List["_models.BuiltInInfoType"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword mip_integration_status: Microsoft information protection integration status. Known + values are: "Ok", "noConsent", "noAutoLabelingRules", and "noMipLabels". + :paramtype mip_integration_status: str or + ~azure.mgmt.security.v2023_02_15_preview.models.MipIntegrationStatus + :keyword labels: List of Microsoft information protection sensitivity labels. + :paramtype labels: list[~azure.mgmt.security.v2023_02_15_preview.models.Label] + :keyword custom_info_types: List of custom user-defined information types. + :paramtype custom_info_types: list[~azure.mgmt.security.v2023_02_15_preview.models.InfoType] + :keyword built_in_info_types: List of pre-configured sensitive information types. + :paramtype built_in_info_types: + list[~azure.mgmt.security.v2023_02_15_preview.models.BuiltInInfoType] + """ + super().__init__(**kwargs) + self.mip_integration_status = mip_integration_status + self.labels = labels + self.custom_info_types = custom_info_types + self.built_in_info_types = built_in_info_types + + +class InfoType(_serialization.Model): + """Custom user-defined information type. + + :ivar name: Display name of the info type. + :vartype name: str + :ivar id: Id of the info type. + :vartype id: str + :ivar description: Description of the info type. + :vartype description: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + description: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Display name of the info type. + :paramtype name: str + :keyword id: Id of the info type. + :paramtype id: str + :keyword description: Description of the info type. + :paramtype description: str + """ + super().__init__(**kwargs) + self.name = name + self.id = id + self.description = description + + +class Label(_serialization.Model): + """Microsoft information protection sensitivity label. + + :ivar name: The display name of the label. + :vartype name: str + :ivar id: The ID of the label. + :vartype id: str + :ivar order: Labels are ordered by sensitivity level. The higher the order of the label, the + more sensitive it is. + :vartype order: float + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "order": {"key": "order", "type": "float"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + order: Optional[float] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: The display name of the label. + :paramtype name: str + :keyword id: The ID of the label. + :paramtype id: str + :keyword order: Labels are ordered by sensitivity level. The higher the order of the label, the + more sensitive it is. + :paramtype order: float + """ + super().__init__(**kwargs) + self.name = name + self.id = id + self.order = order + + +class UpdateSensitivitySettingsRequest(_serialization.Model): + """Request to update data sensitivity settings for sensitive data discovery. + + All required parameters must be populated in order to send to Azure. + + :ivar sensitive_info_types_ids: List of selected sensitive info types' IDs. Required. + :vartype sensitive_info_types_ids: list[str] + :ivar sensitivity_threshold_label_order: The order of the sensitivity threshold label. Any + label at or above this order will be considered sensitive. If set to -1, sensitivity by labels + is turned off. + :vartype sensitivity_threshold_label_order: float + :ivar sensitivity_threshold_label_id: The id of the sensitivity threshold label. Any label at + or above this rank will be considered sensitive. + :vartype sensitivity_threshold_label_id: str + """ + + _validation = { + "sensitive_info_types_ids": {"required": True}, + } + + _attribute_map = { + "sensitive_info_types_ids": {"key": "sensitiveInfoTypesIds", "type": "[str]"}, + "sensitivity_threshold_label_order": {"key": "sensitivityThresholdLabelOrder", "type": "float"}, + "sensitivity_threshold_label_id": {"key": "sensitivityThresholdLabelId", "type": "str"}, + } + + def __init__( + self, + *, + sensitive_info_types_ids: List[str], + sensitivity_threshold_label_order: Optional[float] = None, + sensitivity_threshold_label_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword sensitive_info_types_ids: List of selected sensitive info types' IDs. Required. + :paramtype sensitive_info_types_ids: list[str] + :keyword sensitivity_threshold_label_order: The order of the sensitivity threshold label. Any + label at or above this order will be considered sensitive. If set to -1, sensitivity by labels + is turned off. + :paramtype sensitivity_threshold_label_order: float + :keyword sensitivity_threshold_label_id: The id of the sensitivity threshold label. Any label + at or above this rank will be considered sensitive. + :paramtype sensitivity_threshold_label_id: str + """ + super().__init__(**kwargs) + self.sensitive_info_types_ids = sensitive_info_types_ids + self.sensitivity_threshold_label_order = sensitivity_threshold_label_order + self.sensitivity_threshold_label_id = sensitivity_threshold_label_id diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_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/v2023_02_15_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/_security_center_enums.py new file mode 100644 index 000000000000..88712d8f4277 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/models/_security_center_enums.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 enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class MipIntegrationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Microsoft information protection integration status.""" + + OK = "Ok" + NO_CONSENT = "noConsent" + NO_AUTO_LABELING_RULES = "noAutoLabelingRules" + NO_MIP_LABELS = "noMipLabels" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/operations/__init__.py new file mode 100644 index 000000000000..90eb0802810d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/operations/__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_operations import SecurityCenterOperationsMixin +from ._sensitivity_settings_operations import SensitivitySettingsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenterOperationsMixin", + "SensitivitySettingsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_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/v2023_02_15_preview/operations/_security_center_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/operations/_security_center_operations.py new file mode 100644 index 000000000000..2929028363a9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/operations/_security_center_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 io import IOBase +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 SecurityCenterMixinABC, _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_update_sensitivity_settings_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-15-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Security/sensitivitySettings/current") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_sensitivity_settings_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-15-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Security/sensitivitySettings/current") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SecurityCenterOperationsMixin(SecurityCenterMixinABC): + def _api_version(self, op_name: str) -> str: # pylint: disable=unused-argument + try: + return self._config.api_version + except: # pylint: disable=bare-except + return "" + + @overload + def update_sensitivity_settings( + self, + sensitivity_settings: _models.UpdateSensitivitySettingsRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GetSensitivitySettingsResponse: + """Updates data sensitivity settings for sensitive data discovery. + + :param sensitivity_settings: The data sensitivity settings to update. Required. + :type sensitivity_settings: + ~azure.mgmt.security.v2023_02_15_preview.models.UpdateSensitivitySettingsRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update_sensitivity_settings( + self, sensitivity_settings: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.GetSensitivitySettingsResponse: + """Updates data sensitivity settings for sensitive data discovery. + + :param sensitivity_settings: The data sensitivity settings to update. Required. + :type sensitivity_settings: 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: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update_sensitivity_settings( + self, sensitivity_settings: Union[_models.UpdateSensitivitySettingsRequest, IO], **kwargs: Any + ) -> _models.GetSensitivitySettingsResponse: + """Updates data sensitivity settings for sensitive data discovery. + + :param sensitivity_settings: The data sensitivity settings to update. Is either a + UpdateSensitivitySettingsRequest type or a IO type. Required. + :type sensitivity_settings: + ~azure.mgmt.security.v2023_02_15_preview.models.UpdateSensitivitySettingsRequest 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: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", + _params.pop("api-version", self._api_version("update_sensitivity_settings") or "2023-02-15-preview"), + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GetSensitivitySettingsResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sensitivity_settings, (IOBase, bytes)): + _content = sensitivity_settings + else: + _json = self._serialize.body(sensitivity_settings, "UpdateSensitivitySettingsRequest") + + request = build_update_sensitivity_settings_request( + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update_sensitivity_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GetSensitivitySettingsResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_sensitivity_settings.metadata = {"url": "/providers/Microsoft.Security/sensitivitySettings/current"} + + @distributed_trace + def get_sensitivity_settings(self, **kwargs: Any) -> _models.GetSensitivitySettingsResponse: + """Gets data sensitivity settings for sensitive data discovery. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GetSensitivitySettingsResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", + _params.pop("api-version", self._api_version("get_sensitivity_settings") or "2023-02-15-preview"), + ) + cls: ClsType[_models.GetSensitivitySettingsResponse] = kwargs.pop("cls", None) + + request = build_get_sensitivity_settings_request( + api_version=api_version, + template_url=self.get_sensitivity_settings.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GetSensitivitySettingsResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_sensitivity_settings.metadata = {"url": "/providers/Microsoft.Security/sensitivitySettings/current"} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/operations/_sensitivity_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/operations/_sensitivity_settings_operations.py new file mode 100644 index 000000000000..9bf087b1127f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/operations/_sensitivity_settings_operations.py @@ -0,0 +1,128 @@ +# 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 SecurityCenterMixinABC, _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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-02-15-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Security/sensitivitySettings") + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SensitivitySettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_02_15_preview.SecurityCenter`'s + :attr:`sensitivity_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> _models.GetSensitivitySettingsListResponse: + """Gets a list with a single sensitivity settings resource. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GetSensitivitySettingsListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_02_15_preview.models.GetSensitivitySettingsListResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-02-15-preview") + ) + cls: ClsType[_models.GetSensitivitySettingsListResponse] = kwargs.pop("cls", None) + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GetSensitivitySettingsListResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/providers/Microsoft.Security/sensitivitySettings"} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_15_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_02_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/v2023_03_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_security_center.py index 6191cafe4d13..fdf5c78b6825 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_security_center.py @@ -54,7 +54,7 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.security_connectors = SecurityConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2023-03-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_vendor.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): 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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], 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/v2023_03_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_version.py index 34ea7990c4b4..e5754a47ce68 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/_security_center.py index 473190a468cc..a5c4f44cfecf 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/_security_center.py @@ -54,7 +54,7 @@ def __init__( self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False self.security_connectors = SecurityConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize + self._client, self._config, self._serialize, self._deserialize, "2023-03-01-preview" ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/operations/_security_connectors_operations.py index a30183ad45ae..6e8d2a508228 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/operations/_security_connectors_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/aio/operations/_security_connectors_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -59,6 +60,7 @@ def __init__(self, *args, **kwargs) -> None: self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityConnector"]: @@ -74,7 +76,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityConnector"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") + ) cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) error_map = { @@ -161,7 +165,9 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") + ) cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) error_map = { @@ -259,7 +265,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") + ) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) request = build_get_request( @@ -393,14 +401,16 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_connector, (IO, bytes)): + if isinstance(security_connector, (IOBase, bytes)): _content = security_connector else: _json = self._serialize.body(security_connector, "SecurityConnector") @@ -540,14 +550,16 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_connector, (IO, bytes)): + if isinstance(security_connector, (IOBase, bytes)): _content = security_connector else: _json = self._serialize.body(security_connector, "SecurityConnector") @@ -616,7 +628,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/operations/_security_connectors_operations.py index 616ae06d5e7f..b681b64550d3 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/operations/_security_connectors_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_03_01_preview/operations/_security_connectors_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -27,7 +28,7 @@ from .. import models as _models from ..._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +52,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -83,7 +84,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -118,7 +119,7 @@ def build_get_request( "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,7 +155,7 @@ def build_create_or_update_request( "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -192,7 +193,7 @@ def build_update_request( "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -229,7 +230,7 @@ def build_delete_request( "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -258,6 +259,7 @@ def __init__(self, *args, **kwargs): self._config = input_args.pop(0) if input_args else kwargs.pop("config") self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: @@ -273,7 +275,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") + ) cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) error_map = { @@ -358,7 +362,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") + ) cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) error_map = { @@ -454,7 +460,9 @@ def get(self, resource_group_name: str, security_connector_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") + ) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) request = build_get_request( @@ -588,14 +596,16 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_connector, (IO, bytes)): + if isinstance(security_connector, (IOBase, bytes)): _content = security_connector else: _json = self._serialize.body(security_connector, "SecurityConnector") @@ -735,14 +745,16 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") + ) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(security_connector, (IO, bytes)): + if isinstance(security_connector, (IOBase, bytes)): _content = security_connector else: _json = self._serialize.body(security_connector, "SecurityConnector") @@ -811,7 +823,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-03-01-preview")) + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-03-01-preview") + ) cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/__init__.py new file mode 100644 index 000000000000..e95a015ca6b8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/__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 ._security_center import SecurityCenter +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenter", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_configuration.py new file mode 100644 index 000000000000..d6fb770f931e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_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 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: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-05-01") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) + self._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.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/v2023_05_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_metadata.json new file mode 100644 index 000000000000..9ea718dd0cc7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_metadata.json @@ -0,0 +1,110 @@ +{ + "chosen_version": "2023-05-01", + "total_api_version_list": ["2023-05-01"], + "client": { + "name": "SecurityCenter", + "filename": "_security_center", + "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_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, + "method_location": "positional" + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. The value must be an UUID. Required.", + "docstring_type": "str", + "required": true, + "method_location": "positional" + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. The value must be an UUID. Required.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version: Optional[str]=None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"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_assessments_settings": "ServerVulnerabilityAssessmentsSettingsOperations" + } +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_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/v2023_05_01/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_security_center.py new file mode 100644 index 000000000000..bcd07903a85c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_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, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import ServerVulnerabilityAssessmentsSettingsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword + """API spec for Microsoft.Security (Azure Security Center) resource provider. + + :ivar server_vulnerability_assessments_settings: + ServerVulnerabilityAssessmentsSettingsOperations operations + :vartype server_vulnerability_assessments_settings: + azure.mgmt.security.v2023_05_01.operations.ServerVulnerabilityAssessmentsSettingsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.server_vulnerability_assessments_settings = ServerVulnerabilityAssessmentsSettingsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "SecurityCenter": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_vendor.py new file mode 100644 index 000000000000..0dafe0e287ff --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_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/v2023_05_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/__init__.py new file mode 100644 index 000000000000..d9a53c22b3e6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/__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 ._security_center import SecurityCenter + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenter", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/_configuration.py new file mode 100644 index 000000000000..773ff03fa1be --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_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: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-05-01") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) + self._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/v2023_05_01/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_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/v2023_05_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/_security_center.py new file mode 100644 index 000000000000..6a58f200b895 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_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 as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import ServerVulnerabilityAssessmentsSettingsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword + """API spec for Microsoft.Security (Azure Security Center) resource provider. + + :ivar server_vulnerability_assessments_settings: + ServerVulnerabilityAssessmentsSettingsOperations operations + :vartype server_vulnerability_assessments_settings: + azure.mgmt.security.v2023_05_01.aio.operations.ServerVulnerabilityAssessmentsSettingsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.server_vulnerability_assessments_settings = ServerVulnerabilityAssessmentsSettingsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01" + ) + + 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: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/operations/__init__.py new file mode 100644 index 000000000000..72407abb3340 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_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 ._server_vulnerability_assessments_settings_operations import ServerVulnerabilityAssessmentsSettingsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ServerVulnerabilityAssessmentsSettingsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_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/v2023_05_01/aio/operations/_server_vulnerability_assessments_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/operations/_server_vulnerability_assessments_settings_operations.py new file mode 100644 index 000000000000..a625f718a348 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/aio/operations/_server_vulnerability_assessments_settings_operations.py @@ -0,0 +1,421 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._server_vulnerability_assessments_settings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_subscription_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ServerVulnerabilityAssessmentsSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_05_01.aio.SecurityCenter`'s + :attr:`server_vulnerability_assessments_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ServerVulnerabilityAssessmentsSetting"]: + """Get a list of all the server vulnerability assessments settings over a subscription level + scope. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServerVulnerabilityAssessmentsSetting or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.ServerVulnerabilityAssessmentsSettingsList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ServerVulnerabilityAssessmentsSettingsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings" + } + + @distributed_trace_async + async def get( + self, setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], **kwargs: Any + ) -> _models.ServerVulnerabilityAssessmentsSetting: + """Get a server vulnerability assessments setting of the requested kind, that is set on the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServerVulnerabilityAssessmentsSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.ServerVulnerabilityAssessmentsSetting] = kwargs.pop("cls", None) + + request = build_get_request( + setting_kind=setting_kind, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServerVulnerabilityAssessmentsSetting", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/{settingKind}" + } + + @overload + async def create_or_update( + self, + setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], + server_vulnerability_assessments_setting: _models.ServerVulnerabilityAssessmentsSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessmentsSetting: + """Create or update a server vulnerability assessments setting of the requested kind on the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName + :param server_vulnerability_assessments_setting: A server vulnerability assessments setting + over a predefined scope. Required. + :type server_vulnerability_assessments_setting: + ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServerVulnerabilityAssessmentsSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], + server_vulnerability_assessments_setting: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessmentsSetting: + """Create or update a server vulnerability assessments setting of the requested kind on the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName + :param server_vulnerability_assessments_setting: A server vulnerability assessments setting + over a predefined scope. Required. + :type server_vulnerability_assessments_setting: IO + :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: ServerVulnerabilityAssessmentsSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], + server_vulnerability_assessments_setting: Union[_models.ServerVulnerabilityAssessmentsSetting, IO], + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessmentsSetting: + """Create or update a server vulnerability assessments setting of the requested kind on the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName + :param server_vulnerability_assessments_setting: A server vulnerability assessments setting + over a predefined scope. Is either a ServerVulnerabilityAssessmentsSetting type or a IO type. + Required. + :type server_vulnerability_assessments_setting: + ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting 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: ServerVulnerabilityAssessmentsSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ServerVulnerabilityAssessmentsSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(server_vulnerability_assessments_setting, (IOBase, bytes)): + _content = server_vulnerability_assessments_setting + else: + _json = self._serialize.body( + server_vulnerability_assessments_setting, "ServerVulnerabilityAssessmentsSetting" + ) + + request = build_create_or_update_request( + setting_kind=setting_kind, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ServerVulnerabilityAssessmentsSetting", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ServerVulnerabilityAssessmentsSetting", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/{settingKind}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], **kwargs: Any + ) -> None: + """Delete the server vulnerability assessments setting of the requested kind from the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + setting_kind=setting_kind, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/{settingKind}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/__init__.py new file mode 100644 index 000000000000..835b2d97d7e9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/__init__.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import AzureServersSetting +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import Resource +from ._models_py3 import ServerVulnerabilityAssessmentsSetting +from ._models_py3 import ServerVulnerabilityAssessmentsSettingsList +from ._models_py3 import SystemData + +from ._security_center_enums import CreatedByType +from ._security_center_enums import ServerVulnerabilityAssessmentsAzureSettingSelectedProvider +from ._security_center_enums import ServerVulnerabilityAssessmentsSettingKind +from ._security_center_enums import ServerVulnerabilityAssessmentsSettingKindName +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AzureServersSetting", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "Resource", + "ServerVulnerabilityAssessmentsSetting", + "ServerVulnerabilityAssessmentsSettingsList", + "SystemData", + "CreatedByType", + "ServerVulnerabilityAssessmentsAzureSettingSelectedProvider", + "ServerVulnerabilityAssessmentsSettingKind", + "ServerVulnerabilityAssessmentsSettingKindName", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/_models_py3.py new file mode 100644 index 000000000000..0cdc27976e38 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/_models_py3.py @@ -0,0 +1,358 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import Any, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class Resource(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.security.v2023_05_01.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.system_data = None + + +class ServerVulnerabilityAssessmentsSetting(Resource): + """A base vulnerability assessments setting on servers in the defined scope. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureServersSetting + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.security.v2023_05_01.models.SystemData + :ivar kind: The kind of the server vulnerability assessments setting. Required. + "AzureServersSetting" + :vartype kind: str or + ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKind + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "kind": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "kind": {"key": "kind", "type": "str"}, + } + + _subtype_map = {"kind": {"AzureServersSetting": "AzureServersSetting"}} + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.kind: Optional[str] = None + + +class AzureServersSetting(ServerVulnerabilityAssessmentsSetting): + """A vulnerability assessments setting on Azure servers in the defined scope. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.security.v2023_05_01.models.SystemData + :ivar kind: The kind of the server vulnerability assessments setting. Required. + "AzureServersSetting" + :vartype kind: str or + ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKind + :ivar selected_provider: The selected vulnerability assessments provider on Azure servers in + the defined scope. "MdeTvm" + :vartype selected_provider: str or + ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsAzureSettingSelectedProvider + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "kind": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "kind": {"key": "kind", "type": "str"}, + "selected_provider": {"key": "properties.selectedProvider", "type": "str"}, + } + + def __init__( + self, + *, + selected_provider: Optional[ + Union[str, "_models.ServerVulnerabilityAssessmentsAzureSettingSelectedProvider"] + ] = None, + **kwargs: Any + ) -> None: + """ + :keyword selected_provider: The selected vulnerability assessments provider on Azure servers in + the defined scope. "MdeTvm" + :paramtype selected_provider: str or + ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsAzureSettingSelectedProvider + """ + super().__init__(**kwargs) + self.kind: str = "AzureServersSetting" + self.selected_provider = selected_provider + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.security.v2023_05_01.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.security.v2023_05_01.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.security.v2023_05_01.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.security.v2023_05_01.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class ServerVulnerabilityAssessmentsSettingsList(_serialization.Model): + """A page of a server vulnerability assessments settings list. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: A collection of server vulnerability assessments settings in this page. + :vartype value: + list[~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ServerVulnerabilityAssessmentsSetting]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.security.v2023_05_01.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.security.v2023_05_01.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.security.v2023_05_01.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.security.v2023_05_01.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_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/v2023_05_01/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/_security_center_enums.py new file mode 100644 index 000000000000..7118988347bd --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/models/_security_center_enums.py @@ -0,0 +1,38 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class ServerVulnerabilityAssessmentsAzureSettingSelectedProvider(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The selected vulnerability assessments provider on Azure servers in the defined scope.""" + + MDE_TVM = "MdeTvm" + """Microsoft Defender for Endpoints threat and vulnerability management.""" + + +class ServerVulnerabilityAssessmentsSettingKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The kind of the server vulnerability assessments setting.""" + + AZURE_SERVERS_SETTING = "AzureServersSetting" + + +class ServerVulnerabilityAssessmentsSettingKindName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ServerVulnerabilityAssessmentsSettingKindName.""" + + AZURE_SERVERS_SETTING = "azureServersSetting" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/operations/__init__.py new file mode 100644 index 000000000000..72407abb3340 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_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 ._server_vulnerability_assessments_settings_operations import ServerVulnerabilityAssessmentsSettingsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ServerVulnerabilityAssessmentsSettingsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_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/v2023_05_01/operations/_server_vulnerability_assessments_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/operations/_server_vulnerability_assessments_settings_operations.py new file mode 100644 index 000000000000..4dab2d44dc89 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/operations/_server_vulnerability_assessments_settings_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 io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _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_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/{settingKind}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "settingKind": _SERIALIZER.url("setting_kind", setting_kind, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/{settingKind}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "settingKind": _SERIALIZER.url("setting_kind", setting_kind, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/{settingKind}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "settingKind": _SERIALIZER.url("setting_kind", setting_kind, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ServerVulnerabilityAssessmentsSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_05_01.SecurityCenter`'s + :attr:`server_vulnerability_assessments_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ServerVulnerabilityAssessmentsSetting"]: + """Get a list of all the server vulnerability assessments settings over a subscription level + scope. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServerVulnerabilityAssessmentsSetting or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.ServerVulnerabilityAssessmentsSettingsList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ServerVulnerabilityAssessmentsSettingsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings" + } + + @distributed_trace + def get( + self, setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], **kwargs: Any + ) -> _models.ServerVulnerabilityAssessmentsSetting: + """Get a server vulnerability assessments setting of the requested kind, that is set on the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServerVulnerabilityAssessmentsSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[_models.ServerVulnerabilityAssessmentsSetting] = kwargs.pop("cls", None) + + request = build_get_request( + setting_kind=setting_kind, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ServerVulnerabilityAssessmentsSetting", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/{settingKind}" + } + + @overload + def create_or_update( + self, + setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], + server_vulnerability_assessments_setting: _models.ServerVulnerabilityAssessmentsSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessmentsSetting: + """Create or update a server vulnerability assessments setting of the requested kind on the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName + :param server_vulnerability_assessments_setting: A server vulnerability assessments setting + over a predefined scope. Required. + :type server_vulnerability_assessments_setting: + ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServerVulnerabilityAssessmentsSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], + server_vulnerability_assessments_setting: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessmentsSetting: + """Create or update a server vulnerability assessments setting of the requested kind on the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName + :param server_vulnerability_assessments_setting: A server vulnerability assessments setting + over a predefined scope. Required. + :type server_vulnerability_assessments_setting: IO + :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: ServerVulnerabilityAssessmentsSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], + server_vulnerability_assessments_setting: Union[_models.ServerVulnerabilityAssessmentsSetting, IO], + **kwargs: Any + ) -> _models.ServerVulnerabilityAssessmentsSetting: + """Create or update a server vulnerability assessments setting of the requested kind on the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName + :param server_vulnerability_assessments_setting: A server vulnerability assessments setting + over a predefined scope. Is either a ServerVulnerabilityAssessmentsSetting type or a IO type. + Required. + :type server_vulnerability_assessments_setting: + ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting 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: ServerVulnerabilityAssessmentsSetting or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ServerVulnerabilityAssessmentsSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(server_vulnerability_assessments_setting, (IOBase, bytes)): + _content = server_vulnerability_assessments_setting + else: + _json = self._serialize.body( + server_vulnerability_assessments_setting, "ServerVulnerabilityAssessmentsSetting" + ) + + request = build_create_or_update_request( + setting_kind=setting_kind, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ServerVulnerabilityAssessmentsSetting", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ServerVulnerabilityAssessmentsSetting", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/{settingKind}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, setting_kind: Union[str, _models.ServerVulnerabilityAssessmentsSettingKindName], **kwargs: Any + ) -> None: + """Delete the server vulnerability assessments setting of the requested kind from the + subscription. + + :param setting_kind: The kind of the server vulnerability assessments setting. + "azureServersSetting" Required. + :type setting_kind: str or + ~azure.mgmt.security.v2023_05_01.models.ServerVulnerabilityAssessmentsSettingKindName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-05-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + setting_kind=setting_kind, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/serverVulnerabilityAssessmentsSettings/{settingKind}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_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/v2023_05_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/__init__.py new file mode 100644 index 000000000000..e95a015ca6b8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/__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 ._security_center import SecurityCenter +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenter", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_configuration.py new file mode 100644 index 000000000000..7f7a8366a449 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_configuration.py @@ -0,0 +1,61 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +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 "2023-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-05-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) + self._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.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/v2023_05_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_metadata.json new file mode 100644 index 000000000000..bf7e43608bcd --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_metadata.json @@ -0,0 +1,97 @@ +{ + "chosen_version": "2023-05-01-preview", + "total_api_version_list": ["2023-05-01-preview"], + "client": { + "name": "SecurityCenter", + "filename": "_security_center", + "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_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, + "method_location": "positional" + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + } + }, + "constant": { + }, + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version: Optional[str]=None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"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": { + "health_reports": "HealthReportsOperations" + } +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_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/v2023_05_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_security_center.py new file mode 100644 index 000000000000..31a5dd724329 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_security_center.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import HealthReportsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword + """API spec for Microsoft.Security (Azure Security Center) resource provider. + + :ivar health_reports: HealthReportsOperations operations + :vartype health_reports: + azure.mgmt.security.v2023_05_01_preview.operations.HealthReportsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, credential: "TokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any + ) -> None: + self._config = SecurityCenterConfiguration(credential=credential, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.health_reports = HealthReportsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01-preview" + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "SecurityCenter": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_vendor.py new file mode 100644 index 000000000000..0dafe0e287ff --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_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/v2023_05_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/__init__.py new file mode 100644 index 000000000000..d9a53c22b3e6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/__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 ._security_center import SecurityCenter + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenter", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/_configuration.py new file mode 100644 index 000000000000..bc15b4799de7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/_configuration.py @@ -0,0 +1,61 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +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 "2023-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-05-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) + self._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/v2023_05_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_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/v2023_05_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/_security_center.py new file mode 100644 index 000000000000..60994a1248dd --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/_security_center.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import HealthReportsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword + """API spec for Microsoft.Security (Azure Security Center) resource provider. + + :ivar health_reports: HealthReportsOperations operations + :vartype health_reports: + azure.mgmt.security.v2023_05_01_preview.aio.operations.HealthReportsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, credential: "AsyncTokenCredential", base_url: str = "https://management.azure.com", **kwargs: Any + ) -> None: + self._config = SecurityCenterConfiguration(credential=credential, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.health_reports = HealthReportsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-05-01-preview" + ) + + 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: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..f9b535e20872 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/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 ._health_reports_operations import HealthReportsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "HealthReportsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/operations/_health_reports_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/operations/_health_reports_operations.py new file mode 100644 index 000000000000..33f3c518e1a4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/operations/_health_reports_operations.py @@ -0,0 +1,205 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._health_reports_operations import build_get_request, build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class HealthReportsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_05_01_preview.aio.SecurityCenter`'s + :attr:`health_reports` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.HealthReport"]: + """Get a list of all health reports inside a scope. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + + :param scope: The scope at which the operation is performed. Required. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either HealthReport or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_05_01_preview.models.HealthReport] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-05-01-preview") + ) + cls: ClsType[_models.HealthReportsList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("HealthReportsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/{scope}/providers/Microsoft.Security/healthReports"} + + @distributed_trace_async + async def get(self, resource_id: str, health_report_name: str, **kwargs: Any) -> _models.HealthReport: + """Get health report of resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param health_report_name: The health report Key - Unique key for the health report type. + Required. + :type health_report_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HealthReport or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_05_01_preview.models.HealthReport + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-05-01-preview") + ) + cls: ClsType[_models.HealthReport] = kwargs.pop("cls", None) + + request = build_get_request( + resource_id=resource_id, + health_report_name=health_report_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("HealthReport", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/{resourceId}/providers/Microsoft.Security/healthReports/{healthReportName}"} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/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/v2023_05_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/__init__.py new file mode 100644 index 000000000000..ddea02a9536c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/__init__.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import EnvironmentDetails +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import HealthDataClassification +from ._models_py3 import HealthReport +from ._models_py3 import HealthReportsList +from ._models_py3 import Issue +from ._models_py3 import Resource +from ._models_py3 import ResourceDetails +from ._models_py3 import Status + +from ._security_center_enums import Source +from ._security_center_enums import StatusName +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "EnvironmentDetails", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "HealthDataClassification", + "HealthReport", + "HealthReportsList", + "Issue", + "Resource", + "ResourceDetails", + "Status", + "Source", + "StatusName", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/_models_py3.py new file mode 100644 index 000000000000..8ddd52179cf0 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/_models_py3.py @@ -0,0 +1,528 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class EnvironmentDetails(_serialization.Model): + """The environment details of the resource. + + :ivar native_resource_id: The native resource id of the resource (in case of Azure - the + resource Id, in case of MC - the native resource id). + :vartype native_resource_id: str + :ivar environment_hierarchy_id: The hierarchy id of the connector (in case of Azure - the + subscription Id, in case of MC - the hierarchyId id). + :vartype environment_hierarchy_id: str + :ivar organizational_hierarchy_id: The organizational hierarchy id of the connector (in case of + Azure - the subscription Id, in case of MC - the organizational hierarchyId id). + :vartype organizational_hierarchy_id: str + :ivar subscription_id: The subscription Id. + :vartype subscription_id: str + :ivar tenant_id: The tenant Id. + :vartype tenant_id: str + """ + + _attribute_map = { + "native_resource_id": {"key": "nativeResourceId", "type": "str"}, + "environment_hierarchy_id": {"key": "environmentHierarchyId", "type": "str"}, + "organizational_hierarchy_id": {"key": "organizationalHierarchyId", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + } + + def __init__( + self, + *, + native_resource_id: Optional[str] = None, + environment_hierarchy_id: Optional[str] = None, + organizational_hierarchy_id: Optional[str] = None, + subscription_id: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword native_resource_id: The native resource id of the resource (in case of Azure - the + resource Id, in case of MC - the native resource id). + :paramtype native_resource_id: str + :keyword environment_hierarchy_id: The hierarchy id of the connector (in case of Azure - the + subscription Id, in case of MC - the hierarchyId id). + :paramtype environment_hierarchy_id: str + :keyword organizational_hierarchy_id: The organizational hierarchy id of the connector (in case + of Azure - the subscription Id, in case of MC - the organizational hierarchyId id). + :paramtype organizational_hierarchy_id: str + :keyword subscription_id: The subscription Id. + :paramtype subscription_id: str + :keyword tenant_id: The tenant Id. + :paramtype tenant_id: str + """ + super().__init__(**kwargs) + self.native_resource_id = native_resource_id + self.environment_hierarchy_id = environment_hierarchy_id + self.organizational_hierarchy_id = organizational_hierarchy_id + self.subscription_id = subscription_id + self.tenant_id = tenant_id + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.security.v2023_05_01_preview.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.security.v2023_05_01_preview.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.security.v2023_05_01_preview.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.security.v2023_05_01_preview.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class HealthDataClassification(_serialization.Model): + """The classification of the health report. + + :ivar component: The component describes the name of the agent/service that scans the issue. + :vartype component: str + :ivar scenario: The scenario describes the health scenario issue of the component. + :vartype scenario: str + :ivar scope: The resource scope of the health report. + :vartype scope: str + """ + + _attribute_map = { + "component": {"key": "component", "type": "str"}, + "scenario": {"key": "scenario", "type": "str"}, + "scope": {"key": "scope", "type": "str"}, + } + + def __init__( + self, + *, + component: Optional[str] = None, + scenario: Optional[str] = None, + scope: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword component: The component describes the name of the agent/service that scans the issue. + :paramtype component: str + :keyword scenario: The scenario describes the health scenario issue of the component. + :paramtype scenario: str + :keyword scope: The resource scope of the health report. + :paramtype scope: str + """ + super().__init__(**kwargs) + self.component = component + self.scenario = scenario + self.scope = scope + + +class Resource(_serialization.Model): + """Describes an Azure resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class HealthReport(Resource): # pylint: disable=too-many-instance-attributes + """The health report resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar resource_details: The resource details of the health report. + :vartype resource_details: ~azure.mgmt.security.v2023_05_01_preview.models.ResourceDetails + :ivar environment_details: The environment details of the resource. + :vartype environment_details: + ~azure.mgmt.security.v2023_05_01_preview.models.EnvironmentDetails + :ivar health_data_classification: The classification of the health report. + :vartype health_data_classification: + ~azure.mgmt.security.v2023_05_01_preview.models.HealthDataClassification + :ivar status: The status of the health report. + :vartype status: ~azure.mgmt.security.v2023_05_01_preview.models.Status + :ivar affected_defenders_plans: The affected defenders plans by unhealthy report. + :vartype affected_defenders_plans: list[str] + :ivar affected_defenders_sub_plans: The affected defenders sub plans by unhealthy report. + :vartype affected_defenders_sub_plans: list[str] + :ivar report_additional_data: Additional data for the given health report, this field can + include more details on the resource and the health scenario. + :vartype report_additional_data: dict[str, str] + :ivar issues: A collection of the issues in the report. + :vartype issues: list[~azure.mgmt.security.v2023_05_01_preview.models.Issue] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "report_additional_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "resource_details": {"key": "properties.resourceDetails", "type": "ResourceDetails"}, + "environment_details": {"key": "properties.environmentDetails", "type": "EnvironmentDetails"}, + "health_data_classification": { + "key": "properties.healthDataClassification", + "type": "HealthDataClassification", + }, + "status": {"key": "properties.status", "type": "Status"}, + "affected_defenders_plans": {"key": "properties.affectedDefendersPlans", "type": "[str]"}, + "affected_defenders_sub_plans": {"key": "properties.affectedDefendersSubPlans", "type": "[str]"}, + "report_additional_data": {"key": "properties.reportAdditionalData", "type": "{str}"}, + "issues": {"key": "properties.issues", "type": "[Issue]"}, + } + + def __init__( + self, + *, + resource_details: Optional["_models.ResourceDetails"] = None, + environment_details: Optional["_models.EnvironmentDetails"] = None, + health_data_classification: Optional["_models.HealthDataClassification"] = None, + status: Optional["_models.Status"] = None, + affected_defenders_plans: Optional[List[str]] = None, + affected_defenders_sub_plans: Optional[List[str]] = None, + issues: Optional[List["_models.Issue"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword resource_details: The resource details of the health report. + :paramtype resource_details: ~azure.mgmt.security.v2023_05_01_preview.models.ResourceDetails + :keyword environment_details: The environment details of the resource. + :paramtype environment_details: + ~azure.mgmt.security.v2023_05_01_preview.models.EnvironmentDetails + :keyword health_data_classification: The classification of the health report. + :paramtype health_data_classification: + ~azure.mgmt.security.v2023_05_01_preview.models.HealthDataClassification + :keyword status: The status of the health report. + :paramtype status: ~azure.mgmt.security.v2023_05_01_preview.models.Status + :keyword affected_defenders_plans: The affected defenders plans by unhealthy report. + :paramtype affected_defenders_plans: list[str] + :keyword affected_defenders_sub_plans: The affected defenders sub plans by unhealthy report. + :paramtype affected_defenders_sub_plans: list[str] + :keyword issues: A collection of the issues in the report. + :paramtype issues: list[~azure.mgmt.security.v2023_05_01_preview.models.Issue] + """ + super().__init__(**kwargs) + self.resource_details = resource_details + self.environment_details = environment_details + self.health_data_classification = health_data_classification + self.status = status + self.affected_defenders_plans = affected_defenders_plans + self.affected_defenders_sub_plans = affected_defenders_sub_plans + self.report_additional_data = None + self.issues = issues + + +class HealthReportsList(_serialization.Model): + """Page of health reports list. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Collection of health reports in this page. + :vartype value: list[~azure.mgmt.security.v2023_05_01_preview.models.HealthReport] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[HealthReport]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class Issue(_serialization.Model): + """The issue that caused the resource to by unhealthy. + + All required parameters must be populated in order to send to Azure. + + :ivar issue_key: The unique issue key. Required. + :vartype issue_key: str + :ivar issue_name: The issue name. + :vartype issue_name: str + :ivar security_values: The affected security values that MDC offers that will be affected by + the issue, for example: recommendations, alerts, etc. + :vartype security_values: list[str] + :ivar issue_description: The issue description. + :vartype issue_description: str + :ivar remediation_steps: Human readable description of what you should do to mitigate this + health issue. + :vartype remediation_steps: str + :ivar remediation_script: The remediation script to solve this issue. + :vartype remediation_script: str + :ivar issue_additional_data: Additional data for the given issue. The additional data depends + on the issue type. + :vartype issue_additional_data: dict[str, str] + """ + + _validation = { + "issue_key": {"required": True}, + } + + _attribute_map = { + "issue_key": {"key": "issueKey", "type": "str"}, + "issue_name": {"key": "issueName", "type": "str"}, + "security_values": {"key": "securityValues", "type": "[str]"}, + "issue_description": {"key": "issueDescription", "type": "str"}, + "remediation_steps": {"key": "remediationSteps", "type": "str"}, + "remediation_script": {"key": "remediationScript", "type": "str"}, + "issue_additional_data": {"key": "issueAdditionalData", "type": "{str}"}, + } + + def __init__( + self, + *, + issue_key: str, + issue_name: Optional[str] = None, + security_values: Optional[List[str]] = None, + issue_description: Optional[str] = None, + remediation_steps: Optional[str] = None, + remediation_script: Optional[str] = None, + issue_additional_data: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword issue_key: The unique issue key. Required. + :paramtype issue_key: str + :keyword issue_name: The issue name. + :paramtype issue_name: str + :keyword security_values: The affected security values that MDC offers that will be affected by + the issue, for example: recommendations, alerts, etc. + :paramtype security_values: list[str] + :keyword issue_description: The issue description. + :paramtype issue_description: str + :keyword remediation_steps: Human readable description of what you should do to mitigate this + health issue. + :paramtype remediation_steps: str + :keyword remediation_script: The remediation script to solve this issue. + :paramtype remediation_script: str + :keyword issue_additional_data: Additional data for the given issue. The additional data + depends on the issue type. + :paramtype issue_additional_data: dict[str, str] + """ + super().__init__(**kwargs) + self.issue_key = issue_key + self.issue_name = issue_name + self.security_values = security_values + self.issue_description = issue_description + self.remediation_steps = remediation_steps + self.remediation_script = remediation_script + self.issue_additional_data = issue_additional_data + + +class ResourceDetails(_serialization.Model): + """The resource details of the health report. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar source: The status of the health report. Known values are: "Aws", "Gcp", and "Azure". + :vartype source: str or ~azure.mgmt.security.v2023_05_01_preview.models.Source + :ivar id: The azure id of the resource. + :vartype id: str + :ivar connector_id: The id of the connector. + :vartype connector_id: str + """ + + _validation = { + "id": {"readonly": True}, + "connector_id": {"readonly": True}, + } + + _attribute_map = { + "source": {"key": "source", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "connector_id": {"key": "connectorId", "type": "str"}, + } + + def __init__(self, *, source: Optional[Union[str, "_models.Source"]] = None, **kwargs: Any) -> None: + """ + :keyword source: The status of the health report. Known values are: "Aws", "Gcp", and "Azure". + :paramtype source: str or ~azure.mgmt.security.v2023_05_01_preview.models.Source + """ + super().__init__(**kwargs) + self.source = source + self.id = None + self.connector_id = None + + +class Status(_serialization.Model): + """The status of the health report. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The status of the health report. Known values are: "Healthy", "NotHealthy", and + "NotApplicable". + :vartype code: str or ~azure.mgmt.security.v2023_05_01_preview.models.StatusName + :ivar reason: The reason of the given status. + :vartype reason: str + :ivar last_scanned_date: The date of when the resource was scanned in the last time. + :vartype last_scanned_date: ~datetime.datetime + :ivar status_change_date: The date of when the status of the health report was changed in the + last time. + :vartype status_change_date: ~datetime.datetime + :ivar first_evaluation_date: The date of when the resource of the health report was scanned in + the first time. + :vartype first_evaluation_date: ~datetime.datetime + """ + + _validation = { + "reason": {"readonly": True}, + "last_scanned_date": {"readonly": True}, + "status_change_date": {"readonly": True}, + "first_evaluation_date": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "last_scanned_date": {"key": "lastScannedDate", "type": "iso-8601"}, + "status_change_date": {"key": "statusChangeDate", "type": "iso-8601"}, + "first_evaluation_date": {"key": "firstEvaluationDate", "type": "iso-8601"}, + } + + def __init__(self, *, code: Optional[Union[str, "_models.StatusName"]] = None, **kwargs: Any) -> None: + """ + :keyword code: The status of the health report. Known values are: "Healthy", "NotHealthy", and + "NotApplicable". + :paramtype code: str or ~azure.mgmt.security.v2023_05_01_preview.models.StatusName + """ + super().__init__(**kwargs) + self.code = code + self.reason = None + self.last_scanned_date = None + self.status_change_date = None + self.first_evaluation_date = None diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_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/v2023_05_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/_security_center_enums.py new file mode 100644 index 000000000000..a7cdf242d64f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/models/_security_center_enums.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 enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class Source(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the health report.""" + + AWS = "Aws" + GCP = "Gcp" + AZURE = "Azure" + + +class StatusName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the health report.""" + + HEALTHY = "Healthy" + NOT_HEALTHY = "NotHealthy" + NOT_APPLICABLE = "NotApplicable" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/operations/__init__.py new file mode 100644 index 000000000000..f9b535e20872 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/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 ._health_reports_operations import HealthReportsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "HealthReportsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/operations/_health_reports_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/operations/_health_reports_operations.py new file mode 100644 index 000000000000..5a64947f52f7 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/operations/_health_reports_operations.py @@ -0,0 +1,261 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _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(scope: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Security/healthReports") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True, max_length=90, min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_id: str, health_report_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceId}/providers/Microsoft.Security/healthReports/{healthReportName}") + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "healthReportName": _SERIALIZER.url( + "health_report_name", + health_report_name, + "str", + pattern=r"[{]?[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class HealthReportsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_05_01_preview.SecurityCenter`'s + :attr:`health_reports` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, scope: str, **kwargs: Any) -> Iterable["_models.HealthReport"]: + """Get a list of all health reports inside a scope. Valid scopes are: subscription (format: + 'subscriptions/{subscriptionId}'), or security connector (format: + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName})'. + + :param scope: The scope at which the operation is performed. Required. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either HealthReport or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_05_01_preview.models.HealthReport] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-05-01-preview") + ) + cls: ClsType[_models.HealthReportsList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("HealthReportsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/{scope}/providers/Microsoft.Security/healthReports"} + + @distributed_trace + def get(self, resource_id: str, health_report_name: str, **kwargs: Any) -> _models.HealthReport: + """Get health report of resource. + + :param resource_id: The identifier of the resource. Required. + :type resource_id: str + :param health_report_name: The health report Key - Unique key for the health report type. + Required. + :type health_report_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HealthReport or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_05_01_preview.models.HealthReport + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-05-01-preview") + ) + cls: ClsType[_models.HealthReport] = kwargs.pop("cls", None) + + request = build_get_request( + resource_id=resource_id, + health_report_name=health_report_name, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("HealthReport", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/{resourceId}/providers/Microsoft.Security/healthReports/{healthReportName}"} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_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/v2023_05_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_05_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_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/v2023_09_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/__init__.py new file mode 100644 index 000000000000..e95a015ca6b8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/__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 ._security_center import SecurityCenter +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenter", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_configuration.py new file mode 100644 index 000000000000..420f2676b815 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_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 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: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-09-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) + self._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.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/v2023_09_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_metadata.json new file mode 100644 index 000000000000..d61304c19331 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_metadata.json @@ -0,0 +1,119 @@ +{ + "chosen_version": "2023-09-01-preview", + "total_api_version_list": ["2023-09-01-preview"], + "client": { + "name": "SecurityCenter", + "filename": "_security_center", + "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_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, + "method_location": "positional" + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", + "docstring_type": "str", + "required": true, + "method_location": "positional" + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version: Optional[str]=None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"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": { + "azure_dev_ops_orgs": "AzureDevOpsOrgsOperations", + "azure_dev_ops_projects": "AzureDevOpsProjectsOperations", + "azure_dev_ops_repos": "AzureDevOpsReposOperations", + "dev_ops_configurations": "DevOpsConfigurationsOperations", + "git_hub_owners": "GitHubOwnersOperations", + "git_hub_repos": "GitHubReposOperations", + "git_lab_groups": "GitLabGroupsOperations", + "git_lab_subgroups": "GitLabSubgroupsOperations", + "git_lab_projects": "GitLabProjectsOperations", + "dev_ops_operation_results": "DevOpsOperationResultsOperations" + } +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_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/v2023_09_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_security_center.py new file mode 100644 index 000000000000..cf1b783be0e2 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_security_center.py @@ -0,0 +1,157 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import ( + AzureDevOpsOrgsOperations, + AzureDevOpsProjectsOperations, + AzureDevOpsReposOperations, + DevOpsConfigurationsOperations, + DevOpsOperationResultsOperations, + GitHubOwnersOperations, + GitHubReposOperations, + GitLabGroupsOperations, + GitLabProjectsOperations, + GitLabSubgroupsOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """API spec for Microsoft.Security (Azure Security Center) resource provider. + + :ivar azure_dev_ops_orgs: AzureDevOpsOrgsOperations operations + :vartype azure_dev_ops_orgs: + azure.mgmt.security.v2023_09_01_preview.operations.AzureDevOpsOrgsOperations + :ivar azure_dev_ops_projects: AzureDevOpsProjectsOperations operations + :vartype azure_dev_ops_projects: + azure.mgmt.security.v2023_09_01_preview.operations.AzureDevOpsProjectsOperations + :ivar azure_dev_ops_repos: AzureDevOpsReposOperations operations + :vartype azure_dev_ops_repos: + azure.mgmt.security.v2023_09_01_preview.operations.AzureDevOpsReposOperations + :ivar dev_ops_configurations: DevOpsConfigurationsOperations operations + :vartype dev_ops_configurations: + azure.mgmt.security.v2023_09_01_preview.operations.DevOpsConfigurationsOperations + :ivar git_hub_owners: GitHubOwnersOperations operations + :vartype git_hub_owners: + azure.mgmt.security.v2023_09_01_preview.operations.GitHubOwnersOperations + :ivar git_hub_repos: GitHubReposOperations operations + :vartype git_hub_repos: + azure.mgmt.security.v2023_09_01_preview.operations.GitHubReposOperations + :ivar git_lab_groups: GitLabGroupsOperations operations + :vartype git_lab_groups: + azure.mgmt.security.v2023_09_01_preview.operations.GitLabGroupsOperations + :ivar git_lab_subgroups: GitLabSubgroupsOperations operations + :vartype git_lab_subgroups: + azure.mgmt.security.v2023_09_01_preview.operations.GitLabSubgroupsOperations + :ivar git_lab_projects: GitLabProjectsOperations operations + :vartype git_lab_projects: + azure.mgmt.security.v2023_09_01_preview.operations.GitLabProjectsOperations + :ivar dev_ops_operation_results: DevOpsOperationResultsOperations operations + :vartype dev_ops_operation_results: + azure.mgmt.security.v2023_09_01_preview.operations.DevOpsOperationResultsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.azure_dev_ops_orgs = AzureDevOpsOrgsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + self.azure_dev_ops_projects = AzureDevOpsProjectsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + self.azure_dev_ops_repos = AzureDevOpsReposOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + self.dev_ops_configurations = DevOpsConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + self.git_hub_owners = GitHubOwnersOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + self.git_hub_repos = GitHubReposOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + self.git_lab_groups = GitLabGroupsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + self.git_lab_subgroups = GitLabSubgroupsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + self.git_lab_projects = GitLabProjectsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + self.dev_ops_operation_results = DevOpsOperationResultsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "SecurityCenter": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_vendor.py new file mode 100644 index 000000000000..0dafe0e287ff --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_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/v2023_09_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/__init__.py new file mode 100644 index 000000000000..d9a53c22b3e6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/__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 ._security_center import SecurityCenter + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenter", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/_configuration.py new file mode 100644 index 000000000000..931dbfae07ea --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_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 + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-09-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) + self._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/v2023_09_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_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/v2023_09_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/_security_center.py new file mode 100644 index 000000000000..6c8dd9116dd8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/_security_center.py @@ -0,0 +1,157 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import ( + AzureDevOpsOrgsOperations, + AzureDevOpsProjectsOperations, + AzureDevOpsReposOperations, + DevOpsConfigurationsOperations, + DevOpsOperationResultsOperations, + GitHubOwnersOperations, + GitHubReposOperations, + GitLabGroupsOperations, + GitLabProjectsOperations, + GitLabSubgroupsOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """API spec for Microsoft.Security (Azure Security Center) resource provider. + + :ivar azure_dev_ops_orgs: AzureDevOpsOrgsOperations operations + :vartype azure_dev_ops_orgs: + azure.mgmt.security.v2023_09_01_preview.aio.operations.AzureDevOpsOrgsOperations + :ivar azure_dev_ops_projects: AzureDevOpsProjectsOperations operations + :vartype azure_dev_ops_projects: + azure.mgmt.security.v2023_09_01_preview.aio.operations.AzureDevOpsProjectsOperations + :ivar azure_dev_ops_repos: AzureDevOpsReposOperations operations + :vartype azure_dev_ops_repos: + azure.mgmt.security.v2023_09_01_preview.aio.operations.AzureDevOpsReposOperations + :ivar dev_ops_configurations: DevOpsConfigurationsOperations operations + :vartype dev_ops_configurations: + azure.mgmt.security.v2023_09_01_preview.aio.operations.DevOpsConfigurationsOperations + :ivar git_hub_owners: GitHubOwnersOperations operations + :vartype git_hub_owners: + azure.mgmt.security.v2023_09_01_preview.aio.operations.GitHubOwnersOperations + :ivar git_hub_repos: GitHubReposOperations operations + :vartype git_hub_repos: + azure.mgmt.security.v2023_09_01_preview.aio.operations.GitHubReposOperations + :ivar git_lab_groups: GitLabGroupsOperations operations + :vartype git_lab_groups: + azure.mgmt.security.v2023_09_01_preview.aio.operations.GitLabGroupsOperations + :ivar git_lab_subgroups: GitLabSubgroupsOperations operations + :vartype git_lab_subgroups: + azure.mgmt.security.v2023_09_01_preview.aio.operations.GitLabSubgroupsOperations + :ivar git_lab_projects: GitLabProjectsOperations operations + :vartype git_lab_projects: + azure.mgmt.security.v2023_09_01_preview.aio.operations.GitLabProjectsOperations + :ivar dev_ops_operation_results: DevOpsOperationResultsOperations operations + :vartype dev_ops_operation_results: + azure.mgmt.security.v2023_09_01_preview.aio.operations.DevOpsOperationResultsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.azure_dev_ops_orgs = AzureDevOpsOrgsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + self.azure_dev_ops_projects = AzureDevOpsProjectsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + self.azure_dev_ops_repos = AzureDevOpsReposOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + self.dev_ops_configurations = DevOpsConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + self.git_hub_owners = GitHubOwnersOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + self.git_hub_repos = GitHubReposOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + self.git_lab_groups = GitLabGroupsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + self.git_lab_subgroups = GitLabSubgroupsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + self.git_lab_projects = GitLabProjectsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + self.dev_ops_operation_results = DevOpsOperationResultsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-09-01-preview" + ) + + def _send_request(self, request: HttpRequest, **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: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..f7948e9fc6d4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/__init__.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._azure_dev_ops_orgs_operations import AzureDevOpsOrgsOperations +from ._azure_dev_ops_projects_operations import AzureDevOpsProjectsOperations +from ._azure_dev_ops_repos_operations import AzureDevOpsReposOperations +from ._dev_ops_configurations_operations import DevOpsConfigurationsOperations +from ._git_hub_owners_operations import GitHubOwnersOperations +from ._git_hub_repos_operations import GitHubReposOperations +from ._git_lab_groups_operations import GitLabGroupsOperations +from ._git_lab_subgroups_operations import GitLabSubgroupsOperations +from ._git_lab_projects_operations import GitLabProjectsOperations +from ._dev_ops_operation_results_operations import DevOpsOperationResultsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AzureDevOpsOrgsOperations", + "AzureDevOpsProjectsOperations", + "AzureDevOpsReposOperations", + "DevOpsConfigurationsOperations", + "GitHubOwnersOperations", + "GitHubReposOperations", + "GitLabGroupsOperations", + "GitLabSubgroupsOperations", + "GitLabProjectsOperations", + "DevOpsOperationResultsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_azure_dev_ops_orgs_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_azure_dev_ops_orgs_operations.py new file mode 100644 index 000000000000..6ff311ac2338 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_azure_dev_ops_orgs_operations.py @@ -0,0 +1,812 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._azure_dev_ops_orgs_operations import ( + build_create_or_update_request, + build_get_request, + build_list_available_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AzureDevOpsOrgsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s + :attr:`azure_dev_ops_orgs` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def list_available( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> _models.AzureDevOpsOrgListResponse: + """Returns a list of all Azure DevOps organizations accessible by the user token consumed by the + connector. + + Returns a list of all Azure DevOps organizations accessible by the user token consumed by the + connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AzureDevOpsOrgListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrgListResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.AzureDevOpsOrgListResponse] = kwargs.pop("cls", None) + + request = build_list_available_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_available.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureDevOpsOrgListResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_available.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/listAvailableAzureDevOpsOrgs" + } + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AzureDevOpsOrg"]: + """Returns a list of Azure DevOps organizations onboarded to the connector. + + Returns a list of Azure DevOps organizations onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AzureDevOpsOrg or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.AzureDevOpsOrgListResponse] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AzureDevOpsOrgListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, security_connector_name: str, org_name: str, **kwargs: Any + ) -> _models.AzureDevOpsOrg: + """Returns a monitored Azure DevOps organization resource. + + Returns a monitored Azure DevOps organization resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AzureDevOpsOrg or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}" + } + + async def _create_or_update_initial( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO], + **kwargs: Any + ) -> _models.AzureDevOpsOrg: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(azure_dev_ops_org, (IOBase, bytes)): + _content = azure_dev_ops_org + else: + _json = self._serialize.body(azure_dev_ops_org, "AzureDevOpsOrg") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: _models.AzureDevOpsOrg, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: + """Creates or updates monitored Azure DevOps organization details. + + Creates or updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. + :type azure_dev_ops_org: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 AzureDevOpsOrg or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: + """Creates or updates monitored Azure DevOps organization details. + + Creates or updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. + :type azure_dev_ops_org: IO + :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 AzureDevOpsOrg or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: + """Creates or updates monitored Azure DevOps organization details. + + Creates or updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Is either a + AzureDevOpsOrg type or a IO type. Required. + :type azure_dev_ops_org: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg 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 AzureDevOpsOrg or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + azure_dev_ops_org=azure_dev_ops_org, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}" + } + + async def _update_initial( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO], + **kwargs: Any + ) -> _models.AzureDevOpsOrg: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(azure_dev_ops_org, (IOBase, bytes)): + _content = azure_dev_ops_org + else: + _json = self._serialize.body(azure_dev_ops_org, "AzureDevOpsOrg") + + request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: _models.AzureDevOpsOrg, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: + """Updates monitored Azure DevOps organization details. + + Updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. + :type azure_dev_ops_org: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 AzureDevOpsOrg or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: + """Updates monitored Azure DevOps organization details. + + Updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. + :type azure_dev_ops_org: IO + :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 AzureDevOpsOrg or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsOrg]: + """Updates monitored Azure DevOps organization details. + + Updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Is either a + AzureDevOpsOrg type or a IO type. Required. + :type azure_dev_ops_org: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg 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 AzureDevOpsOrg or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + azure_dev_ops_org=azure_dev_ops_org, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_azure_dev_ops_projects_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_azure_dev_ops_projects_operations.py new file mode 100644 index 000000000000..76558908cb24 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_azure_dev_ops_projects_operations.py @@ -0,0 +1,772 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._azure_dev_ops_projects_operations import ( + build_create_or_update_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 AzureDevOpsProjectsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s + :attr:`azure_dev_ops_projects` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, org_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AzureDevOpsProject"]: + """Returns a list of Azure DevOps projects onboarded to the connector. + + Returns a list of Azure DevOps projects onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AzureDevOpsProject or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.AzureDevOpsProjectListResponse] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AzureDevOpsProjectListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, security_connector_name: str, org_name: str, project_name: str, **kwargs: Any + ) -> _models.AzureDevOpsProject: + """Returns a monitored Azure DevOps project resource. + + Returns a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AzureDevOpsProject or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}" + } + + async def _create_or_update_initial( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO], + **kwargs: Any + ) -> _models.AzureDevOpsProject: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(azure_dev_ops_project, (IOBase, bytes)): + _content = azure_dev_ops_project + else: + _json = self._serialize.body(azure_dev_ops_project, "AzureDevOpsProject") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: _models.AzureDevOpsProject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsProject]: + """Creates or updates a monitored Azure DevOps project resource. + + Creates or updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. + :type azure_dev_ops_project: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 AzureDevOpsProject or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsProject]: + """Creates or updates a monitored Azure DevOps project resource. + + Creates or updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. + :type azure_dev_ops_project: IO + :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 AzureDevOpsProject or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsProject]: + """Creates or updates a monitored Azure DevOps project resource. + + Creates or updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Is either a + AzureDevOpsProject type or a IO type. Required. + :type azure_dev_ops_project: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject + 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 AzureDevOpsProject or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + azure_dev_ops_project=azure_dev_ops_project, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}" + } + + async def _update_initial( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO], + **kwargs: Any + ) -> _models.AzureDevOpsProject: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(azure_dev_ops_project, (IOBase, bytes)): + _content = azure_dev_ops_project + else: + _json = self._serialize.body(azure_dev_ops_project, "AzureDevOpsProject") + + request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: _models.AzureDevOpsProject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsProject]: + """Updates a monitored Azure DevOps project resource. + + Updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. + :type azure_dev_ops_project: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 AzureDevOpsProject or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsProject]: + """Updates a monitored Azure DevOps project resource. + + Updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. + :type azure_dev_ops_project: IO + :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 AzureDevOpsProject or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsProject]: + """Updates a monitored Azure DevOps project resource. + + Updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Is either a + AzureDevOpsProject type or a IO type. Required. + :type azure_dev_ops_project: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject + 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 AzureDevOpsProject or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + azure_dev_ops_project=azure_dev_ops_project, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_azure_dev_ops_repos_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_azure_dev_ops_repos_operations.py new file mode 100644 index 000000000000..bf2c604fd9ca --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_azure_dev_ops_repos_operations.py @@ -0,0 +1,811 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._azure_dev_ops_repos_operations import ( + build_create_or_update_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 AzureDevOpsReposOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s + :attr:`azure_dev_ops_repos` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, org_name: str, project_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AzureDevOpsRepository"]: + """Returns a list of Azure DevOps repositories onboarded to the connector. + + Returns a list of Azure DevOps repositories onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AzureDevOpsRepository or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.AzureDevOpsRepositoryListResponse] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AzureDevOpsRepositoryListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos" + } + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + **kwargs: Any + ) -> _models.AzureDevOpsRepository: + """Returns a monitored Azure DevOps repository resource. + + Returns a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AzureDevOpsRepository or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}" + } + + async def _create_or_update_initial( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO], + **kwargs: Any + ) -> _models.AzureDevOpsRepository: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(azure_dev_ops_repository, (IOBase, bytes)): + _content = azure_dev_ops_repository + else: + _json = self._serialize.body(azure_dev_ops_repository, "AzureDevOpsRepository") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: _models.AzureDevOpsRepository, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: + """Creates or updates a monitored Azure DevOps repository resource. + + Creates or updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. + :type azure_dev_ops_repository: + ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 AzureDevOpsRepository or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: + """Creates or updates a monitored Azure DevOps repository resource. + + Creates or updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. + :type azure_dev_ops_repository: IO + :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 AzureDevOpsRepository or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: + """Creates or updates a monitored Azure DevOps repository resource. + + Creates or updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Is either a + AzureDevOpsRepository type or a IO type. Required. + :type azure_dev_ops_repository: + ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository 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 AzureDevOpsRepository or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_name, + azure_dev_ops_repository=azure_dev_ops_repository, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}" + } + + async def _update_initial( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO], + **kwargs: Any + ) -> _models.AzureDevOpsRepository: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(azure_dev_ops_repository, (IOBase, bytes)): + _content = azure_dev_ops_repository + else: + _json = self._serialize.body(azure_dev_ops_repository, "AzureDevOpsRepository") + + request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: _models.AzureDevOpsRepository, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: + """Updates a monitored Azure DevOps repository resource. + + Updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. + :type azure_dev_ops_repository: + ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 AzureDevOpsRepository or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: + """Updates a monitored Azure DevOps repository resource. + + Updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. + :type azure_dev_ops_repository: IO + :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 AzureDevOpsRepository or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.AzureDevOpsRepository]: + """Updates a monitored Azure DevOps repository resource. + + Updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Is either a + AzureDevOpsRepository type or a IO type. Required. + :type azure_dev_ops_repository: + ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository 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 AzureDevOpsRepository or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_name, + azure_dev_ops_repository=azure_dev_ops_repository, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_dev_ops_configurations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_dev_ops_configurations_operations.py new file mode 100644 index 000000000000..1b359549dde3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_dev_ops_configurations_operations.py @@ -0,0 +1,841 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._dev_ops_configurations_operations import ( + build_create_or_update_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 DevOpsConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s + :attr:`dev_ops_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DevOpsConfiguration"]: + """List DevOps Configurations. + + List DevOps Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DevOpsConfiguration or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.DevOpsConfigurationListResponse] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DevOpsConfigurationListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> _models.DevOpsConfiguration: + """Gets a DevOps Configuration. + + Gets a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DevOpsConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default" + } + + async def _create_or_update_initial( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: Union[_models.DevOpsConfiguration, IO], + **kwargs: Any + ) -> _models.DevOpsConfiguration: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(dev_ops_configuration, (IOBase, bytes)): + _content = dev_ops_configuration + else: + _json = self._serialize.body(dev_ops_configuration, "DevOpsConfiguration") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default" + } + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: _models.DevOpsConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DevOpsConfiguration]: + """Creates or updates a DevOps Configuration. + + Creates or updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Required. + :type dev_ops_configuration: + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 DevOpsConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DevOpsConfiguration]: + """Creates or updates a DevOps Configuration. + + Creates or updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Required. + :type dev_ops_configuration: IO + :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 DevOpsConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: Union[_models.DevOpsConfiguration, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DevOpsConfiguration]: + """Creates or updates a DevOps Configuration. + + Creates or updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Is either a + DevOpsConfiguration type or a IO type. Required. + :type dev_ops_configuration: + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration 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 DevOpsConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + dev_ops_configuration=dev_ops_configuration, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default" + } + + async def _update_initial( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: Union[_models.DevOpsConfiguration, IO], + **kwargs: Any + ) -> _models.DevOpsConfiguration: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(dev_ops_configuration, (IOBase, bytes)): + _content = dev_ops_configuration + else: + _json = self._serialize.body(dev_ops_configuration, "DevOpsConfiguration") + + request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: _models.DevOpsConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DevOpsConfiguration]: + """Updates a DevOps Configuration. + + Updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Required. + :type dev_ops_configuration: + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 DevOpsConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DevOpsConfiguration]: + """Updates a DevOps Configuration. + + Updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Required. + :type dev_ops_configuration: IO + :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 DevOpsConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: Union[_models.DevOpsConfiguration, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.DevOpsConfiguration]: + """Updates a DevOps Configuration. + + Updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Is either a + DevOpsConfiguration type or a IO type. Required. + :type dev_ops_configuration: + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration 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 DevOpsConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + dev_ops_configuration=dev_ops_configuration, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a DevOps Connector. + + Deletes a DevOps Connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_dev_ops_operation_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_dev_ops_operation_results_operations.py new file mode 100644 index 000000000000..83b930d9aa18 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_dev_ops_operation_results_operations.py @@ -0,0 +1,124 @@ +# 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._dev_ops_operation_results_operations import build_get_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DevOpsOperationResultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s + :attr:`dev_ops_operation_results` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def get( + self, resource_group_name: str, security_connector_name: str, operation_result_id: str, **kwargs: Any + ) -> _models.OperationStatusResult: + """Get devops long running operation result. + + Get devops long running operation result. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param operation_result_id: The operation result Id. Required. + :type operation_result_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.OperationStatusResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + operation_result_id=operation_result_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/operationResults/{operationResultId}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_hub_owners_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_hub_owners_operations.py new file mode 100644 index 000000000000..33fa4f7ba291 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_hub_owners_operations.py @@ -0,0 +1,293 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._git_hub_owners_operations import build_get_request, build_list_available_request, build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GitHubOwnersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s + :attr:`git_hub_owners` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def list_available( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> _models.GitHubOwnerListResponse: + """Returns a list of all GitHub owners accessible by the user token consumed by the connector. + + Returns a list of all GitHub owners accessible by the user token consumed by the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GitHubOwnerListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwnerListResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitHubOwnerListResponse] = kwargs.pop("cls", None) + + request = build_list_available_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_available.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitHubOwnerListResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_available.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/listAvailableGitHubOwners" + } + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GitHubOwner"]: + """Returns a list of GitHub owners onboarded to the connector. + + Returns a list of GitHub owners onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GitHubOwner or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwner] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitHubOwnerListResponse] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GitHubOwnerListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, security_connector_name: str, owner_name: str, **kwargs: Any + ) -> _models.GitHubOwner: + """Returns a monitored GitHub owner. + + Returns a monitored GitHub owner. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param owner_name: The GitHub owner name. Required. + :type owner_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GitHubOwner or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwner + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitHubOwner] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + owner_name=owner_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitHubOwner", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners/{ownerName}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_hub_repos_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_hub_repos_operations.py new file mode 100644 index 000000000000..682a9caca3bf --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_hub_repos_operations.py @@ -0,0 +1,230 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._git_hub_repos_operations import build_get_request, build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GitHubReposOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s + :attr:`git_hub_repos` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, owner_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GitHubRepository"]: + """Returns a list of GitHub repositories onboarded to the connector. + + Returns a list of GitHub repositories onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param owner_name: The GitHub owner name. Required. + :type owner_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GitHubRepository or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.GitHubRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitHubRepositoryListResponse] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + owner_name=owner_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GitHubRepositoryListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners/{ownerName}/repos" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, security_connector_name: str, owner_name: str, repo_name: str, **kwargs: Any + ) -> _models.GitHubRepository: + """Returns a monitored GitHub repository. + + Returns a monitored GitHub repository. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param owner_name: The GitHub owner name. Required. + :type owner_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GitHubRepository or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitHubRepository + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitHubRepository] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + owner_name=owner_name, + repo_name=repo_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitHubRepository", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners/{ownerName}/repos/{repoName}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_lab_groups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_lab_groups_operations.py new file mode 100644 index 000000000000..b07ca86ad361 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_lab_groups_operations.py @@ -0,0 +1,293 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._git_lab_groups_operations import build_get_request, build_list_available_request, build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GitLabGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s + :attr:`git_lab_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def list_available( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> _models.GitLabGroupListResponse: + """Returns a list of all GitLab groups accessible by the user token consumed by the connector. + + Returns a list of all GitLab groups accessible by the user token consumed by the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GitLabGroupListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroupListResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) + + request = build_list_available_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_available.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitLabGroupListResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_available.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/listAvailableGitLabGroups" + } + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GitLabGroup"]: + """Returns a list of GitLab groups onboarded to the connector. + + Returns a list of GitLab groups onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GitLabGroup or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GitLabGroupListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, security_connector_name: str, group_fq_name: str, **kwargs: Any + ) -> _models.GitLabGroup: + """Returns a monitored GitLab Group resource for a given fully-qualified name. + + Returns a monitored GitLab Group resource for a given fully-qualified name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param group_fq_name: The GitLab group fully-qualified name. Required. + :type group_fq_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GitLabGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitLabGroup] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + group_fq_name=group_fq_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitLabGroup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_lab_projects_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_lab_projects_operations.py new file mode 100644 index 000000000000..0245550b54ed --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_lab_projects_operations.py @@ -0,0 +1,239 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._git_lab_projects_operations import build_get_request, build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GitLabProjectsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s + :attr:`git_lab_projects` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, group_fq_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GitLabProject"]: + """Gets a list of GitLab projects that are directly owned by given group and onboarded to the + connector. + + Gets a list of GitLab projects that are directly owned by given group and onboarded to the + connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param group_fq_name: The GitLab group fully-qualified name. Required. + :type group_fq_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GitLabProject or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.GitLabProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitLabProjectListResponse] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + group_fq_name=group_fq_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GitLabProjectListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}/projects" + } + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + security_connector_name: str, + group_fq_name: str, + project_name: str, + **kwargs: Any + ) -> _models.GitLabProject: + """Returns a monitored GitLab Project resource for a given fully-qualified group name and project + name. + + Returns a monitored GitLab Project resource for a given fully-qualified group name and project + name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param group_fq_name: The GitLab group fully-qualified name. Required. + :type group_fq_name: str + :param project_name: The project name. Required. + :type project_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GitLabProject or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabProject + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitLabProject] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + group_fq_name=group_fq_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitLabProject", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}/projects/{projectName}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_lab_subgroups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_lab_subgroups_operations.py new file mode 100644 index 000000000000..7d23828f34a8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_git_lab_subgroups_operations.py @@ -0,0 +1,124 @@ +# 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._git_lab_subgroups_operations import build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class GitLabSubgroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.aio.SecurityCenter`'s + :attr:`git_lab_subgroups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace_async + async def list( + self, resource_group_name: str, security_connector_name: str, group_fq_name: str, **kwargs: Any + ) -> _models.GitLabGroupListResponse: + """Gets nested subgroups of given GitLab Group which are onboarded to the connector. + + Gets nested subgroups of given GitLab Group which are onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param group_fq_name: The GitLab group fully-qualified name. Required. + :type group_fq_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GitLabGroupListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroupListResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) + + request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + group_fq_name=group_fq_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitLabGroupListResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}/listSubgroups" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/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/v2023_09_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/__init__.py new file mode 100644 index 000000000000..2153763afd16 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/__init__.py @@ -0,0 +1,115 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import ActionableRemediation +from ._models_py3 import Authorization +from ._models_py3 import AzureDevOpsOrg +from ._models_py3 import AzureDevOpsOrgListResponse +from ._models_py3 import AzureDevOpsOrgProperties +from ._models_py3 import AzureDevOpsOrganizationConfiguration +from ._models_py3 import AzureDevOpsProject +from ._models_py3 import AzureDevOpsProjectConfiguration +from ._models_py3 import AzureDevOpsProjectListResponse +from ._models_py3 import AzureDevOpsProjectProperties +from ._models_py3 import AzureDevOpsRepository +from ._models_py3 import AzureDevOpsRepositoryListResponse +from ._models_py3 import AzureDevOpsRepositoryProperties +from ._models_py3 import BaseResourceConfiguration +from ._models_py3 import CategoryConfiguration +from ._models_py3 import DevOpsConfiguration +from ._models_py3 import DevOpsConfigurationListResponse +from ._models_py3 import DevOpsConfigurationProperties +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import GitHubOwner +from ._models_py3 import GitHubOwnerConfiguration +from ._models_py3 import GitHubOwnerListResponse +from ._models_py3 import GitHubOwnerProperties +from ._models_py3 import GitHubRepository +from ._models_py3 import GitHubRepositoryListResponse +from ._models_py3 import GitHubRepositoryProperties +from ._models_py3 import GitLabGroup +from ._models_py3 import GitLabGroupConfiguration +from ._models_py3 import GitLabGroupListResponse +from ._models_py3 import GitLabGroupProperties +from ._models_py3 import GitLabProject +from ._models_py3 import GitLabProjectListResponse +from ._models_py3 import GitLabProjectProperties +from ._models_py3 import OperationStatusResult +from ._models_py3 import ProxyResource +from ._models_py3 import Resource +from ._models_py3 import SystemData +from ._models_py3 import TargetBranchConfiguration + +from ._security_center_enums import ActionableRemediationState +from ._security_center_enums import AnnotateDefaultBranchState +from ._security_center_enums import AutoDiscovery +from ._security_center_enums import CreatedByType +from ._security_center_enums import DesiredOnboardingState +from ._security_center_enums import DevOpsProvisioningState +from ._security_center_enums import InheritFromParentState +from ._security_center_enums import OnboardingState +from ._security_center_enums import RuleCategory +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ActionableRemediation", + "Authorization", + "AzureDevOpsOrg", + "AzureDevOpsOrgListResponse", + "AzureDevOpsOrgProperties", + "AzureDevOpsOrganizationConfiguration", + "AzureDevOpsProject", + "AzureDevOpsProjectConfiguration", + "AzureDevOpsProjectListResponse", + "AzureDevOpsProjectProperties", + "AzureDevOpsRepository", + "AzureDevOpsRepositoryListResponse", + "AzureDevOpsRepositoryProperties", + "BaseResourceConfiguration", + "CategoryConfiguration", + "DevOpsConfiguration", + "DevOpsConfigurationListResponse", + "DevOpsConfigurationProperties", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "GitHubOwner", + "GitHubOwnerConfiguration", + "GitHubOwnerListResponse", + "GitHubOwnerProperties", + "GitHubRepository", + "GitHubRepositoryListResponse", + "GitHubRepositoryProperties", + "GitLabGroup", + "GitLabGroupConfiguration", + "GitLabGroupListResponse", + "GitLabGroupProperties", + "GitLabProject", + "GitLabProjectListResponse", + "GitLabProjectProperties", + "OperationStatusResult", + "ProxyResource", + "Resource", + "SystemData", + "TargetBranchConfiguration", + "ActionableRemediationState", + "AnnotateDefaultBranchState", + "AutoDiscovery", + "CreatedByType", + "DesiredOnboardingState", + "DevOpsProvisioningState", + "InheritFromParentState", + "OnboardingState", + "RuleCategory", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/_models_py3.py new file mode 100644 index 000000000000..6bc759d2b914 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/_models_py3.py @@ -0,0 +1,2127 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class ActionableRemediation(_serialization.Model): + """Configuration payload for PR Annotations. + + :ivar state: ActionableRemediation Setting. + None - the setting was never set. + Enabled - ActionableRemediation is enabled. + Disabled - ActionableRemediation is disabled. Known values are: "None", "Disabled", and + "Enabled". + :vartype state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.ActionableRemediationState + :ivar category_configurations: Gets or sets list of categories and severity levels. + :vartype category_configurations: + list[~azure.mgmt.security.v2023_09_01_preview.models.CategoryConfiguration] + :ivar branch_configuration: Repository branch configuration for PR Annotations. + :vartype branch_configuration: + ~azure.mgmt.security.v2023_09_01_preview.models.TargetBranchConfiguration + :ivar inherit_from_parent_state: Update Settings. + + Enabled - Resource should inherit configurations from parent. + Disabled - Resource should not inherit configurations from parent. Known values are: + "Disabled" and "Enabled". + :vartype inherit_from_parent_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.InheritFromParentState + """ + + _attribute_map = { + "state": {"key": "state", "type": "str"}, + "category_configurations": {"key": "categoryConfigurations", "type": "[CategoryConfiguration]"}, + "branch_configuration": {"key": "branchConfiguration", "type": "TargetBranchConfiguration"}, + "inherit_from_parent_state": {"key": "inheritFromParentState", "type": "str"}, + } + + def __init__( + self, + *, + state: Optional[Union[str, "_models.ActionableRemediationState"]] = None, + category_configurations: Optional[List["_models.CategoryConfiguration"]] = None, + branch_configuration: Optional["_models.TargetBranchConfiguration"] = None, + inherit_from_parent_state: Optional[Union[str, "_models.InheritFromParentState"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword state: ActionableRemediation Setting. + None - the setting was never set. + Enabled - ActionableRemediation is enabled. + Disabled - ActionableRemediation is disabled. Known values are: "None", "Disabled", and + "Enabled". + :paramtype state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.ActionableRemediationState + :keyword category_configurations: Gets or sets list of categories and severity levels. + :paramtype category_configurations: + list[~azure.mgmt.security.v2023_09_01_preview.models.CategoryConfiguration] + :keyword branch_configuration: Repository branch configuration for PR Annotations. + :paramtype branch_configuration: + ~azure.mgmt.security.v2023_09_01_preview.models.TargetBranchConfiguration + :keyword inherit_from_parent_state: Update Settings. + + Enabled - Resource should inherit configurations from parent. + Disabled - Resource should not inherit configurations from parent. Known values are: + "Disabled" and "Enabled". + :paramtype inherit_from_parent_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.InheritFromParentState + """ + super().__init__(**kwargs) + self.state = state + self.category_configurations = category_configurations + self.branch_configuration = branch_configuration + self.inherit_from_parent_state = inherit_from_parent_state + + +class Authorization(_serialization.Model): + """Authorization payload. + + :ivar code: Gets or sets one-time OAuth code to exchange for refresh and access tokens. + + Only used during PUT/PATCH operations. The secret is cleared during GET. + :vartype code: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + } + + def __init__(self, *, code: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword code: Gets or sets one-time OAuth code to exchange for refresh and access tokens. + + Only used during PUT/PATCH operations. The secret is cleared during GET. + :paramtype code: str + """ + super().__init__(**kwargs) + self.code = code + + +class Resource(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + + +class AzureDevOpsOrg(ProxyResource): + """Azure DevOps Organization resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.security.v2023_09_01_preview.models.SystemData + :ivar properties: Azure DevOps Organization properties. + :vartype properties: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrgProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "AzureDevOpsOrgProperties"}, + } + + def __init__(self, *, properties: Optional["_models.AzureDevOpsOrgProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: Azure DevOps Organization properties. + :paramtype properties: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrgProperties + """ + super().__init__(**kwargs) + self.system_data = None + self.properties = properties + + +class AzureDevOpsOrganizationConfiguration(_serialization.Model): + """AzureDevOps Org Inventory Configuration. + + :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :vartype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery + :ivar project_configs: AzureDevOps Project Inventory Configuration. + Dictionary of AzureDevOps project name to desired project configuration. + If AutoDiscovery is Enabled, this field should be empty or null. + :vartype project_configs: dict[str, + ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProjectConfiguration] + """ + + _attribute_map = { + "auto_discovery": {"key": "autoDiscovery", "type": "str"}, + "project_configs": {"key": "projectConfigs", "type": "{AzureDevOpsProjectConfiguration}"}, + } + + def __init__( + self, + *, + auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, + project_configs: Optional[Dict[str, "_models.AzureDevOpsProjectConfiguration"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :paramtype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery + :keyword project_configs: AzureDevOps Project Inventory Configuration. + Dictionary of AzureDevOps project name to desired project configuration. + If AutoDiscovery is Enabled, this field should be empty or null. + :paramtype project_configs: dict[str, + ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProjectConfiguration] + """ + super().__init__(**kwargs) + self.auto_discovery = auto_discovery + self.project_configs = project_configs + + +class AzureDevOpsOrgListResponse(_serialization.Model): + """List of RP resources which supports pagination. + + :ivar value: Gets or sets list of resources. + :vartype value: list[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] + :ivar next_link: Gets or sets next link to scroll over the results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AzureDevOpsOrg]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.AzureDevOpsOrg"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: Gets or sets list of resources. + :paramtype value: list[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] + :keyword next_link: Gets or sets next link to scroll over the results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AzureDevOpsOrgProperties(_serialization.Model): + """Azure DevOps Organization properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_status_message: Gets or sets resource status message. + :vartype provisioning_status_message: str + :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. + :vartype provisioning_status_update_time_utc: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :vartype provisioning_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState + :ivar onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. + This is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :vartype onboarding_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState + :ivar actionable_remediation: Configuration payload for PR Annotations. + :vartype actionable_remediation: + ~azure.mgmt.security.v2023_09_01_preview.models.ActionableRemediation + """ + + _validation = { + "provisioning_status_message": {"readonly": True}, + "provisioning_status_update_time_utc": {"readonly": True}, + } + + _attribute_map = { + "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, + "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "onboarding_state": {"key": "onboardingState", "type": "str"}, + "actionable_remediation": {"key": "actionableRemediation", "type": "ActionableRemediation"}, + } + + def __init__( + self, + *, + provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, + onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, + actionable_remediation: Optional["_models.ActionableRemediation"] = None, + **kwargs: Any + ) -> None: + """ + :keyword provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :paramtype provisioning_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState + :keyword onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. + This is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :paramtype onboarding_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState + :keyword actionable_remediation: Configuration payload for PR Annotations. + :paramtype actionable_remediation: + ~azure.mgmt.security.v2023_09_01_preview.models.ActionableRemediation + """ + super().__init__(**kwargs) + self.provisioning_status_message = None + self.provisioning_status_update_time_utc = None + self.provisioning_state = provisioning_state + self.onboarding_state = onboarding_state + self.actionable_remediation = actionable_remediation + + +class AzureDevOpsProject(ProxyResource): + """Azure DevOps Project resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.security.v2023_09_01_preview.models.SystemData + :ivar properties: Azure DevOps Project properties. + :vartype properties: + ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProjectProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "AzureDevOpsProjectProperties"}, + } + + def __init__(self, *, properties: Optional["_models.AzureDevOpsProjectProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: Azure DevOps Project properties. + :paramtype properties: + ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProjectProperties + """ + super().__init__(**kwargs) + self.system_data = None + self.properties = properties + + +class AzureDevOpsProjectConfiguration(_serialization.Model): + """AzureDevOps Project Inventory Configuration. + + :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :vartype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery + :ivar repository_configs: AzureDevOps Repository Inventory Configuration. + Dictionary of AzureDevOps repository name to desired repository configuration. + If AutoDiscovery is Enabled, this field should be null or empty. + :vartype repository_configs: dict[str, + ~azure.mgmt.security.v2023_09_01_preview.models.BaseResourceConfiguration] + """ + + _attribute_map = { + "auto_discovery": {"key": "autoDiscovery", "type": "str"}, + "repository_configs": {"key": "repositoryConfigs", "type": "{BaseResourceConfiguration}"}, + } + + def __init__( + self, + *, + auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, + repository_configs: Optional[Dict[str, "_models.BaseResourceConfiguration"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :paramtype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery + :keyword repository_configs: AzureDevOps Repository Inventory Configuration. + Dictionary of AzureDevOps repository name to desired repository configuration. + If AutoDiscovery is Enabled, this field should be null or empty. + :paramtype repository_configs: dict[str, + ~azure.mgmt.security.v2023_09_01_preview.models.BaseResourceConfiguration] + """ + super().__init__(**kwargs) + self.auto_discovery = auto_discovery + self.repository_configs = repository_configs + + +class AzureDevOpsProjectListResponse(_serialization.Model): + """List of RP resources which supports pagination. + + :ivar value: Gets or sets list of resources. + :vartype value: list[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] + :ivar next_link: Gets or sets next link to scroll over the results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AzureDevOpsProject]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.AzureDevOpsProject"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Gets or sets list of resources. + :paramtype value: list[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] + :keyword next_link: Gets or sets next link to scroll over the results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AzureDevOpsProjectProperties(_serialization.Model): + """Azure DevOps Project properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_status_message: Gets or sets resource status message. + :vartype provisioning_status_message: str + :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. + :vartype provisioning_status_update_time_utc: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :vartype provisioning_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState + :ivar parent_org_name: Gets or sets parent Azure DevOps Organization name. + :vartype parent_org_name: str + :ivar project_id: Gets or sets Azure DevOps Project id. + :vartype project_id: str + :ivar onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. + This is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :vartype onboarding_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState + :ivar actionable_remediation: Configuration payload for PR Annotations. + :vartype actionable_remediation: + ~azure.mgmt.security.v2023_09_01_preview.models.ActionableRemediation + """ + + _validation = { + "provisioning_status_message": {"readonly": True}, + "provisioning_status_update_time_utc": {"readonly": True}, + "project_id": {"readonly": True}, + } + + _attribute_map = { + "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, + "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "parent_org_name": {"key": "parentOrgName", "type": "str"}, + "project_id": {"key": "projectId", "type": "str"}, + "onboarding_state": {"key": "onboardingState", "type": "str"}, + "actionable_remediation": {"key": "actionableRemediation", "type": "ActionableRemediation"}, + } + + def __init__( + self, + *, + provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, + parent_org_name: Optional[str] = None, + onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, + actionable_remediation: Optional["_models.ActionableRemediation"] = None, + **kwargs: Any + ) -> None: + """ + :keyword provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :paramtype provisioning_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState + :keyword parent_org_name: Gets or sets parent Azure DevOps Organization name. + :paramtype parent_org_name: str + :keyword onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. + This is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :paramtype onboarding_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState + :keyword actionable_remediation: Configuration payload for PR Annotations. + :paramtype actionable_remediation: + ~azure.mgmt.security.v2023_09_01_preview.models.ActionableRemediation + """ + super().__init__(**kwargs) + self.provisioning_status_message = None + self.provisioning_status_update_time_utc = None + self.provisioning_state = provisioning_state + self.parent_org_name = parent_org_name + self.project_id = None + self.onboarding_state = onboarding_state + self.actionable_remediation = actionable_remediation + + +class AzureDevOpsRepository(ProxyResource): + """Azure DevOps Repository resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.security.v2023_09_01_preview.models.SystemData + :ivar properties: Azure DevOps Repository properties. + :vartype properties: + ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepositoryProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "AzureDevOpsRepositoryProperties"}, + } + + def __init__( + self, *, properties: Optional["_models.AzureDevOpsRepositoryProperties"] = None, **kwargs: Any + ) -> None: + """ + :keyword properties: Azure DevOps Repository properties. + :paramtype properties: + ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepositoryProperties + """ + super().__init__(**kwargs) + self.system_data = None + self.properties = properties + + +class AzureDevOpsRepositoryListResponse(_serialization.Model): + """List of RP resources which supports pagination. + + :ivar value: Gets or sets list of resources. + :vartype value: list[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] + :ivar next_link: Gets or sets next link to scroll over the results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[AzureDevOpsRepository]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.AzureDevOpsRepository"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Gets or sets list of resources. + :paramtype value: list[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] + :keyword next_link: Gets or sets next link to scroll over the results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AzureDevOpsRepositoryProperties(_serialization.Model): + """Azure DevOps Repository properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_status_message: Gets or sets resource status message. + :vartype provisioning_status_message: str + :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. + :vartype provisioning_status_update_time_utc: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :vartype provisioning_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState + :ivar parent_org_name: Gets or sets parent Azure DevOps Organization name. + :vartype parent_org_name: str + :ivar parent_project_name: Gets or sets parent Azure DevOps Project name. + :vartype parent_project_name: str + :ivar repo_id: Gets or sets Azure DevOps Repository id. + :vartype repo_id: str + :ivar repo_url: Gets or sets Azure DevOps Repository url. + :vartype repo_url: str + :ivar visibility: Gets or sets Azure DevOps repository visibility, whether it is public or + private etc. + :vartype visibility: str + :ivar onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. + This is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :vartype onboarding_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState + :ivar actionable_remediation: Configuration payload for PR Annotations. + :vartype actionable_remediation: + ~azure.mgmt.security.v2023_09_01_preview.models.ActionableRemediation + """ + + _validation = { + "provisioning_status_message": {"readonly": True}, + "provisioning_status_update_time_utc": {"readonly": True}, + "repo_id": {"readonly": True}, + "repo_url": {"readonly": True}, + "visibility": {"readonly": True}, + } + + _attribute_map = { + "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, + "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "parent_org_name": {"key": "parentOrgName", "type": "str"}, + "parent_project_name": {"key": "parentProjectName", "type": "str"}, + "repo_id": {"key": "repoId", "type": "str"}, + "repo_url": {"key": "repoUrl", "type": "str"}, + "visibility": {"key": "visibility", "type": "str"}, + "onboarding_state": {"key": "onboardingState", "type": "str"}, + "actionable_remediation": {"key": "actionableRemediation", "type": "ActionableRemediation"}, + } + + def __init__( + self, + *, + provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, + parent_org_name: Optional[str] = None, + parent_project_name: Optional[str] = None, + onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, + actionable_remediation: Optional["_models.ActionableRemediation"] = None, + **kwargs: Any + ) -> None: + """ + :keyword provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :paramtype provisioning_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState + :keyword parent_org_name: Gets or sets parent Azure DevOps Organization name. + :paramtype parent_org_name: str + :keyword parent_project_name: Gets or sets parent Azure DevOps Project name. + :paramtype parent_project_name: str + :keyword onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. + This is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :paramtype onboarding_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState + :keyword actionable_remediation: Configuration payload for PR Annotations. + :paramtype actionable_remediation: + ~azure.mgmt.security.v2023_09_01_preview.models.ActionableRemediation + """ + super().__init__(**kwargs) + self.provisioning_status_message = None + self.provisioning_status_update_time_utc = None + self.provisioning_state = provisioning_state + self.parent_org_name = parent_org_name + self.parent_project_name = parent_project_name + self.repo_id = None + self.repo_url = None + self.visibility = None + self.onboarding_state = onboarding_state + self.actionable_remediation = actionable_remediation + + +class BaseResourceConfiguration(_serialization.Model): + """Base Resource Inventory configuration changes. + + :ivar desired_onboarding_state: Onboarding states. Known values are: "Disabled" and "Enabled". + :vartype desired_onboarding_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.DesiredOnboardingState + """ + + _attribute_map = { + "desired_onboarding_state": {"key": "desiredOnboardingState", "type": "str"}, + } + + def __init__( + self, *, desired_onboarding_state: Optional[Union[str, "_models.DesiredOnboardingState"]] = None, **kwargs: Any + ) -> None: + """ + :keyword desired_onboarding_state: Onboarding states. Known values are: "Disabled" and + "Enabled". + :paramtype desired_onboarding_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.DesiredOnboardingState + """ + super().__init__(**kwargs) + self.desired_onboarding_state = desired_onboarding_state + + +class CategoryConfiguration(_serialization.Model): + """Severity level per category configuration for PR Annotations. + + :ivar minimum_severity_level: Gets or sets minimum severity level for a given category. + :vartype minimum_severity_level: str + :ivar category: Rule categories. + Code - code scanning results. + Artifact scanning results. + Dependencies scanning results. + IaC results. + Secrets scanning results. + Container scanning results. Known values are: "Code", "Artifacts", "Dependencies", "Secrets", + "IaC", and "Containers". + :vartype category: str or ~azure.mgmt.security.v2023_09_01_preview.models.RuleCategory + """ + + _attribute_map = { + "minimum_severity_level": {"key": "minimumSeverityLevel", "type": "str"}, + "category": {"key": "category", "type": "str"}, + } + + def __init__( + self, + *, + minimum_severity_level: Optional[str] = None, + category: Optional[Union[str, "_models.RuleCategory"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword minimum_severity_level: Gets or sets minimum severity level for a given category. + :paramtype minimum_severity_level: str + :keyword category: Rule categories. + Code - code scanning results. + Artifact scanning results. + Dependencies scanning results. + IaC results. + Secrets scanning results. + Container scanning results. Known values are: "Code", "Artifacts", "Dependencies", "Secrets", + "IaC", and "Containers". + :paramtype category: str or ~azure.mgmt.security.v2023_09_01_preview.models.RuleCategory + """ + super().__init__(**kwargs) + self.minimum_severity_level = minimum_severity_level + self.category = category + + +class DevOpsConfiguration(ProxyResource): + """DevOps Configuration resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.security.v2023_09_01_preview.models.SystemData + :ivar properties: DevOps Configuration properties. + :vartype properties: + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfigurationProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "DevOpsConfigurationProperties"}, + } + + def __init__(self, *, properties: Optional["_models.DevOpsConfigurationProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: DevOps Configuration properties. + :paramtype properties: + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfigurationProperties + """ + super().__init__(**kwargs) + self.system_data = None + self.properties = properties + + +class DevOpsConfigurationListResponse(_serialization.Model): + """List of RP resources which supports pagination. + + :ivar value: Gets or sets list of resources. + :vartype value: list[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] + :ivar next_link: Gets or sets next link to scroll over the results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[DevOpsConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.DevOpsConfiguration"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Gets or sets list of resources. + :paramtype value: list[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] + :keyword next_link: Gets or sets next link to scroll over the results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class DevOpsConfigurationProperties(_serialization.Model): + """DevOps Configuration properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_status_message: Gets or sets resource status message. + :vartype provisioning_status_message: str + :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. + :vartype provisioning_status_update_time_utc: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :vartype provisioning_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState + :ivar authorization: Authorization payload. + :vartype authorization: ~azure.mgmt.security.v2023_09_01_preview.models.Authorization + :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :vartype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery + :ivar top_level_inventory_list: List of top-level inventory to select when AutoDiscovery is + disabled. + This field is ignored when AutoDiscovery is enabled. + :vartype top_level_inventory_list: list[str] + """ + + _validation = { + "provisioning_status_message": {"readonly": True}, + "provisioning_status_update_time_utc": {"readonly": True}, + } + + _attribute_map = { + "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, + "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "authorization": {"key": "authorization", "type": "Authorization"}, + "auto_discovery": {"key": "autoDiscovery", "type": "str"}, + "top_level_inventory_list": {"key": "topLevelInventoryList", "type": "[str]"}, + } + + def __init__( + self, + *, + provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, + authorization: Optional["_models.Authorization"] = None, + auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, + top_level_inventory_list: Optional[List[str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :paramtype provisioning_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState + :keyword authorization: Authorization payload. + :paramtype authorization: ~azure.mgmt.security.v2023_09_01_preview.models.Authorization + :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :paramtype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery + :keyword top_level_inventory_list: List of top-level inventory to select when AutoDiscovery is + disabled. + This field is ignored when AutoDiscovery is enabled. + :paramtype top_level_inventory_list: list[str] + """ + super().__init__(**kwargs) + self.provisioning_status_message = None + self.provisioning_status_update_time_utc = None + self.provisioning_state = provisioning_state + self.authorization = authorization + self.auto_discovery = auto_discovery + self.top_level_inventory_list = top_level_inventory_list + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.security.v2023_09_01_preview.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.security.v2023_09_01_preview.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.security.v2023_09_01_preview.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.security.v2023_09_01_preview.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class GitHubOwner(ProxyResource): + """GitHub Owner resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.security.v2023_09_01_preview.models.SystemData + :ivar properties: GitHub Owner properties. + :vartype properties: ~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwnerProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "GitHubOwnerProperties"}, + } + + def __init__(self, *, properties: Optional["_models.GitHubOwnerProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: GitHub Owner properties. + :paramtype properties: ~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwnerProperties + """ + super().__init__(**kwargs) + self.system_data = None + self.properties = properties + + +class GitHubOwnerConfiguration(_serialization.Model): + """GitHub Owner Inventory Configuration. + + :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :vartype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery + :ivar repository_configs: GitHub Repository Inventory Configuration. + Dictionary of GitHub repository name to desired repository configuration. + If AutoDiscovery is Enabled, this field should be null or empty. + :vartype repository_configs: dict[str, + ~azure.mgmt.security.v2023_09_01_preview.models.BaseResourceConfiguration] + """ + + _attribute_map = { + "auto_discovery": {"key": "autoDiscovery", "type": "str"}, + "repository_configs": {"key": "repositoryConfigs", "type": "{BaseResourceConfiguration}"}, + } + + def __init__( + self, + *, + auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, + repository_configs: Optional[Dict[str, "_models.BaseResourceConfiguration"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :paramtype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery + :keyword repository_configs: GitHub Repository Inventory Configuration. + Dictionary of GitHub repository name to desired repository configuration. + If AutoDiscovery is Enabled, this field should be null or empty. + :paramtype repository_configs: dict[str, + ~azure.mgmt.security.v2023_09_01_preview.models.BaseResourceConfiguration] + """ + super().__init__(**kwargs) + self.auto_discovery = auto_discovery + self.repository_configs = repository_configs + + +class GitHubOwnerListResponse(_serialization.Model): + """List of RP resources which supports pagination. + + :ivar value: Gets or sets list of resources. + :vartype value: list[~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwner] + :ivar next_link: Gets or sets next link to scroll over the results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GitHubOwner]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.GitHubOwner"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: Gets or sets list of resources. + :paramtype value: list[~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwner] + :keyword next_link: Gets or sets next link to scroll over the results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GitHubOwnerProperties(_serialization.Model): + """GitHub Owner properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_status_message: Gets or sets resource status message. + :vartype provisioning_status_message: str + :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. + :vartype provisioning_status_update_time_utc: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :vartype provisioning_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState + :ivar owner_url: Gets or sets GitHub Owner url. + :vartype owner_url: str + :ivar git_hub_internal_id: Gets or sets internal GitHub id. + :vartype git_hub_internal_id: str + :ivar onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. + This is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :vartype onboarding_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState + """ + + _validation = { + "provisioning_status_message": {"readonly": True}, + "provisioning_status_update_time_utc": {"readonly": True}, + "owner_url": {"readonly": True}, + "git_hub_internal_id": {"readonly": True}, + } + + _attribute_map = { + "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, + "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "owner_url": {"key": "ownerUrl", "type": "str"}, + "git_hub_internal_id": {"key": "gitHubInternalId", "type": "str"}, + "onboarding_state": {"key": "onboardingState", "type": "str"}, + } + + def __init__( + self, + *, + provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, + onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :paramtype provisioning_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState + :keyword onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. + This is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :paramtype onboarding_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState + """ + super().__init__(**kwargs) + self.provisioning_status_message = None + self.provisioning_status_update_time_utc = None + self.provisioning_state = provisioning_state + self.owner_url = None + self.git_hub_internal_id = None + self.onboarding_state = onboarding_state + + +class GitHubRepository(ProxyResource): + """GitHub Repository resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.security.v2023_09_01_preview.models.SystemData + :ivar properties: GitHub Repository properties. + :vartype properties: ~azure.mgmt.security.v2023_09_01_preview.models.GitHubRepositoryProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "GitHubRepositoryProperties"}, + } + + def __init__(self, *, properties: Optional["_models.GitHubRepositoryProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: GitHub Repository properties. + :paramtype properties: + ~azure.mgmt.security.v2023_09_01_preview.models.GitHubRepositoryProperties + """ + super().__init__(**kwargs) + self.system_data = None + self.properties = properties + + +class GitHubRepositoryListResponse(_serialization.Model): + """List of RP resources which supports pagination. + + :ivar value: Gets or sets list of resources. + :vartype value: list[~azure.mgmt.security.v2023_09_01_preview.models.GitHubRepository] + :ivar next_link: Gets or sets next link to scroll over the results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GitHubRepository]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.GitHubRepository"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Gets or sets list of resources. + :paramtype value: list[~azure.mgmt.security.v2023_09_01_preview.models.GitHubRepository] + :keyword next_link: Gets or sets next link to scroll over the results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GitHubRepositoryProperties(_serialization.Model): + """GitHub Repository properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_status_message: Gets or sets resource status message. + :vartype provisioning_status_message: str + :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. + :vartype provisioning_status_update_time_utc: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :vartype provisioning_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState + :ivar repo_id: Gets or sets GitHub Repository id. + + This is a numeric id defined by Github. + Eg: "123456". + :vartype repo_id: str + :ivar repo_name: Gets or sets GitHub Repository name. + Eg: "new-repo-1". + :vartype repo_name: str + :ivar repo_full_name: Gets or sets GitHub Full Name. + Repository name, prefixed with Owner name. + Eg: "my-org/new-repo-1". + :vartype repo_full_name: str + :ivar onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. + This is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :vartype onboarding_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState + :ivar repo_url: Gets or sets GitHub Repository url. + :vartype repo_url: str + :ivar parent_owner_name: Gets or sets parent GitHub Owner name. + :vartype parent_owner_name: str + """ + + _validation = { + "provisioning_status_message": {"readonly": True}, + "provisioning_status_update_time_utc": {"readonly": True}, + "repo_id": {"readonly": True}, + "repo_name": {"readonly": True}, + "repo_full_name": {"readonly": True}, + "repo_url": {"readonly": True}, + } + + _attribute_map = { + "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, + "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "repo_id": {"key": "repoId", "type": "str"}, + "repo_name": {"key": "repoName", "type": "str"}, + "repo_full_name": {"key": "repoFullName", "type": "str"}, + "onboarding_state": {"key": "onboardingState", "type": "str"}, + "repo_url": {"key": "repoUrl", "type": "str"}, + "parent_owner_name": {"key": "parentOwnerName", "type": "str"}, + } + + def __init__( + self, + *, + provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, + onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, + parent_owner_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :paramtype provisioning_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState + :keyword onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. + This is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :paramtype onboarding_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState + :keyword parent_owner_name: Gets or sets parent GitHub Owner name. + :paramtype parent_owner_name: str + """ + super().__init__(**kwargs) + self.provisioning_status_message = None + self.provisioning_status_update_time_utc = None + self.provisioning_state = provisioning_state + self.repo_id = None + self.repo_name = None + self.repo_full_name = None + self.onboarding_state = onboarding_state + self.repo_url = None + self.parent_owner_name = parent_owner_name + + +class GitLabGroup(ProxyResource): + """GitLab Group resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.security.v2023_09_01_preview.models.SystemData + :ivar properties: GitLab Group properties. + :vartype properties: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroupProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "GitLabGroupProperties"}, + } + + def __init__(self, *, properties: Optional["_models.GitLabGroupProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: GitLab Group properties. + :paramtype properties: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroupProperties + """ + super().__init__(**kwargs) + self.system_data = None + self.properties = properties + + +class GitLabGroupConfiguration(_serialization.Model): + """GitLab Group Inventory Configuration. + + :ivar auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :vartype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery + :ivar project_configs: GitLab Project Inventory Configuration. + Dictionary of GitLab fully-qualified project name to desired project configuration. + If AutoDiscovery is Enabled, this field should be null or empty. + :vartype project_configs: dict[str, + ~azure.mgmt.security.v2023_09_01_preview.models.BaseResourceConfiguration] + """ + + _attribute_map = { + "auto_discovery": {"key": "autoDiscovery", "type": "str"}, + "project_configs": {"key": "projectConfigs", "type": "{BaseResourceConfiguration}"}, + } + + def __init__( + self, + *, + auto_discovery: Optional[Union[str, "_models.AutoDiscovery"]] = None, + project_configs: Optional[Dict[str, "_models.BaseResourceConfiguration"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword auto_discovery: AutoDiscovery states. Known values are: "Disabled", "Enabled", and + "NotApplicable". + :paramtype auto_discovery: str or ~azure.mgmt.security.v2023_09_01_preview.models.AutoDiscovery + :keyword project_configs: GitLab Project Inventory Configuration. + Dictionary of GitLab fully-qualified project name to desired project configuration. + If AutoDiscovery is Enabled, this field should be null or empty. + :paramtype project_configs: dict[str, + ~azure.mgmt.security.v2023_09_01_preview.models.BaseResourceConfiguration] + """ + super().__init__(**kwargs) + self.auto_discovery = auto_discovery + self.project_configs = project_configs + + +class GitLabGroupListResponse(_serialization.Model): + """List of RP resources which supports pagination. + + :ivar value: Gets or sets list of resources. + :vartype value: list[~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroup] + :ivar next_link: Gets or sets next link to scroll over the results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GitLabGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.GitLabGroup"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: Gets or sets list of resources. + :paramtype value: list[~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroup] + :keyword next_link: Gets or sets next link to scroll over the results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GitLabGroupProperties(_serialization.Model): + """GitLab Group properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_status_message: Gets or sets resource status message. + :vartype provisioning_status_message: str + :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. + :vartype provisioning_status_update_time_utc: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :vartype provisioning_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState + :ivar fully_qualified_name: Gets or sets the fully-qualified name of the Group object. + + This contains the entire namespace hierarchy where namespaces are separated by the '$' + character. + :vartype fully_qualified_name: str + :ivar fully_qualified_friendly_name: Gets or sets the human readable fully-qualified name of + the Group object. + + This contains the entire namespace hierarchy as seen on GitLab UI where namespaces are + separated by the '/' character. + :vartype fully_qualified_friendly_name: str + :ivar url: Gets or sets the url of the GitLab Group. + :vartype url: str + :ivar onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. + This is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :vartype onboarding_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState + """ + + _validation = { + "provisioning_status_message": {"readonly": True}, + "provisioning_status_update_time_utc": {"readonly": True}, + "fully_qualified_name": {"readonly": True}, + "fully_qualified_friendly_name": {"readonly": True}, + "url": {"readonly": True}, + } + + _attribute_map = { + "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, + "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "fully_qualified_name": {"key": "fullyQualifiedName", "type": "str"}, + "fully_qualified_friendly_name": {"key": "fullyQualifiedFriendlyName", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "onboarding_state": {"key": "onboardingState", "type": "str"}, + } + + def __init__( + self, + *, + provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, + onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :paramtype provisioning_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState + :keyword onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. + This is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :paramtype onboarding_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState + """ + super().__init__(**kwargs) + self.provisioning_status_message = None + self.provisioning_status_update_time_utc = None + self.provisioning_state = provisioning_state + self.fully_qualified_name = None + self.fully_qualified_friendly_name = None + self.url = None + self.onboarding_state = onboarding_state + + +class GitLabProject(ProxyResource): + """GitLab Project resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.security.v2023_09_01_preview.models.SystemData + :ivar properties: GitLab Project properties. + :vartype properties: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabProjectProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "GitLabProjectProperties"}, + } + + def __init__(self, *, properties: Optional["_models.GitLabProjectProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: GitLab Project properties. + :paramtype properties: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabProjectProperties + """ + super().__init__(**kwargs) + self.system_data = None + self.properties = properties + + +class GitLabProjectListResponse(_serialization.Model): + """List of RP resources which supports pagination. + + :ivar value: Gets or sets list of resources. + :vartype value: list[~azure.mgmt.security.v2023_09_01_preview.models.GitLabProject] + :ivar next_link: Gets or sets next link to scroll over the results. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[GitLabProject]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.GitLabProject"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: Gets or sets list of resources. + :paramtype value: list[~azure.mgmt.security.v2023_09_01_preview.models.GitLabProject] + :keyword next_link: Gets or sets next link to scroll over the results. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GitLabProjectProperties(_serialization.Model): + """GitLab Project properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_status_message: Gets or sets resource status message. + :vartype provisioning_status_message: str + :ivar provisioning_status_update_time_utc: Gets or sets time when resource was last checked. + :vartype provisioning_status_update_time_utc: ~datetime.datetime + :ivar provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :vartype provisioning_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState + :ivar fully_qualified_name: Gets or sets the fully-qualified name of the project object. + + This contains the entire hierarchy where entities are separated by the '$' character. + :vartype fully_qualified_name: str + :ivar fully_qualified_friendly_name: Gets or sets the human readable fully-qualified name of + the Project object. + + This contains the entire namespace hierarchy as seen on GitLab UI where entities are separated + by the '/' character. + :vartype fully_qualified_friendly_name: str + :ivar fully_qualified_parent_group_name: Gets or sets the fully-qualified name of the project's + parent group object. + + This contains the entire hierarchy where namespaces are separated by the '$' character. + :vartype fully_qualified_parent_group_name: str + :ivar url: Gets or sets the url of the GitLab Project. + :vartype url: str + :ivar onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. + This is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :vartype onboarding_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState + """ + + _validation = { + "provisioning_status_message": {"readonly": True}, + "provisioning_status_update_time_utc": {"readonly": True}, + "fully_qualified_name": {"readonly": True}, + "fully_qualified_friendly_name": {"readonly": True}, + "fully_qualified_parent_group_name": {"readonly": True}, + "url": {"readonly": True}, + } + + _attribute_map = { + "provisioning_status_message": {"key": "provisioningStatusMessage", "type": "str"}, + "provisioning_status_update_time_utc": {"key": "provisioningStatusUpdateTimeUtc", "type": "iso-8601"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "fully_qualified_name": {"key": "fullyQualifiedName", "type": "str"}, + "fully_qualified_friendly_name": {"key": "fullyQualifiedFriendlyName", "type": "str"}, + "fully_qualified_parent_group_name": {"key": "fullyQualifiedParentGroupName", "type": "str"}, + "url": {"key": "url", "type": "str"}, + "onboarding_state": {"key": "onboardingState", "type": "str"}, + } + + def __init__( + self, + *, + provisioning_state: Optional[Union[str, "_models.DevOpsProvisioningState"]] = None, + onboarding_state: Optional[Union[str, "_models.OnboardingState"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword provisioning_state: The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. Known values are: "Succeeded", "Failed", "Canceled", + "Pending", "PendingDeletion", "DeletionSuccess", and "DeletionFailure". + :paramtype provisioning_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsProvisioningState + :keyword onboarding_state: Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. + This is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. Known values + are: "NotApplicable", "OnboardedByOtherConnector", "Onboarded", and "NotOnboarded". + :paramtype onboarding_state: str or + ~azure.mgmt.security.v2023_09_01_preview.models.OnboardingState + """ + super().__init__(**kwargs) + self.provisioning_status_message = None + self.provisioning_status_update_time_utc = None + self.provisioning_state = provisioning_state + self.fully_qualified_name = None + self.fully_qualified_friendly_name = None + self.fully_qualified_parent_group_name = None + self.url = None + self.onboarding_state = onboarding_state + + +class OperationStatusResult(_serialization.Model): + """The current status of an async operation. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified ID for the async operation. + :vartype id: str + :ivar name: Name of the async operation. + :vartype name: str + :ivar status: Operation status. Required. + :vartype status: str + :ivar percent_complete: Percent of the operation that is complete. + :vartype percent_complete: float + :ivar start_time: The start time of the operation. + :vartype start_time: ~datetime.datetime + :ivar end_time: The end time of the operation. + :vartype end_time: ~datetime.datetime + :ivar operations: The operations list. + :vartype operations: + list[~azure.mgmt.security.v2023_09_01_preview.models.OperationStatusResult] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.security.v2023_09_01_preview.models.ErrorDetail + """ + + _validation = { + "status": {"required": True}, + "percent_complete": {"maximum": 100, "minimum": 0}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "percent_complete": {"key": "percentComplete", "type": "float"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "operations": {"key": "operations", "type": "[OperationStatusResult]"}, + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__( + self, + *, + status: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + percent_complete: Optional[float] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + operations: Optional[List["_models.OperationStatusResult"]] = None, + error: Optional["_models.ErrorDetail"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Fully qualified ID for the async operation. + :paramtype id: str + :keyword name: Name of the async operation. + :paramtype name: str + :keyword status: Operation status. Required. + :paramtype status: str + :keyword percent_complete: Percent of the operation that is complete. + :paramtype percent_complete: float + :keyword start_time: The start time of the operation. + :paramtype start_time: ~datetime.datetime + :keyword end_time: The end time of the operation. + :paramtype end_time: ~datetime.datetime + :keyword operations: The operations list. + :paramtype operations: + list[~azure.mgmt.security.v2023_09_01_preview.models.OperationStatusResult] + :keyword error: If present, details of the operation error. + :paramtype error: ~azure.mgmt.security.v2023_09_01_preview.models.ErrorDetail + """ + super().__init__(**kwargs) + self.id = id + self.name = name + self.status = status + self.percent_complete = percent_complete + self.start_time = start_time + self.end_time = end_time + self.operations = operations + self.error = error + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.security.v2023_09_01_preview.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.security.v2023_09_01_preview.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or + ~azure.mgmt.security.v2023_09_01_preview.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.security.v2023_09_01_preview.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class TargetBranchConfiguration(_serialization.Model): + """Repository branch configuration for PR Annotations. + + :ivar branch_names: Gets or sets branches that should have annotations. + :vartype branch_names: list[str] + :ivar annotate_default_branch: Configuration of PR Annotations on default branch. + + Enabled - PR Annotations are enabled on the resource's default branch. + Disabled - PR Annotations are disabled on the resource's default branch. Known values are: + "Disabled" and "Enabled". + :vartype annotate_default_branch: str or + ~azure.mgmt.security.v2023_09_01_preview.models.AnnotateDefaultBranchState + """ + + _attribute_map = { + "branch_names": {"key": "branchNames", "type": "[str]"}, + "annotate_default_branch": {"key": "annotateDefaultBranch", "type": "str"}, + } + + def __init__( + self, + *, + branch_names: Optional[List[str]] = None, + annotate_default_branch: Optional[Union[str, "_models.AnnotateDefaultBranchState"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword branch_names: Gets or sets branches that should have annotations. + :paramtype branch_names: list[str] + :keyword annotate_default_branch: Configuration of PR Annotations on default branch. + + Enabled - PR Annotations are enabled on the resource's default branch. + Disabled - PR Annotations are disabled on the resource's default branch. Known values are: + "Disabled" and "Enabled". + :paramtype annotate_default_branch: str or + ~azure.mgmt.security.v2023_09_01_preview.models.AnnotateDefaultBranchState + """ + super().__init__(**kwargs) + self.branch_names = branch_names + self.annotate_default_branch = annotate_default_branch diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_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/v2023_09_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/_security_center_enums.py new file mode 100644 index 000000000000..3744941c0212 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/models/_security_center_enums.py @@ -0,0 +1,123 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class ActionableRemediationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ActionableRemediation Setting. + None - the setting was never set. + Enabled - ActionableRemediation is enabled. + Disabled - ActionableRemediation is disabled. + """ + + NONE = "None" + DISABLED = "Disabled" + ENABLED = "Enabled" + + +class AnnotateDefaultBranchState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Configuration of PR Annotations on default branch. + + Enabled - PR Annotations are enabled on the resource's default branch. + Disabled - PR Annotations are disabled on the resource's default branch. + """ + + DISABLED = "Disabled" + ENABLED = "Enabled" + + +class AutoDiscovery(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AutoDiscovery states.""" + + DISABLED = "Disabled" + ENABLED = "Enabled" + NOT_APPLICABLE = "NotApplicable" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class DesiredOnboardingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Onboarding states.""" + + DISABLED = "Disabled" + ENABLED = "Enabled" + + +class DevOpsProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state of the resource. + + Pending - Provisioning pending. + Failed - Provisioning failed. + Succeeded - Successful provisioning. + Canceled - Provisioning canceled. + PendingDeletion - Deletion pending. + DeletionSuccess - Deletion successful. + DeletionFailure - Deletion failure. + """ + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + PENDING = "Pending" + PENDING_DELETION = "PendingDeletion" + DELETION_SUCCESS = "DeletionSuccess" + DELETION_FAILURE = "DeletionFailure" + + +class InheritFromParentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Update Settings. + + Enabled - Resource should inherit configurations from parent. + Disabled - Resource should not inherit configurations from parent. + """ + + DISABLED = "Disabled" + ENABLED = "Enabled" + + +class OnboardingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Details about resource onboarding status across all connectors. + + OnboardedByOtherConnector - this resource has already been onboarded to another connector. This + is only applicable to top-level resources. + Onboarded - this resource has already been onboarded by the specified connector. + NotOnboarded - this resource has not been onboarded to any connector. + NotApplicable - the onboarding state is not applicable to the current endpoint. + """ + + NOT_APPLICABLE = "NotApplicable" + ONBOARDED_BY_OTHER_CONNECTOR = "OnboardedByOtherConnector" + ONBOARDED = "Onboarded" + NOT_ONBOARDED = "NotOnboarded" + + +class RuleCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Rule categories. + Code - code scanning results. + Artifact scanning results. + Dependencies scanning results. + IaC results. + Secrets scanning results. + Container scanning results. + """ + + CODE = "Code" + ARTIFACTS = "Artifacts" + DEPENDENCIES = "Dependencies" + SECRETS = "Secrets" + IA_C = "IaC" + CONTAINERS = "Containers" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/__init__.py new file mode 100644 index 000000000000..f7948e9fc6d4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/__init__.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._azure_dev_ops_orgs_operations import AzureDevOpsOrgsOperations +from ._azure_dev_ops_projects_operations import AzureDevOpsProjectsOperations +from ._azure_dev_ops_repos_operations import AzureDevOpsReposOperations +from ._dev_ops_configurations_operations import DevOpsConfigurationsOperations +from ._git_hub_owners_operations import GitHubOwnersOperations +from ._git_hub_repos_operations import GitHubReposOperations +from ._git_lab_groups_operations import GitLabGroupsOperations +from ._git_lab_subgroups_operations import GitLabSubgroupsOperations +from ._git_lab_projects_operations import GitLabProjectsOperations +from ._dev_ops_operation_results_operations import DevOpsOperationResultsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AzureDevOpsOrgsOperations", + "AzureDevOpsProjectsOperations", + "AzureDevOpsReposOperations", + "DevOpsConfigurationsOperations", + "GitHubOwnersOperations", + "GitHubReposOperations", + "GitLabGroupsOperations", + "GitLabSubgroupsOperations", + "GitLabProjectsOperations", + "DevOpsOperationResultsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_azure_dev_ops_orgs_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_azure_dev_ops_orgs_operations.py new file mode 100644 index 000000000000..be5fcea0f25b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_azure_dev_ops_orgs_operations.py @@ -0,0 +1,980 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _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_available_request( + resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/listAvailableAzureDevOpsOrgs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, security_connector_name: str, org_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, security_connector_name: str, org_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, security_connector_name: str, org_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class AzureDevOpsOrgsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s + :attr:`azure_dev_ops_orgs` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_available( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> _models.AzureDevOpsOrgListResponse: + """Returns a list of all Azure DevOps organizations accessible by the user token consumed by the + connector. + + Returns a list of all Azure DevOps organizations accessible by the user token consumed by the + connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AzureDevOpsOrgListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrgListResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.AzureDevOpsOrgListResponse] = kwargs.pop("cls", None) + + request = build_list_available_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_available.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureDevOpsOrgListResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_available.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/listAvailableAzureDevOpsOrgs" + } + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> Iterable["_models.AzureDevOpsOrg"]: + """Returns a list of Azure DevOps organizations onboarded to the connector. + + Returns a list of Azure DevOps organizations onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AzureDevOpsOrg or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.AzureDevOpsOrgListResponse] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AzureDevOpsOrgListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs" + } + + @distributed_trace + def get( + self, resource_group_name: str, security_connector_name: str, org_name: str, **kwargs: Any + ) -> _models.AzureDevOpsOrg: + """Returns a monitored Azure DevOps organization resource. + + Returns a monitored Azure DevOps organization resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AzureDevOpsOrg or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}" + } + + def _create_or_update_initial( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO], + **kwargs: Any + ) -> _models.AzureDevOpsOrg: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(azure_dev_ops_org, (IOBase, bytes)): + _content = azure_dev_ops_org + else: + _json = self._serialize.body(azure_dev_ops_org, "AzureDevOpsOrg") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: _models.AzureDevOpsOrg, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsOrg]: + """Creates or updates monitored Azure DevOps organization details. + + Creates or updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. + :type azure_dev_ops_org: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 AzureDevOpsOrg or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsOrg]: + """Creates or updates monitored Azure DevOps organization details. + + Creates or updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. + :type azure_dev_ops_org: IO + :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 AzureDevOpsOrg or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO], + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsOrg]: + """Creates or updates monitored Azure DevOps organization details. + + Creates or updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Is either a + AzureDevOpsOrg type or a IO type. Required. + :type azure_dev_ops_org: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg 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 AzureDevOpsOrg or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + azure_dev_ops_org=azure_dev_ops_org, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}" + } + + def _update_initial( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO], + **kwargs: Any + ) -> _models.AzureDevOpsOrg: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(azure_dev_ops_org, (IOBase, bytes)): + _content = azure_dev_ops_org + else: + _json = self._serialize.body(azure_dev_ops_org, "AzureDevOpsOrg") + + request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: _models.AzureDevOpsOrg, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsOrg]: + """Updates monitored Azure DevOps organization details. + + Updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. + :type azure_dev_ops_org: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 AzureDevOpsOrg or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsOrg]: + """Updates monitored Azure DevOps organization details. + + Updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Required. + :type azure_dev_ops_org: IO + :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 AzureDevOpsOrg or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + azure_dev_ops_org: Union[_models.AzureDevOpsOrg, IO], + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsOrg]: + """Updates monitored Azure DevOps organization details. + + Updates monitored Azure DevOps organization details. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param azure_dev_ops_org: The Azure DevOps organization resource payload. Is either a + AzureDevOpsOrg type or a IO type. Required. + :type azure_dev_ops_org: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg 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 AzureDevOpsOrg or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsOrg] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsOrg] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + azure_dev_ops_org=azure_dev_ops_org, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AzureDevOpsOrg", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_azure_dev_ops_projects_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_azure_dev_ops_projects_operations.py new file mode 100644 index 000000000000..1fdf561a8e5c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_azure_dev_ops_projects_operations.py @@ -0,0 +1,927 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _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( + resource_group_name: str, security_connector_name: str, org_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class AzureDevOpsProjectsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s + :attr:`azure_dev_ops_projects` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, org_name: str, **kwargs: Any + ) -> Iterable["_models.AzureDevOpsProject"]: + """Returns a list of Azure DevOps projects onboarded to the connector. + + Returns a list of Azure DevOps projects onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AzureDevOpsProject or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.AzureDevOpsProjectListResponse] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AzureDevOpsProjectListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects" + } + + @distributed_trace + def get( + self, resource_group_name: str, security_connector_name: str, org_name: str, project_name: str, **kwargs: Any + ) -> _models.AzureDevOpsProject: + """Returns a monitored Azure DevOps project resource. + + Returns a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AzureDevOpsProject or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}" + } + + def _create_or_update_initial( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO], + **kwargs: Any + ) -> _models.AzureDevOpsProject: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(azure_dev_ops_project, (IOBase, bytes)): + _content = azure_dev_ops_project + else: + _json = self._serialize.body(azure_dev_ops_project, "AzureDevOpsProject") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: _models.AzureDevOpsProject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsProject]: + """Creates or updates a monitored Azure DevOps project resource. + + Creates or updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. + :type azure_dev_ops_project: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 AzureDevOpsProject or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsProject]: + """Creates or updates a monitored Azure DevOps project resource. + + Creates or updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. + :type azure_dev_ops_project: IO + :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 AzureDevOpsProject or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO], + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsProject]: + """Creates or updates a monitored Azure DevOps project resource. + + Creates or updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Is either a + AzureDevOpsProject type or a IO type. Required. + :type azure_dev_ops_project: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject + 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 AzureDevOpsProject or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + azure_dev_ops_project=azure_dev_ops_project, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}" + } + + def _update_initial( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO], + **kwargs: Any + ) -> _models.AzureDevOpsProject: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(azure_dev_ops_project, (IOBase, bytes)): + _content = azure_dev_ops_project + else: + _json = self._serialize.body(azure_dev_ops_project, "AzureDevOpsProject") + + request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: _models.AzureDevOpsProject, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsProject]: + """Updates a monitored Azure DevOps project resource. + + Updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. + :type azure_dev_ops_project: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 AzureDevOpsProject or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsProject]: + """Updates a monitored Azure DevOps project resource. + + Updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Required. + :type azure_dev_ops_project: IO + :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 AzureDevOpsProject or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + azure_dev_ops_project: Union[_models.AzureDevOpsProject, IO], + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsProject]: + """Updates a monitored Azure DevOps project resource. + + Updates a monitored Azure DevOps project resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param azure_dev_ops_project: The Azure DevOps project resource payload. Is either a + AzureDevOpsProject type or a IO type. Required. + :type azure_dev_ops_project: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject + 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 AzureDevOpsProject or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsProject] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + azure_dev_ops_project=azure_dev_ops_project, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AzureDevOpsProject", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_azure_dev_ops_repos_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_azure_dev_ops_repos_operations.py new file mode 100644 index 000000000000..8c8557b2d082 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_azure_dev_ops_repos_operations.py @@ -0,0 +1,978 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _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( + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "repoName": _SERIALIZER.url("repo_name", repo_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "repoName": _SERIALIZER.url("repo_name", repo_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "orgName": _SERIALIZER.url("org_name", org_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + "repoName": _SERIALIZER.url("repo_name", repo_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class AzureDevOpsReposOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s + :attr:`azure_dev_ops_repos` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, org_name: str, project_name: str, **kwargs: Any + ) -> Iterable["_models.AzureDevOpsRepository"]: + """Returns a list of Azure DevOps repositories onboarded to the connector. + + Returns a list of Azure DevOps repositories onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AzureDevOpsRepository or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.AzureDevOpsRepositoryListResponse] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AzureDevOpsRepositoryListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos" + } + + @distributed_trace + def get( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + **kwargs: Any + ) -> _models.AzureDevOpsRepository: + """Returns a monitored Azure DevOps repository resource. + + Returns a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AzureDevOpsRepository or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}" + } + + def _create_or_update_initial( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO], + **kwargs: Any + ) -> _models.AzureDevOpsRepository: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(azure_dev_ops_repository, (IOBase, bytes)): + _content = azure_dev_ops_repository + else: + _json = self._serialize.body(azure_dev_ops_repository, "AzureDevOpsRepository") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: _models.AzureDevOpsRepository, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsRepository]: + """Creates or updates a monitored Azure DevOps repository resource. + + Creates or updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. + :type azure_dev_ops_repository: + ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 AzureDevOpsRepository or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsRepository]: + """Creates or updates a monitored Azure DevOps repository resource. + + Creates or updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. + :type azure_dev_ops_repository: IO + :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 AzureDevOpsRepository or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO], + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsRepository]: + """Creates or updates a monitored Azure DevOps repository resource. + + Creates or updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Is either a + AzureDevOpsRepository type or a IO type. Required. + :type azure_dev_ops_repository: + ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository 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 AzureDevOpsRepository or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_name, + azure_dev_ops_repository=azure_dev_ops_repository, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}" + } + + def _update_initial( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO], + **kwargs: Any + ) -> _models.AzureDevOpsRepository: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(azure_dev_ops_repository, (IOBase, bytes)): + _content = azure_dev_ops_repository + else: + _json = self._serialize.body(azure_dev_ops_repository, "AzureDevOpsRepository") + + request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: _models.AzureDevOpsRepository, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsRepository]: + """Updates a monitored Azure DevOps repository resource. + + Updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. + :type azure_dev_ops_repository: + ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 AzureDevOpsRepository or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsRepository]: + """Updates a monitored Azure DevOps repository resource. + + Updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Required. + :type azure_dev_ops_repository: IO + :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 AzureDevOpsRepository or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + org_name: str, + project_name: str, + repo_name: str, + azure_dev_ops_repository: Union[_models.AzureDevOpsRepository, IO], + **kwargs: Any + ) -> LROPoller[_models.AzureDevOpsRepository]: + """Updates a monitored Azure DevOps repository resource. + + Updates a monitored Azure DevOps repository resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param org_name: The Azure DevOps organization name. Required. + :type org_name: str + :param project_name: The project name. Required. + :type project_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :param azure_dev_ops_repository: The Azure DevOps repository resource payload. Is either a + AzureDevOpsRepository type or a IO type. Required. + :type azure_dev_ops_repository: + ~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository 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 AzureDevOpsRepository or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.AzureDevOpsRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureDevOpsRepository] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + org_name=org_name, + project_name=project_name, + repo_name=repo_name, + azure_dev_ops_repository=azure_dev_ops_repository, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("AzureDevOpsRepository", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/azureDevOpsOrgs/{orgName}/projects/{projectName}/repos/{repoName}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_dev_ops_configurations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_dev_ops_configurations_operations.py new file mode 100644 index 000000000000..8c9105f4ec2d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_dev_ops_configurations_operations.py @@ -0,0 +1,1002 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _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( + resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class DevOpsConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s + :attr:`dev_ops_configurations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> Iterable["_models.DevOpsConfiguration"]: + """List DevOps Configurations. + + List DevOps Configurations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DevOpsConfiguration or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.DevOpsConfigurationListResponse] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DevOpsConfigurationListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops" + } + + @distributed_trace + def get(self, resource_group_name: str, security_connector_name: str, **kwargs: Any) -> _models.DevOpsConfiguration: + """Gets a DevOps Configuration. + + Gets a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DevOpsConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default" + } + + def _create_or_update_initial( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: Union[_models.DevOpsConfiguration, IO], + **kwargs: Any + ) -> _models.DevOpsConfiguration: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(dev_ops_configuration, (IOBase, bytes)): + _content = dev_ops_configuration + else: + _json = self._serialize.body(dev_ops_configuration, "DevOpsConfiguration") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default" + } + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: _models.DevOpsConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DevOpsConfiguration]: + """Creates or updates a DevOps Configuration. + + Creates or updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Required. + :type dev_ops_configuration: + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 DevOpsConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DevOpsConfiguration]: + """Creates or updates a DevOps Configuration. + + Creates or updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Required. + :type dev_ops_configuration: IO + :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 DevOpsConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: Union[_models.DevOpsConfiguration, IO], + **kwargs: Any + ) -> LROPoller[_models.DevOpsConfiguration]: + """Creates or updates a DevOps Configuration. + + Creates or updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Is either a + DevOpsConfiguration type or a IO type. Required. + :type dev_ops_configuration: + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration 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 DevOpsConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + dev_ops_configuration=dev_ops_configuration, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default" + } + + def _update_initial( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: Union[_models.DevOpsConfiguration, IO], + **kwargs: Any + ) -> _models.DevOpsConfiguration: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(dev_ops_configuration, (IOBase, bytes)): + _content = dev_ops_configuration + else: + _json = self._serialize.body(dev_ops_configuration, "DevOpsConfiguration") + + request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default" + } + + @overload + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: _models.DevOpsConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DevOpsConfiguration]: + """Updates a DevOps Configuration. + + Updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Required. + :type dev_ops_configuration: + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :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 DevOpsConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DevOpsConfiguration]: + """Updates a DevOps Configuration. + + Updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Required. + :type dev_ops_configuration: IO + :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 DevOpsConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + security_connector_name: str, + dev_ops_configuration: Union[_models.DevOpsConfiguration, IO], + **kwargs: Any + ) -> LROPoller[_models.DevOpsConfiguration]: + """Updates a DevOps Configuration. + + Updates a DevOps Configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param dev_ops_configuration: The DevOps configuration resource payload. Is either a + DevOpsConfiguration type or a IO type. Required. + :type dev_ops_configuration: + ~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration 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 DevOpsConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_09_01_preview.models.DevOpsConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DevOpsConfiguration] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + dev_ops_configuration=dev_ops_configuration, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DevOpsConfiguration", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default" + } + + @distributed_trace + def begin_delete(self, resource_group_name: str, security_connector_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes a DevOps Connector. + + Deletes a DevOps Connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_dev_ops_operation_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_dev_ops_operation_results_operations.py new file mode 100644 index 000000000000..4530b1af1a3c --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_dev_ops_operation_results_operations.py @@ -0,0 +1,165 @@ +# 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 + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + security_connector_name: str, + operation_result_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/operationResults/{operationResultId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "operationResultId": _SERIALIZER.url("operation_result_id", operation_result_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class DevOpsOperationResultsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s + :attr:`dev_ops_operation_results` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def get( + self, resource_group_name: str, security_connector_name: str, operation_result_id: str, **kwargs: Any + ) -> _models.OperationStatusResult: + """Get devops long running operation result. + + Get devops long running operation result. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param operation_result_id: The operation result Id. Required. + :type operation_result_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatusResult or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.OperationStatusResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + operation_result_id=operation_result_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/operationResults/{operationResultId}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_hub_owners_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_hub_owners_operations.py new file mode 100644 index 000000000000..6556d6b7eebd --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_hub_owners_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, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _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_available_request( + resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/listAvailableGitHubOwners", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, security_connector_name: str, owner_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners/{ownerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "ownerName": _SERIALIZER.url("owner_name", owner_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class GitHubOwnersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s + :attr:`git_hub_owners` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_available( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> _models.GitHubOwnerListResponse: + """Returns a list of all GitHub owners accessible by the user token consumed by the connector. + + Returns a list of all GitHub owners accessible by the user token consumed by the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GitHubOwnerListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwnerListResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitHubOwnerListResponse] = kwargs.pop("cls", None) + + request = build_list_available_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_available.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitHubOwnerListResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_available.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/listAvailableGitHubOwners" + } + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> Iterable["_models.GitHubOwner"]: + """Returns a list of GitHub owners onboarded to the connector. + + Returns a list of GitHub owners onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GitHubOwner or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwner] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitHubOwnerListResponse] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GitHubOwnerListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners" + } + + @distributed_trace + def get( + self, resource_group_name: str, security_connector_name: str, owner_name: str, **kwargs: Any + ) -> _models.GitHubOwner: + """Returns a monitored GitHub owner. + + Returns a monitored GitHub owner. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param owner_name: The GitHub owner name. Required. + :type owner_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GitHubOwner or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitHubOwner + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitHubOwner] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + owner_name=owner_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitHubOwner", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners/{ownerName}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_hub_repos_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_hub_repos_operations.py new file mode 100644 index 000000000000..c60668ed57f9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_hub_repos_operations.py @@ -0,0 +1,306 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _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( + resource_group_name: str, security_connector_name: str, owner_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners/{ownerName}/repos", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "ownerName": _SERIALIZER.url("owner_name", owner_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + security_connector_name: str, + owner_name: str, + repo_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners/{ownerName}/repos/{repoName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "ownerName": _SERIALIZER.url("owner_name", owner_name, "str"), + "repoName": _SERIALIZER.url("repo_name", repo_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class GitHubReposOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s + :attr:`git_hub_repos` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, owner_name: str, **kwargs: Any + ) -> Iterable["_models.GitHubRepository"]: + """Returns a list of GitHub repositories onboarded to the connector. + + Returns a list of GitHub repositories onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param owner_name: The GitHub owner name. Required. + :type owner_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GitHubRepository or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.GitHubRepository] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitHubRepositoryListResponse] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + owner_name=owner_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GitHubRepositoryListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners/{ownerName}/repos" + } + + @distributed_trace + def get( + self, resource_group_name: str, security_connector_name: str, owner_name: str, repo_name: str, **kwargs: Any + ) -> _models.GitHubRepository: + """Returns a monitored GitHub repository. + + Returns a monitored GitHub repository. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param owner_name: The GitHub owner name. Required. + :type owner_name: str + :param repo_name: The repository name. Required. + :type repo_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GitHubRepository or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitHubRepository + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitHubRepository] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + owner_name=owner_name, + repo_name=repo_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitHubRepository", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitHubOwners/{ownerName}/repos/{repoName}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_lab_groups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_lab_groups_operations.py new file mode 100644 index 000000000000..ec4620190d35 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_lab_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, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _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_available_request( + resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/listAvailableGitLabGroups", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, security_connector_name: str, group_fq_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "groupFQName": _SERIALIZER.url("group_fq_name", group_fq_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class GitLabGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s + :attr:`git_lab_groups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_available( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> _models.GitLabGroupListResponse: + """Returns a list of all GitLab groups accessible by the user token consumed by the connector. + + Returns a list of all GitLab groups accessible by the user token consumed by the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GitLabGroupListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroupListResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) + + request = build_list_available_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_available.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitLabGroupListResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_available.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/listAvailableGitLabGroups" + } + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> Iterable["_models.GitLabGroup"]: + """Returns a list of GitLab groups onboarded to the connector. + + Returns a list of GitLab groups onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GitLabGroup or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GitLabGroupListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups" + } + + @distributed_trace + def get( + self, resource_group_name: str, security_connector_name: str, group_fq_name: str, **kwargs: Any + ) -> _models.GitLabGroup: + """Returns a monitored GitLab Group resource for a given fully-qualified name. + + Returns a monitored GitLab Group resource for a given fully-qualified name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param group_fq_name: The GitLab group fully-qualified name. Required. + :type group_fq_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GitLabGroup or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroup + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitLabGroup] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + group_fq_name=group_fq_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitLabGroup", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_lab_projects_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_lab_projects_operations.py new file mode 100644 index 000000000000..7bf023a2b1c5 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_lab_projects_operations.py @@ -0,0 +1,315 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _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( + resource_group_name: str, security_connector_name: str, group_fq_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}/projects", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "groupFQName": _SERIALIZER.url("group_fq_name", group_fq_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + security_connector_name: str, + group_fq_name: str, + project_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}/projects/{projectName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "groupFQName": _SERIALIZER.url("group_fq_name", group_fq_name, "str"), + "projectName": _SERIALIZER.url("project_name", project_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class GitLabProjectsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s + :attr:`git_lab_projects` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, group_fq_name: str, **kwargs: Any + ) -> Iterable["_models.GitLabProject"]: + """Gets a list of GitLab projects that are directly owned by given group and onboarded to the + connector. + + Gets a list of GitLab projects that are directly owned by given group and onboarded to the + connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param group_fq_name: The GitLab group fully-qualified name. Required. + :type group_fq_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GitLabProject or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_09_01_preview.models.GitLabProject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitLabProjectListResponse] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + group_fq_name=group_fq_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("GitLabProjectListResponse", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}/projects" + } + + @distributed_trace + def get( + self, + resource_group_name: str, + security_connector_name: str, + group_fq_name: str, + project_name: str, + **kwargs: Any + ) -> _models.GitLabProject: + """Returns a monitored GitLab Project resource for a given fully-qualified group name and project + name. + + Returns a monitored GitLab Project resource for a given fully-qualified group name and project + name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param group_fq_name: The GitLab group fully-qualified name. Required. + :type group_fq_name: str + :param project_name: The project name. Required. + :type project_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GitLabProject or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabProject + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitLabProject] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + group_fq_name=group_fq_name, + project_name=project_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitLabProject", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}/projects/{projectName}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_lab_subgroups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_lab_subgroups_operations.py new file mode 100644 index 000000000000..3de056ecc0d9 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_git_lab_subgroups_operations.py @@ -0,0 +1,161 @@ +# 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 + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, security_connector_name: str, group_fq_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}/listSubgroups", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + "groupFQName": _SERIALIZER.url("group_fq_name", group_fq_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class GitLabSubgroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_09_01_preview.SecurityCenter`'s + :attr:`git_lab_subgroups` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list( + self, resource_group_name: str, security_connector_name: str, group_fq_name: str, **kwargs: Any + ) -> _models.GitLabGroupListResponse: + """Gets nested subgroups of given GitLab Group which are onboarded to the connector. + + Gets nested subgroups of given GitLab Group which are onboarded to the connector. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param group_fq_name: The GitLab group fully-qualified name. Required. + :type group_fq_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GitLabGroupListResponse or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_09_01_preview.models.GitLabGroupListResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-09-01-preview") + ) + cls: ClsType[_models.GitLabGroupListResponse] = kwargs.pop("cls", None) + + request = build_list_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + group_fq_name=group_fq_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("GitLabGroupListResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}/devops/default/gitLabGroups/{groupFQName}/listSubgroups" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_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/v2023_09_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_09_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/v2023_10_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/__init__.py new file mode 100644 index 000000000000..e95a015ca6b8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/__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 ._security_center import SecurityCenter +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenter", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_configuration.py new file mode 100644 index 000000000000..cfac4aa396bf --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_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 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 "2023-10-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-10-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) + self._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.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/v2023_10_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_metadata.json new file mode 100644 index 000000000000..d96af28a71ce --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_metadata.json @@ -0,0 +1,110 @@ +{ + "chosen_version": "2023-10-01-preview", + "total_api_version_list": ["2023-10-01-preview"], + "client": { + "name": "SecurityCenter", + "filename": "_security_center", + "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_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, + "method_location": "positional" + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Azure subscription ID. Required.", + "docstring_type": "str", + "required": true, + "method_location": "positional" + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Azure subscription ID. Required.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version: Optional[str]=None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"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": { + "security_connectors": "SecurityConnectorsOperations" + } +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_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/v2023_10_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_security_center.py new file mode 100644 index 000000000000..72935b7c7465 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_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 as _models +from .._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import SecurityConnectorsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword + """API spec for Microsoft.Security (Azure Security Center) resource provider. + + :ivar security_connectors: SecurityConnectorsOperations operations + :vartype security_connectors: + azure.mgmt.security.v2023_10_01_preview.operations.SecurityConnectorsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Azure subscription ID. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-10-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.security_connectors = SecurityConnectorsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "SecurityCenter": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_vendor.py new file mode 100644 index 000000000000..0dafe0e287ff --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_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/v2023_10_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/__init__.py new file mode 100644 index 000000000000..d9a53c22b3e6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/__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 ._security_center import SecurityCenter + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenter", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/_configuration.py new file mode 100644 index 000000000000..ef7956ce433e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_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 + :param subscription_id: Azure subscription ID. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-10-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-10-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) + self._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/v2023_10_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_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/v2023_10_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/_security_center.py new file mode 100644 index 000000000000..2591ea8ecbe3 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/_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, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import SecurityConnectorsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword + """API spec for Microsoft.Security (Azure Security Center) resource provider. + + :ivar security_connectors: SecurityConnectorsOperations operations + :vartype security_connectors: + azure.mgmt.security.v2023_10_01_preview.aio.operations.SecurityConnectorsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Azure subscription ID. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-10-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.security_connectors = SecurityConnectorsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-10-01-preview" + ) + + 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: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..8e4ac6c4f04e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/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 ._security_connectors_operations import SecurityConnectorsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityConnectorsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/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/v2023_10_01_preview/aio/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/operations/_security_connectors_operations.py new file mode 100644 index 000000000000..9a5340637e11 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/aio/operations/_security_connectors_operations.py @@ -0,0 +1,664 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._security_connectors_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SecurityConnectorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_10_01_preview.aio.SecurityCenter`'s + :attr:`security_connectors` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityConnector"]: + """Lists all the security connectors in the specified subscription. Use the 'nextLink' property in + the response to get the next page of security connectors for the specified subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SecurityConnector or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityConnectors"} + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SecurityConnector"]: + """Lists all the security connectors in the specified resource group. Use the 'nextLink' property + in the response to get the next page of security connectors for the specified resource group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SecurityConnector or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> _models.SecurityConnector: + """Retrieves details of a specific security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityConnector", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: _models.SecurityConnector, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Creates or updates a security connector. If a security connector is already created and a + subsequent request is issued for the same security connector id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Creates or updates a security connector. If a security connector is already created and a + subsequent request is issued for the same security connector id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: IO + :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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: Union[_models.SecurityConnector, IO], + **kwargs: Any + ) -> _models.SecurityConnector: + """Creates or updates a security connector. If a security connector is already created and a + subsequent request is issued for the same security connector id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Is either a SecurityConnector type + or a IO type. Required. + :type security_connector: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector 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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_connector, (IOBase, bytes)): + _content = security_connector + else: + _json = self._serialize.body(security_connector, "SecurityConnector") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SecurityConnector", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SecurityConnector", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}" + } + + @overload + async def update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: _models.SecurityConnector, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Updates a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Updates a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: IO + :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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: Union[_models.SecurityConnector, IO], + **kwargs: Any + ) -> _models.SecurityConnector: + """Updates a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Is either a SecurityConnector type + or a IO type. Required. + :type security_connector: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector 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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_connector, (IOBase, bytes)): + _content = security_connector + else: + _json = self._serialize.body(security_connector, "SecurityConnector") + + request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityConnector", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> None: + """Deletes a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/__init__.py new file mode 100644 index 000000000000..edf6edd347c5 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/__init__.py @@ -0,0 +1,227 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import AwsEnvironmentData +from ._models_py3 import AwsOrganizationalData +from ._models_py3 import AwsOrganizationalDataMaster +from ._models_py3 import AwsOrganizationalDataMember +from ._models_py3 import AzureDevOpsScopeEnvironmentData +from ._models_py3 import AzureTrackedResourceLocation +from ._models_py3 import CloudErrorBody +from ._models_py3 import CloudOffering +from ._models_py3 import CspmMonitorAwsOffering +from ._models_py3 import CspmMonitorAwsOfferingNativeCloudConnection +from ._models_py3 import CspmMonitorAzureDevOpsOffering +from ._models_py3 import CspmMonitorGcpOffering +from ._models_py3 import CspmMonitorGcpOfferingNativeCloudConnection +from ._models_py3 import CspmMonitorGitLabOffering +from ._models_py3 import CspmMonitorGithubOffering +from ._models_py3 import DefenderCspmAwsOffering +from ._models_py3 import DefenderCspmAwsOfferingCiem +from ._models_py3 import DefenderCspmAwsOfferingCiemDiscovery +from ._models_py3 import DefenderCspmAwsOfferingCiemOidc +from ._models_py3 import DefenderCspmAwsOfferingDataSensitivityDiscovery +from ._models_py3 import DefenderCspmAwsOfferingDatabasesDspm +from ._models_py3 import DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S +from ._models_py3 import DefenderCspmAwsOfferingMdcContainersImageAssessment +from ._models_py3 import DefenderCspmAwsOfferingVmScanners +from ._models_py3 import DefenderCspmAwsOfferingVmScannersConfiguration +from ._models_py3 import DefenderCspmGcpOffering +from ._models_py3 import DefenderCspmGcpOfferingCiemDiscovery +from ._models_py3 import DefenderCspmGcpOfferingDataSensitivityDiscovery +from ._models_py3 import DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S +from ._models_py3 import DefenderCspmGcpOfferingMdcContainersImageAssessment +from ._models_py3 import DefenderCspmGcpOfferingVmScanners +from ._models_py3 import DefenderCspmGcpOfferingVmScannersConfiguration +from ._models_py3 import DefenderFoDatabasesAwsOffering +from ._models_py3 import DefenderFoDatabasesAwsOfferingArcAutoProvisioning +from ._models_py3 import DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration +from ._models_py3 import DefenderFoDatabasesAwsOfferingDatabasesDspm +from ._models_py3 import DefenderFoDatabasesAwsOfferingRds +from ._models_py3 import DefenderForContainersAwsOffering +from ._models_py3 import DefenderForContainersAwsOfferingCloudWatchToKinesis +from ._models_py3 import DefenderForContainersAwsOfferingContainerVulnerabilityAssessment +from ._models_py3 import DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask +from ._models_py3 import DefenderForContainersAwsOfferingKinesisToS3 +from ._models_py3 import DefenderForContainersAwsOfferingKubernetesScubaReader +from ._models_py3 import DefenderForContainersAwsOfferingKubernetesService +from ._models_py3 import DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S +from ._models_py3 import DefenderForContainersAwsOfferingMdcContainersImageAssessment +from ._models_py3 import DefenderForContainersGcpOffering +from ._models_py3 import DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection +from ._models_py3 import DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S +from ._models_py3 import DefenderForContainersGcpOfferingMdcContainersImageAssessment +from ._models_py3 import DefenderForContainersGcpOfferingNativeCloudConnection +from ._models_py3 import DefenderForDatabasesGcpOffering +from ._models_py3 import DefenderForDatabasesGcpOfferingArcAutoProvisioning +from ._models_py3 import DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration +from ._models_py3 import DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning +from ._models_py3 import DefenderForDevOpsAzureDevOpsOffering +from ._models_py3 import DefenderForDevOpsGitLabOffering +from ._models_py3 import DefenderForDevOpsGithubOffering +from ._models_py3 import DefenderForServersAwsOffering +from ._models_py3 import DefenderForServersAwsOfferingArcAutoProvisioning +from ._models_py3 import DefenderForServersAwsOfferingArcAutoProvisioningConfiguration +from ._models_py3 import DefenderForServersAwsOfferingDefenderForServers +from ._models_py3 import DefenderForServersAwsOfferingMdeAutoProvisioning +from ._models_py3 import DefenderForServersAwsOfferingSubPlan +from ._models_py3 import DefenderForServersAwsOfferingVaAutoProvisioning +from ._models_py3 import DefenderForServersAwsOfferingVaAutoProvisioningConfiguration +from ._models_py3 import DefenderForServersAwsOfferingVmScanners +from ._models_py3 import DefenderForServersAwsOfferingVmScannersConfiguration +from ._models_py3 import DefenderForServersGcpOffering +from ._models_py3 import DefenderForServersGcpOfferingArcAutoProvisioning +from ._models_py3 import DefenderForServersGcpOfferingArcAutoProvisioningConfiguration +from ._models_py3 import DefenderForServersGcpOfferingDefenderForServers +from ._models_py3 import DefenderForServersGcpOfferingMdeAutoProvisioning +from ._models_py3 import DefenderForServersGcpOfferingSubPlan +from ._models_py3 import DefenderForServersGcpOfferingVaAutoProvisioning +from ._models_py3 import DefenderForServersGcpOfferingVaAutoProvisioningConfiguration +from ._models_py3 import DefenderForServersGcpOfferingVmScanners +from ._models_py3 import DefenderForServersGcpOfferingVmScannersConfiguration +from ._models_py3 import ETag +from ._models_py3 import EnvironmentData +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import GcpOrganizationalData +from ._models_py3 import GcpOrganizationalDataMember +from ._models_py3 import GcpOrganizationalDataOrganization +from ._models_py3 import GcpProjectDetails +from ._models_py3 import GcpProjectEnvironmentData +from ._models_py3 import GithubScopeEnvironmentData +from ._models_py3 import GitlabScopeEnvironmentData +from ._models_py3 import InformationProtectionAwsOffering +from ._models_py3 import InformationProtectionAwsOfferingInformationProtection +from ._models_py3 import Kind +from ._models_py3 import Resource +from ._models_py3 import SecurityConnector +from ._models_py3 import SecurityConnectorsList +from ._models_py3 import SystemData +from ._models_py3 import Tags +from ._models_py3 import TrackedResource + +from ._security_center_enums import CloudName +from ._security_center_enums import CreatedByType +from ._security_center_enums import EnvironmentType +from ._security_center_enums import OfferingType +from ._security_center_enums import OrganizationMembershipType +from ._security_center_enums import ScanningMode +from ._security_center_enums import SubPlan +from ._security_center_enums import Type +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AwsEnvironmentData", + "AwsOrganizationalData", + "AwsOrganizationalDataMaster", + "AwsOrganizationalDataMember", + "AzureDevOpsScopeEnvironmentData", + "AzureTrackedResourceLocation", + "CloudErrorBody", + "CloudOffering", + "CspmMonitorAwsOffering", + "CspmMonitorAwsOfferingNativeCloudConnection", + "CspmMonitorAzureDevOpsOffering", + "CspmMonitorGcpOffering", + "CspmMonitorGcpOfferingNativeCloudConnection", + "CspmMonitorGitLabOffering", + "CspmMonitorGithubOffering", + "DefenderCspmAwsOffering", + "DefenderCspmAwsOfferingCiem", + "DefenderCspmAwsOfferingCiemDiscovery", + "DefenderCspmAwsOfferingCiemOidc", + "DefenderCspmAwsOfferingDataSensitivityDiscovery", + "DefenderCspmAwsOfferingDatabasesDspm", + "DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S", + "DefenderCspmAwsOfferingMdcContainersImageAssessment", + "DefenderCspmAwsOfferingVmScanners", + "DefenderCspmAwsOfferingVmScannersConfiguration", + "DefenderCspmGcpOffering", + "DefenderCspmGcpOfferingCiemDiscovery", + "DefenderCspmGcpOfferingDataSensitivityDiscovery", + "DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S", + "DefenderCspmGcpOfferingMdcContainersImageAssessment", + "DefenderCspmGcpOfferingVmScanners", + "DefenderCspmGcpOfferingVmScannersConfiguration", + "DefenderFoDatabasesAwsOffering", + "DefenderFoDatabasesAwsOfferingArcAutoProvisioning", + "DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration", + "DefenderFoDatabasesAwsOfferingDatabasesDspm", + "DefenderFoDatabasesAwsOfferingRds", + "DefenderForContainersAwsOffering", + "DefenderForContainersAwsOfferingCloudWatchToKinesis", + "DefenderForContainersAwsOfferingContainerVulnerabilityAssessment", + "DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask", + "DefenderForContainersAwsOfferingKinesisToS3", + "DefenderForContainersAwsOfferingKubernetesScubaReader", + "DefenderForContainersAwsOfferingKubernetesService", + "DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S", + "DefenderForContainersAwsOfferingMdcContainersImageAssessment", + "DefenderForContainersGcpOffering", + "DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection", + "DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S", + "DefenderForContainersGcpOfferingMdcContainersImageAssessment", + "DefenderForContainersGcpOfferingNativeCloudConnection", + "DefenderForDatabasesGcpOffering", + "DefenderForDatabasesGcpOfferingArcAutoProvisioning", + "DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration", + "DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning", + "DefenderForDevOpsAzureDevOpsOffering", + "DefenderForDevOpsGitLabOffering", + "DefenderForDevOpsGithubOffering", + "DefenderForServersAwsOffering", + "DefenderForServersAwsOfferingArcAutoProvisioning", + "DefenderForServersAwsOfferingArcAutoProvisioningConfiguration", + "DefenderForServersAwsOfferingDefenderForServers", + "DefenderForServersAwsOfferingMdeAutoProvisioning", + "DefenderForServersAwsOfferingSubPlan", + "DefenderForServersAwsOfferingVaAutoProvisioning", + "DefenderForServersAwsOfferingVaAutoProvisioningConfiguration", + "DefenderForServersAwsOfferingVmScanners", + "DefenderForServersAwsOfferingVmScannersConfiguration", + "DefenderForServersGcpOffering", + "DefenderForServersGcpOfferingArcAutoProvisioning", + "DefenderForServersGcpOfferingArcAutoProvisioningConfiguration", + "DefenderForServersGcpOfferingDefenderForServers", + "DefenderForServersGcpOfferingMdeAutoProvisioning", + "DefenderForServersGcpOfferingSubPlan", + "DefenderForServersGcpOfferingVaAutoProvisioning", + "DefenderForServersGcpOfferingVaAutoProvisioningConfiguration", + "DefenderForServersGcpOfferingVmScanners", + "DefenderForServersGcpOfferingVmScannersConfiguration", + "ETag", + "EnvironmentData", + "ErrorAdditionalInfo", + "GcpOrganizationalData", + "GcpOrganizationalDataMember", + "GcpOrganizationalDataOrganization", + "GcpProjectDetails", + "GcpProjectEnvironmentData", + "GithubScopeEnvironmentData", + "GitlabScopeEnvironmentData", + "InformationProtectionAwsOffering", + "InformationProtectionAwsOfferingInformationProtection", + "Kind", + "Resource", + "SecurityConnector", + "SecurityConnectorsList", + "SystemData", + "Tags", + "TrackedResource", + "CloudName", + "CreatedByType", + "EnvironmentType", + "OfferingType", + "OrganizationMembershipType", + "ScanningMode", + "SubPlan", + "Type", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/_models_py3.py new file mode 100644 index 000000000000..b3bcc0ab234b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/_models_py3.py @@ -0,0 +1,3962 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object + + +class EnvironmentData(_serialization.Model): + """The security connector environment data. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AwsEnvironmentData, AzureDevOpsScopeEnvironmentData, GcpProjectEnvironmentData, + GithubScopeEnvironmentData, GitlabScopeEnvironmentData + + All required parameters must be populated in order to send to Azure. + + :ivar environment_type: The type of the environment data. Required. Known values are: + "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", and "GitlabScope". + :vartype environment_type: str or + ~azure.mgmt.security.v2023_10_01_preview.models.EnvironmentType + """ + + _validation = { + "environment_type": {"required": True}, + } + + _attribute_map = { + "environment_type": {"key": "environmentType", "type": "str"}, + } + + _subtype_map = { + "environment_type": { + "AwsAccount": "AwsEnvironmentData", + "AzureDevOpsScope": "AzureDevOpsScopeEnvironmentData", + "GcpProject": "GcpProjectEnvironmentData", + "GithubScope": "GithubScopeEnvironmentData", + "GitlabScope": "GitlabScopeEnvironmentData", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.environment_type: Optional[str] = None + + +class AwsEnvironmentData(EnvironmentData): + """The AWS connector environment data. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar environment_type: The type of the environment data. Required. Known values are: + "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", and "GitlabScope". + :vartype environment_type: str or + ~azure.mgmt.security.v2023_10_01_preview.models.EnvironmentType + :ivar organizational_data: The AWS account's organizational data. + :vartype organizational_data: + ~azure.mgmt.security.v2023_10_01_preview.models.AwsOrganizationalData + :ivar regions: list of regions to scan. + :vartype regions: list[str] + :ivar account_name: The AWS account name. + :vartype account_name: str + :ivar scan_interval: Scan interval in hours (value should be between 1-hour to 24-hours). + :vartype scan_interval: int + """ + + _validation = { + "environment_type": {"required": True}, + "account_name": {"readonly": True}, + } + + _attribute_map = { + "environment_type": {"key": "environmentType", "type": "str"}, + "organizational_data": {"key": "organizationalData", "type": "AwsOrganizationalData"}, + "regions": {"key": "regions", "type": "[str]"}, + "account_name": {"key": "accountName", "type": "str"}, + "scan_interval": {"key": "scanInterval", "type": "int"}, + } + + def __init__( + self, + *, + organizational_data: Optional["_models.AwsOrganizationalData"] = None, + regions: Optional[List[str]] = None, + scan_interval: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword organizational_data: The AWS account's organizational data. + :paramtype organizational_data: + ~azure.mgmt.security.v2023_10_01_preview.models.AwsOrganizationalData + :keyword regions: list of regions to scan. + :paramtype regions: list[str] + :keyword scan_interval: Scan interval in hours (value should be between 1-hour to 24-hours). + :paramtype scan_interval: int + """ + super().__init__(**kwargs) + self.environment_type: str = "AwsAccount" + self.organizational_data = organizational_data + self.regions = regions + self.account_name = None + self.scan_interval = scan_interval + + +class AwsOrganizationalData(_serialization.Model): + """The AWS organization data. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AwsOrganizationalDataMember, AwsOrganizationalDataMaster + + All required parameters must be populated in order to send to Azure. + + :ivar organization_membership_type: The multi cloud account's membership type in the + organization. Required. Known values are: "Member" and "Organization". + :vartype organization_membership_type: str or + ~azure.mgmt.security.v2023_10_01_preview.models.OrganizationMembershipType + """ + + _validation = { + "organization_membership_type": {"required": True}, + } + + _attribute_map = { + "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, + } + + _subtype_map = { + "organization_membership_type": { + "Member": "AwsOrganizationalDataMember", + "Organization": "AwsOrganizationalDataMaster", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.organization_membership_type: Optional[str] = None + + +class AwsOrganizationalDataMaster(AwsOrganizationalData): + """The AWS organization data for the master account. + + All required parameters must be populated in order to send to Azure. + + :ivar organization_membership_type: The multi cloud account's membership type in the + organization. Required. Known values are: "Member" and "Organization". + :vartype organization_membership_type: str or + ~azure.mgmt.security.v2023_10_01_preview.models.OrganizationMembershipType + :ivar stackset_name: If the multi cloud account is of membership type organization, this will + be the name of the onboarding stackset. + :vartype stackset_name: str + :ivar excluded_account_ids: If the multi cloud account is of membership type organization, list + of accounts excluded from offering. + :vartype excluded_account_ids: list[str] + """ + + _validation = { + "organization_membership_type": {"required": True}, + } + + _attribute_map = { + "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, + "stackset_name": {"key": "stacksetName", "type": "str"}, + "excluded_account_ids": {"key": "excludedAccountIds", "type": "[str]"}, + } + + def __init__( + self, *, stackset_name: Optional[str] = None, excluded_account_ids: Optional[List[str]] = None, **kwargs: Any + ) -> None: + """ + :keyword stackset_name: If the multi cloud account is of membership type organization, this + will be the name of the onboarding stackset. + :paramtype stackset_name: str + :keyword excluded_account_ids: If the multi cloud account is of membership type organization, + list of accounts excluded from offering. + :paramtype excluded_account_ids: list[str] + """ + super().__init__(**kwargs) + self.organization_membership_type: str = "Organization" + self.stackset_name = stackset_name + self.excluded_account_ids = excluded_account_ids + + +class AwsOrganizationalDataMember(AwsOrganizationalData): + """The AWS organization data for the member account. + + All required parameters must be populated in order to send to Azure. + + :ivar organization_membership_type: The multi cloud account's membership type in the + organization. Required. Known values are: "Member" and "Organization". + :vartype organization_membership_type: str or + ~azure.mgmt.security.v2023_10_01_preview.models.OrganizationMembershipType + :ivar parent_hierarchy_id: If the multi cloud account is not of membership type organization, + this will be the ID of the account's parent. + :vartype parent_hierarchy_id: str + """ + + _validation = { + "organization_membership_type": {"required": True}, + } + + _attribute_map = { + "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, + "parent_hierarchy_id": {"key": "parentHierarchyId", "type": "str"}, + } + + def __init__(self, *, parent_hierarchy_id: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword parent_hierarchy_id: If the multi cloud account is not of membership type + organization, this will be the ID of the account's parent. + :paramtype parent_hierarchy_id: str + """ + super().__init__(**kwargs) + self.organization_membership_type: str = "Member" + self.parent_hierarchy_id = parent_hierarchy_id + + +class AzureDevOpsScopeEnvironmentData(EnvironmentData): + """The AzureDevOps scope connector's environment data. + + All required parameters must be populated in order to send to Azure. + + :ivar environment_type: The type of the environment data. Required. Known values are: + "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", and "GitlabScope". + :vartype environment_type: str or + ~azure.mgmt.security.v2023_10_01_preview.models.EnvironmentType + """ + + _validation = { + "environment_type": {"required": True}, + } + + _attribute_map = { + "environment_type": {"key": "environmentType", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.environment_type: str = "AzureDevOpsScope" + + +class AzureTrackedResourceLocation(_serialization.Model): + """Describes an Azure resource with location. + + :ivar location: Location where the resource is stored. + :vartype location: str + """ + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword location: Location where the resource is stored. + :paramtype location: str + """ + super().__init__(**kwargs) + self.location = location + + +class CloudErrorBody(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.security.v2023_10_01_preview.models.CloudErrorBody] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.security.v2023_10_01_preview.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class CloudOffering(_serialization.Model): + """The security offering details. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + CspmMonitorAwsOffering, CspmMonitorAzureDevOpsOffering, CspmMonitorGcpOffering, + CspmMonitorGitLabOffering, CspmMonitorGithubOffering, DefenderCspmAwsOffering, + DefenderCspmGcpOffering, DefenderForContainersAwsOffering, DefenderForContainersGcpOffering, + DefenderFoDatabasesAwsOffering, DefenderForDatabasesGcpOffering, + DefenderForDevOpsAzureDevOpsOffering, DefenderForDevOpsGitLabOffering, + DefenderForDevOpsGithubOffering, DefenderForServersAwsOffering, DefenderForServersGcpOffering, + InformationProtectionAwsOffering + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", + "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". + :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + _subtype_map = { + "offering_type": { + "CspmMonitorAws": "CspmMonitorAwsOffering", + "CspmMonitorAzureDevOps": "CspmMonitorAzureDevOpsOffering", + "CspmMonitorGcp": "CspmMonitorGcpOffering", + "CspmMonitorGitLab": "CspmMonitorGitLabOffering", + "CspmMonitorGithub": "CspmMonitorGithubOffering", + "DefenderCspmAws": "DefenderCspmAwsOffering", + "DefenderCspmGcp": "DefenderCspmGcpOffering", + "DefenderForContainersAws": "DefenderForContainersAwsOffering", + "DefenderForContainersGcp": "DefenderForContainersGcpOffering", + "DefenderForDatabasesAws": "DefenderFoDatabasesAwsOffering", + "DefenderForDatabasesGcp": "DefenderForDatabasesGcpOffering", + "DefenderForDevOpsAzureDevOps": "DefenderForDevOpsAzureDevOpsOffering", + "DefenderForDevOpsGitLab": "DefenderForDevOpsGitLabOffering", + "DefenderForDevOpsGithub": "DefenderForDevOpsGithubOffering", + "DefenderForServersAws": "DefenderForServersAwsOffering", + "DefenderForServersGcp": "DefenderForServersGcpOffering", + "InformationProtectionAws": "InformationProtectionAwsOffering", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.offering_type: Optional[str] = None + self.description = None + + +class CspmMonitorAwsOffering(CloudOffering): + """The CSPM monitoring for AWS offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", + "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". + :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar native_cloud_connection: The native cloud connection configuration. + :vartype native_cloud_connection: + ~azure.mgmt.security.v2023_10_01_preview.models.CspmMonitorAwsOfferingNativeCloudConnection + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "native_cloud_connection": { + "key": "nativeCloudConnection", + "type": "CspmMonitorAwsOfferingNativeCloudConnection", + }, + } + + def __init__( + self, + *, + native_cloud_connection: Optional["_models.CspmMonitorAwsOfferingNativeCloudConnection"] = None, + **kwargs: Any + ) -> None: + """ + :keyword native_cloud_connection: The native cloud connection configuration. + :paramtype native_cloud_connection: + ~azure.mgmt.security.v2023_10_01_preview.models.CspmMonitorAwsOfferingNativeCloudConnection + """ + super().__init__(**kwargs) + self.offering_type: str = "CspmMonitorAws" + self.native_cloud_connection = native_cloud_connection + + +class CspmMonitorAwsOfferingNativeCloudConnection(_serialization.Model): + """The native cloud connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class CspmMonitorAzureDevOpsOffering(CloudOffering): + """The CSPM monitoring for AzureDevOps offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", + "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". + :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.offering_type: str = "CspmMonitorAzureDevOps" + + +class CspmMonitorGcpOffering(CloudOffering): + """The CSPM monitoring for GCP offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", + "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". + :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar native_cloud_connection: The native cloud connection configuration. + :vartype native_cloud_connection: + ~azure.mgmt.security.v2023_10_01_preview.models.CspmMonitorGcpOfferingNativeCloudConnection + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "native_cloud_connection": { + "key": "nativeCloudConnection", + "type": "CspmMonitorGcpOfferingNativeCloudConnection", + }, + } + + def __init__( + self, + *, + native_cloud_connection: Optional["_models.CspmMonitorGcpOfferingNativeCloudConnection"] = None, + **kwargs: Any + ) -> None: + """ + :keyword native_cloud_connection: The native cloud connection configuration. + :paramtype native_cloud_connection: + ~azure.mgmt.security.v2023_10_01_preview.models.CspmMonitorGcpOfferingNativeCloudConnection + """ + super().__init__(**kwargs) + self.offering_type: str = "CspmMonitorGcp" + self.native_cloud_connection = native_cloud_connection + + +class CspmMonitorGcpOfferingNativeCloudConnection(_serialization.Model): + """The native cloud connection configuration. + + :ivar workload_identity_provider_id: The GCP workload identity provider id for the offering. + :vartype workload_identity_provider_id: str + :ivar service_account_email_address: The service account email address in GCP for this + offering. + :vartype service_account_email_address: str + """ + + _attribute_map = { + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + } + + def __init__( + self, + *, + workload_identity_provider_id: Optional[str] = None, + service_account_email_address: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword workload_identity_provider_id: The GCP workload identity provider id for the offering. + :paramtype workload_identity_provider_id: str + :keyword service_account_email_address: The service account email address in GCP for this + offering. + :paramtype service_account_email_address: str + """ + super().__init__(**kwargs) + self.workload_identity_provider_id = workload_identity_provider_id + self.service_account_email_address = service_account_email_address + + +class CspmMonitorGithubOffering(CloudOffering): + """The CSPM monitoring for github offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", + "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". + :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.offering_type: str = "CspmMonitorGithub" + + +class CspmMonitorGitLabOffering(CloudOffering): + """The CSPM (Cloud security posture management) monitoring for gitlab offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", + "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". + :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.offering_type: str = "CspmMonitorGitLab" + + +class DefenderCspmAwsOffering(CloudOffering): + """The CSPM P1 for AWS offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", + "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". + :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar vm_scanners: The Microsoft Defender for Server VM scanning configuration. + :vartype vm_scanners: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingVmScanners + :ivar data_sensitivity_discovery: The Microsoft Defender Data Sensitivity discovery + configuration. + :vartype data_sensitivity_discovery: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingDataSensitivityDiscovery + :ivar databases_dspm: The databases DSPM configuration. + :vartype databases_dspm: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingDatabasesDspm + :ivar ciem: Defenders CSPM Cloud infrastructure entitlement management (CIEM) offering + configurations. + :vartype ciem: ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingCiem + :ivar mdc_containers_image_assessment: The Microsoft Defender container image assessment + configuration. + :vartype mdc_containers_image_assessment: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingMdcContainersImageAssessment + :ivar mdc_containers_agentless_discovery_k8_s: The Microsoft Defender container agentless + discovery K8s configuration. + :vartype mdc_containers_agentless_discovery_k8_s: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "vm_scanners": {"key": "vmScanners", "type": "DefenderCspmAwsOfferingVmScanners"}, + "data_sensitivity_discovery": { + "key": "dataSensitivityDiscovery", + "type": "DefenderCspmAwsOfferingDataSensitivityDiscovery", + }, + "databases_dspm": {"key": "databasesDspm", "type": "DefenderCspmAwsOfferingDatabasesDspm"}, + "ciem": {"key": "ciem", "type": "DefenderCspmAwsOfferingCiem"}, + "mdc_containers_image_assessment": { + "key": "mdcContainersImageAssessment", + "type": "DefenderCspmAwsOfferingMdcContainersImageAssessment", + }, + "mdc_containers_agentless_discovery_k8_s": { + "key": "mdcContainersAgentlessDiscoveryK8s", + "type": "DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S", + }, + } + + def __init__( + self, + *, + vm_scanners: Optional["_models.DefenderCspmAwsOfferingVmScanners"] = None, + data_sensitivity_discovery: Optional["_models.DefenderCspmAwsOfferingDataSensitivityDiscovery"] = None, + databases_dspm: Optional["_models.DefenderCspmAwsOfferingDatabasesDspm"] = None, + ciem: Optional["_models.DefenderCspmAwsOfferingCiem"] = None, + mdc_containers_image_assessment: Optional["_models.DefenderCspmAwsOfferingMdcContainersImageAssessment"] = None, + mdc_containers_agentless_discovery_k8_s: Optional[ + "_models.DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S" + ] = None, + **kwargs: Any + ) -> None: + """ + :keyword vm_scanners: The Microsoft Defender for Server VM scanning configuration. + :paramtype vm_scanners: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingVmScanners + :keyword data_sensitivity_discovery: The Microsoft Defender Data Sensitivity discovery + configuration. + :paramtype data_sensitivity_discovery: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingDataSensitivityDiscovery + :keyword databases_dspm: The databases DSPM configuration. + :paramtype databases_dspm: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingDatabasesDspm + :keyword ciem: Defenders CSPM Cloud infrastructure entitlement management (CIEM) offering + configurations. + :paramtype ciem: ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingCiem + :keyword mdc_containers_image_assessment: The Microsoft Defender container image assessment + configuration. + :paramtype mdc_containers_image_assessment: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingMdcContainersImageAssessment + :keyword mdc_containers_agentless_discovery_k8_s: The Microsoft Defender container agentless + discovery K8s configuration. + :paramtype mdc_containers_agentless_discovery_k8_s: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S + """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderCspmAws" + self.vm_scanners = vm_scanners + self.data_sensitivity_discovery = data_sensitivity_discovery + self.databases_dspm = databases_dspm + self.ciem = ciem + self.mdc_containers_image_assessment = mdc_containers_image_assessment + self.mdc_containers_agentless_discovery_k8_s = mdc_containers_agentless_discovery_k8_s + + +class DefenderCspmAwsOfferingCiem(_serialization.Model): + """Defenders CSPM Cloud infrastructure entitlement management (CIEM) offering configurations. + + :ivar ciem_discovery: Defender CSPM CIEM discovery configuration. + :vartype ciem_discovery: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingCiemDiscovery + :ivar ciem_oidc: Defender CSPM CIEM AWS OIDC (open id connect) configuration. + :vartype ciem_oidc: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingCiemOidc + """ + + _attribute_map = { + "ciem_discovery": {"key": "ciemDiscovery", "type": "DefenderCspmAwsOfferingCiemDiscovery"}, + "ciem_oidc": {"key": "ciemOidc", "type": "DefenderCspmAwsOfferingCiemOidc"}, + } + + def __init__( + self, + *, + ciem_discovery: Optional["_models.DefenderCspmAwsOfferingCiemDiscovery"] = None, + ciem_oidc: Optional["_models.DefenderCspmAwsOfferingCiemOidc"] = None, + **kwargs: Any + ) -> None: + """ + :keyword ciem_discovery: Defender CSPM CIEM discovery configuration. + :paramtype ciem_discovery: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingCiemDiscovery + :keyword ciem_oidc: Defender CSPM CIEM AWS OIDC (open id connect) configuration. + :paramtype ciem_oidc: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingCiemOidc + """ + super().__init__(**kwargs) + self.ciem_discovery = ciem_discovery + self.ciem_oidc = ciem_oidc + + +class DefenderCspmAwsOfferingCiemDiscovery(_serialization.Model): + """Defender CSPM CIEM discovery configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for CIEM discovery. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for CIEM discovery. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderCspmAwsOfferingCiemOidc(_serialization.Model): + """Defender CSPM CIEM AWS OIDC (open id connect) configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for CIEM oidc connection. + :vartype cloud_role_arn: str + :ivar azure_active_directory_app_name: the azure active directory app name used of + authenticating against AWS. + :vartype azure_active_directory_app_name: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + "azure_active_directory_app_name": {"key": "azureActiveDirectoryAppName", "type": "str"}, + } + + def __init__( + self, + *, + cloud_role_arn: Optional[str] = None, + azure_active_directory_app_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for CIEM oidc connection. + :paramtype cloud_role_arn: str + :keyword azure_active_directory_app_name: the azure active directory app name used of + authenticating against AWS. + :paramtype azure_active_directory_app_name: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + self.azure_active_directory_app_name = azure_active_directory_app_name + + +class DefenderCspmAwsOfferingDatabasesDspm(_serialization.Model): + """The databases DSPM configuration. + + :ivar enabled: Is databases DSPM protection enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is databases DSPM protection enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + + +class DefenderCspmAwsOfferingDataSensitivityDiscovery(_serialization.Model): + """The Microsoft Defender Data Sensitivity discovery configuration. + + :ivar enabled: Is Microsoft Defender Data Sensitivity discovery enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is Microsoft Defender Data Sensitivity discovery enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + + +class DefenderCspmAwsOfferingMdcContainersAgentlessDiscoveryK8S(_serialization.Model): + """The Microsoft Defender container agentless discovery K8s configuration. + + :ivar enabled: Is Microsoft Defender container agentless discovery K8s enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is Microsoft Defender container agentless discovery K8s enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + + +class DefenderCspmAwsOfferingMdcContainersImageAssessment(_serialization.Model): + """The Microsoft Defender container image assessment configuration. + + :ivar enabled: Is Microsoft Defender container image assessment enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is Microsoft Defender container image assessment enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + + +class DefenderCspmAwsOfferingVmScanners(_serialization.Model): + """The Microsoft Defender for Server VM scanning configuration. + + :ivar enabled: Is Microsoft Defender for Server VM scanning enabled. + :vartype enabled: bool + :ivar configuration: configuration for Microsoft Defender for Server VM scanning. + :vartype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingVmScannersConfiguration + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": {"key": "configuration", "type": "DefenderCspmAwsOfferingVmScannersConfiguration"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + configuration: Optional["_models.DefenderCspmAwsOfferingVmScannersConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is Microsoft Defender for Server VM scanning enabled. + :paramtype enabled: bool + :keyword configuration: configuration for Microsoft Defender for Server VM scanning. + :paramtype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmAwsOfferingVmScannersConfiguration + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderCspmAwsOfferingVmScannersConfiguration(_serialization.Model): + """configuration for Microsoft Defender for Server VM scanning. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + :ivar scanning_mode: The scanning mode for the VM scan. "Default" + :vartype scanning_mode: str or ~azure.mgmt.security.v2023_10_01_preview.models.ScanningMode + :ivar exclusion_tags: VM tags that indicates that VM should not be scanned. + :vartype exclusion_tags: dict[str, str] + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + "scanning_mode": {"key": "scanningMode", "type": "str"}, + "exclusion_tags": {"key": "exclusionTags", "type": "{str}"}, + } + + def __init__( + self, + *, + cloud_role_arn: Optional[str] = None, + scanning_mode: Optional[Union[str, "_models.ScanningMode"]] = None, + exclusion_tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + :keyword scanning_mode: The scanning mode for the VM scan. "Default" + :paramtype scanning_mode: str or ~azure.mgmt.security.v2023_10_01_preview.models.ScanningMode + :keyword exclusion_tags: VM tags that indicates that VM should not be scanned. + :paramtype exclusion_tags: dict[str, str] + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + self.scanning_mode = scanning_mode + self.exclusion_tags = exclusion_tags + + +class DefenderCspmGcpOffering(CloudOffering): + """The CSPM P1 for GCP offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", + "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". + :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar ciem_discovery: GCP Defenders CSPM Cloud infrastructure entitlement management (CIEM) + discovery offering configurations. + :vartype ciem_discovery: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingCiemDiscovery + :ivar vm_scanners: The Microsoft Defender for Server VM scanning configuration. + :vartype vm_scanners: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingVmScanners + :ivar data_sensitivity_discovery: The Microsoft Defender Data Sensitivity discovery + configuration. + :vartype data_sensitivity_discovery: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingDataSensitivityDiscovery + :ivar mdc_containers_image_assessment: The Microsoft Defender Container image assessment + configuration. + :vartype mdc_containers_image_assessment: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingMdcContainersImageAssessment + :ivar mdc_containers_agentless_discovery_k8_s: The Microsoft Defender Container agentless + discovery configuration. + :vartype mdc_containers_agentless_discovery_k8_s: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "ciem_discovery": {"key": "ciemDiscovery", "type": "DefenderCspmGcpOfferingCiemDiscovery"}, + "vm_scanners": {"key": "vmScanners", "type": "DefenderCspmGcpOfferingVmScanners"}, + "data_sensitivity_discovery": { + "key": "dataSensitivityDiscovery", + "type": "DefenderCspmGcpOfferingDataSensitivityDiscovery", + }, + "mdc_containers_image_assessment": { + "key": "mdcContainersImageAssessment", + "type": "DefenderCspmGcpOfferingMdcContainersImageAssessment", + }, + "mdc_containers_agentless_discovery_k8_s": { + "key": "mdcContainersAgentlessDiscoveryK8s", + "type": "DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S", + }, + } + + def __init__( + self, + *, + ciem_discovery: Optional["_models.DefenderCspmGcpOfferingCiemDiscovery"] = None, + vm_scanners: Optional["_models.DefenderCspmGcpOfferingVmScanners"] = None, + data_sensitivity_discovery: Optional["_models.DefenderCspmGcpOfferingDataSensitivityDiscovery"] = None, + mdc_containers_image_assessment: Optional["_models.DefenderCspmGcpOfferingMdcContainersImageAssessment"] = None, + mdc_containers_agentless_discovery_k8_s: Optional[ + "_models.DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S" + ] = None, + **kwargs: Any + ) -> None: + """ + :keyword ciem_discovery: GCP Defenders CSPM Cloud infrastructure entitlement management (CIEM) + discovery offering configurations. + :paramtype ciem_discovery: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingCiemDiscovery + :keyword vm_scanners: The Microsoft Defender for Server VM scanning configuration. + :paramtype vm_scanners: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingVmScanners + :keyword data_sensitivity_discovery: The Microsoft Defender Data Sensitivity discovery + configuration. + :paramtype data_sensitivity_discovery: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingDataSensitivityDiscovery + :keyword mdc_containers_image_assessment: The Microsoft Defender Container image assessment + configuration. + :paramtype mdc_containers_image_assessment: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingMdcContainersImageAssessment + :keyword mdc_containers_agentless_discovery_k8_s: The Microsoft Defender Container agentless + discovery configuration. + :paramtype mdc_containers_agentless_discovery_k8_s: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S + """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderCspmGcp" + self.ciem_discovery = ciem_discovery + self.vm_scanners = vm_scanners + self.data_sensitivity_discovery = data_sensitivity_discovery + self.mdc_containers_image_assessment = mdc_containers_image_assessment + self.mdc_containers_agentless_discovery_k8_s = mdc_containers_agentless_discovery_k8_s + + +class DefenderCspmGcpOfferingCiemDiscovery(_serialization.Model): + """GCP Defenders CSPM Cloud infrastructure entitlement management (CIEM) discovery offering + configurations. + + :ivar workload_identity_provider_id: The GCP workload identity provider id for CIEM discovery + offering. + :vartype workload_identity_provider_id: str + :ivar service_account_email_address: The service account email address in GCP for CIEM + discovery offering. + :vartype service_account_email_address: str + :ivar azure_active_directory_app_name: the azure active directory app name used of + authenticating against GCP workload identity federation. + :vartype azure_active_directory_app_name: str + """ + + _attribute_map = { + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + "azure_active_directory_app_name": {"key": "azureActiveDirectoryAppName", "type": "str"}, + } + + def __init__( + self, + *, + workload_identity_provider_id: Optional[str] = None, + service_account_email_address: Optional[str] = None, + azure_active_directory_app_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword workload_identity_provider_id: The GCP workload identity provider id for CIEM + discovery offering. + :paramtype workload_identity_provider_id: str + :keyword service_account_email_address: The service account email address in GCP for CIEM + discovery offering. + :paramtype service_account_email_address: str + :keyword azure_active_directory_app_name: the azure active directory app name used of + authenticating against GCP workload identity federation. + :paramtype azure_active_directory_app_name: str + """ + super().__init__(**kwargs) + self.workload_identity_provider_id = workload_identity_provider_id + self.service_account_email_address = service_account_email_address + self.azure_active_directory_app_name = azure_active_directory_app_name + + +class DefenderCspmGcpOfferingDataSensitivityDiscovery(_serialization.Model): + """The Microsoft Defender Data Sensitivity discovery configuration. + + :ivar enabled: Is Microsoft Defender Data Sensitivity discovery enabled. + :vartype enabled: bool + :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. + :vartype workload_identity_provider_id: str + :ivar service_account_email_address: The service account email address in GCP for this feature. + :vartype service_account_email_address: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + workload_identity_provider_id: Optional[str] = None, + service_account_email_address: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is Microsoft Defender Data Sensitivity discovery enabled. + :paramtype enabled: bool + :keyword workload_identity_provider_id: The workload identity provider id in GCP for this + feature. + :paramtype workload_identity_provider_id: str + :keyword service_account_email_address: The service account email address in GCP for this + feature. + :paramtype service_account_email_address: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.workload_identity_provider_id = workload_identity_provider_id + self.service_account_email_address = service_account_email_address + + +class DefenderCspmGcpOfferingMdcContainersAgentlessDiscoveryK8S(_serialization.Model): + """The Microsoft Defender Container agentless discovery configuration. + + :ivar enabled: Is Microsoft Defender container agentless discovery enabled. + :vartype enabled: bool + :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. + :vartype workload_identity_provider_id: str + :ivar service_account_email_address: The service account email address in GCP for this feature. + :vartype service_account_email_address: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + workload_identity_provider_id: Optional[str] = None, + service_account_email_address: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is Microsoft Defender container agentless discovery enabled. + :paramtype enabled: bool + :keyword workload_identity_provider_id: The workload identity provider id in GCP for this + feature. + :paramtype workload_identity_provider_id: str + :keyword service_account_email_address: The service account email address in GCP for this + feature. + :paramtype service_account_email_address: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.workload_identity_provider_id = workload_identity_provider_id + self.service_account_email_address = service_account_email_address + + +class DefenderCspmGcpOfferingMdcContainersImageAssessment(_serialization.Model): + """The Microsoft Defender Container image assessment configuration. + + :ivar enabled: Is Microsoft Defender container image assessment enabled. + :vartype enabled: bool + :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. + :vartype workload_identity_provider_id: str + :ivar service_account_email_address: The service account email address in GCP for this feature. + :vartype service_account_email_address: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + workload_identity_provider_id: Optional[str] = None, + service_account_email_address: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is Microsoft Defender container image assessment enabled. + :paramtype enabled: bool + :keyword workload_identity_provider_id: The workload identity provider id in GCP for this + feature. + :paramtype workload_identity_provider_id: str + :keyword service_account_email_address: The service account email address in GCP for this + feature. + :paramtype service_account_email_address: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.workload_identity_provider_id = workload_identity_provider_id + self.service_account_email_address = service_account_email_address + + +class DefenderCspmGcpOfferingVmScanners(_serialization.Model): + """The Microsoft Defender for Server VM scanning configuration. + + :ivar enabled: Is Microsoft Defender for Server VM scanning enabled. + :vartype enabled: bool + :ivar configuration: configuration for Microsoft Defender for Server VM scanning. + :vartype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingVmScannersConfiguration + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": {"key": "configuration", "type": "DefenderCspmGcpOfferingVmScannersConfiguration"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + configuration: Optional["_models.DefenderCspmGcpOfferingVmScannersConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is Microsoft Defender for Server VM scanning enabled. + :paramtype enabled: bool + :keyword configuration: configuration for Microsoft Defender for Server VM scanning. + :paramtype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderCspmGcpOfferingVmScannersConfiguration + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderCspmGcpOfferingVmScannersConfiguration(_serialization.Model): + """configuration for Microsoft Defender for Server VM scanning. + + :ivar scanning_mode: The scanning mode for the VM scan. "Default" + :vartype scanning_mode: str or ~azure.mgmt.security.v2023_10_01_preview.models.ScanningMode + :ivar exclusion_tags: VM tags that indicates that VM should not be scanned. + :vartype exclusion_tags: dict[str, str] + """ + + _attribute_map = { + "scanning_mode": {"key": "scanningMode", "type": "str"}, + "exclusion_tags": {"key": "exclusionTags", "type": "{str}"}, + } + + def __init__( + self, + *, + scanning_mode: Optional[Union[str, "_models.ScanningMode"]] = None, + exclusion_tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword scanning_mode: The scanning mode for the VM scan. "Default" + :paramtype scanning_mode: str or ~azure.mgmt.security.v2023_10_01_preview.models.ScanningMode + :keyword exclusion_tags: VM tags that indicates that VM should not be scanned. + :paramtype exclusion_tags: dict[str, str] + """ + super().__init__(**kwargs) + self.scanning_mode = scanning_mode + self.exclusion_tags = exclusion_tags + + +class DefenderFoDatabasesAwsOffering(CloudOffering): + """The Defender for Databases AWS offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", + "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". + :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. + :vartype arc_auto_provisioning: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning + :ivar rds: The RDS configuration. + :vartype rds: ~azure.mgmt.security.v2023_10_01_preview.models.DefenderFoDatabasesAwsOfferingRds + :ivar databases_dspm: The databases data security posture management (DSPM) configuration. + :vartype databases_dspm: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderFoDatabasesAwsOfferingDatabasesDspm + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "arc_auto_provisioning": { + "key": "arcAutoProvisioning", + "type": "DefenderFoDatabasesAwsOfferingArcAutoProvisioning", + }, + "rds": {"key": "rds", "type": "DefenderFoDatabasesAwsOfferingRds"}, + "databases_dspm": {"key": "databasesDspm", "type": "DefenderFoDatabasesAwsOfferingDatabasesDspm"}, + } + + def __init__( + self, + *, + arc_auto_provisioning: Optional["_models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning"] = None, + rds: Optional["_models.DefenderFoDatabasesAwsOfferingRds"] = None, + databases_dspm: Optional["_models.DefenderFoDatabasesAwsOfferingDatabasesDspm"] = None, + **kwargs: Any + ) -> None: + """ + :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. + :paramtype arc_auto_provisioning: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning + :keyword rds: The RDS configuration. + :paramtype rds: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderFoDatabasesAwsOfferingRds + :keyword databases_dspm: The databases data security posture management (DSPM) configuration. + :paramtype databases_dspm: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderFoDatabasesAwsOfferingDatabasesDspm + """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderForDatabasesAws" + self.arc_auto_provisioning = arc_auto_provisioning + self.rds = rds + self.databases_dspm = databases_dspm + + +class DefenderFoDatabasesAwsOfferingArcAutoProvisioning(_serialization.Model): + """The ARC autoprovisioning configuration. + + :ivar enabled: Is arc auto provisioning enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + :ivar configuration: Configuration for servers Arc auto provisioning. + :vartype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + "configuration": { + "key": "configuration", + "type": "DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration", + }, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + cloud_role_arn: Optional[str] = None, + configuration: Optional["_models.DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is arc auto provisioning enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + :keyword configuration: Configuration for servers Arc auto provisioning. + :paramtype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + self.configuration = configuration + + +class DefenderFoDatabasesAwsOfferingArcAutoProvisioningConfiguration(_serialization.Model): + """Configuration for servers Arc auto provisioning. + + :ivar proxy: Optional http proxy endpoint to use for the Arc agent. + :vartype proxy: str + :ivar private_link_scope: Optional Arc private link scope resource id to link the Arc agent. + :vartype private_link_scope: str + """ + + _attribute_map = { + "proxy": {"key": "proxy", "type": "str"}, + "private_link_scope": {"key": "privateLinkScope", "type": "str"}, + } + + def __init__(self, *, proxy: Optional[str] = None, private_link_scope: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword proxy: Optional http proxy endpoint to use for the Arc agent. + :paramtype proxy: str + :keyword private_link_scope: Optional Arc private link scope resource id to link the Arc agent. + :paramtype private_link_scope: str + """ + super().__init__(**kwargs) + self.proxy = proxy + self.private_link_scope = private_link_scope + + +class DefenderFoDatabasesAwsOfferingDatabasesDspm(_serialization.Model): + """The databases data security posture management (DSPM) configuration. + + :ivar enabled: Is databases data security posture management (DSPM) protection enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is databases data security posture management (DSPM) protection enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + + +class DefenderFoDatabasesAwsOfferingRds(_serialization.Model): + """The RDS configuration. + + :ivar enabled: Is RDS protection enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is RDS protection enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOffering(CloudOffering): # pylint: disable=too-many-instance-attributes + """The Defender for Containers AWS offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", + "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". + :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar kubernetes_service: The kubernetes service connection configuration. + :vartype kubernetes_service: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingKubernetesService + :ivar kubernetes_scuba_reader: The kubernetes to scuba connection configuration. + :vartype kubernetes_scuba_reader: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingKubernetesScubaReader + :ivar cloud_watch_to_kinesis: The cloudwatch to kinesis connection configuration. + :vartype cloud_watch_to_kinesis: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingCloudWatchToKinesis + :ivar kinesis_to_s3: The kinesis to s3 connection configuration. + :vartype kinesis_to_s3: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingKinesisToS3 + :ivar container_vulnerability_assessment: The container vulnerability assessment configuration. + :vartype container_vulnerability_assessment: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessment + :ivar container_vulnerability_assessment_task: The container vulnerability assessment task + configuration. + :vartype container_vulnerability_assessment_task: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask + :ivar enable_container_vulnerability_assessment: Enable container vulnerability assessment + feature. + :vartype enable_container_vulnerability_assessment: bool + :ivar auto_provisioning: Is audit logs pipeline auto provisioning enabled. + :vartype auto_provisioning: bool + :ivar kube_audit_retention_time: The retention time in days of kube audit logs set on the + CloudWatch log group. + :vartype kube_audit_retention_time: int + :ivar scuba_external_id: The externalId used by the data reader to prevent the confused deputy + attack. + :vartype scuba_external_id: str + :ivar mdc_containers_image_assessment: The Microsoft Defender container image assessment + configuration. + :vartype mdc_containers_image_assessment: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingMdcContainersImageAssessment + :ivar mdc_containers_agentless_discovery_k8_s: The Microsoft Defender container agentless + discovery K8s configuration. + :vartype mdc_containers_agentless_discovery_k8_s: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "kubernetes_service": {"key": "kubernetesService", "type": "DefenderForContainersAwsOfferingKubernetesService"}, + "kubernetes_scuba_reader": { + "key": "kubernetesScubaReader", + "type": "DefenderForContainersAwsOfferingKubernetesScubaReader", + }, + "cloud_watch_to_kinesis": { + "key": "cloudWatchToKinesis", + "type": "DefenderForContainersAwsOfferingCloudWatchToKinesis", + }, + "kinesis_to_s3": {"key": "kinesisToS3", "type": "DefenderForContainersAwsOfferingKinesisToS3"}, + "container_vulnerability_assessment": { + "key": "containerVulnerabilityAssessment", + "type": "DefenderForContainersAwsOfferingContainerVulnerabilityAssessment", + }, + "container_vulnerability_assessment_task": { + "key": "containerVulnerabilityAssessmentTask", + "type": "DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask", + }, + "enable_container_vulnerability_assessment": {"key": "enableContainerVulnerabilityAssessment", "type": "bool"}, + "auto_provisioning": {"key": "autoProvisioning", "type": "bool"}, + "kube_audit_retention_time": {"key": "kubeAuditRetentionTime", "type": "int"}, + "scuba_external_id": {"key": "scubaExternalId", "type": "str"}, + "mdc_containers_image_assessment": { + "key": "mdcContainersImageAssessment", + "type": "DefenderForContainersAwsOfferingMdcContainersImageAssessment", + }, + "mdc_containers_agentless_discovery_k8_s": { + "key": "mdcContainersAgentlessDiscoveryK8s", + "type": "DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S", + }, + } + + def __init__( + self, + *, + kubernetes_service: Optional["_models.DefenderForContainersAwsOfferingKubernetesService"] = None, + kubernetes_scuba_reader: Optional["_models.DefenderForContainersAwsOfferingKubernetesScubaReader"] = None, + cloud_watch_to_kinesis: Optional["_models.DefenderForContainersAwsOfferingCloudWatchToKinesis"] = None, + kinesis_to_s3: Optional["_models.DefenderForContainersAwsOfferingKinesisToS3"] = None, + container_vulnerability_assessment: Optional[ + "_models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessment" + ] = None, + container_vulnerability_assessment_task: Optional[ + "_models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask" + ] = None, + enable_container_vulnerability_assessment: Optional[bool] = None, + auto_provisioning: Optional[bool] = None, + kube_audit_retention_time: Optional[int] = None, + scuba_external_id: Optional[str] = None, + mdc_containers_image_assessment: Optional[ + "_models.DefenderForContainersAwsOfferingMdcContainersImageAssessment" + ] = None, + mdc_containers_agentless_discovery_k8_s: Optional[ + "_models.DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S" + ] = None, + **kwargs: Any + ) -> None: + """ + :keyword kubernetes_service: The kubernetes service connection configuration. + :paramtype kubernetes_service: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingKubernetesService + :keyword kubernetes_scuba_reader: The kubernetes to scuba connection configuration. + :paramtype kubernetes_scuba_reader: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingKubernetesScubaReader + :keyword cloud_watch_to_kinesis: The cloudwatch to kinesis connection configuration. + :paramtype cloud_watch_to_kinesis: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingCloudWatchToKinesis + :keyword kinesis_to_s3: The kinesis to s3 connection configuration. + :paramtype kinesis_to_s3: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingKinesisToS3 + :keyword container_vulnerability_assessment: The container vulnerability assessment + configuration. + :paramtype container_vulnerability_assessment: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessment + :keyword container_vulnerability_assessment_task: The container vulnerability assessment task + configuration. + :paramtype container_vulnerability_assessment_task: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask + :keyword enable_container_vulnerability_assessment: Enable container vulnerability assessment + feature. + :paramtype enable_container_vulnerability_assessment: bool + :keyword auto_provisioning: Is audit logs pipeline auto provisioning enabled. + :paramtype auto_provisioning: bool + :keyword kube_audit_retention_time: The retention time in days of kube audit logs set on the + CloudWatch log group. + :paramtype kube_audit_retention_time: int + :keyword scuba_external_id: The externalId used by the data reader to prevent the confused + deputy attack. + :paramtype scuba_external_id: str + :keyword mdc_containers_image_assessment: The Microsoft Defender container image assessment + configuration. + :paramtype mdc_containers_image_assessment: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingMdcContainersImageAssessment + :keyword mdc_containers_agentless_discovery_k8_s: The Microsoft Defender container agentless + discovery K8s configuration. + :paramtype mdc_containers_agentless_discovery_k8_s: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S + """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderForContainersAws" + self.kubernetes_service = kubernetes_service + self.kubernetes_scuba_reader = kubernetes_scuba_reader + self.cloud_watch_to_kinesis = cloud_watch_to_kinesis + self.kinesis_to_s3 = kinesis_to_s3 + self.container_vulnerability_assessment = container_vulnerability_assessment + self.container_vulnerability_assessment_task = container_vulnerability_assessment_task + self.enable_container_vulnerability_assessment = enable_container_vulnerability_assessment + self.auto_provisioning = auto_provisioning + self.kube_audit_retention_time = kube_audit_retention_time + self.scuba_external_id = scuba_external_id + self.mdc_containers_image_assessment = mdc_containers_image_assessment + self.mdc_containers_agentless_discovery_k8_s = mdc_containers_agentless_discovery_k8_s + + +class DefenderForContainersAwsOfferingCloudWatchToKinesis(_serialization.Model): + """The cloudwatch to kinesis connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS used by CloudWatch to transfer data into + Kinesis. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS used by CloudWatch to transfer data into + Kinesis. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOfferingContainerVulnerabilityAssessment(_serialization.Model): + """The container vulnerability assessment configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask(_serialization.Model): + """The container vulnerability assessment task configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOfferingKinesisToS3(_serialization.Model): + """The kinesis to s3 connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS used by Kinesis to transfer data into S3. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS used by Kinesis to transfer data into S3. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOfferingKubernetesScubaReader(_serialization.Model): + """The kubernetes to scuba connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature used for reading data. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature used for reading data. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOfferingKubernetesService(_serialization.Model): + """The kubernetes service connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature used for provisioning + resources. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature used for provisioning + resources. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOfferingMdcContainersAgentlessDiscoveryK8S(_serialization.Model): + """The Microsoft Defender container agentless discovery K8s configuration. + + :ivar enabled: Is Microsoft Defender container agentless discovery K8s enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is Microsoft Defender container agentless discovery K8s enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOfferingMdcContainersImageAssessment(_serialization.Model): + """The Microsoft Defender container image assessment configuration. + + :ivar enabled: Is Microsoft Defender container image assessment enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is Microsoft Defender container image assessment enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersGcpOffering(CloudOffering): + """The containers GCP offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", + "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". + :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar native_cloud_connection: The native cloud connection configuration. + :vartype native_cloud_connection: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersGcpOfferingNativeCloudConnection + :ivar data_pipeline_native_cloud_connection: The native cloud connection configuration. + :vartype data_pipeline_native_cloud_connection: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection + :ivar audit_logs_auto_provisioning_flag: Is audit logs data collection enabled. + :vartype audit_logs_auto_provisioning_flag: bool + :ivar defender_agent_auto_provisioning_flag: Is Microsoft Defender for Cloud Kubernetes agent + auto provisioning enabled. + :vartype defender_agent_auto_provisioning_flag: bool + :ivar policy_agent_auto_provisioning_flag: Is Policy Kubernetes agent auto provisioning + enabled. + :vartype policy_agent_auto_provisioning_flag: bool + :ivar mdc_containers_image_assessment: The Microsoft Defender Container image assessment + configuration. + :vartype mdc_containers_image_assessment: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersGcpOfferingMdcContainersImageAssessment + :ivar mdc_containers_agentless_discovery_k8_s: The Microsoft Defender Container agentless + discovery configuration. + :vartype mdc_containers_agentless_discovery_k8_s: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "native_cloud_connection": { + "key": "nativeCloudConnection", + "type": "DefenderForContainersGcpOfferingNativeCloudConnection", + }, + "data_pipeline_native_cloud_connection": { + "key": "dataPipelineNativeCloudConnection", + "type": "DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection", + }, + "audit_logs_auto_provisioning_flag": {"key": "auditLogsAutoProvisioningFlag", "type": "bool"}, + "defender_agent_auto_provisioning_flag": {"key": "defenderAgentAutoProvisioningFlag", "type": "bool"}, + "policy_agent_auto_provisioning_flag": {"key": "policyAgentAutoProvisioningFlag", "type": "bool"}, + "mdc_containers_image_assessment": { + "key": "mdcContainersImageAssessment", + "type": "DefenderForContainersGcpOfferingMdcContainersImageAssessment", + }, + "mdc_containers_agentless_discovery_k8_s": { + "key": "mdcContainersAgentlessDiscoveryK8s", + "type": "DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S", + }, + } + + def __init__( + self, + *, + native_cloud_connection: Optional["_models.DefenderForContainersGcpOfferingNativeCloudConnection"] = None, + data_pipeline_native_cloud_connection: Optional[ + "_models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection" + ] = None, + audit_logs_auto_provisioning_flag: Optional[bool] = None, + defender_agent_auto_provisioning_flag: Optional[bool] = None, + policy_agent_auto_provisioning_flag: Optional[bool] = None, + mdc_containers_image_assessment: Optional[ + "_models.DefenderForContainersGcpOfferingMdcContainersImageAssessment" + ] = None, + mdc_containers_agentless_discovery_k8_s: Optional[ + "_models.DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S" + ] = None, + **kwargs: Any + ) -> None: + """ + :keyword native_cloud_connection: The native cloud connection configuration. + :paramtype native_cloud_connection: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersGcpOfferingNativeCloudConnection + :keyword data_pipeline_native_cloud_connection: The native cloud connection configuration. + :paramtype data_pipeline_native_cloud_connection: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection + :keyword audit_logs_auto_provisioning_flag: Is audit logs data collection enabled. + :paramtype audit_logs_auto_provisioning_flag: bool + :keyword defender_agent_auto_provisioning_flag: Is Microsoft Defender for Cloud Kubernetes + agent auto provisioning enabled. + :paramtype defender_agent_auto_provisioning_flag: bool + :keyword policy_agent_auto_provisioning_flag: Is Policy Kubernetes agent auto provisioning + enabled. + :paramtype policy_agent_auto_provisioning_flag: bool + :keyword mdc_containers_image_assessment: The Microsoft Defender Container image assessment + configuration. + :paramtype mdc_containers_image_assessment: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersGcpOfferingMdcContainersImageAssessment + :keyword mdc_containers_agentless_discovery_k8_s: The Microsoft Defender Container agentless + discovery configuration. + :paramtype mdc_containers_agentless_discovery_k8_s: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S + """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderForContainersGcp" + self.native_cloud_connection = native_cloud_connection + self.data_pipeline_native_cloud_connection = data_pipeline_native_cloud_connection + self.audit_logs_auto_provisioning_flag = audit_logs_auto_provisioning_flag + self.defender_agent_auto_provisioning_flag = defender_agent_auto_provisioning_flag + self.policy_agent_auto_provisioning_flag = policy_agent_auto_provisioning_flag + self.mdc_containers_image_assessment = mdc_containers_image_assessment + self.mdc_containers_agentless_discovery_k8_s = mdc_containers_agentless_discovery_k8_s + + +class DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection(_serialization.Model): + """The native cloud connection configuration. + + :ivar service_account_email_address: The data collection service account email address in GCP + for this offering. + :vartype service_account_email_address: str + :ivar workload_identity_provider_id: The data collection GCP workload identity provider id for + this offering. + :vartype workload_identity_provider_id: str + """ + + _attribute_map = { + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + } + + def __init__( + self, + *, + service_account_email_address: Optional[str] = None, + workload_identity_provider_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword service_account_email_address: The data collection service account email address in + GCP for this offering. + :paramtype service_account_email_address: str + :keyword workload_identity_provider_id: The data collection GCP workload identity provider id + for this offering. + :paramtype workload_identity_provider_id: str + """ + super().__init__(**kwargs) + self.service_account_email_address = service_account_email_address + self.workload_identity_provider_id = workload_identity_provider_id + + +class DefenderForContainersGcpOfferingMdcContainersAgentlessDiscoveryK8S(_serialization.Model): + """The Microsoft Defender Container agentless discovery configuration. + + :ivar enabled: Is Microsoft Defender container agentless discovery enabled. + :vartype enabled: bool + :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. + :vartype workload_identity_provider_id: str + :ivar service_account_email_address: The service account email address in GCP for this feature. + :vartype service_account_email_address: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + workload_identity_provider_id: Optional[str] = None, + service_account_email_address: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is Microsoft Defender container agentless discovery enabled. + :paramtype enabled: bool + :keyword workload_identity_provider_id: The workload identity provider id in GCP for this + feature. + :paramtype workload_identity_provider_id: str + :keyword service_account_email_address: The service account email address in GCP for this + feature. + :paramtype service_account_email_address: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.workload_identity_provider_id = workload_identity_provider_id + self.service_account_email_address = service_account_email_address + + +class DefenderForContainersGcpOfferingMdcContainersImageAssessment(_serialization.Model): + """The Microsoft Defender Container image assessment configuration. + + :ivar enabled: Is Microsoft Defender container image assessment enabled. + :vartype enabled: bool + :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. + :vartype workload_identity_provider_id: str + :ivar service_account_email_address: The service account email address in GCP for this feature. + :vartype service_account_email_address: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + workload_identity_provider_id: Optional[str] = None, + service_account_email_address: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is Microsoft Defender container image assessment enabled. + :paramtype enabled: bool + :keyword workload_identity_provider_id: The workload identity provider id in GCP for this + feature. + :paramtype workload_identity_provider_id: str + :keyword service_account_email_address: The service account email address in GCP for this + feature. + :paramtype service_account_email_address: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.workload_identity_provider_id = workload_identity_provider_id + self.service_account_email_address = service_account_email_address + + +class DefenderForContainersGcpOfferingNativeCloudConnection(_serialization.Model): + """The native cloud connection configuration. + + :ivar service_account_email_address: The service account email address in GCP for this + offering. + :vartype service_account_email_address: str + :ivar workload_identity_provider_id: The GCP workload identity provider id for this offering. + :vartype workload_identity_provider_id: str + """ + + _attribute_map = { + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + } + + def __init__( + self, + *, + service_account_email_address: Optional[str] = None, + workload_identity_provider_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword service_account_email_address: The service account email address in GCP for this + offering. + :paramtype service_account_email_address: str + :keyword workload_identity_provider_id: The GCP workload identity provider id for this + offering. + :paramtype workload_identity_provider_id: str + """ + super().__init__(**kwargs) + self.service_account_email_address = service_account_email_address + self.workload_identity_provider_id = workload_identity_provider_id + + +class DefenderForDatabasesGcpOffering(CloudOffering): + """The Defender for Databases GCP offering configurations. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", + "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". + :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. + :vartype arc_auto_provisioning: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioning + :ivar defender_for_databases_arc_auto_provisioning: The native cloud connection configuration. + :vartype defender_for_databases_arc_auto_provisioning: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "arc_auto_provisioning": { + "key": "arcAutoProvisioning", + "type": "DefenderForDatabasesGcpOfferingArcAutoProvisioning", + }, + "defender_for_databases_arc_auto_provisioning": { + "key": "defenderForDatabasesArcAutoProvisioning", + "type": "DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning", + }, + } + + def __init__( + self, + *, + arc_auto_provisioning: Optional["_models.DefenderForDatabasesGcpOfferingArcAutoProvisioning"] = None, + defender_for_databases_arc_auto_provisioning: Optional[ + "_models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning" + ] = None, + **kwargs: Any + ) -> None: + """ + :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. + :paramtype arc_auto_provisioning: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioning + :keyword defender_for_databases_arc_auto_provisioning: The native cloud connection + configuration. + :paramtype defender_for_databases_arc_auto_provisioning: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning + """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderForDatabasesGcp" + self.arc_auto_provisioning = arc_auto_provisioning + self.defender_for_databases_arc_auto_provisioning = defender_for_databases_arc_auto_provisioning + + +class DefenderForDatabasesGcpOfferingArcAutoProvisioning(_serialization.Model): + """The ARC autoprovisioning configuration. + + :ivar enabled: Is arc auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: Configuration for servers Arc auto provisioning. + :vartype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": { + "key": "configuration", + "type": "DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration", + }, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + configuration: Optional["_models.DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is arc auto provisioning enabled. + :paramtype enabled: bool + :keyword configuration: Configuration for servers Arc auto provisioning. + :paramtype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderForDatabasesGcpOfferingArcAutoProvisioningConfiguration(_serialization.Model): + """Configuration for servers Arc auto provisioning. + + :ivar proxy: Optional http proxy endpoint to use for the Arc agent. + :vartype proxy: str + :ivar private_link_scope: Optional Arc private link scope resource id to link the Arc agent. + :vartype private_link_scope: str + """ + + _attribute_map = { + "proxy": {"key": "proxy", "type": "str"}, + "private_link_scope": {"key": "privateLinkScope", "type": "str"}, + } + + def __init__(self, *, proxy: Optional[str] = None, private_link_scope: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword proxy: Optional http proxy endpoint to use for the Arc agent. + :paramtype proxy: str + :keyword private_link_scope: Optional Arc private link scope resource id to link the Arc agent. + :paramtype private_link_scope: str + """ + super().__init__(**kwargs) + self.proxy = proxy + self.private_link_scope = private_link_scope + + +class DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning(_serialization.Model): + """The native cloud connection configuration. + + :ivar service_account_email_address: The service account email address in GCP for this + offering. + :vartype service_account_email_address: str + :ivar workload_identity_provider_id: The GCP workload identity provider id for this offering. + :vartype workload_identity_provider_id: str + """ + + _attribute_map = { + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + } + + def __init__( + self, + *, + service_account_email_address: Optional[str] = None, + workload_identity_provider_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword service_account_email_address: The service account email address in GCP for this + offering. + :paramtype service_account_email_address: str + :keyword workload_identity_provider_id: The GCP workload identity provider id for this + offering. + :paramtype workload_identity_provider_id: str + """ + super().__init__(**kwargs) + self.service_account_email_address = service_account_email_address + self.workload_identity_provider_id = workload_identity_provider_id + + +class DefenderForDevOpsAzureDevOpsOffering(CloudOffering): + """The Defender for DevOps for Azure DevOps offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", + "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". + :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderForDevOpsAzureDevOps" + + +class DefenderForDevOpsGithubOffering(CloudOffering): + """The Defender for DevOps for Github offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", + "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". + :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderForDevOpsGithub" + + +class DefenderForDevOpsGitLabOffering(CloudOffering): + """The Defender for DevOps for Gitlab offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", + "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". + :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderForDevOpsGitLab" + + +class DefenderForServersAwsOffering(CloudOffering): + """The Defender for Servers AWS offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", + "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". + :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar defender_for_servers: The Defender for servers connection configuration. + :vartype defender_for_servers: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingDefenderForServers + :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. + :vartype arc_auto_provisioning: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioning + :ivar va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. + :vartype va_auto_provisioning: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioning + :ivar mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning + configuration. + :vartype mde_auto_provisioning: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingMdeAutoProvisioning + :ivar sub_plan: configuration for the servers offering subPlan. + :vartype sub_plan: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingSubPlan + :ivar vm_scanners: The Microsoft Defender for Server VM scanning configuration. + :vartype vm_scanners: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingVmScanners + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "defender_for_servers": { + "key": "defenderForServers", + "type": "DefenderForServersAwsOfferingDefenderForServers", + }, + "arc_auto_provisioning": { + "key": "arcAutoProvisioning", + "type": "DefenderForServersAwsOfferingArcAutoProvisioning", + }, + "va_auto_provisioning": { + "key": "vaAutoProvisioning", + "type": "DefenderForServersAwsOfferingVaAutoProvisioning", + }, + "mde_auto_provisioning": { + "key": "mdeAutoProvisioning", + "type": "DefenderForServersAwsOfferingMdeAutoProvisioning", + }, + "sub_plan": {"key": "subPlan", "type": "DefenderForServersAwsOfferingSubPlan"}, + "vm_scanners": {"key": "vmScanners", "type": "DefenderForServersAwsOfferingVmScanners"}, + } + + def __init__( + self, + *, + defender_for_servers: Optional["_models.DefenderForServersAwsOfferingDefenderForServers"] = None, + arc_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingArcAutoProvisioning"] = None, + va_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingVaAutoProvisioning"] = None, + mde_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingMdeAutoProvisioning"] = None, + sub_plan: Optional["_models.DefenderForServersAwsOfferingSubPlan"] = None, + vm_scanners: Optional["_models.DefenderForServersAwsOfferingVmScanners"] = None, + **kwargs: Any + ) -> None: + """ + :keyword defender_for_servers: The Defender for servers connection configuration. + :paramtype defender_for_servers: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingDefenderForServers + :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. + :paramtype arc_auto_provisioning: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioning + :keyword va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. + :paramtype va_auto_provisioning: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioning + :keyword mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning + configuration. + :paramtype mde_auto_provisioning: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingMdeAutoProvisioning + :keyword sub_plan: configuration for the servers offering subPlan. + :paramtype sub_plan: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingSubPlan + :keyword vm_scanners: The Microsoft Defender for Server VM scanning configuration. + :paramtype vm_scanners: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingVmScanners + """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderForServersAws" + self.defender_for_servers = defender_for_servers + self.arc_auto_provisioning = arc_auto_provisioning + self.va_auto_provisioning = va_auto_provisioning + self.mde_auto_provisioning = mde_auto_provisioning + self.sub_plan = sub_plan + self.vm_scanners = vm_scanners + + +class DefenderForServersAwsOfferingArcAutoProvisioning(_serialization.Model): + """The ARC autoprovisioning configuration. + + :ivar enabled: Is arc auto provisioning enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + :ivar configuration: Configuration for servers Arc auto provisioning. + :vartype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioningConfiguration + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + "configuration": { + "key": "configuration", + "type": "DefenderForServersAwsOfferingArcAutoProvisioningConfiguration", + }, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + cloud_role_arn: Optional[str] = None, + configuration: Optional["_models.DefenderForServersAwsOfferingArcAutoProvisioningConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is arc auto provisioning enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + :keyword configuration: Configuration for servers Arc auto provisioning. + :paramtype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioningConfiguration + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + self.configuration = configuration + + +class DefenderForServersAwsOfferingArcAutoProvisioningConfiguration(_serialization.Model): + """Configuration for servers Arc auto provisioning. + + :ivar proxy: Optional HTTP proxy endpoint to use for the Arc agent. + :vartype proxy: str + :ivar private_link_scope: Optional Arc private link scope resource id to link the Arc agent. + :vartype private_link_scope: str + """ + + _attribute_map = { + "proxy": {"key": "proxy", "type": "str"}, + "private_link_scope": {"key": "privateLinkScope", "type": "str"}, + } + + def __init__(self, *, proxy: Optional[str] = None, private_link_scope: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword proxy: Optional HTTP proxy endpoint to use for the Arc agent. + :paramtype proxy: str + :keyword private_link_scope: Optional Arc private link scope resource id to link the Arc agent. + :paramtype private_link_scope: str + """ + super().__init__(**kwargs) + self.proxy = proxy + self.private_link_scope = private_link_scope + + +class DefenderForServersAwsOfferingDefenderForServers(_serialization.Model): + """The Defender for servers connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderForServersAwsOfferingMdeAutoProvisioning(_serialization.Model): + """The Microsoft Defender for Endpoint autoprovisioning configuration. + + :ivar enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. + :vartype configuration: JSON + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": {"key": "configuration", "type": "object"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, configuration: Optional[JSON] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. + :paramtype enabled: bool + :keyword configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. + :paramtype configuration: JSON + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderForServersAwsOfferingSubPlan(_serialization.Model): + """configuration for the servers offering subPlan. + + :ivar type: The available sub plans. Known values are: "P1" and "P2". + :vartype type: str or ~azure.mgmt.security.v2023_10_01_preview.models.SubPlan + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Union[str, "_models.SubPlan"]] = None, **kwargs: Any) -> None: + """ + :keyword type: The available sub plans. Known values are: "P1" and "P2". + :paramtype type: str or ~azure.mgmt.security.v2023_10_01_preview.models.SubPlan + """ + super().__init__(**kwargs) + self.type = type + + +class DefenderForServersAwsOfferingVaAutoProvisioning(_serialization.Model): + """The Vulnerability Assessment autoprovisioning configuration. + + :ivar enabled: Is Vulnerability Assessment auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: configuration for Vulnerability Assessment autoprovisioning. + :vartype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": { + "key": "configuration", + "type": "DefenderForServersAwsOfferingVaAutoProvisioningConfiguration", + }, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + configuration: Optional["_models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is Vulnerability Assessment auto provisioning enabled. + :paramtype enabled: bool + :keyword configuration: configuration for Vulnerability Assessment autoprovisioning. + :paramtype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderForServersAwsOfferingVaAutoProvisioningConfiguration(_serialization.Model): + """configuration for Vulnerability Assessment autoprovisioning. + + :ivar type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or + 'Qualys'. Known values are: "Qualys" and "TVM". + :vartype type: str or ~azure.mgmt.security.v2023_10_01_preview.models.Type + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Union[str, "_models.Type"]] = None, **kwargs: Any) -> None: + """ + :keyword type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or + 'Qualys'. Known values are: "Qualys" and "TVM". + :paramtype type: str or ~azure.mgmt.security.v2023_10_01_preview.models.Type + """ + super().__init__(**kwargs) + self.type = type + + +class DefenderForServersAwsOfferingVmScanners(_serialization.Model): + """The Microsoft Defender for Server VM scanning configuration. + + :ivar enabled: Is Microsoft Defender for Server VM scanning enabled. + :vartype enabled: bool + :ivar configuration: configuration for Microsoft Defender for Server VM scanning. + :vartype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingVmScannersConfiguration + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": {"key": "configuration", "type": "DefenderForServersAwsOfferingVmScannersConfiguration"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + configuration: Optional["_models.DefenderForServersAwsOfferingVmScannersConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is Microsoft Defender for Server VM scanning enabled. + :paramtype enabled: bool + :keyword configuration: configuration for Microsoft Defender for Server VM scanning. + :paramtype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersAwsOfferingVmScannersConfiguration + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderForServersAwsOfferingVmScannersConfiguration(_serialization.Model): + """configuration for Microsoft Defender for Server VM scanning. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + :ivar scanning_mode: The scanning mode for the VM scan. "Default" + :vartype scanning_mode: str or ~azure.mgmt.security.v2023_10_01_preview.models.ScanningMode + :ivar exclusion_tags: VM tags that indicates that VM should not be scanned. + :vartype exclusion_tags: dict[str, str] + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + "scanning_mode": {"key": "scanningMode", "type": "str"}, + "exclusion_tags": {"key": "exclusionTags", "type": "{str}"}, + } + + def __init__( + self, + *, + cloud_role_arn: Optional[str] = None, + scanning_mode: Optional[Union[str, "_models.ScanningMode"]] = None, + exclusion_tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + :keyword scanning_mode: The scanning mode for the VM scan. "Default" + :paramtype scanning_mode: str or ~azure.mgmt.security.v2023_10_01_preview.models.ScanningMode + :keyword exclusion_tags: VM tags that indicates that VM should not be scanned. + :paramtype exclusion_tags: dict[str, str] + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + self.scanning_mode = scanning_mode + self.exclusion_tags = exclusion_tags + + +class DefenderForServersGcpOffering(CloudOffering): + """The Defender for Servers GCP offering configurations. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", + "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". + :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar defender_for_servers: The Defender for servers connection configuration. + :vartype defender_for_servers: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingDefenderForServers + :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. + :vartype arc_auto_provisioning: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioning + :ivar va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. + :vartype va_auto_provisioning: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioning + :ivar mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning + configuration. + :vartype mde_auto_provisioning: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingMdeAutoProvisioning + :ivar sub_plan: configuration for the servers offering subPlan. + :vartype sub_plan: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingSubPlan + :ivar vm_scanners: The Microsoft Defender for Server VM scanning configuration. + :vartype vm_scanners: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingVmScanners + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "defender_for_servers": { + "key": "defenderForServers", + "type": "DefenderForServersGcpOfferingDefenderForServers", + }, + "arc_auto_provisioning": { + "key": "arcAutoProvisioning", + "type": "DefenderForServersGcpOfferingArcAutoProvisioning", + }, + "va_auto_provisioning": { + "key": "vaAutoProvisioning", + "type": "DefenderForServersGcpOfferingVaAutoProvisioning", + }, + "mde_auto_provisioning": { + "key": "mdeAutoProvisioning", + "type": "DefenderForServersGcpOfferingMdeAutoProvisioning", + }, + "sub_plan": {"key": "subPlan", "type": "DefenderForServersGcpOfferingSubPlan"}, + "vm_scanners": {"key": "vmScanners", "type": "DefenderForServersGcpOfferingVmScanners"}, + } + + def __init__( + self, + *, + defender_for_servers: Optional["_models.DefenderForServersGcpOfferingDefenderForServers"] = None, + arc_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingArcAutoProvisioning"] = None, + va_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingVaAutoProvisioning"] = None, + mde_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingMdeAutoProvisioning"] = None, + sub_plan: Optional["_models.DefenderForServersGcpOfferingSubPlan"] = None, + vm_scanners: Optional["_models.DefenderForServersGcpOfferingVmScanners"] = None, + **kwargs: Any + ) -> None: + """ + :keyword defender_for_servers: The Defender for servers connection configuration. + :paramtype defender_for_servers: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingDefenderForServers + :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. + :paramtype arc_auto_provisioning: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioning + :keyword va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. + :paramtype va_auto_provisioning: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioning + :keyword mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning + configuration. + :paramtype mde_auto_provisioning: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingMdeAutoProvisioning + :keyword sub_plan: configuration for the servers offering subPlan. + :paramtype sub_plan: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingSubPlan + :keyword vm_scanners: The Microsoft Defender for Server VM scanning configuration. + :paramtype vm_scanners: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingVmScanners + """ + super().__init__(**kwargs) + self.offering_type: str = "DefenderForServersGcp" + self.defender_for_servers = defender_for_servers + self.arc_auto_provisioning = arc_auto_provisioning + self.va_auto_provisioning = va_auto_provisioning + self.mde_auto_provisioning = mde_auto_provisioning + self.sub_plan = sub_plan + self.vm_scanners = vm_scanners + + +class DefenderForServersGcpOfferingArcAutoProvisioning(_serialization.Model): + """The ARC autoprovisioning configuration. + + :ivar enabled: Is arc auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: Configuration for servers Arc auto provisioning. + :vartype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioningConfiguration + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": { + "key": "configuration", + "type": "DefenderForServersGcpOfferingArcAutoProvisioningConfiguration", + }, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + configuration: Optional["_models.DefenderForServersGcpOfferingArcAutoProvisioningConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is arc auto provisioning enabled. + :paramtype enabled: bool + :keyword configuration: Configuration for servers Arc auto provisioning. + :paramtype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioningConfiguration + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderForServersGcpOfferingArcAutoProvisioningConfiguration(_serialization.Model): + """Configuration for servers Arc auto provisioning. + + :ivar proxy: Optional HTTP proxy endpoint to use for the Arc agent. + :vartype proxy: str + :ivar private_link_scope: Optional Arc private link scope resource id to link the Arc agent. + :vartype private_link_scope: str + """ + + _attribute_map = { + "proxy": {"key": "proxy", "type": "str"}, + "private_link_scope": {"key": "privateLinkScope", "type": "str"}, + } + + def __init__(self, *, proxy: Optional[str] = None, private_link_scope: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword proxy: Optional HTTP proxy endpoint to use for the Arc agent. + :paramtype proxy: str + :keyword private_link_scope: Optional Arc private link scope resource id to link the Arc agent. + :paramtype private_link_scope: str + """ + super().__init__(**kwargs) + self.proxy = proxy + self.private_link_scope = private_link_scope + + +class DefenderForServersGcpOfferingDefenderForServers(_serialization.Model): + """The Defender for servers connection configuration. + + :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. + :vartype workload_identity_provider_id: str + :ivar service_account_email_address: The service account email address in GCP for this feature. + :vartype service_account_email_address: str + """ + + _attribute_map = { + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + } + + def __init__( + self, + *, + workload_identity_provider_id: Optional[str] = None, + service_account_email_address: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword workload_identity_provider_id: The workload identity provider id in GCP for this + feature. + :paramtype workload_identity_provider_id: str + :keyword service_account_email_address: The service account email address in GCP for this + feature. + :paramtype service_account_email_address: str + """ + super().__init__(**kwargs) + self.workload_identity_provider_id = workload_identity_provider_id + self.service_account_email_address = service_account_email_address + + +class DefenderForServersGcpOfferingMdeAutoProvisioning(_serialization.Model): + """The Microsoft Defender for Endpoint autoprovisioning configuration. + + :ivar enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. + :vartype configuration: JSON + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": {"key": "configuration", "type": "object"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, configuration: Optional[JSON] = None, **kwargs: Any) -> None: + """ + :keyword enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. + :paramtype enabled: bool + :keyword configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. + :paramtype configuration: JSON + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderForServersGcpOfferingSubPlan(_serialization.Model): + """configuration for the servers offering subPlan. + + :ivar type: The available sub plans. Known values are: "P1" and "P2". + :vartype type: str or ~azure.mgmt.security.v2023_10_01_preview.models.SubPlan + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Union[str, "_models.SubPlan"]] = None, **kwargs: Any) -> None: + """ + :keyword type: The available sub plans. Known values are: "P1" and "P2". + :paramtype type: str or ~azure.mgmt.security.v2023_10_01_preview.models.SubPlan + """ + super().__init__(**kwargs) + self.type = type + + +class DefenderForServersGcpOfferingVaAutoProvisioning(_serialization.Model): + """The Vulnerability Assessment autoprovisioning configuration. + + :ivar enabled: Is Vulnerability Assessment auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: configuration for Vulnerability Assessment autoprovisioning. + :vartype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": { + "key": "configuration", + "type": "DefenderForServersGcpOfferingVaAutoProvisioningConfiguration", + }, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + configuration: Optional["_models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is Vulnerability Assessment auto provisioning enabled. + :paramtype enabled: bool + :keyword configuration: configuration for Vulnerability Assessment autoprovisioning. + :paramtype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderForServersGcpOfferingVaAutoProvisioningConfiguration(_serialization.Model): + """configuration for Vulnerability Assessment autoprovisioning. + + :ivar type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or + 'Qualys'. Known values are: "Qualys" and "TVM". + :vartype type: str or ~azure.mgmt.security.v2023_10_01_preview.models.Type + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Union[str, "_models.Type"]] = None, **kwargs: Any) -> None: + """ + :keyword type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or + 'Qualys'. Known values are: "Qualys" and "TVM". + :paramtype type: str or ~azure.mgmt.security.v2023_10_01_preview.models.Type + """ + super().__init__(**kwargs) + self.type = type + + +class DefenderForServersGcpOfferingVmScanners(_serialization.Model): + """The Microsoft Defender for Server VM scanning configuration. + + :ivar enabled: Is Microsoft Defender for Server VM scanning enabled. + :vartype enabled: bool + :ivar configuration: configuration for Microsoft Defender for Server VM scanning. + :vartype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingVmScannersConfiguration + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": {"key": "configuration", "type": "DefenderForServersGcpOfferingVmScannersConfiguration"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + configuration: Optional["_models.DefenderForServersGcpOfferingVmScannersConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword enabled: Is Microsoft Defender for Server VM scanning enabled. + :paramtype enabled: bool + :keyword configuration: configuration for Microsoft Defender for Server VM scanning. + :paramtype configuration: + ~azure.mgmt.security.v2023_10_01_preview.models.DefenderForServersGcpOfferingVmScannersConfiguration + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderForServersGcpOfferingVmScannersConfiguration(_serialization.Model): + """configuration for Microsoft Defender for Server VM scanning. + + :ivar scanning_mode: The scanning mode for the VM scan. "Default" + :vartype scanning_mode: str or ~azure.mgmt.security.v2023_10_01_preview.models.ScanningMode + :ivar exclusion_tags: VM tags that indicate that VM should not be scanned. + :vartype exclusion_tags: dict[str, str] + """ + + _attribute_map = { + "scanning_mode": {"key": "scanningMode", "type": "str"}, + "exclusion_tags": {"key": "exclusionTags", "type": "{str}"}, + } + + def __init__( + self, + *, + scanning_mode: Optional[Union[str, "_models.ScanningMode"]] = None, + exclusion_tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword scanning_mode: The scanning mode for the VM scan. "Default" + :paramtype scanning_mode: str or ~azure.mgmt.security.v2023_10_01_preview.models.ScanningMode + :keyword exclusion_tags: VM tags that indicate that VM should not be scanned. + :paramtype exclusion_tags: dict[str, str] + """ + super().__init__(**kwargs) + self.scanning_mode = scanning_mode + self.exclusion_tags = exclusion_tags + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ETag(_serialization.Model): + """Entity tag is used for comparing two or more entities from the same requested resource. + + :ivar etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :vartype etag: str + """ + + _attribute_map = { + "etag": {"key": "etag", "type": "str"}, + } + + def __init__(self, *, etag: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :paramtype etag: str + """ + super().__init__(**kwargs) + self.etag = etag + + +class GcpOrganizationalData(_serialization.Model): + """The gcpOrganization data. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + GcpOrganizationalDataMember, GcpOrganizationalDataOrganization + + All required parameters must be populated in order to send to Azure. + + :ivar organization_membership_type: The multi cloud account's membership type in the + organization. Required. Known values are: "Member" and "Organization". + :vartype organization_membership_type: str or + ~azure.mgmt.security.v2023_10_01_preview.models.OrganizationMembershipType + """ + + _validation = { + "organization_membership_type": {"required": True}, + } + + _attribute_map = { + "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, + } + + _subtype_map = { + "organization_membership_type": { + "Member": "GcpOrganizationalDataMember", + "Organization": "GcpOrganizationalDataOrganization", + } + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.organization_membership_type: Optional[str] = None + + +class GcpOrganizationalDataMember(GcpOrganizationalData): + """The gcpOrganization data for the member account. + + All required parameters must be populated in order to send to Azure. + + :ivar organization_membership_type: The multi cloud account's membership type in the + organization. Required. Known values are: "Member" and "Organization". + :vartype organization_membership_type: str or + ~azure.mgmt.security.v2023_10_01_preview.models.OrganizationMembershipType + :ivar parent_hierarchy_id: If the multi cloud account is not of membership type organization, + this will be the ID of the project's parent. + :vartype parent_hierarchy_id: str + :ivar management_project_number: The GCP management project number from organizational + onboarding. + :vartype management_project_number: str + """ + + _validation = { + "organization_membership_type": {"required": True}, + } + + _attribute_map = { + "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, + "parent_hierarchy_id": {"key": "parentHierarchyId", "type": "str"}, + "management_project_number": {"key": "managementProjectNumber", "type": "str"}, + } + + def __init__( + self, + *, + parent_hierarchy_id: Optional[str] = None, + management_project_number: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword parent_hierarchy_id: If the multi cloud account is not of membership type + organization, this will be the ID of the project's parent. + :paramtype parent_hierarchy_id: str + :keyword management_project_number: The GCP management project number from organizational + onboarding. + :paramtype management_project_number: str + """ + super().__init__(**kwargs) + self.organization_membership_type: str = "Member" + self.parent_hierarchy_id = parent_hierarchy_id + self.management_project_number = management_project_number + + +class GcpOrganizationalDataOrganization(GcpOrganizationalData): + """The gcpOrganization data for the parent account. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar organization_membership_type: The multi cloud account's membership type in the + organization. Required. Known values are: "Member" and "Organization". + :vartype organization_membership_type: str or + ~azure.mgmt.security.v2023_10_01_preview.models.OrganizationMembershipType + :ivar excluded_project_numbers: If the multi cloud account is of membership type organization, + list of accounts excluded from offering. + :vartype excluded_project_numbers: list[str] + :ivar service_account_email_address: The service account email address which represents the + organization level permissions container. + :vartype service_account_email_address: str + :ivar workload_identity_provider_id: The GCP workload identity provider id which represents the + permissions required to auto provision security connectors. + :vartype workload_identity_provider_id: str + :ivar organization_name: GCP organization name. + :vartype organization_name: str + """ + + _validation = { + "organization_membership_type": {"required": True}, + "organization_name": {"readonly": True}, + } + + _attribute_map = { + "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, + "excluded_project_numbers": {"key": "excludedProjectNumbers", "type": "[str]"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "organization_name": {"key": "organizationName", "type": "str"}, + } + + def __init__( + self, + *, + excluded_project_numbers: Optional[List[str]] = None, + service_account_email_address: Optional[str] = None, + workload_identity_provider_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword excluded_project_numbers: If the multi cloud account is of membership type + organization, list of accounts excluded from offering. + :paramtype excluded_project_numbers: list[str] + :keyword service_account_email_address: The service account email address which represents the + organization level permissions container. + :paramtype service_account_email_address: str + :keyword workload_identity_provider_id: The GCP workload identity provider id which represents + the permissions required to auto provision security connectors. + :paramtype workload_identity_provider_id: str + """ + super().__init__(**kwargs) + self.organization_membership_type: str = "Organization" + self.excluded_project_numbers = excluded_project_numbers + self.service_account_email_address = service_account_email_address + self.workload_identity_provider_id = workload_identity_provider_id + self.organization_name = None + + +class GcpProjectDetails(_serialization.Model): + """The details about the project represented by the security connector. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar project_number: The unique GCP Project number. + :vartype project_number: str + :ivar project_id: The GCP Project id. + :vartype project_id: str + :ivar workload_identity_pool_id: The GCP workload identity federation pool id. + :vartype workload_identity_pool_id: str + :ivar project_name: GCP project name. + :vartype project_name: str + """ + + _validation = { + "workload_identity_pool_id": {"readonly": True}, + "project_name": {"readonly": True}, + } + + _attribute_map = { + "project_number": {"key": "projectNumber", "type": "str"}, + "project_id": {"key": "projectId", "type": "str"}, + "workload_identity_pool_id": {"key": "workloadIdentityPoolId", "type": "str"}, + "project_name": {"key": "projectName", "type": "str"}, + } + + def __init__( + self, *, project_number: Optional[str] = None, project_id: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword project_number: The unique GCP Project number. + :paramtype project_number: str + :keyword project_id: The GCP Project id. + :paramtype project_id: str + """ + super().__init__(**kwargs) + self.project_number = project_number + self.project_id = project_id + self.workload_identity_pool_id = None + self.project_name = None + + +class GcpProjectEnvironmentData(EnvironmentData): + """The GCP project connector environment data. + + All required parameters must be populated in order to send to Azure. + + :ivar environment_type: The type of the environment data. Required. Known values are: + "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", and "GitlabScope". + :vartype environment_type: str or + ~azure.mgmt.security.v2023_10_01_preview.models.EnvironmentType + :ivar organizational_data: The Gcp project's organizational data. + :vartype organizational_data: + ~azure.mgmt.security.v2023_10_01_preview.models.GcpOrganizationalData + :ivar project_details: The Gcp project's details. + :vartype project_details: ~azure.mgmt.security.v2023_10_01_preview.models.GcpProjectDetails + :ivar scan_interval: Scan interval in hours (value should be between 1-hour to 24-hours). + :vartype scan_interval: int + """ + + _validation = { + "environment_type": {"required": True}, + } + + _attribute_map = { + "environment_type": {"key": "environmentType", "type": "str"}, + "organizational_data": {"key": "organizationalData", "type": "GcpOrganizationalData"}, + "project_details": {"key": "projectDetails", "type": "GcpProjectDetails"}, + "scan_interval": {"key": "scanInterval", "type": "int"}, + } + + def __init__( + self, + *, + organizational_data: Optional["_models.GcpOrganizationalData"] = None, + project_details: Optional["_models.GcpProjectDetails"] = None, + scan_interval: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword organizational_data: The Gcp project's organizational data. + :paramtype organizational_data: + ~azure.mgmt.security.v2023_10_01_preview.models.GcpOrganizationalData + :keyword project_details: The Gcp project's details. + :paramtype project_details: ~azure.mgmt.security.v2023_10_01_preview.models.GcpProjectDetails + :keyword scan_interval: Scan interval in hours (value should be between 1-hour to 24-hours). + :paramtype scan_interval: int + """ + super().__init__(**kwargs) + self.environment_type: str = "GcpProject" + self.organizational_data = organizational_data + self.project_details = project_details + self.scan_interval = scan_interval + + +class GithubScopeEnvironmentData(EnvironmentData): + """The github scope connector's environment data. + + All required parameters must be populated in order to send to Azure. + + :ivar environment_type: The type of the environment data. Required. Known values are: + "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", and "GitlabScope". + :vartype environment_type: str or + ~azure.mgmt.security.v2023_10_01_preview.models.EnvironmentType + """ + + _validation = { + "environment_type": {"required": True}, + } + + _attribute_map = { + "environment_type": {"key": "environmentType", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.environment_type: str = "GithubScope" + + +class GitlabScopeEnvironmentData(EnvironmentData): + """The GitLab scope connector's environment data. + + All required parameters must be populated in order to send to Azure. + + :ivar environment_type: The type of the environment data. Required. Known values are: + "AwsAccount", "GcpProject", "GithubScope", "AzureDevOpsScope", and "GitlabScope". + :vartype environment_type: str or + ~azure.mgmt.security.v2023_10_01_preview.models.EnvironmentType + """ + + _validation = { + "environment_type": {"required": True}, + } + + _attribute_map = { + "environment_type": {"key": "environmentType", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.environment_type: str = "GitlabScope" + + +class InformationProtectionAwsOffering(CloudOffering): + """The information protection for AWS offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", + "DefenderForDevOpsAzureDevOps", "CspmMonitorGitLab", and "DefenderForDevOpsGitLab". + :vartype offering_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar information_protection: The native cloud connection configuration. + :vartype information_protection: + ~azure.mgmt.security.v2023_10_01_preview.models.InformationProtectionAwsOfferingInformationProtection + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "information_protection": { + "key": "informationProtection", + "type": "InformationProtectionAwsOfferingInformationProtection", + }, + } + + def __init__( + self, + *, + information_protection: Optional["_models.InformationProtectionAwsOfferingInformationProtection"] = None, + **kwargs: Any + ) -> None: + """ + :keyword information_protection: The native cloud connection configuration. + :paramtype information_protection: + ~azure.mgmt.security.v2023_10_01_preview.models.InformationProtectionAwsOfferingInformationProtection + """ + super().__init__(**kwargs) + self.offering_type: str = "InformationProtectionAws" + self.information_protection = information_protection + + +class InformationProtectionAwsOfferingInformationProtection(_serialization.Model): + """The native cloud connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class Kind(_serialization.Model): + """Describes an Azure resource with kind. + + :ivar kind: Kind of the resource. + :vartype kind: str + """ + + _attribute_map = { + "kind": {"key": "kind", "type": "str"}, + } + + def __init__(self, *, kind: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword kind: Kind of the resource. + :paramtype kind: str + """ + super().__init__(**kwargs) + self.kind = kind + + +class Resource(_serialization.Model): + """Describes an Azure resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class Tags(_serialization.Model): + """A list of key value pairs that describe the resource. + + :ivar tags: A list of key value pairs that describe the resource. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: A list of key value pairs that describe the resource. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class TrackedResource(Resource, AzureTrackedResourceLocation, Kind, ETag, Tags): + """Describes an Azure tracked resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tags: A list of key value pairs that describe the resource. + :vartype tags: dict[str, str] + :ivar etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :vartype etag: str + :ivar kind: Kind of the resource. + :vartype kind: str + :ivar location: Location where the resource is stored. + :vartype location: str + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + etag: Optional[str] = None, + kind: Optional[str] = None, + location: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: A list of key value pairs that describe the resource. + :paramtype tags: dict[str, str] + :keyword etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :paramtype etag: str + :keyword kind: Kind of the resource. + :paramtype kind: str + :keyword location: Location where the resource is stored. + :paramtype location: str + """ + super().__init__(location=location, kind=kind, etag=etag, tags=tags, **kwargs) + self.tags = tags + self.etag = etag + self.kind = kind + self.location = location + self.id = None + self.name = None + self.type = None + + +class SecurityConnector(TrackedResource): # pylint: disable=too-many-instance-attributes + """The security connector resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tags: A list of key value pairs that describe the resource. + :vartype tags: dict[str, str] + :ivar etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :vartype etag: str + :ivar kind: Kind of the resource. + :vartype kind: str + :ivar location: Location where the resource is stored. + :vartype location: str + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.security.v2023_10_01_preview.models.SystemData + :ivar hierarchy_identifier: The multi cloud resource identifier (account id in case of AWS + connector, project number in case of GCP connector). + :vartype hierarchy_identifier: str + :ivar hierarchy_identifier_trial_end_date: The date on which the trial period will end, if + applicable. Trial period exists for 30 days after upgrading to payed offerings. + :vartype hierarchy_identifier_trial_end_date: ~datetime.datetime + :ivar environment_name: The multi cloud resource's cloud name. Known values are: "Azure", + "AWS", "GCP", "Github", "AzureDevOps", and "GitLab". + :vartype environment_name: str or ~azure.mgmt.security.v2023_10_01_preview.models.CloudName + :ivar offerings: A collection of offerings for the security connector. + :vartype offerings: list[~azure.mgmt.security.v2023_10_01_preview.models.CloudOffering] + :ivar environment_data: The security connector environment data. + :vartype environment_data: ~azure.mgmt.security.v2023_10_01_preview.models.EnvironmentData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "hierarchy_identifier_trial_end_date": {"readonly": True}, + } + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "hierarchy_identifier": {"key": "properties.hierarchyIdentifier", "type": "str"}, + "hierarchy_identifier_trial_end_date": { + "key": "properties.hierarchyIdentifierTrialEndDate", + "type": "iso-8601", + }, + "environment_name": {"key": "properties.environmentName", "type": "str"}, + "offerings": {"key": "properties.offerings", "type": "[CloudOffering]"}, + "environment_data": {"key": "properties.environmentData", "type": "EnvironmentData"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + etag: Optional[str] = None, + kind: Optional[str] = None, + location: Optional[str] = None, + hierarchy_identifier: Optional[str] = None, + environment_name: Optional[Union[str, "_models.CloudName"]] = None, + offerings: Optional[List["_models.CloudOffering"]] = None, + environment_data: Optional["_models.EnvironmentData"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: A list of key value pairs that describe the resource. + :paramtype tags: dict[str, str] + :keyword etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :paramtype etag: str + :keyword kind: Kind of the resource. + :paramtype kind: str + :keyword location: Location where the resource is stored. + :paramtype location: str + :keyword hierarchy_identifier: The multi cloud resource identifier (account id in case of AWS + connector, project number in case of GCP connector). + :paramtype hierarchy_identifier: str + :keyword environment_name: The multi cloud resource's cloud name. Known values are: "Azure", + "AWS", "GCP", "Github", "AzureDevOps", and "GitLab". + :paramtype environment_name: str or ~azure.mgmt.security.v2023_10_01_preview.models.CloudName + :keyword offerings: A collection of offerings for the security connector. + :paramtype offerings: list[~azure.mgmt.security.v2023_10_01_preview.models.CloudOffering] + :keyword environment_data: The security connector environment data. + :paramtype environment_data: ~azure.mgmt.security.v2023_10_01_preview.models.EnvironmentData + """ + super().__init__(tags=tags, etag=etag, kind=kind, location=location, **kwargs) + self.system_data = None + self.hierarchy_identifier = hierarchy_identifier + self.hierarchy_identifier_trial_end_date = None + self.environment_name = environment_name + self.offerings = offerings + self.environment_data = environment_data + + +class SecurityConnectorsList(_serialization.Model): + """List of security connectors response. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The list of security connectors under the given scope. Required. + :vartype value: list[~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SecurityConnector]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.SecurityConnector"], **kwargs: Any) -> None: + """ + :keyword value: The list of security connectors under the given scope. Required. + :paramtype value: list[~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.security.v2023_10_01_preview.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.security.v2023_10_01_preview.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or + ~azure.mgmt.security.v2023_10_01_preview.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.security.v2023_10_01_preview.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_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/v2023_10_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/_security_center_enums.py new file mode 100644 index 000000000000..d93bbb6e8d04 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/models/_security_center_enums.py @@ -0,0 +1,89 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class CloudName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The multi cloud resource's cloud name.""" + + AZURE = "Azure" + AWS = "AWS" + GCP = "GCP" + GITHUB = "Github" + AZURE_DEV_OPS = "AzureDevOps" + GIT_LAB = "GitLab" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class EnvironmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the environment data.""" + + AWS_ACCOUNT = "AwsAccount" + GCP_PROJECT = "GcpProject" + GITHUB_SCOPE = "GithubScope" + AZURE_DEV_OPS_SCOPE = "AzureDevOpsScope" + GITLAB_SCOPE = "GitlabScope" + + +class OfferingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the security offering.""" + + CSPM_MONITOR_AWS = "CspmMonitorAws" + DEFENDER_FOR_CONTAINERS_AWS = "DefenderForContainersAws" + DEFENDER_FOR_SERVERS_AWS = "DefenderForServersAws" + DEFENDER_FOR_DATABASES_AWS = "DefenderForDatabasesAws" + INFORMATION_PROTECTION_AWS = "InformationProtectionAws" + CSPM_MONITOR_GCP = "CspmMonitorGcp" + CSPM_MONITOR_GITHUB = "CspmMonitorGithub" + CSPM_MONITOR_AZURE_DEV_OPS = "CspmMonitorAzureDevOps" + DEFENDER_FOR_SERVERS_GCP = "DefenderForServersGcp" + DEFENDER_FOR_CONTAINERS_GCP = "DefenderForContainersGcp" + DEFENDER_FOR_DATABASES_GCP = "DefenderForDatabasesGcp" + DEFENDER_CSPM_AWS = "DefenderCspmAws" + DEFENDER_CSPM_GCP = "DefenderCspmGcp" + DEFENDER_FOR_DEV_OPS_GITHUB = "DefenderForDevOpsGithub" + DEFENDER_FOR_DEV_OPS_AZURE_DEV_OPS = "DefenderForDevOpsAzureDevOps" + CSPM_MONITOR_GIT_LAB = "CspmMonitorGitLab" + DEFENDER_FOR_DEV_OPS_GIT_LAB = "DefenderForDevOpsGitLab" + + +class OrganizationMembershipType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The multi cloud account's membership type in the organization.""" + + MEMBER = "Member" + ORGANIZATION = "Organization" + + +class ScanningMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The scanning mode for the VM scan.""" + + DEFAULT = "Default" + + +class SubPlan(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The available sub plans.""" + + P1 = "P1" + P2 = "P2" + + +class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or 'Qualys'.""" + + QUALYS = "Qualys" + TVM = "TVM" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/operations/__init__.py new file mode 100644 index 000000000000..8e4ac6c4f04e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/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 ._security_connectors_operations import SecurityConnectorsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityConnectorsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_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/v2023_10_01_preview/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/operations/_security_connectors_operations.py new file mode 100644 index 000000000000..d4985d7e3f6d --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/operations/_security_connectors_operations.py @@ -0,0 +1,859 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _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(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityConnectors") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, security_connector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class SecurityConnectorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_10_01_preview.SecurityCenter`'s + :attr:`security_connectors` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: + """Lists all the security connectors in the specified subscription. Use the 'nextLink' property in + the response to get the next page of security connectors for the specified subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SecurityConnector or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 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) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityConnectors"} + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: + """Lists all the security connectors in the specified resource group. Use the 'nextLink' property + in the response to get the next page of security connectors for the specified resource group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SecurityConnector or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.SecurityConnectorsList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors" + } + + @distributed_trace + def get(self, resource_group_name: str, security_connector_name: str, **kwargs: Any) -> _models.SecurityConnector: + """Retrieves details of a specific security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityConnector", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: _models.SecurityConnector, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Creates or updates a security connector. If a security connector is already created and a + subsequent request is issued for the same security connector id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Creates or updates a security connector. If a security connector is already created and a + subsequent request is issued for the same security connector id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: IO + :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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: Union[_models.SecurityConnector, IO], + **kwargs: Any + ) -> _models.SecurityConnector: + """Creates or updates a security connector. If a security connector is already created and a + subsequent request is issued for the same security connector id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Is either a SecurityConnector type + or a IO type. Required. + :type security_connector: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector 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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_connector, (IOBase, bytes)): + _content = security_connector + else: + _json = self._serialize.body(security_connector, "SecurityConnector") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SecurityConnector", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SecurityConnector", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}" + } + + @overload + def update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: _models.SecurityConnector, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Updates a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Updates a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: IO + :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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: Union[_models.SecurityConnector, IO], + **kwargs: Any + ) -> _models.SecurityConnector: + """Updates a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Is either a SecurityConnector type + or a IO type. Required. + :type security_connector: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector 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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_10_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecurityConnector] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_connector, (IOBase, bytes)): + _content = security_connector + else: + _json = self._serialize.body(security_connector, "SecurityConnector") + + request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityConnector", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> None: + """Deletes a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop( + "api_version", _params.pop("api-version", self._api_version or "2023-10-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_10_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/v2023_11_15/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/__init__.py new file mode 100644 index 000000000000..e95a015ca6b8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/__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 ._security_center import SecurityCenter +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenter", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_configuration.py new file mode 100644 index 000000000000..f73723a507f1 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_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 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: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-11-15". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-11-15") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) + self._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.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/v2023_11_15/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_metadata.json new file mode 100644 index 000000000000..3334c93398cc --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_metadata.json @@ -0,0 +1,110 @@ +{ + "chosen_version": "2023-11-15", + "total_api_version_list": ["2023-11-15"], + "client": { + "name": "SecurityCenter", + "filename": "_security_center", + "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_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, + "method_location": "positional" + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. The value must be an UUID. Required.", + "docstring_type": "str", + "required": true, + "method_location": "positional" + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. The value must be an UUID. Required.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version: Optional[str]=None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"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": { + "api_collections": "APICollectionsOperations" + } +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_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/v2023_11_15/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_security_center.py new file mode 100644 index 000000000000..7b48319c991b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_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, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import APICollectionsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword + """API spec for Microsoft.Security (Azure Security Center) resource provider. + + :ivar api_collections: APICollectionsOperations operations + :vartype api_collections: azure.mgmt.security.v2023_11_15.operations.APICollectionsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-11-15". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.api_collections = APICollectionsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-11-15" + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "SecurityCenter": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_vendor.py new file mode 100644 index 000000000000..0dafe0e287ff --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/_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/v2023_11_15/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/__init__.py new file mode 100644 index 000000000000..d9a53c22b3e6 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/__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 ._security_center import SecurityCenter + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenter", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/_configuration.py new file mode 100644 index 000000000000..7d17595c1a19 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/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: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2023-11-15". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-11-15") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) + self._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/v2023_11_15/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/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/v2023_11_15/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/_security_center.py new file mode 100644 index 000000000000..ec089e24b3e1 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/_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, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import APICollectionsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword + """API spec for Microsoft.Security (Azure Security Center) resource provider. + + :ivar api_collections: APICollectionsOperations operations + :vartype api_collections: + azure.mgmt.security.v2023_11_15.aio.operations.APICollectionsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2023-11-15". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.api_collections = APICollectionsOperations( + self._client, self._config, self._serialize, self._deserialize, "2023-11-15" + ) + + 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: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/operations/__init__.py new file mode 100644 index 000000000000..7ca7884efe21 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/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 ._api_collections_operations import APICollectionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "APICollectionsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/operations/_api_collections_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/operations/_api_collections_operations.py new file mode 100644 index 000000000000..0cdf12e9eced --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/operations/_api_collections_operations.py @@ -0,0 +1,622 @@ +# 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, cast +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._api_collections_operations import ( + build_get_by_azure_api_management_service_request, + build_list_by_azure_api_management_service_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_offboard_azure_api_management_api_request, + build_onboard_azure_api_management_api_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class APICollectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_11_15.aio.SecurityCenter`'s + :attr:`api_collections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ApiCollection"]: + """Gets a list of API collections within a subscription. + + Gets a list of API collections within a subscription that have been onboarded to Microsoft + Defender for APIs. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiCollection or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_11_15.models.ApiCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) + cls: ClsType[_models.ApiCollectionList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiCollectionList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/apiCollections" + } + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.ApiCollection"]: + """Gets a list of API collections within a resource group. + + Gets a list of API collections within a resource group that have been onboarded to Microsoft + Defender for APIs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiCollection or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_11_15.models.ApiCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) + cls: ClsType[_models.ApiCollectionList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiCollectionList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/apiCollections" + } + + @distributed_trace + def list_by_azure_api_management_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ApiCollection"]: + """Gets a list of onboarded Azure API Management APIs. + + Gets a list of Azure API Management APIs that have been onboarded to Microsoft Defender for + APIs. If an Azure API Management API is onboarded to Microsoft Defender for APIs, the system + will monitor the operations within the Azure API Management API for intrusive behaviors and + provide alerts for attacks that have been detected. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiCollection or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2023_11_15.models.ApiCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) + cls: ClsType[_models.ApiCollectionList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_azure_api_management_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_azure_api_management_service.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ApiCollectionList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_azure_api_management_service.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections" + } + + @distributed_trace_async + async def get_by_azure_api_management_service( + self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any + ) -> _models.ApiCollection: + """Gets an onboarded Azure API Management API. + + Gets an Azure API Management API if it has been onboarded to Microsoft Defender for APIs. If an + Azure API Management API is onboarded to Microsoft Defender for APIs, the system will monitor + the operations within the Azure API Management API for intrusive behaviors and provide alerts + for attacks that have been detected. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the API Management service instance. + Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiCollection or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_11_15.models.ApiCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) + cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) + + request = build_get_by_azure_api_management_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_azure_api_management_service.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApiCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_azure_api_management_service.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}" + } + + async def _onboard_azure_api_management_api_initial( + self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any + ) -> _models.ApiCollection: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) + cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) + + request = build_onboard_azure_api_management_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._onboard_azure_api_management_api_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ApiCollection", pipeline_response) + + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("ApiCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _onboard_azure_api_management_api_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}" + } + + @distributed_trace_async + async def begin_onboard_azure_api_management_api( + self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ApiCollection]: + """Onboard an Azure API Management API to Microsoft Defender for APIs. + + Onboard an Azure API Management API to Microsoft Defender for APIs. The system will start + monitoring the operations within the Azure Management API for intrusive behaviors and provide + alerts for attacks that have been detected. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the API Management service instance. + Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :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 ApiCollection or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.security.v2023_11_15.models.ApiCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) + cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._onboard_azure_api_management_api_initial( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ApiCollection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_onboard_azure_api_management_api.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}" + } + + @distributed_trace_async + async def offboard_azure_api_management_api( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any + ) -> None: + """Offboard an Azure API Management API from Microsoft Defender for APIs. + + Offboard an Azure API Management API from Microsoft Defender for APIs. The system will stop + monitoring the operations within the Azure API Management API for intrusive behaviors. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the API Management service instance. + Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_offboard_azure_api_management_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.offboard_azure_api_management_api.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + offboard_azure_api_management_api.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/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/v2023_11_15/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/__init__.py new file mode 100644 index 000000000000..963840654215 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/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 ApiCollection +from ._models_py3 import ApiCollectionList +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import Resource + +from ._security_center_enums import ProvisioningState +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ApiCollection", + "ApiCollectionList", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "Resource", + "ProvisioningState", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/_models_py3.py new file mode 100644 index 000000000000..238ceee2e173 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/_models_py3.py @@ -0,0 +1,263 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional, TYPE_CHECKING + +from ... import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class Resource(_serialization.Model): + """Describes an Azure resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class ApiCollection(Resource): # pylint: disable=too-many-instance-attributes + """An API collection as represented by Microsoft Defender for APIs. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar provisioning_state: Gets the provisioning state of the API collection. Known values are: + "Succeeded", "Failed", "Canceled", and "InProgress". + :vartype provisioning_state: str or ~azure.mgmt.security.v2023_11_15.models.ProvisioningState + :ivar display_name: The display name of the API collection. + :vartype display_name: str + :ivar discovered_via: The resource Id of the resource from where this API collection was + discovered. + :vartype discovered_via: str + :ivar base_url: The base URI for this API collection. All endpoints of this API collection + extend this base URI. + :vartype base_url: str + :ivar number_of_api_endpoints: The number of API endpoints discovered in this API collection. + :vartype number_of_api_endpoints: int + :ivar number_of_inactive_api_endpoints: The number of API endpoints in this API collection that + have not received any API traffic in the last 30 days. + :vartype number_of_inactive_api_endpoints: int + :ivar number_of_unauthenticated_api_endpoints: The number of API endpoints in this API + collection that are unauthenticated. + :vartype number_of_unauthenticated_api_endpoints: int + :ivar number_of_external_api_endpoints: The number of API endpoints in this API collection for + which API traffic from the internet was observed. + :vartype number_of_external_api_endpoints: int + :ivar number_of_api_endpoints_with_sensitive_data_exposed: The number of API endpoints in this + API collection which are exposing sensitive data in their requests and/or responses. + :vartype number_of_api_endpoints_with_sensitive_data_exposed: int + :ivar sensitivity_label: The highest priority sensitivity label from Microsoft Purview in this + API collection. + :vartype sensitivity_label: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "display_name": {"readonly": True}, + "discovered_via": {"readonly": True}, + "base_url": {"readonly": True}, + "number_of_api_endpoints": {"readonly": True}, + "number_of_inactive_api_endpoints": {"readonly": True}, + "number_of_unauthenticated_api_endpoints": {"readonly": True}, + "number_of_external_api_endpoints": {"readonly": True}, + "number_of_api_endpoints_with_sensitive_data_exposed": {"readonly": True}, + "sensitivity_label": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "discovered_via": {"key": "properties.discoveredVia", "type": "str"}, + "base_url": {"key": "properties.baseUrl", "type": "str"}, + "number_of_api_endpoints": {"key": "properties.numberOfApiEndpoints", "type": "int"}, + "number_of_inactive_api_endpoints": {"key": "properties.numberOfInactiveApiEndpoints", "type": "int"}, + "number_of_unauthenticated_api_endpoints": { + "key": "properties.numberOfUnauthenticatedApiEndpoints", + "type": "int", + }, + "number_of_external_api_endpoints": {"key": "properties.numberOfExternalApiEndpoints", "type": "int"}, + "number_of_api_endpoints_with_sensitive_data_exposed": { + "key": "properties.numberOfApiEndpointsWithSensitiveDataExposed", + "type": "int", + }, + "sensitivity_label": {"key": "properties.sensitivityLabel", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.provisioning_state = None + self.display_name = None + self.discovered_via = None + self.base_url = None + self.number_of_api_endpoints = None + self.number_of_inactive_api_endpoints = None + self.number_of_unauthenticated_api_endpoints = None + self.number_of_external_api_endpoints = None + self.number_of_api_endpoints_with_sensitive_data_exposed = None + self.sensitivity_label = None + + +class ApiCollectionList(_serialization.Model): + """Page of a list of API collections as represented by Microsoft Defender for APIs. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: API collections in this page. + :vartype value: list[~azure.mgmt.security.v2023_11_15.models.ApiCollection] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ApiCollection]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.security.v2023_11_15.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.security.v2023_11_15.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.security.v2023_11_15.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.security.v2023_11_15.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/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/v2023_11_15/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/_security_center_enums.py new file mode 100644 index 000000000000..018a701d8035 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/models/_security_center_enums.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 enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the provisioning state of the API collection.""" + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + IN_PROGRESS = "InProgress" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/operations/__init__.py new file mode 100644 index 000000000000..7ca7884efe21 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/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 ._api_collections_operations import APICollectionsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "APICollectionsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/operations/_api_collections_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/operations/_api_collections_operations.py new file mode 100644 index 000000000000..60bcdd330044 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/operations/_api_collections_operations.py @@ -0,0 +1,830 @@ +# 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, cast +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-15")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/apiCollections") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-15")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/apiCollections", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_azure_api_management_service_request( + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-15")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_by_azure_api_management_service_request( + resource_group_name: str, service_name: str, api_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-15")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_onboard_azure_api_management_api_request( + resource_group_name: str, service_name: str, api_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-15")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_offboard_azure_api_management_api_request( + resource_group_name: str, service_name: str, api_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-15")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "serviceName": _SERIALIZER.url( + "service_name", + service_name, + "str", + max_length=50, + min_length=1, + pattern=r"^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$", + ), + "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class APICollectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2023_11_15.SecurityCenter`'s + :attr:`api_collections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ApiCollection"]: + """Gets a list of API collections within a subscription. + + Gets a list of API collections within a subscription that have been onboarded to Microsoft + Defender for APIs. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiCollection or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_11_15.models.ApiCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) + cls: ClsType[_models.ApiCollectionList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiCollectionList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/apiCollections" + } + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ApiCollection"]: + """Gets a list of API collections within a resource group. + + Gets a list of API collections within a resource group that have been onboarded to Microsoft + Defender for APIs. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiCollection or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_11_15.models.ApiCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) + cls: ClsType[_models.ApiCollectionList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiCollectionList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/apiCollections" + } + + @distributed_trace + def list_by_azure_api_management_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> Iterable["_models.ApiCollection"]: + """Gets a list of onboarded Azure API Management APIs. + + Gets a list of Azure API Management APIs that have been onboarded to Microsoft Defender for + APIs. If an Azure API Management API is onboarded to Microsoft Defender for APIs, the system + will monitor the operations within the Azure API Management API for intrusive behaviors and + provide alerts for attacks that have been detected. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiCollection or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2023_11_15.models.ApiCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) + cls: ClsType[_models.ApiCollectionList] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_azure_api_management_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_azure_api_management_service.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ApiCollectionList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_azure_api_management_service.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections" + } + + @distributed_trace + def get_by_azure_api_management_service( + self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any + ) -> _models.ApiCollection: + """Gets an onboarded Azure API Management API. + + Gets an Azure API Management API if it has been onboarded to Microsoft Defender for APIs. If an + Azure API Management API is onboarded to Microsoft Defender for APIs, the system will monitor + the operations within the Azure API Management API for intrusive behaviors and provide alerts + for attacks that have been detected. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the API Management service instance. + Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiCollection or the result of cls(response) + :rtype: ~azure.mgmt.security.v2023_11_15.models.ApiCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) + cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) + + request = build_get_by_azure_api_management_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_azure_api_management_service.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ApiCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_azure_api_management_service.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}" + } + + def _onboard_azure_api_management_api_initial( + self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any + ) -> _models.ApiCollection: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) + cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) + + request = build_onboard_azure_api_management_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._onboard_azure_api_management_api_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("ApiCollection", pipeline_response) + + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = self._deserialize("ApiCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + _onboard_azure_api_management_api_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}" + } + + @distributed_trace + def begin_onboard_azure_api_management_api( + self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any + ) -> LROPoller[_models.ApiCollection]: + """Onboard an Azure API Management API to Microsoft Defender for APIs. + + Onboard an Azure API Management API to Microsoft Defender for APIs. The system will start + monitoring the operations within the Azure Management API for intrusive behaviors and provide + alerts for attacks that have been detected. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the API Management service instance. + Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :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 ApiCollection or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.security.v2023_11_15.models.ApiCollection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) + cls: ClsType[_models.ApiCollection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._onboard_azure_api_management_api_initial( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ApiCollection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_onboard_azure_api_management_api.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}" + } + + @distributed_trace + def offboard_azure_api_management_api( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any + ) -> None: + """Offboard an Azure API Management API from Microsoft Defender for APIs. + + Offboard an Azure API Management API from Microsoft Defender for APIs. The system will stop + monitoring the operations within the Azure API Management API for intrusive behaviors. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the API Management service instance. + Non-current revision has ;rev=n as a suffix where n is the revision number. Required. + :type api_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-11-15")) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_offboard_azure_api_management_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.offboard_azure_api_management_api.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + offboard_azure_api_management_api.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/providers/Microsoft.Security/apiCollections/{apiId}" + } diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/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/v2023_11_15/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2023_11_15/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_cloud_posture_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_cloud_posture_example.py new file mode 100644 index 000000000000..8017397a433d --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_cloud_posture_example.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 azure.identity import DefaultAzureCredential +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_pricing_by_name_cloud_posture_example.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.pricings.get( + pricing_name="CloudPosture", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameCloudPosture_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_containers_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_containers_example.py new file mode 100644 index 000000000000..ce6d86c97096 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_containers_example.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 azure.identity import DefaultAzureCredential +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_pricing_by_name_containers_example.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.pricings.get( + pricing_name="Containers", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameContainers_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_dns_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_dns_example.py new file mode 100644 index 000000000000..2e11fb0479eb --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_dns_example.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 azure.identity import DefaultAzureCredential +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_pricing_by_name_dns_example.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.pricings.get( + pricing_name="Dns", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameDns_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_storage_accounts_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_storage_accounts_example.py new file mode 100644 index 000000000000..270278401b8c --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_storage_accounts_example.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 azure.identity import DefaultAzureCredential +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_pricing_by_name_storage_accounts_example.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.pricings.get( + pricing_name="StorageAccounts", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameStorageAccounts_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_virtual_machines_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_virtual_machines_example.py new file mode 100644 index 000000000000..8e2dfa237042 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/get_pricing_by_name_virtual_machines_example.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 azure.identity import DefaultAzureCredential +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python get_pricing_by_name_virtual_machines_example.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.pricings.get( + pricing_name="VirtualMachines", + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameVirtualMachines_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/list_pricings_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/list_pricings_example.py new file mode 100644 index 000000000000..dd7a40416371 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/list_pricings_example.py @@ -0,0 +1,38 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python list_pricings_example.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.pricings.list() + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/ListPricings_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/put_pricing_by_name_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/put_pricing_by_name_example.py new file mode 100644 index 000000000000..031f255e6107 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/put_pricing_by_name_example.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_pricing_by_name_example.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.pricings.update( + pricing_name="CloudPosture", + pricing={"properties": {"pricingTier": "Standard"}}, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/PutPricingByName_example.json +if __name__ == "__main__": + main() diff --git a/sdk/security/azure-mgmt-security/generated_samples/pricings/put_pricing_by_name_partial_success_example.py b/sdk/security/azure-mgmt-security/generated_samples/pricings/put_pricing_by_name_partial_success_example.py new file mode 100644 index 000000000000..add40d31d217 --- /dev/null +++ b/sdk/security/azure-mgmt-security/generated_samples/pricings/put_pricing_by_name_partial_success_example.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.security import SecurityCenter + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-security +# USAGE + python put_pricing_by_name_partial_success_example.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = SecurityCenter( + credential=DefaultAzureCredential(), + subscription_id="20ff7fc3-e762-44dd-bd96-b71116dcdc23", + ) + + response = client.pricings.update( + pricing_name="CloudPosture", + pricing={"properties": {"pricingTier": "Standard"}}, + ) + print(response) + + +# x-ms-original-file: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/PutPricingByNamePartialSuccess_example.json +if __name__ == "__main__": + main()