2015-10-13 14:47:56 +00:00
#!/usr/bin/python
# -*- coding: utf-8 -*-
2016-03-02 14:36:53 +00:00
# (c) 2015, Corwin Brown <corwin@corwinbrown.com>
2015-10-13 14:47:56 +00:00
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# this is a windows documentation stub. actual code lives in the .ps1
# file of the same name
2016-12-06 10:35:25 +00:00
ANSIBLE_METADATA = { ' status ' : [ ' preview ' ] ,
' supported_by ' : ' community ' ,
' version ' : ' 1.0 ' }
2017-01-19 01:57:33 +00:00
DOCUMENTATION = r '''
2015-10-13 14:47:56 +00:00
- - -
module : win_uri
2016-02-08 21:15:05 +00:00
version_added : " 2.1 "
2015-10-13 14:47:56 +00:00
short_description : Interacts with webservices .
description :
2016-03-02 14:36:53 +00:00
- Interacts with HTTP and HTTPS web services and supports Digest , Basic and WSSE HTTP authentication mechanisms .
2015-10-13 14:47:56 +00:00
options :
url :
description :
- HTTP or HTTPS URL in the form of ( http | https ) : / / host . domain : port / path
2017-01-27 23:24:32 +00:00
required : True
2015-10-13 14:47:56 +00:00
method :
description :
- The HTTP Method of the request or response .
default : GET
choices :
- GET
- POST
- PUT
- HEAD
- DELETE
- OPTIONS
- PATCH
- TRACE
- CONNECT
- REFRESH
content_type :
description :
- Sets the " Content-Type " header .
body :
description :
- The body of the HTTP request / response to the web service .
2017-01-04 21:33:47 +00:00
dest :
version_added : " 2.3 "
description :
- Output the response body to a file .
2015-10-13 14:47:56 +00:00
headers :
description :
2016-03-02 14:36:53 +00:00
- ' Key Value pairs for headers. Example " Host: www.somesite.com " '
2016-02-08 21:15:05 +00:00
use_basic_parsing :
description :
- This module relies upon ' Invoke-WebRequest ' , which by default uses the Internet Explorer Engine to parse a webpage . There ' s an edge-case where if a user hasn ' t run IE before , this will fail . The only advantage to using the Internet Explorer praser is that you can traverse the DOM in a powershell script . That isn ' t useful for Ansible, so by default we toggle ' UseBasicParsing ' . However, you can toggle that off here.
choices :
- True
- False
default : True
2015-10-27 20:02:02 +00:00
author : Corwin Brown ( @blakfeld )
2017-01-19 01:57:33 +00:00
'''
2015-10-13 14:47:56 +00:00
2017-01-19 01:57:33 +00:00
EXAMPLES = r '''
2015-10-13 14:47:56 +00:00
- name : Perform a GET and Store Output
win_uri :
2016-12-15 18:38:02 +00:00
url : http : / / example . com / endpoint
2015-10-13 14:47:56 +00:00
register : http_output
# Set a HOST header to hit an internal webserver:
- name : Hit a Specific Host on the Server
win_uri :
2017-01-27 23:24:32 +00:00
url : http : / / example . com /
2015-10-13 14:47:56 +00:00
method : GET
headers :
2016-12-15 18:38:02 +00:00
host : www . somesite . com
2015-10-13 14:47:56 +00:00
- name : Perform a HEAD on an Endpoint
win_uri :
2017-01-27 23:24:32 +00:00
url : http : / / www . example . com /
2015-10-13 14:47:56 +00:00
method : HEAD
- name : POST a Body to an Endpoint
win_uri :
2017-01-27 23:24:32 +00:00
url : http : / / www . somesite . com /
2015-10-13 14:47:56 +00:00
method : POST
body : " { ' some ' : ' json ' } "
2017-01-19 01:57:33 +00:00
'''
2015-10-27 20:02:02 +00:00
2017-01-19 01:57:33 +00:00
RETURN = r '''
2016-02-08 21:15:05 +00:00
url :
description : The Target URL
returned : always
type : string
2017-01-27 23:24:32 +00:00
sample : https : / / www . ansible . com
2016-02-08 21:15:05 +00:00
method :
description : The HTTP method used .
returned : always
type : string
2017-01-27 23:24:32 +00:00
sample : GET
2016-02-08 21:15:05 +00:00
content_type :
description : The " content-type " header used .
returned : always
type : string
2017-01-27 23:24:32 +00:00
sample : application / json
2016-02-08 21:15:05 +00:00
use_basic_parsing :
description : The state of the " use_basic_parsing " flag .
returned : always
type : bool
sample : True
2016-11-07 21:04:09 +00:00
body :
2016-12-08 05:34:16 +00:00
description : The content of the body used
2016-11-07 21:04:09 +00:00
returned : when body is specified
type : string
sample : ' { " id " :1} '
2016-12-08 05:34:16 +00:00
version_added : " 2.3 "
2016-03-02 14:36:53 +00:00
status_code :
2016-02-08 21:15:05 +00:00
description : The HTTP Status Code of the response .
returned : success
type : int
sample : 200
2016-03-02 14:36:53 +00:00
status_description :
2016-02-08 21:15:05 +00:00
description : A summery of the status .
returned : success
type : string
2017-01-27 23:24:32 +00:00
sample : OK
2016-03-02 14:36:53 +00:00
raw_content :
2016-02-08 21:15:05 +00:00
description : The raw content of the HTTP response .
returned : success
type : string
sample : ' HTTP/1.1 200 OK \n X-XSS-Protection: 1; mode=block \n X-Frame-Options: SAMEORIGIN \n Alternate-Protocol: 443:quic,p=1 \n Alt-Svc: quic= " www.google.com:443 " ; ma=2592000; v= " 30,29,28,27,26,25 " ,quic= " :443 " ; ma=2... '
2016-03-02 14:36:53 +00:00
headers :
2016-02-08 21:15:05 +00:00
description : The Headers of the response .
returned : success
type : dict
sample : { " Content-Type " : " application/json " }
2016-03-02 14:36:53 +00:00
raw_content_length :
2016-02-08 21:15:05 +00:00
description : The byte size of the response .
returned : success
type : int
sample : 54447
2017-01-19 01:57:33 +00:00
'''