PEP-8 style fixes

This commit is contained in:
Nick Harring 2015-05-06 09:43:38 -07:00
parent dd02f24df9
commit c0ca227717

View file

@ -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,14 +100,15 @@ 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):
'''Takes api token, returns headers with it included.'''
headers = {'X-Circonus-App-Name': 'ansible', headers = {'X-Circonus-App-Name': 'ansible',
'Host': 'api.circonus.com', 'X-Circonus-Auth-Token': api_token, 'Host': 'api.circonus.com', 'X-Circonus-Auth-Token': api_token,
'Accept': 'application/json'} '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'),
@ -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()