mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Using Get-AnsibleParam
conflict typo
This commit is contained in:
parent
a979624b88
commit
88e4faa1ac
2 changed files with 36 additions and 25 deletions
|
@ -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)
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
DOCUMENTATION = """
|
DOCUMENTATION = """
|
||||||
---
|
---
|
||||||
module: win_uri
|
module: win_uri
|
||||||
version_added: ""
|
version_added: "2.0"
|
||||||
short_description: Interacts with webservices.
|
short_description: Interacts with webservices.
|
||||||
description:
|
description:
|
||||||
- Interacts with HTTP and HTTPS services.
|
- Interacts with HTTP and HTTPS services.
|
||||||
|
@ -32,10 +32,12 @@ options:
|
||||||
url:
|
url:
|
||||||
description:
|
description:
|
||||||
- HTTP or HTTPS URL in the form of (http|https)://host.domain:port/path
|
- HTTP or HTTPS URL in the form of (http|https)://host.domain:port/path
|
||||||
|
required: true
|
||||||
method:
|
method:
|
||||||
description:
|
description:
|
||||||
- The HTTP Method of the request or response.
|
- The HTTP Method of the request or response.
|
||||||
default: GET
|
default: GET
|
||||||
|
required: false
|
||||||
choices:
|
choices:
|
||||||
- GET
|
- GET
|
||||||
- POST
|
- POST
|
||||||
|
@ -53,13 +55,17 @@ options:
|
||||||
body:
|
body:
|
||||||
description:
|
description:
|
||||||
- The body of the HTTP request/response to the web service.
|
- The body of the HTTP request/response to the web service.
|
||||||
|
required: false
|
||||||
|
default: None
|
||||||
headers:
|
headers:
|
||||||
description:
|
description:
|
||||||
- Key Value pairs for headers. Example "Host: www.somesite.com"
|
- Key Value pairs for headers. Example "Host: www.somesite.com"
|
||||||
author: Corwin Brown
|
required: false
|
||||||
|
default: None
|
||||||
|
author: Corwin Brown (@blakfeld)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Examples= """
|
Examples = """
|
||||||
# Send a GET request and store the output:
|
# Send a GET request and store the output:
|
||||||
---
|
---
|
||||||
- name: Perform a GET and Store Output
|
- name: Perform a GET and Store Output
|
||||||
|
@ -90,4 +96,19 @@ Examples= """
|
||||||
url: http://www.somesite.com
|
url: http://www.somesite.com
|
||||||
method: POST
|
method: POST
|
||||||
body: "{ 'some': 'json' }"
|
body: "{ 'some': 'json' }"
|
||||||
|
|
||||||
|
# Check if a file is available on a webserver
|
||||||
|
---
|
||||||
|
- name: Ensure Build is Available on Fileserver
|
||||||
|
when: ensure_build
|
||||||
|
win_uri:
|
||||||
|
url: "http://www.somesite.com"
|
||||||
|
method: HEAD
|
||||||
|
headers:
|
||||||
|
test: one
|
||||||
|
another: two
|
||||||
|
register: build_check_output
|
||||||
|
until: build_check_output.StatusCode == 200
|
||||||
|
retries: 30
|
||||||
|
delay: 10
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue