PEP-8 style fixes
This commit is contained in:
parent
dd02f24df9
commit
c0ca227717
1 changed files with 18 additions and 14 deletions
|
@ -71,13 +71,16 @@ EXAMPLES = '''
|
||||||
end_time: 1395954407
|
end_time: 1395954407
|
||||||
'''
|
'''
|
||||||
def post_annotation(annotation, api_key):
|
def post_annotation(annotation, api_key):
|
||||||
|
''' Takes annotation dict and api_key string'''
|
||||||
base_url = 'https://api.circonus.com/v2'
|
base_url = 'https://api.circonus.com/v2'
|
||||||
anootate_post_endpoint = '/annotation'
|
anootate_post_endpoint = '/annotation'
|
||||||
resp = requests.post(base_url + anootate_post_endpoint, headers=build_headers(api_key), data=json.dumps(annotation))
|
resp = requests.post(base_url + anootate_post_endpoint,
|
||||||
|
headers=build_headers(api_key), data=json.dumps(annotation))
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
def create_annotation(module):
|
def create_annotation(module):
|
||||||
|
''' Takes ansible module object '''
|
||||||
annotation = {}
|
annotation = {}
|
||||||
if module.params['duration'] != None:
|
if module.params['duration'] != None:
|
||||||
duration = module.params['duration']
|
duration = module.params['duration']
|
||||||
|
@ -97,23 +100,24 @@ def create_annotation(module):
|
||||||
annotation['description'] = module.params['description']
|
annotation['description'] = module.params['description']
|
||||||
annotation['title'] = module.params['title']
|
annotation['title'] = module.params['title']
|
||||||
return annotation
|
return annotation
|
||||||
|
|
||||||
def build_headers(api_token):
|
def build_headers(api_token):
|
||||||
headers = {'X-Circonus-App-Name': 'ansible',
|
'''Takes api token, returns headers with it included.'''
|
||||||
'Host': 'api.circonus.com', 'X-Circonus-Auth-Token': api_token,
|
headers = {'X-Circonus-App-Name': 'ansible',
|
||||||
'Accept': 'application/json'}
|
'Host': 'api.circonus.com', 'X-Circonus-Auth-Token': api_token,
|
||||||
|
'Accept': 'application/json'}
|
||||||
return headers
|
return headers
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
'''Main function, dispatches logic'''
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec = dict(
|
argument_spec=dict(
|
||||||
start = dict(required=False, type='int'),
|
start=dict(required=False, type='int'),
|
||||||
stop = dict(required=False, type='int'),
|
stop=dict(required=False, type='int'),
|
||||||
category = dict(required=True),
|
category=dict(required=True),
|
||||||
title = dict(required=True),
|
title=dict(required=True),
|
||||||
description = dict(required=True),
|
description=dict(required=True),
|
||||||
duration = dict(required=False, type='int'),
|
duration=dict(required=False, type='int'),
|
||||||
api_key = dict(required=True)
|
api_key=dict(required=True)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
annotation = create_annotation(module)
|
annotation = create_annotation(module)
|
||||||
|
@ -123,5 +127,5 @@ def main():
|
||||||
module.fail_json(msg='Request Failed', reason=e)
|
module.fail_json(msg='Request Failed', reason=e)
|
||||||
module.exit_json(changed=True, annotation=resp.json())
|
module.exit_json(changed=True, annotation=resp.json())
|
||||||
|
|
||||||
from ansible.module_utils.basic import *
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue