async def rest_api_suiteql(config, args) -> str: rest_api = _get_rest_api_or_error(config) with args.q_file as fh: q = fh.read() resp = await rest_api.suiteql(q=q, limit=args.limit, offset=args.offset) return json.dumps_str(resp)
async def rest_api_patch(config, args) -> str: rest_api = _get_rest_api_or_error(config) with args.payload_file as fh: payload_str = fh.read() payload = json.loads(payload_str) resp = await rest_api.patch(args.subpath, json=payload) return json.dumps_str(resp)
async def rest_api_get(config, args) -> str: rest_api = _get_rest_api_or_error(config) params = {} if args.expandSubResources is True: params["expandSubResources"] = "true" if args.limit is not None: params["limit"] = args.limit if args.offset is not None: params["offset"] = args.offset if args.fields is not None: params["fields"] = ",".join(args.fields) if args.expand is not None: params["expand"] = ",".join(args.expand) if args.query is not None: params["q"] = args.query resp = await rest_api.get(args.subpath, params=params) return json.dumps_str(resp)
async def rest_api_openapi(config, args) -> str: rest_api = _get_rest_api_or_error(config) resp = await rest_api.openapi(args.record_types) return json.dumps_str(resp)
async def rest_api_jsonschema(config, args) -> str: rest_api = _get_rest_api_or_error(config) resp = await rest_api.jsonschema(args.record_type) return json.dumps_str(resp)
async def rest_api_delete(config, args) -> str: rest_api = _get_rest_api_or_error(config) resp = await rest_api.delete(args.subpath) return json.dumps_str(resp)