mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-25 13:12:46 +00:00
Reformat everything.
This commit is contained in:
parent
3f2213791a
commit
340ff8586d
1008 changed files with 61301 additions and 58309 deletions
|
|
@ -112,39 +112,39 @@ from ansible.module_utils.urls import fetch_url
|
|||
|
||||
|
||||
def post_annotation(module):
|
||||
user = module.params['user']
|
||||
api_key = module.params['api_key']
|
||||
name = module.params['name']
|
||||
title = module.params['title']
|
||||
user = module.params["user"]
|
||||
api_key = module.params["api_key"]
|
||||
name = module.params["name"]
|
||||
title = module.params["title"]
|
||||
|
||||
url = f'https://metrics-api.librato.com/v1/annotations/{name}'
|
||||
url = f"https://metrics-api.librato.com/v1/annotations/{name}"
|
||||
params = {}
|
||||
params['title'] = title
|
||||
params["title"] = title
|
||||
|
||||
if module.params['source'] is not None:
|
||||
params['source'] = module.params['source']
|
||||
if module.params['description'] is not None:
|
||||
params['description'] = module.params['description']
|
||||
if module.params['start_time'] is not None:
|
||||
params['start_time'] = module.params['start_time']
|
||||
if module.params['end_time'] is not None:
|
||||
params['end_time'] = module.params['end_time']
|
||||
if module.params['links'] is not None:
|
||||
params['links'] = module.params['links']
|
||||
if module.params["source"] is not None:
|
||||
params["source"] = module.params["source"]
|
||||
if module.params["description"] is not None:
|
||||
params["description"] = module.params["description"]
|
||||
if module.params["start_time"] is not None:
|
||||
params["start_time"] = module.params["start_time"]
|
||||
if module.params["end_time"] is not None:
|
||||
params["end_time"] = module.params["end_time"]
|
||||
if module.params["links"] is not None:
|
||||
params["links"] = module.params["links"]
|
||||
|
||||
json_body = module.jsonify(params)
|
||||
|
||||
headers = {}
|
||||
headers['Content-Type'] = 'application/json'
|
||||
headers["Content-Type"] = "application/json"
|
||||
|
||||
# Hack send parameters the way fetch_url wants them
|
||||
module.params['url_username'] = user
|
||||
module.params['url_password'] = api_key
|
||||
module.params["url_username"] = user
|
||||
module.params["url_password"] = api_key
|
||||
response, info = fetch_url(module, url, data=json_body, headers=headers)
|
||||
response_code = str(info['status'])
|
||||
response_body = info['body']
|
||||
if info['status'] != 201:
|
||||
if info['status'] >= 400:
|
||||
response_code = str(info["status"])
|
||||
response_body = info["body"]
|
||||
if info["status"] != 201:
|
||||
if info["status"] >= 400:
|
||||
module.fail_json(msg=f"Request Failed. Response code: {response_code} Response body: {response_body}")
|
||||
else:
|
||||
module.fail_json(msg=f"Request Failed. Response code: {response_code}")
|
||||
|
|
@ -153,7 +153,6 @@ def post_annotation(module):
|
|||
|
||||
|
||||
def main():
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
user=dict(required=True),
|
||||
|
|
@ -162,14 +161,14 @@ def main():
|
|||
title=dict(required=True),
|
||||
source=dict(),
|
||||
description=dict(),
|
||||
start_time=dict(type='int'),
|
||||
end_time=dict(type='int'),
|
||||
links=dict(type='list', elements='dict')
|
||||
start_time=dict(type="int"),
|
||||
end_time=dict(type="int"),
|
||||
links=dict(type="list", elements="dict"),
|
||||
)
|
||||
)
|
||||
|
||||
post_annotation(module)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue