예제 #1
0
def main():
    module = get_playbook_vars()
    api_name = module.params['api_name']
    api_team = module.params['api_team']
    api_swagger = module.params['api_swagger']
    api_quota = module.params['api_quota']
    api_description = module.params['api_description']
    api_spike_arrest = module.params['api_spike_arrest']
    none_auth_api_methods = module.params['none_auth_api_methods']
    api_base_path = module.params['api_base_path']
    api_proxy_base_path = '/api'
    api_cors = module.params['api_cors']
    api_proxy_tag = module.params['api_proxy_tag']

    if not api_base_path.startswith('/', 0, 1):
        api_base_path = '/' + api_base_path
    changed = False
    try:
        proxy_bundle = proxy_builder(api_name, api_team, api_description, api_base_path, api_proxy_base_path)\
            .proxy_for_ctportal(api_swagger, api_proxy_tag)

        proxy_bundle = create_policies(proxy_bundle, api_quota,
                                       api_spike_arrest, none_auth_api_methods,
                                       api_cors)
        bundle_path = zip_proxy_bundle(api_name, proxy_bundle)
        changed = True
        module.exit_json(changed=changed,
                         msg="Proxy XML bundle was generated successfully",
                         response=bundle_path)
    except Exception as e:
        print(e)
        module.fail_json(
            changed=changed,
            msg="Proxy could not be generated, error was:{}".format(e))
def main():
    module = get_playbook_vars()
    api_name = module.params['api_name']
    api_description = module.params['api_description']
    api_base_path = module.params['api_base_path']
    api_team = module.params['api_team']
    api_implementation = module.params['api_implementation']
    api_url = re.match('https?://[^/]*', module.params['api_url'])
    api_url = api_url.group(0)
    api_proxy_base_path = module.params['api_proxy_base_path']
    if api_implementation:
        api_prefix = api_team + '_' + api_implementation
    else:
        api_prefix = api_team
    if not api_base_path.startswith('/', 0, 1):
        api_base_path = '/' + api_base_path
    changed = False
    try:
        proxy_bundle = proxy_builder(api_name, api_team, api_description, api_base_path, api_proxy_base_path)\
            .microgateway_aware(api_prefix, api_url, api_base_path)
        bundle_path = zip_proxy_bundle(api_name, proxy_bundle)
        changed = True
        module.exit_json(changed=changed,
                         msg="Proxy XML bundle was generated successfully",
                         response=bundle_path)
    except Exception as e:
        print(e)
        module.fail_json(
            changed=changed,
            msg="Proxy could not be generated, error was:{}".format(e))
예제 #3
0
 def _new_proxy():
     proxy = proxy_builder('test_api_name', 'apim', 'test description', '/api', '/api') \
         .proxy_for_ctportal(swagger, '1.0.0')
     return proxy
예제 #4
0
 def _new_microgateway():
     micro_proxy = proxy_builder('test_api_name', 'apim', 'test description', '/api', '/api').\
                   microgateway_aware('my-api-team', 'www.google.com', '/api')
     return micro_proxy