Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SQL DB, SQL MI] Add minimal_tls_version property for MI and SQL DB #12414

Merged
merged 19 commits into from
Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/azure-cli/azure/cli/command_modules/sql/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
ComputeModelType,
DatabaseCapabilitiesAdditionalDetails,
ElasticPoolCapabilitiesAdditionalDetails,
FailoverPolicyType
FailoverPolicyType,
SqlServerMinimalTlsVersionType,
SqlManagedInstanceMinimalTlsVersionType
)

from ._validators import (
Expand Down Expand Up @@ -1039,6 +1041,10 @@ def _configure_security_policy_storage_params(arg_ctx):
help='Generate and assign an Azure Active Directory Identity for this server'
'for use with key management services like Azure KeyVault.')

c.argument('minimal_tls_version',
arg_type=get_enum_type(SqlServerMinimalTlsVersionType),
Copy link
Contributor

@Juliehzl Juliehzl Mar 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Can we mark the parameter as preview by adding is_preview=True to give a sprint time to test the parameter behavior with the following flag?
  2. Do you have a default value for the parameter?

help='The minimal TLS version enforced by the sql server for inbound connections.')

c.argument('enable_public_network',
options_list=['--enable-public-network', '-e'],
arg_type=get_three_state_flag(),
Expand All @@ -1055,7 +1061,8 @@ def _configure_security_policy_storage_params(arg_ctx):
c, 'parameters', Server, [
'administrator_login',
'administrator_login_password',
'location'
'location',
'minimal_tls_version'
])

c.argument('administrator_login',
Expand Down Expand Up @@ -1253,6 +1260,11 @@ def _configure_security_policy_storage_params(arg_ctx):
arg_type=get_enum_type(ServerConnectionType),
help='The connection type used for connecting to the instance.')

c.argument('minimal_tls_version',
arg_type=get_enum_type(SqlManagedInstanceMinimalTlsVersionType),
help='The minimal TLS version enforced by the managed instance for inbound connections.',
is_preview=True)

c.argument('public_data_endpoint_enabled',
arg_type=get_three_state_flag(),
help='Whether or not the public data endpoint is enabled for the instance.')
Expand All @@ -1271,6 +1283,7 @@ def _configure_security_policy_storage_params(arg_ctx):
'administrator_login',
'administrator_login_password',
'license_type',
'minimal_tls_version',
'virtual_network_subnet_id',
'vcores',
'storage_size_in_gb',
Expand Down
21 changes: 20 additions & 1 deletion src/azure-cli/azure/cli/command_modules/sql/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,19 @@ class FailoverPolicyType(Enum):
manual = 'Manual'


class SqlServerMinimalTlsVersionType(Enum):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should have defined this enum in swagger so that it showed up in generated sdk. Then you wouldn't need to define it here. This is what I was asking about on your swagger review. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sorry about that, we have plans to fix it and do it the right way :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, please do :)

tls_1_0 = "1.0"
tls_1_1 = "1.1"
tls_1_2 = "1.2"


class SqlManagedInstanceMinimalTlsVersionType(Enum):
no_tls = "None"
tls_1_0 = "1.0"
tls_1_1 = "1.1"
tls_1_2 = "1.2"


class ComputeModelType(str, Enum):

provisioned = "Provisioned"
Expand Down Expand Up @@ -2015,6 +2028,7 @@ def server_update(
instance,
administrator_login_password=None,
assign_identity=False,
minimal_tls_version=None,
enable_public_network=None):
'''
Updates a server. Custom update function to apply parameters to instance.
Expand All @@ -2027,6 +2041,8 @@ def server_update(
# Apply params to instance
instance.administrator_login_password = (
administrator_login_password or instance.administrator_login_password)
instance.minimal_tls_version = (
minimal_tls_version or instance.minimal_tls_version)

if enable_public_network is not None:
instance.public_network_access = (
Expand Down Expand Up @@ -2372,7 +2388,8 @@ def managed_instance_update(
proxy_override=None,
public_data_endpoint_enabled=None,
tier=None,
family=None):
family=None,
minimal_tls_version=None):
'''
Updates a managed instance. Custom update function to apply parameters to instance.
'''
Expand All @@ -2392,6 +2409,8 @@ def managed_instance_update(
storage_size_in_gb or instance.storage_size_in_gb)
instance.proxy_override = (
proxy_override or instance.proxy_override)
instance.minimal_tls_version = (
minimal_tls_version or instance.minimal_tls_version)

instance.sku.name = None
instance.sku.tier = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 05 Mar 2020 03:58:02 GMT
- Thu, 05 Mar 2020 04:16:29 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -1095,7 +1095,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 05 Mar 2020 03:58:11 GMT
- Thu, 05 Mar 2020 04:16:31 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -1652,7 +1652,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 05 Mar 2020 03:58:25 GMT
- Thu, 05 Mar 2020 04:16:33 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -2209,7 +2209,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 05 Mar 2020 03:58:45 GMT
- Thu, 05 Mar 2020 04:16:34 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -2766,7 +2766,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 05 Mar 2020 03:58:49 GMT
- Thu, 05 Mar 2020 04:16:36 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -3323,7 +3323,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 05 Mar 2020 03:58:54 GMT
- Thu, 05 Mar 2020 04:16:38 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -3880,7 +3880,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 05 Mar 2020 03:59:00 GMT
- Thu, 05 Mar 2020 04:16:40 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -4185,7 +4185,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 05 Mar 2020 03:59:06 GMT
- Thu, 05 Mar 2020 04:16:41 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -4490,7 +4490,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 05 Mar 2020 03:59:15 GMT
- Thu, 05 Mar 2020 04:16:43 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -4795,7 +4795,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 05 Mar 2020 03:59:23 GMT
- Thu, 05 Mar 2020 04:16:45 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -5100,7 +5100,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 05 Mar 2020 03:59:35 GMT
- Thu, 05 Mar 2020 04:16:48 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -5405,7 +5405,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 05 Mar 2020 03:59:44 GMT
- Thu, 05 Mar 2020 04:16:50 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -5710,7 +5710,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 05 Mar 2020 03:59:56 GMT
- Thu, 05 Mar 2020 04:16:52 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -6015,7 +6015,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 05 Mar 2020 04:00:08 GMT
- Thu, 05 Mar 2020 04:16:54 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -6320,7 +6320,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 05 Mar 2020 04:00:16 GMT
- Thu, 05 Mar 2020 04:16:57 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -6625,7 +6625,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Thu, 05 Mar 2020 04:00:26 GMT
- Thu, 05 Mar 2020 04:16:58 GMT
expires:
- '-1'
pragma:
Expand Down
Loading