osducli 0.0.50__py3-none-any.whl → 0.0.52__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
osducli/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.50
1
+ 0.0.52
@@ -12,12 +12,18 @@
12
12
 
13
13
  """Search service query command"""
14
14
 
15
+ import collections
16
+
15
17
  import click
18
+ from jmespath import Options
19
+ from jmespath import compile as compile_jmespath
16
20
  from osdu_api.model.search.query_request import QueryRequest
17
21
 
18
22
  from osducli.click_cli import CustomClickCommand, State, command_with_output
19
23
  from osducli.cliclient import CliOsduClient, handle_cli_exceptions
20
24
 
25
+ QUERY_JMESPATH_EXPRESSION = compile_jmespath("results[*].{Id:id,Kind:kind,CreateTime:createTime}")
26
+ AGGREGATE_JMESPATH_EXPRESSION = compile_jmespath("sort_by(aggregations,&key)[*].{Key:key,Count:count}")
21
27
 
22
28
  # click entry point
23
29
  @click.command(cls=CustomClickCommand)
@@ -32,14 +38,15 @@ from osducli.cliclient import CliOsduClient, handle_cli_exceptions
32
38
  show_default=True,
33
39
  help="maximum number of records to return.",
34
40
  )
41
+ @click.option("-a", "--aggregate", "_aggr", help="Aggregate by element", required=False)
35
42
  @handle_cli_exceptions
36
- @command_with_output("results[*].{Id:id,Kind:kind,CreateTime:createTime}")
37
- def _click_command(state: State, kind: str, _id: str, _query: str, limit: int):
43
+ @command_with_output(None)
44
+ def _click_command(state: State, kind: str, _id: str, _query: str, limit: int, _aggr: str):
38
45
  """Search using more advanced query terms"""
39
- return query(state, kind, _id, _query, limit)
46
+ return query(state, kind, _id, _query, limit, _aggr)
40
47
 
41
48
 
42
- def query(state: State, kind: str, identifier: str, custom_query: str, limit: int):
49
+ def query(state: State, kind: str, identifier: str, custom_query: str, limit: int, aggregate: str = None):
43
50
  """Query search service
44
51
 
45
52
  Args:
@@ -48,6 +55,7 @@ def query(state: State, kind: str, identifier: str, custom_query: str, limit: in
48
55
  identifier (str): id to search for
49
56
  custom_query (str): custom search query
50
57
  limit (int): maximum number of records to return.
58
+ aggregate (str): aggregate by element
51
59
  """
52
60
  client = CliOsduClient(state.config)
53
61
  search_client = client.get_search_client()
@@ -59,8 +67,13 @@ def query(state: State, kind: str, identifier: str, custom_query: str, limit: in
59
67
  kind = "*:*:*:*"
60
68
 
61
69
  query_val = f'id:("{identifier}")' if identifier is not None else custom_query
62
- request_data = QueryRequest(kind=kind, query=query_val, limit=limit)
70
+ request_data = QueryRequest(kind=kind, query=query_val, limit=limit, aggregate_by=aggregate)
63
71
 
64
72
  response = search_client.query_records(query_request=request_data)
65
73
  client.check_status_code(response)
66
- return response.json()
74
+ response_data = response.json()
75
+
76
+ if aggregate is not None:
77
+ return AGGREGATE_JMESPATH_EXPRESSION.search(response_data, Options(collections.OrderedDict))
78
+
79
+ return QUERY_JMESPATH_EXPRESSION.search(response_data, Options(collections.OrderedDict))
@@ -0,0 +1,13 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+ """Storage service version commands"""
@@ -0,0 +1,47 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+ """Storage service version get command"""
14
+
15
+ import click
16
+
17
+ from osducli.click_cli import CustomClickCommand, State, command_with_output
18
+ from osducli.cliclient import CliOsduClient, handle_cli_exceptions
19
+
20
+
21
+ # click entry point
22
+ @click.command(cls=CustomClickCommand)
23
+ @click.option("-id", "--id", "_id", help="Record id to search for", required=True)
24
+ @click.option("-v", "--version", "_ver", help="Record version to search for", required=True)
25
+ @click.option("-a", "--attributes", "_attr", help="Filter attributes to restrict the returned fields of the record.", required=False)
26
+ @handle_cli_exceptions
27
+ @command_with_output("results || {Id:id,Version:version,Kind:kind,CreateUser:createUser,CreateTime:createTime}")
28
+ def _click_command(state: State, _id: str, _ver: str, _attr: list):
29
+ """Get specific record by id and version"""
30
+ return get(state, _id, _ver, _attr)
31
+
32
+
33
+ def get(state: State, id: str, version: str, attributes: list = None): # pylint: disable=redefined-builtin
34
+ """Get specific record by id and version
35
+
36
+ Args:
37
+ state (State): Global state
38
+ id (str): Id of records
39
+ version (str): Version of records
40
+ attributes (list): Filter attributes
41
+ """
42
+ client = CliOsduClient(state.config)
43
+ record_client = client.get_storage_record_client()
44
+ response = record_client.get_specific_record(id, version, attributes)
45
+
46
+ client.check_status_code(response)
47
+ return response.json()
@@ -10,33 +10,34 @@
10
10
  # See the License for the specific language governing permissions and
11
11
  # limitations under the License.
12
12
 
13
- """Storage service versions command"""
13
+ """Storage service version list command"""
14
14
 
15
15
  import click
16
16
 
17
17
  from osducli.click_cli import CustomClickCommand, State, command_with_output
18
18
  from osducli.cliclient import CliOsduClient, handle_cli_exceptions
19
- from osducli.config import CONFIG_STORAGE_URL
20
19
 
21
20
 
22
21
  # click entry point
23
22
  @click.command(cls=CustomClickCommand)
24
- @click.option("-id", "--id", "_id", required=True, help="id to get versions for")
23
+ @click.option("-id", "--id", "_id", help="Record id to search for", required=True)
25
24
  @handle_cli_exceptions
26
25
  @command_with_output("versions")
27
26
  def _click_command(state: State, _id: str):
28
- """List record versions"""
29
- return versions(state, _id)
27
+ """Get record versions for given id"""
28
+ return get(state, _id)
30
29
 
31
30
 
32
- def versions(state: State, id: str): # pylint: disable=invalid-name,redefined-builtin
33
- """List record versions
31
+ def get(state: State, id: str): # pylint: disable=redefined-builtin
32
+ """Get record versions for given id
34
33
 
35
34
  Args:
36
35
  state (State): Global state
37
- id (str): id to get versions for
36
+ id (str): Id of records
38
37
  """
39
- connection = CliOsduClient(state.config)
40
- url = "records/versions/" + id
41
- json = connection.cli_get_returning_json(CONFIG_STORAGE_URL, url)
42
- return json
38
+ client = CliOsduClient(state.config)
39
+ record_client = client.get_storage_record_client()
40
+ response = record_client.get_record_versions(id)
41
+
42
+ client.check_status_code(response)
43
+ return response.json()
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: osducli
3
- Version: 0.0.50
3
+ Version: 0.0.52
4
4
  Summary: OSDU command line
5
- Author-email: Equinor ASA <mhew@equinor.com>
5
+ Author: OSDU Community
6
6
  License-Expression: Apache-2.0
7
7
  Project-URL: homepage, https://community.opengroup.org/osdu/platform/data-flow/data-loading/osdu-cli
8
8
  Project-URL: issue-tracker, https://community.opengroup.org/osdu/platform/data-flow/data-loading/osdu-cli/-/issues
@@ -11,7 +11,7 @@ Classifier: Development Status :: 3 - Alpha
11
11
  Classifier: Environment :: Console
12
12
  Classifier: Natural Language :: English
13
13
  Classifier: Programming Language :: Python :: 3.13
14
- Requires-Python: >=3.12
14
+ Requires-Python: >=3.13
15
15
  Description-Content-Type: text/x-rst
16
16
  License-File: LICENSE.md
17
17
  Requires-Dist: click
@@ -75,6 +75,15 @@ For more information, specify the `-h` flag:
75
75
  Change Log
76
76
  ==========
77
77
 
78
+ 0.0.52
79
+ ------
80
+ - Fix result for aggregate in search command
81
+
82
+ 0.0.51
83
+ ------
84
+ - Get record version command
85
+ - Aggregate by in search query
86
+
78
87
  0.0.50
79
88
  ------
80
89
  - Maintenance release
@@ -1,4 +1,4 @@
1
- osducli/VERSION,sha256=ZpjJE3lqnDmHmv4SwQLhYc-x2Nfi3YlnlDJwdkFsP2A,6
1
+ osducli/VERSION,sha256=G1mbYZqgx_9E_1oendInfs1C3OixdTj3J-8x9IPDbVY,6
2
2
  osducli/__init__.py,sha256=J3RwqAbN7MWvz8vL24fMUar9Sfk8nMI8xq_aSHGXUy8,591
3
3
  osducli/__main__.py,sha256=4HonhahSaS3Un0f93qnbs_pmJ5pbbVHU-qdhsssVkB0,3661
4
4
  osducli/click_cli.py,sha256=EIe42DOnHDRKU3mPGwT12jI-yX3hsBOp_nS4nMTWc_Y,10864
@@ -70,7 +70,7 @@ osducli/commands/search/_const.py,sha256=YYTZd35Z9O0gEf6kb9Ntonvv3qArkAcszKAq2VA
70
70
  osducli/commands/search/id.py,sha256=1tVbgpDRhW08gyaLfQbCZjFrQDUGPh8gupf7pNhiN6c,1909
71
71
  osducli/commands/search/info.py,sha256=j6cjYDbxiiQEKXs0LJGQ_0scKReCGi6iQJrfn2X0B20,1333
72
72
  osducli/commands/search/kind.py,sha256=9vGVp4QG4dTII4LGcLYKDAE2PmcB-isgiCfwiITVauU,1786
73
- osducli/commands/search/query.py,sha256=EUHnIFvuCxAYBQK_k7YkBb8mYnedvRPMwBpeM1vj9r4,2405
73
+ osducli/commands/search/query.py,sha256=4ifV-F3mixs0c05v7wljUdvXE9WU9LR_rjJKbTXDPds,3094
74
74
  osducli/commands/status/__init__.py,sha256=5g1PB_tU0sqP7aplnihjfhMzVVQdlB3Y01QIeHAtSMw,595
75
75
  osducli/commands/status/status.py,sha256=yh6KVUpNYbrLJIH-7GjMyo2MpR8Wvycr4KdkxUI1V5A,4543
76
76
  osducli/commands/storage/__init__.py,sha256=Ilc97Kje3VVLZIBJucd_2jsW1GF5En00xF-A6kiLAFM,585
@@ -80,7 +80,9 @@ osducli/commands/storage/delete.py,sha256=ryjrd24wiJlTAL6jIsTW1gCxB0icAMu0YIyUTx
80
80
  osducli/commands/storage/get.py,sha256=FgjoN_1cY90cbU1osh53XviGvTZaPtRjthUmtP2Y2-k,2136
81
81
  osducli/commands/storage/info.py,sha256=CGbA92GJYkWcLXHx1Z4i9g7Auk-ws2Cg6n6X7_m27iw,1345
82
82
  osducli/commands/storage/list.py,sha256=bIN76XW70Xml0CCldNvjN-qCumqICjZkQPXs7LTY69M,1413
83
- osducli/commands/storage/versions.py,sha256=9KtVFIofIXPjozw_haeZDx28Y5SVfbYKtOyP8Q4jxx4,1483
83
+ osducli/commands/storage/version/__init__.py,sha256=h_BEt3whnDdxWHMNK9ej3_aQ_oWtRN41Wjr4XN9kQ6k,593
84
+ osducli/commands/storage/version/get.py,sha256=r7_HRE5FS2HNrltyO-RsxVcAlhlmwoKmGdOMDy76w_E,1983
85
+ osducli/commands/storage/version/list.py,sha256=F9bAHnmp-Iy2cDIjR7rT4CcPYWnrzBARC2ZEWNjg-uk,1483
84
86
  osducli/commands/unit/__init__.py,sha256=wi3jN5VORSyR-1R9p3smO6zkzejAnAI0-T9_moGSl08,582
85
87
  osducli/commands/unit/_const.py,sha256=GuBlXzsI723OKlqcBzsG21T44V_SbOPqdbaw8_c2c5s,696
86
88
  osducli/commands/unit/info.py,sha256=3mAB14C5256cDQGR_pUbSpKXN-0ohA7gxqxwq4t4VP8,1210
@@ -234,9 +236,9 @@ osducli/util/file.py,sha256=kfh6SLOI7X54gZ0hWF3kQ1npXPylNYgE1d1_w-fFyr0,1821
234
236
  osducli/util/prompt.py,sha256=0i3eNnxOHRQstvsvfiKnN0lIxXu6sEXIcU8txeYRhNs,7492
235
237
  osducli/util/pypi.py,sha256=-DW5CThkKKiOwLp2tg85BmrLKZzkMI9pu8DyWNPZH6E,1192
236
238
  osducli/util/service_info.py,sha256=YsVvoRoeG1osFjql2AgVkGoj1TePuhBZf3CQXl2a9As,2577
237
- osducli-0.0.50.dist-info/licenses/LICENSE.md,sha256=9xnGPjJkOAgd0kH4QLlvOIYKqY1M49gWUQpoUxAU-9Y,12788
238
- osducli-0.0.50.dist-info/METADATA,sha256=dZXA1t4OQiGFavpnmqNh6GqJcszqJHTNz9K8oWpEB98,6251
239
- osducli-0.0.50.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
240
- osducli-0.0.50.dist-info/entry_points.txt,sha256=gASIcihV0BSJDZOUK-zTzb8RiccZCvKfVZMna9RsEIg,47
241
- osducli-0.0.50.dist-info/top_level.txt,sha256=lqiP5fuyH8lx7c2emYoIVZNxZAPX-bSwnMH789wxUAY,8
242
- osducli-0.0.50.dist-info/RECORD,,
239
+ osducli-0.0.52.dist-info/licenses/LICENSE.md,sha256=9xnGPjJkOAgd0kH4QLlvOIYKqY1M49gWUQpoUxAU-9Y,12788
240
+ osducli-0.0.52.dist-info/METADATA,sha256=GeVpDwPmeIaWRhbUSh3Lklw_bCDax_4lDCusbo0p2yU,6364
241
+ osducli-0.0.52.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
242
+ osducli-0.0.52.dist-info/entry_points.txt,sha256=gASIcihV0BSJDZOUK-zTzb8RiccZCvKfVZMna9RsEIg,47
243
+ osducli-0.0.52.dist-info/top_level.txt,sha256=lqiP5fuyH8lx7c2emYoIVZNxZAPX-bSwnMH789wxUAY,8
244
+ osducli-0.0.52.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5