Use fetch_url's basic auth instead of code specific to this module
This commit is contained in:
parent
9f57c1b114
commit
8be4ffd07c
1 changed files with 5 additions and 6 deletions
|
@ -20,8 +20,6 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
import base64
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = '''
|
||||||
---
|
---
|
||||||
module: librato_annotation
|
module: librato_annotation
|
||||||
|
@ -29,9 +27,8 @@ short_description: create an annotation in librato
|
||||||
description:
|
description:
|
||||||
- Create an annotation event on the given annotation stream :name. If the annotation stream does not exist, it will be created automatically
|
- Create an annotation event on the given annotation stream :name. If the annotation stream does not exist, it will be created automatically
|
||||||
version_added: "1.6"
|
version_added: "1.6"
|
||||||
author: Seth Edwards
|
author: "Seth Edwards (@sedward)"
|
||||||
requirements:
|
requirements: []
|
||||||
- base64
|
|
||||||
options:
|
options:
|
||||||
user:
|
user:
|
||||||
description:
|
description:
|
||||||
|
@ -130,8 +127,10 @@ def post_annotation(module):
|
||||||
|
|
||||||
headers = {}
|
headers = {}
|
||||||
headers['Content-Type'] = 'application/json'
|
headers['Content-Type'] = 'application/json'
|
||||||
headers['Authorization'] = "Basic " + base64.b64encode(user + ":" + api_key).strip()
|
|
||||||
|
|
||||||
|
# Hack send parameters the way fetch_url wants them
|
||||||
|
module.params['url_username'] = user
|
||||||
|
module.params['url_password'] = api_key
|
||||||
response, info = fetch_url(module, url, data=json_body, headers=headers)
|
response, info = fetch_url(module, url, data=json_body, headers=headers)
|
||||||
if info['status'] != 200:
|
if info['status'] != 200:
|
||||||
module.fail_json(msg="Request Failed", reason=e.reason)
|
module.fail_json(msg="Request Failed", reason=e.reason)
|
||||||
|
|
Loading…
Reference in a new issue