Esempio n. 1
0
def clients_in_shell(stage, api_url, api_token, search_api_url,
                     search_api_token):
    print('Retrieving credentials...')
    api_token = api_token or get_auth_token('api', stage)
    search_api_token = search_api_token or get_auth_token('search_api', stage)

    print('Creating clients...')
    data = DataAPIClient(api_url or get_api_endpoint_from_stage(stage),
                         api_token)  # noqa
    search = SearchAPIClient(
        search_api_url or get_api_endpoint_from_stage(stage, app='search-api'),
        search_api_token)  # noqa

    print('Dropping into shell...')
    IPython.embed()
Esempio n. 2
0
def clients_in_shell(stage):
    print('Retrieving credentials...')
    api_token = 'myToken'
    search_api_token = 'myToken'

    if stage != 'development':
        api_token = get_auth_token('api', stage),
        search_api_token = get_auth_token('search_api', stage)

    print('Creating clients...')
    data = DataAPIClient(get_api_endpoint_from_stage(stage), api_token)  # noqa
    search = SearchAPIClient(get_api_endpoint_from_stage(stage, app='search-api'), search_api_token)  # noqa

    print('Dropping into shell...')
    IPython.embed()
        )
        sys.exit(1)

    args.lots = args.lots.lower().split(',')
    if set(args.lots) - set(LOTS_WHITELIST):
        print(
            "This script only allows the following lots: {}. If you need other lots, please add them to the "
            "whitelist (this is just a sanity-check against typos).".format(
                LOTS_WHITELIST))
        sys.exit(1)

    data_api_url = get_api_endpoint_from_stage(args.env, 'api')
    data_api_client = DataAPIClient(data_api_url, args.data_api_token)

    search_api_url = get_api_endpoint_from_stage(args.env, 'search-api')
    search_api_client = SearchAPIClient(search_api_url, args.search_api_token)

    services_generated = 0
    gcloud_service_faker = JsonSchemaGCloudServiceFaker()
    email_address = "*****@*****.**"
    identity = 'generate-g-cloud-services script ({})'.format(
        getpass.getuser())
    filepath_declaration_validator = 'schemas/{}.declaration.json'.format(
        args.new_slug)

    # 0) Store the current framework state so that it can be restored at the end.
    current_framework_state = data_api_client.get_framework(
        args.new_slug)['frameworks']['status']

    # 1) Set a given (new) framework to open
    data_api_client._post_with_updated_by(
Esempio n. 4
0
def search_client():
    return SearchAPIClient('http://baseurl', 'auth-token', True)
    print(f"Setting user to '{user}'...")

    print('Retrieving credentials...')
    api_token = args.api_token or get_auth_token('api', stage)
    search_api_token = args.search_api_token or get_auth_token(
        'search_api', stage)

    print('Creating clients...')
    data = DataAPIClient(
        base_url=args.api_url or get_api_endpoint_from_stage(stage),
        auth_token=api_token,
        user=user,
    )
    search = SearchAPIClient(
        base_url=args.search_api_url
        or get_api_endpoint_from_stage(stage, app='search-api'),
        auth_token=search_api_token,
        user=user,
    )

    if args.read_only:
        data = ReadOnlyDataAPIClient(data)

    ipython_config = Config()
    ipython_config.TerminalInteractiveShell.prompts_class = DMEnvironmentPrompt(
        stage, args.read_only)

    print('Dropping into shell...')
    IPython.start_ipython(argv=[],
                          config=ipython_config,
                          user_ns={
                              "data": data,
#!/usr/bin/env python
"""

Usage:
    set-search-alias.py <stage> <search_api_token> <alias> <index>
"""

import sys
from docopt import docopt

sys.path.insert(0, '.')
from dmscripts.env import get_api_endpoint_from_stage
from dmapiclient import SearchAPIClient


if __name__ == '__main__':
    arguments = docopt(__doc__)

    search_api_url = get_api_endpoint_from_stage(arguments['<stage>'], 'search-api')
    search_api_token = arguments['<search_api_token>']

    client = SearchAPIClient(search_api_url, arguments['<search_api_url>'])
    client.set_alias(arguments['<alias>'], arguments['<index>'])