mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-19 14:50:21 -07:00
uri/win_uri: Make method a free text field (#49719)
* uri/win_uri: Make method a free text field Since various interfaces introduce their own HTTP method (e.g. like PROPFIND, LIST or TRACE) it's better to leave this up to the user. * Fix HTTP method check in module_utils urls * Add integration test for method UNKNOWN * Clarify the change as requested during review
This commit is contained in:
parent
81ec48c7b4
commit
4e6c113bf0
7 changed files with 50 additions and 11 deletions
|
@ -15,7 +15,6 @@ $spec = @{
|
|||
method = @{
|
||||
type = "str"
|
||||
default = "GET"
|
||||
choices = "CONNECT", "DELETE", "GET", "HEAD", "MERGE", "OPTIONS", "PATCH", "POST", "PUT", "REFRESH", "TRACE"
|
||||
}
|
||||
content_type = @{ type = "str" }
|
||||
headers = @{ type = "dict" }
|
||||
|
@ -44,7 +43,7 @@ $spec = @{
|
|||
$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec)
|
||||
|
||||
$url = $module.Params.url
|
||||
$method = $module.Params.method
|
||||
$method = $module.Params.method.ToUpper()
|
||||
$content_type = $module.Params.content_type
|
||||
$headers = $module.Params.headers
|
||||
$body = $module.Params.body
|
||||
|
@ -68,6 +67,10 @@ $JSON_CANDIDATES = @('text', 'json', 'javascript')
|
|||
$module.Result.elapsed = 0
|
||||
$module.Result.url = $url
|
||||
|
||||
if (-not ($method -cmatch '^[A-Z]+$')) {
|
||||
$module.FailJson("Parameter 'method' needs to be a single word in uppercase, like GET or POST.")
|
||||
}
|
||||
|
||||
if ($creates -and (Test-AnsiblePath -Path $creates)) {
|
||||
$module.Result.skipped = $true
|
||||
$module.Result.msg = "The 'creates' file or directory ($creates) already exists."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue