Commit 335c4b32 authored by Mark Hewitt's avatar Mark Hewitt
Browse files

search query supports limit

parent ba7192f5
Pipeline #74953 passed with stages
in 2 minutes and 35 seconds
...@@ -28,6 +28,11 @@ For more information, specify the `-h` flag: ...@@ -28,6 +28,11 @@ For more information, specify the `-h` flag:
Change Log Change Log
========== ==========
0.0.22
------
- search query supports limit
0.0.21 0.0.21
------ ------
......
...@@ -51,6 +51,7 @@ setup( ...@@ -51,6 +51,7 @@ setup(
"Natural Language :: English", "Natural Language :: English",
"Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
], ],
keywords="osdu", keywords="osdu",
python_requires=">=3.8", python_requires=">=3.8",
...@@ -58,7 +59,7 @@ setup( ...@@ -58,7 +59,7 @@ setup(
package_dir={"": "src"}, package_dir={"": "src"},
py_modules=[splitext(basename(path))[0] for path in glob("src/*.py")], py_modules=[splitext(basename(path))[0] for path in glob("src/*.py")],
include_package_data=True, include_package_data=True,
install_requires=["click", "jmespath", "osdu-sdk==0.0.7", "requests", "tabulate", "msal"], install_requires=["click", "jmespath", "osdu-sdk==0.0.8", "requests", "tabulate", "msal"],
project_urls={ project_urls={
"Issue Tracker": "https://community.opengroup.org/osdu/platform/data-flow/data-loading/osdu-cli/-/issues", "Issue Tracker": "https://community.opengroup.org/osdu/platform/data-flow/data-loading/osdu-cli/-/issues",
}, },
......
...@@ -12,4 +12,4 @@ ...@@ -12,4 +12,4 @@
""" OSDU command line environment""" """ OSDU command line environment"""
__VERSION__ = "0.0.21" __VERSION__ = "0.0.22"
...@@ -254,7 +254,7 @@ def _ingest_json_as_sequence_file( ...@@ -254,7 +254,7 @@ def _ingest_json_as_sequence_file(
for entry in sequence_file: for entry in sequence_file:
_sequence_run_ids = _ingest_files( _sequence_run_ids = _ingest_files(
config, config,
[entry["FileName"]], get_files_from_path(entry["FileName"]),
files, files,
runid_log, runid_log,
batch_size, batch_size,
......
...@@ -23,14 +23,24 @@ from osducli.cliclient import CliOsduClient, handle_cli_exceptions ...@@ -23,14 +23,24 @@ from osducli.cliclient import CliOsduClient, handle_cli_exceptions
@click.command(cls=CustomClickCommand) @click.command(cls=CustomClickCommand)
@click.option("-k", "--kind", "kind", help="kind to search for") @click.option("-k", "--kind", "kind", help="kind to search for")
@click.option("-id", "--id", "_id", help="id to search for") @click.option("-id", "--id", "_id", help="id to search for")
@click.option(
"-l",
"--limit",
"limit",
default=10,
show_default=True,
help="maximum number of records to return.",
)
@handle_cli_exceptions @handle_cli_exceptions
@command_with_output("results[*].{Id:id,Kind:kind,CreateTime:createTime}") @command_with_output("results[*].{Id:id,Kind:kind,CreateTime:createTime}")
def _click_command(state: State, kind: str, _id: str): def _click_command(state: State, kind: str, _id: str, limit: int):
"""Query search service""" """Query search service"""
return query(state, kind, _id) return query(state, kind, _id, limit)
def query(state: State, kind: str, id: str): # pylint: disable=invalid-name,redefined-builtin def query(
state: State, kind: str, id: str, limit: int
): # pylint: disable=invalid-name,redefined-builtin
"""Query search service """Query search service
Args: Args:
...@@ -39,6 +49,6 @@ def query(state: State, kind: str, id: str): # pylint: disable=invalid-name,red ...@@ -39,6 +49,6 @@ def query(state: State, kind: str, id: str): # pylint: disable=invalid-name,red
connection = CliOsduClient(state.config) connection = CliOsduClient(state.config)
search_client = SearchClient(connection) search_client = SearchClient(connection)
json_response = search_client.query(kind, id) json_response = search_client.query(kind, id, limit)
return json_response return json_response
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment