diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mariadb/_maria_db_management_client.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mariadb/_maria_db_management_client.py index 630e5446cf31..ba4232c42fdf 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mariadb/_maria_db_management_client.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mariadb/_maria_db_management_client.py @@ -23,7 +23,6 @@ from .operations import LogFilesOperations from .operations import LocationBasedPerformanceTierOperations from .operations import CheckNameAvailabilityOperations -from .operations import ServerSecurityAlertPoliciesOperations from .operations import Operations from .operations import QueryTextsOperations from .operations import TopQueryStatisticsOperations @@ -34,6 +33,7 @@ from .operations import LocationBasedRecommendedActionSessionsResultOperations from .operations import PrivateEndpointConnectionsOperations from .operations import PrivateLinkResourcesOperations +from .operations import ServerSecurityAlertPoliciesOperations from . import models @@ -61,8 +61,6 @@ class MariaDBManagementClient(MariaDBManagementClientOperationsMixin, SDKClient) :vartype location_based_performance_tier: azure.mgmt.rdbms.mariadb.operations.LocationBasedPerformanceTierOperations :ivar check_name_availability: CheckNameAvailability operations :vartype check_name_availability: azure.mgmt.rdbms.mariadb.operations.CheckNameAvailabilityOperations - :ivar server_security_alert_policies: ServerSecurityAlertPolicies operations - :vartype server_security_alert_policies: azure.mgmt.rdbms.mariadb.operations.ServerSecurityAlertPoliciesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.rdbms.mariadb.operations.Operations :ivar query_texts: QueryTexts operations @@ -83,6 +81,8 @@ class MariaDBManagementClient(MariaDBManagementClientOperationsMixin, SDKClient) :vartype private_endpoint_connections: azure.mgmt.rdbms.mariadb.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResources operations :vartype private_link_resources: azure.mgmt.rdbms.mariadb.operations.PrivateLinkResourcesOperations + :ivar server_security_alert_policies: ServerSecurityAlertPolicies operations + :vartype server_security_alert_policies: azure.mgmt.rdbms.mariadb.operations.ServerSecurityAlertPoliciesOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials @@ -121,8 +121,6 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.check_name_availability = CheckNameAvailabilityOperations( self._client, self.config, self._serialize, self._deserialize) - self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( - self._client, self.config, self._serialize, self._deserialize) self.operations = Operations( self._client, self.config, self._serialize, self._deserialize) self.query_texts = QueryTextsOperations( @@ -143,3 +141,5 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.private_link_resources = PrivateLinkResourcesOperations( self._client, self.config, self._serialize, self._deserialize) + self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mariadb/operations/__init__.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mariadb/operations/__init__.py index 133208b9f021..0b18bc99ed13 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mariadb/operations/__init__.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mariadb/operations/__init__.py @@ -18,7 +18,6 @@ from ._log_files_operations import LogFilesOperations from ._location_based_performance_tier_operations import LocationBasedPerformanceTierOperations from ._check_name_availability_operations import CheckNameAvailabilityOperations -from ._server_security_alert_policies_operations import ServerSecurityAlertPoliciesOperations from ._operations import Operations from ._query_texts_operations import QueryTextsOperations from ._top_query_statistics_operations import TopQueryStatisticsOperations @@ -29,6 +28,7 @@ from ._location_based_recommended_action_sessions_result_operations import LocationBasedRecommendedActionSessionsResultOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._server_security_alert_policies_operations import ServerSecurityAlertPoliciesOperations from ._maria_db_management_client_operations import MariaDBManagementClientOperationsMixin __all__ = [ @@ -41,7 +41,6 @@ 'LogFilesOperations', 'LocationBasedPerformanceTierOperations', 'CheckNameAvailabilityOperations', - 'ServerSecurityAlertPoliciesOperations', 'Operations', 'QueryTextsOperations', 'TopQueryStatisticsOperations', @@ -52,5 +51,6 @@ 'LocationBasedRecommendedActionSessionsResultOperations', 'PrivateEndpointConnectionsOperations', 'PrivateLinkResourcesOperations', + 'ServerSecurityAlertPoliciesOperations', 'MariaDBManagementClientOperationsMixin', ] diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/_postgre_sql_management_client.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/_postgre_sql_management_client.py index febfd16ddd4d..f1148989b5e7 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/_postgre_sql_management_client.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/_postgre_sql_management_client.py @@ -23,11 +23,11 @@ from .operations import ServerAdministratorsOperations from .operations import LocationBasedPerformanceTierOperations from .operations import CheckNameAvailabilityOperations -from .operations import ServerSecurityAlertPoliciesOperations from .operations import Operations from .operations import PrivateEndpointConnectionsOperations from .operations import PrivateLinkResourcesOperations from .operations import ServerKeysOperations +from .operations import ServerSecurityAlertPoliciesOperations from . import models @@ -57,8 +57,6 @@ class PostgreSQLManagementClient(SDKClient): :vartype location_based_performance_tier: azure.mgmt.rdbms.postgresql.operations.LocationBasedPerformanceTierOperations :ivar check_name_availability: CheckNameAvailability operations :vartype check_name_availability: azure.mgmt.rdbms.postgresql.operations.CheckNameAvailabilityOperations - :ivar server_security_alert_policies: ServerSecurityAlertPolicies operations - :vartype server_security_alert_policies: azure.mgmt.rdbms.postgresql.operations.ServerSecurityAlertPoliciesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.rdbms.postgresql.operations.Operations :ivar private_endpoint_connections: PrivateEndpointConnections operations @@ -67,6 +65,8 @@ class PostgreSQLManagementClient(SDKClient): :vartype private_link_resources: azure.mgmt.rdbms.postgresql.operations.PrivateLinkResourcesOperations :ivar server_keys: ServerKeys operations :vartype server_keys: azure.mgmt.rdbms.postgresql.operations.ServerKeysOperations + :ivar server_security_alert_policies: ServerSecurityAlertPolicies operations + :vartype server_security_alert_policies: azure.mgmt.rdbms.postgresql.operations.ServerSecurityAlertPoliciesOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials @@ -106,8 +106,6 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.check_name_availability = CheckNameAvailabilityOperations( self._client, self.config, self._serialize, self._deserialize) - self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( - self._client, self.config, self._serialize, self._deserialize) self.operations = Operations( self._client, self.config, self._serialize, self._deserialize) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( @@ -116,3 +114,5 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.server_keys = ServerKeysOperations( self._client, self.config, self._serialize, self._deserialize) + self.server_security_alert_policies = ServerSecurityAlertPoliciesOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/__init__.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/__init__.py index 595a3f8fd2ce..ae4b74863ead 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/__init__.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/__init__.py @@ -48,6 +48,7 @@ from ._models_py3 import ServerUpdateParameters from ._models_py3 import Sku from ._models_py3 import StorageProfile + from ._models_py3 import SystemData from ._models_py3 import TagsObject from ._models_py3 import TrackedResource from ._models_py3 import VirtualNetworkRule @@ -90,6 +91,7 @@ from ._models import ServerUpdateParameters from ._models import Sku from ._models import StorageProfile + from ._models import SystemData from ._models import TagsObject from ._models import TrackedResource from ._models import VirtualNetworkRule @@ -103,6 +105,7 @@ from ._paged_models import ServerAdministratorResourcePaged from ._paged_models import ServerKeyPaged from ._paged_models import ServerPaged +from ._paged_models import ServerSecurityAlertPolicyPaged from ._paged_models import VirtualNetworkRulePaged from ._postgre_sql_management_client_enums import ( ServerVersion, @@ -121,6 +124,7 @@ VirtualNetworkRuleState, OperationOrigin, ServerSecurityAlertPolicyState, + CreatedByType, ) __all__ = [ @@ -162,6 +166,7 @@ 'ServerUpdateParameters', 'Sku', 'StorageProfile', + 'SystemData', 'TagsObject', 'TrackedResource', 'VirtualNetworkRule', @@ -176,6 +181,7 @@ 'PrivateEndpointConnectionPaged', 'PrivateLinkResourcePaged', 'ServerKeyPaged', + 'ServerSecurityAlertPolicyPaged', 'ServerVersion', 'SslEnforcementEnum', 'MinimalTlsVersionEnum', @@ -192,4 +198,5 @@ 'VirtualNetworkRuleState', 'OperationOrigin', 'ServerSecurityAlertPolicyState', + 'CreatedByType', ] diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/_models.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/_models.py index b7c386b0d76a..a8934b39f930 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/_models.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/_models.py @@ -1601,26 +1601,8 @@ class ServerSecurityAlertPolicy(ProxyResource): enabled or disabled. Possible values include: 'Enabled', 'Disabled' :type state: str or ~azure.mgmt.rdbms.postgresql.models.ServerSecurityAlertPolicyState - :param disabled_alerts: Specifies an array of alerts that are disabled. - Allowed values are: Sql_Injection, Sql_Injection_Vulnerability, - Access_Anomaly - :type disabled_alerts: list[str] - :param email_addresses: Specifies an array of e-mail addresses to which - the alert is sent. - :type email_addresses: list[str] - :param email_account_admins: Specifies that the alert is sent to the - account administrators. - :type email_account_admins: bool - :param storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). This blob storage will hold all - Threat Detection audit logs. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the - Threat Detection audit storage account. - :type storage_account_access_key: str - :param retention_days: Specifies the number of days to keep in the Threat - Detection audit logs. - :type retention_days: int + :ivar system_data: + :vartype system_data: ~azure.mgmt.rdbms.postgresql.models.SystemData """ _validation = { @@ -1628,6 +1610,7 @@ class ServerSecurityAlertPolicy(ProxyResource): 'name': {'readonly': True}, 'type': {'readonly': True}, 'state': {'required': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -1635,23 +1618,13 @@ class ServerSecurityAlertPolicy(ProxyResource): 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'state': {'key': 'properties.state', 'type': 'ServerSecurityAlertPolicyState'}, - 'disabled_alerts': {'key': 'properties.disabledAlerts', 'type': '[str]'}, - 'email_addresses': {'key': 'properties.emailAddresses', 'type': '[str]'}, - 'email_account_admins': {'key': 'properties.emailAccountAdmins', 'type': 'bool'}, - 'storage_endpoint': {'key': 'properties.storageEndpoint', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'retention_days': {'key': 'properties.retentionDays', 'type': 'int'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__(self, **kwargs): super(ServerSecurityAlertPolicy, self).__init__(**kwargs) self.state = kwargs.get('state', None) - self.disabled_alerts = kwargs.get('disabled_alerts', None) - self.email_addresses = kwargs.get('email_addresses', None) - self.email_account_admins = kwargs.get('email_account_admins', None) - self.storage_endpoint = kwargs.get('storage_endpoint', None) - self.storage_account_access_key = kwargs.get('storage_account_access_key', None) - self.retention_days = kwargs.get('retention_days', None) + self.system_data = None class ServerUpdateParameters(Model): @@ -1787,6 +1760,48 @@ def __init__(self, **kwargs): self.storage_autogrow = kwargs.get('storage_autogrow', None) +class SystemData(Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. + Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + :type created_by_type: str or + ~azure.mgmt.rdbms.postgresql.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the + resource. Possible values include: 'User', 'Application', + 'ManagedIdentity', 'Key' + :type last_modified_by_type: str or + ~azure.mgmt.rdbms.postgresql.models.CreatedByType + :param last_modified_at: The type of identity that last modified the + resource. + :type last_modified_at: datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__(self, **kwargs): + super(SystemData, self).__init__(**kwargs) + self.created_by = kwargs.get('created_by', None) + self.created_by_type = kwargs.get('created_by_type', None) + self.created_at = kwargs.get('created_at', None) + self.last_modified_by = kwargs.get('last_modified_by', None) + self.last_modified_by_type = kwargs.get('last_modified_by_type', None) + self.last_modified_at = kwargs.get('last_modified_at', None) + + class TagsObject(Model): """Tags object for patch operations. diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/_models_py3.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/_models_py3.py index 2a4fb4166d94..bf61b4d533db 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/_models_py3.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/_models_py3.py @@ -1601,26 +1601,8 @@ class ServerSecurityAlertPolicy(ProxyResource): enabled or disabled. Possible values include: 'Enabled', 'Disabled' :type state: str or ~azure.mgmt.rdbms.postgresql.models.ServerSecurityAlertPolicyState - :param disabled_alerts: Specifies an array of alerts that are disabled. - Allowed values are: Sql_Injection, Sql_Injection_Vulnerability, - Access_Anomaly - :type disabled_alerts: list[str] - :param email_addresses: Specifies an array of e-mail addresses to which - the alert is sent. - :type email_addresses: list[str] - :param email_account_admins: Specifies that the alert is sent to the - account administrators. - :type email_account_admins: bool - :param storage_endpoint: Specifies the blob storage endpoint (e.g. - https://MyAccount.blob.core.windows.net). This blob storage will hold all - Threat Detection audit logs. - :type storage_endpoint: str - :param storage_account_access_key: Specifies the identifier key of the - Threat Detection audit storage account. - :type storage_account_access_key: str - :param retention_days: Specifies the number of days to keep in the Threat - Detection audit logs. - :type retention_days: int + :ivar system_data: + :vartype system_data: ~azure.mgmt.rdbms.postgresql.models.SystemData """ _validation = { @@ -1628,6 +1610,7 @@ class ServerSecurityAlertPolicy(ProxyResource): 'name': {'readonly': True}, 'type': {'readonly': True}, 'state': {'required': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -1635,23 +1618,13 @@ class ServerSecurityAlertPolicy(ProxyResource): 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'state': {'key': 'properties.state', 'type': 'ServerSecurityAlertPolicyState'}, - 'disabled_alerts': {'key': 'properties.disabledAlerts', 'type': '[str]'}, - 'email_addresses': {'key': 'properties.emailAddresses', 'type': '[str]'}, - 'email_account_admins': {'key': 'properties.emailAccountAdmins', 'type': 'bool'}, - 'storage_endpoint': {'key': 'properties.storageEndpoint', 'type': 'str'}, - 'storage_account_access_key': {'key': 'properties.storageAccountAccessKey', 'type': 'str'}, - 'retention_days': {'key': 'properties.retentionDays', 'type': 'int'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } - def __init__(self, *, state, disabled_alerts=None, email_addresses=None, email_account_admins: bool=None, storage_endpoint: str=None, storage_account_access_key: str=None, retention_days: int=None, **kwargs) -> None: + def __init__(self, *, state, **kwargs) -> None: super(ServerSecurityAlertPolicy, self).__init__(**kwargs) self.state = state - self.disabled_alerts = disabled_alerts - self.email_addresses = email_addresses - self.email_account_admins = email_account_admins - self.storage_endpoint = storage_endpoint - self.storage_account_access_key = storage_account_access_key - self.retention_days = retention_days + self.system_data = None class ServerUpdateParameters(Model): @@ -1787,6 +1760,48 @@ def __init__(self, *, backup_retention_days: int=None, geo_redundant_backup=None self.storage_autogrow = storage_autogrow +class SystemData(Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. + Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + :type created_by_type: str or + ~azure.mgmt.rdbms.postgresql.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the + resource. Possible values include: 'User', 'Application', + 'ManagedIdentity', 'Key' + :type last_modified_by_type: str or + ~azure.mgmt.rdbms.postgresql.models.CreatedByType + :param last_modified_at: The type of identity that last modified the + resource. + :type last_modified_at: 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: str=None, created_by_type=None, created_at=None, last_modified_by: str=None, last_modified_by_type=None, last_modified_at=None, **kwargs) -> None: + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + class TagsObject(Model): """Tags object for patch operations. diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/_paged_models.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/_paged_models.py index eb66a2bb4784..8c3f8cc2f06c 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/_paged_models.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/_paged_models.py @@ -155,3 +155,16 @@ class ServerKeyPaged(Paged): def __init__(self, *args, **kwargs): super(ServerKeyPaged, self).__init__(*args, **kwargs) +class ServerSecurityAlertPolicyPaged(Paged): + """ + A paging container for iterating over a list of :class:`ServerSecurityAlertPolicy ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[ServerSecurityAlertPolicy]'} + } + + def __init__(self, *args, **kwargs): + + super(ServerSecurityAlertPolicyPaged, self).__init__(*args, **kwargs) diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/_postgre_sql_management_client_enums.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/_postgre_sql_management_client_enums.py index 354d4c8c9987..07024cfbb376 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/_postgre_sql_management_client_enums.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/models/_postgre_sql_management_client_enums.py @@ -38,8 +38,8 @@ class MinimalTlsVersionEnum(str, Enum): class InfrastructureEncryption(str, Enum): - enabled = "Enabled" - disabled = "Disabled" + enabled = "Enabled" #: Default value for single layer of encryption for data at rest. + disabled = "Disabled" #: Additional (2nd) layer of encryption for data at rest class PublicNetworkAccessEnum(str, Enum): @@ -122,3 +122,11 @@ class ServerSecurityAlertPolicyState(str, Enum): enabled = "Enabled" disabled = "Disabled" + + +class CreatedByType(str, Enum): + + user = "User" + application = "Application" + managed_identity = "ManagedIdentity" + key = "Key" diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/operations/__init__.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/operations/__init__.py index 625d902647d7..2a236865816c 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/operations/__init__.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/operations/__init__.py @@ -19,11 +19,11 @@ from ._server_administrators_operations import ServerAdministratorsOperations from ._location_based_performance_tier_operations import LocationBasedPerformanceTierOperations from ._check_name_availability_operations import CheckNameAvailabilityOperations -from ._server_security_alert_policies_operations import ServerSecurityAlertPoliciesOperations from ._operations import Operations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations from ._server_keys_operations import ServerKeysOperations +from ._server_security_alert_policies_operations import ServerSecurityAlertPoliciesOperations __all__ = [ 'ServersOperations', @@ -36,9 +36,9 @@ 'ServerAdministratorsOperations', 'LocationBasedPerformanceTierOperations', 'CheckNameAvailabilityOperations', - 'ServerSecurityAlertPoliciesOperations', 'Operations', 'PrivateEndpointConnectionsOperations', 'PrivateLinkResourcesOperations', 'ServerKeysOperations', + 'ServerSecurityAlertPoliciesOperations', ] diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/operations/_server_security_alert_policies_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/operations/_server_security_alert_policies_operations.py index d87af7b07f8c..29b44b8808d4 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/operations/_server_security_alert_policies_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/operations/_server_security_alert_policies_operations.py @@ -28,7 +28,7 @@ class ServerSecurityAlertPoliciesOperations(object): :param serializer: An object model serializer. :param deserializer: An object model deserializer. :ivar security_alert_policy_name: The name of the security alert policy. Constant value: "Default". - :ivar api_version: The API version to use for this operation. Constant value: "2017-12-01". + :ivar api_version: The API version to use for this operation. Constant value: "2020-01-01". """ models = models @@ -39,7 +39,7 @@ def __init__(self, client, config, serializer, deserializer): self._serialize = serializer self._deserialize = deserializer self.security_alert_policy_name = "Default" - self.api_version = "2017-12-01" + self.api_version = "2020-01-01" self.config = config @@ -108,7 +108,9 @@ def get( def _create_or_update_initial( - self, resource_group_name, server_name, parameters, custom_headers=None, raw=False, **operation_config): + self, resource_group_name, server_name, state, custom_headers=None, raw=False, **operation_config): + parameters = models.ServerSecurityAlertPolicy(state=state) + # Construct URL url = self.create_or_update.metadata['url'] path_format_arguments = { @@ -158,7 +160,7 @@ def _create_or_update_initial( return deserialized def create_or_update( - self, resource_group_name, server_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + self, resource_group_name, server_name, state, custom_headers=None, raw=False, polling=True, **operation_config): """Creates or updates a threat detection policy. :param resource_group_name: The name of the resource group. The name @@ -166,9 +168,10 @@ def create_or_update( :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param parameters: The server security alert policy. - :type parameters: - ~azure.mgmt.rdbms.postgresql.models.ServerSecurityAlertPolicy + :param state: Specifies the state of the policy, whether it is enabled + or disabled. Possible values include: 'Enabled', 'Disabled' + :type state: str or + ~azure.mgmt.rdbms.postgresql.models.ServerSecurityAlertPolicyState :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response @@ -186,7 +189,7 @@ def create_or_update( raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, server_name=server_name, - parameters=parameters, + state=state, custom_headers=custom_headers, raw=True, **operation_config @@ -209,3 +212,76 @@ def get_long_running_output(response): else: polling_method = polling return LROPoller(self._client, raw_result, get_long_running_output, polling_method) create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName}'} + + def list_by_server( + self, resource_group_name, server_name, custom_headers=None, raw=False, **operation_config): + """Get the server's threat detection policies. + + :param resource_group_name: The name of the resource group. The name + is case insensitive. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of ServerSecurityAlertPolicy + :rtype: + ~azure.mgmt.rdbms.postgresql.models.ServerSecurityAlertPolicyPaged[~azure.mgmt.rdbms.postgresql.models.ServerSecurityAlertPolicy] + :raises: :class:`CloudError` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_server.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverName': self._serialize.url("server_name", server_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.ServerSecurityAlertPolicyPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/servers/{serverName}/securityAlertPolicies'} diff --git a/sdk/rdbms/azure-mgmt-rdbms/setup.py b/sdk/rdbms/azure-mgmt-rdbms/setup.py index ccc2d30de0d8..60fdabe1cfc7 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/setup.py +++ b/sdk/rdbms/azure-mgmt-rdbms/setup.py @@ -36,7 +36,9 @@ pass # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1)