mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00: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:
@@ -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."
|
||||
|
||||
@@ -28,7 +28,6 @@ options:
|
||||
description:
|
||||
- The HTTP Method of the request or response.
|
||||
type: str
|
||||
choices: [ CONNECT, DELETE, GET, HEAD, MERGE, OPTIONS, PATCH, POST, PUT, REFRESH, TRACE ]
|
||||
default: GET
|
||||
content_type:
|
||||
description:
|
||||
|
||||
Reference in New Issue
Block a user