|
|
@ -1,7 +1,7 @@
|
|
|
|
#!powershell
|
|
|
|
#!powershell
|
|
|
|
# This file is part of Ansible
|
|
|
|
# This file is part of Ansible
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Copyright 2015, Corwin Brown <blakfeld@gmail.com>
|
|
|
|
# Copyright 2015, Corwin Brown <corwin.brown@maxpoint.com>
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Ansible is free software: you can redistribute it and/or modify
|
|
|
|
# Ansible is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
@ -27,32 +27,22 @@ $result = New-Object psobject @{
|
|
|
|
|
|
|
|
|
|
|
|
# Build Arguments
|
|
|
|
# Build Arguments
|
|
|
|
$webrequest_opts = @{}
|
|
|
|
$webrequest_opts = @{}
|
|
|
|
if (Get-Member -InputObject $params -Name url) {
|
|
|
|
|
|
|
|
$url = $params.url.ToString()
|
|
|
|
|
|
|
|
$webrequest_opts.Uri = $url
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Fail-Json $result "Missing required argument: url"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Get-Member -InputObject $params -Name method) {
|
|
|
|
$url = Get-AnsibleParam -obj $params -name "url" -failifempty $true
|
|
|
|
$method = $params.method.ToString()
|
|
|
|
$method = Get-AnsibleParam -obj $params "method" -default "GET"
|
|
|
|
$webrequest_opts.Method = $method
|
|
|
|
$content_type = Get-AnsibleParam -obj $params -name "content_type"
|
|
|
|
}
|
|
|
|
$body = Get-AnsibleParam -obj $params -name "body"
|
|
|
|
|
|
|
|
|
|
|
|
if (Get-Member -InputObject $params -Name content_type) {
|
|
|
|
$webrequest_opts.Uri = $url
|
|
|
|
$content_type = $params.method.content_type.ToString()
|
|
|
|
Set-Attr $result.win_uri "url" $url
|
|
|
|
$webrequest_opts.ContentType = $content_type
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Get-Member -InputObject $params -Name body) {
|
|
|
|
@webrequest_opts.Method = $method
|
|
|
|
$body = $params.method.body.ToString()
|
|
|
|
Set-Attr $result.win_uri "method" $method
|
|
|
|
$webrequest_opts.Body = $body
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Get-Member -InputObject $params -Name headers) {
|
|
|
|
@webrequest_opts.content_type = $content_type
|
|
|
|
$headers = $params.headers
|
|
|
|
Set-Attr $result.content_type "content_type" $content_type
|
|
|
|
Set-Attr $result.win_uri "headers" $headers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($headers -ne $null) {
|
|
|
|
$req_headers = @{}
|
|
|
|
$req_headers = @{}
|
|
|
|
ForEach ($header in $headers.psobject.properties) {
|
|
|
|
ForEach ($header in $headers.psobject.properties) {
|
|
|
|
$req_headers.Add($header.Name, $header.Value)
|
|
|
|
$req_headers.Add($header.Name, $header.Value)
|
|
|
|