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

azure_rm_sqldatabase: parse datetime module arguments #623

Merged
merged 8 commits into from
Feb 25, 2022
15 changes: 11 additions & 4 deletions plugins/modules/azure_rm_sqldatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@

import time
from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common import AzureRMModuleBase, format_resource_id
import dateutil.parser
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
import dateutil.parser


try:
from msrestazure.azure_exceptions import CloudError
nbr23 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -308,10 +309,10 @@ def __init__(self):
type='str'
),
source_database_deletion_date=dict(
type='datetime'
type='str'
),
restore_point_in_time=dict(
type='datetime'
type='str'
),
recovery_services_recovery_point_resource_id=dict(
type='str'
Expand Down Expand Up @@ -393,9 +394,15 @@ def exec_module(self, **kwargs):
elif key == "source_database_id":
self.parameters["source_database_id"] = kwargs[key]
elif key == "source_database_deletion_date":
self.parameters["source_database_deletion_date"] = kwargs[key]
try:
self.parameters["source_database_deletion_date"] = dateutil.parser.parse(kwargs[key])
except dateutil.parser._parser.ParserError:
self.fail("Error parsing date from source_database_deletion_date: {0}".format(kwargs[key]))
elif key == "restore_point_in_time":
self.parameters["restore_point_in_time"] = kwargs[key]
try:
self.parameters["restore_point_in_time"] = dateutil.parser.parse(kwargs[key])
except dateutil.parser._parser.ParserError:
self.fail("Error parsing date from restore_point_in_time: {0}".format(kwargs[key]))
elif key == "recovery_services_recovery_point_resource_id":
self.parameters["recovery_services_recovery_point_resource_id"] = kwargs[key]
elif key == "edition":
Expand Down
1 change: 0 additions & 1 deletion tests/sanity/ignore-2.10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ plugins/modules/azure_rm_servicebussaspolicy.py validate-modules:doc-required-mi
plugins/modules/azure_rm_snapshot.py validate-modules:doc-required-mismatch
plugins/modules/azure_rm_snapshot.py validate-modules:invalid-ansiblemodule-schema
plugins/modules/azure_rm_sqldatabase.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_sqldatabase.py validate-modules:invalid-ansiblemodule-schema
plugins/modules/azure_rm_sqldatabase_info.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_sqldatabase_info.py validate-modules:parameter-list-no-elements
plugins/modules/azure_rm_sqlfirewallrule.py validate-modules:parameter-type-not-in-doc
Expand Down