def do_environment_model_edit(mc, args): """Edit an environment's object model.""" jp_obj = None if not args.filename: jp_obj = json.load(sys.stdin) else: with open(args.filename) as fpatch: jp_obj = json.load(fpatch) if not isinstance(jp_obj, list): raise exceptions.CommandError('JSON-patch must be a list of changes') for change in jp_obj: if 'op' not in change or 'path' not in change: raise exceptions.CommandError('Every change in JSON-patch must ' 'contain "op" and "path" keys') op = change['op'] if op not in ['add', 'replace', 'remove']: raise exceptions.CommandError('The value of "op" item must be ' '"add", "replace" or "remove", ' 'got {0}'.format(op)) if op != 'remove' and 'value' not in change: raise exceptions.CommandError('"add" or "replace" change in ' 'JSON-patch must contain "value" ' 'key') session_id = args.session_id new_model = mc.environments.update_model(args.id, jp_obj, session_id) print(utils.json_formatter(new_model))
def do_environment_model_edit(mc, args): """Edit an environment's object model.""" jp_obj = None if not args.filename: jp_obj = json.load(sys.stdin) else: with open(args.filename) as fpatch: jp_obj = json.load(fpatch) if not isinstance(jp_obj, list): raise exceptions.CommandError('JSON-patch must be a list of changes') for change in jp_obj: if 'op' not in change or 'path' not in change: raise exceptions.CommandError('Every change in JSON-patch must ' 'contain "op" and "path" keys') op = change['op'] if op not in ['add', 'replace', 'remove']: raise exceptions.CommandError('The value of "op" item must be ' '"add", "replace" or "remove", ' 'got {0}'.format(op)) if op != 'remove' and 'value' not in change: raise exceptions.CommandError('"add" or "replace" change in ' 'JSON-patch must contain "value" ' 'key') session_id = args.session_id new_model = mc.environments.update_model(args.id, jp_obj, session_id) print(utils.json_formatter(new_model))
def do_class_schema(mc, args): """Display class schema""" schema = mc.schemas.get(args.class_name, args.method_names, class_version=args.class_version, package_name=args.package_name) print(utils.json_formatter(schema.data))
def do_environment_show(mc, args): """Display environment details.""" try: environment = utils.find_resource( mc.environments, args.id, session_id=args.session_id) except exceptions.NotFound: raise exceptions.CommandError("Environment %s not found" % args.id) else: if getattr(args, 'only_apps', False): print(utils.json_formatter(environment.services)) else: formatters = { "id": utils.text_wrap_formatter, "created": utils.text_wrap_formatter, "name": utils.text_wrap_formatter, "tenant_id": utils.text_wrap_formatter, "services": utils.json_formatter, } utils.print_dict(environment.to_dict(), formatters=formatters)
def do_environment_show(mc, args): """Display environment details.""" try: environment = utils.find_resource(mc.environments, args.id, session_id=args.session_id) except exceptions.NotFound: raise exceptions.CommandError("Environment %s not found" % args.id) else: if getattr(args, 'only_apps', False): print(utils.json_formatter(environment.services)) else: formatters = { "id": utils.text_wrap_formatter, "created": utils.text_wrap_formatter, "name": utils.text_wrap_formatter, "tenant_id": utils.text_wrap_formatter, "services": utils.json_formatter, } utils.print_dict(environment.to_dict(), formatters=formatters)
def do_environment_model_show(mc, args): """Display an environment's object model.""" session_id = args.session_id or None path = six.moves.urllib.parse.quote(args.path) env_model = mc.environments.get_model(args.id, path, session_id) print(utils.json_formatter(env_model))
def do_class_schema(mc, args): """Display class schema""" schema = mc.schemas.get(args.class_name, args.method_names, class_version=args.class_version, package_name=args.package_name) print(utils.json_formatter(schema.data))
def do_environment_model_show(mc, args): """Display an environment's object model.""" session_id = args.session_id or None path = six.moves.urllib.parse.quote(args.path) env_model = mc.environments.get_model(args.id, path, session_id) print(utils.json_formatter(env_model))