osducli 0.0.44__py3-none-any.whl → 0.0.45__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/__init__.py CHANGED
@@ -12,4 +12,4 @@
12
12
 
13
13
  """ OSDU command line environment"""
14
14
 
15
- __VERSION__ = "0.0.44"
15
+ __VERSION__ = "0.0.45"
@@ -13,7 +13,6 @@
13
13
 
14
14
  import os
15
15
 
16
- from msal import ConfidentialClientApplication
17
16
  from osdu_api.providers.types import BaseCredentials
18
17
 
19
18
  from osducli.auth.aws_token_credential import AwsTokenCredential
@@ -47,13 +46,11 @@ def msal_non_interactive_credentials(config) -> BaseCredentials:
47
46
  authority = config.get("core", CONFIG_AUTHENTICATION_AUTHORITY, None)
48
47
  scopes = config.get("core", CONFIG_AUTHENTICATION_SCOPES, None)
49
48
  client_secret = config.get("core", CONFIG_CLIENT_SECRET, None)
50
- app = ConfidentialClientApplication(client_id, client_secret, authority)
51
49
  credentials = MsalNonInteractiveCredential(
52
50
  client_id=client_id,
53
51
  client_secret=client_secret,
54
52
  authority=authority,
55
53
  scopes=scopes,
56
- client=app,
57
54
  )
58
55
  return credentials
59
56
 
@@ -21,14 +21,13 @@ logger = get_logger(__name__)
21
21
  class MsalNonInteractiveCredential(BaseCredentials):
22
22
  """Get token based client for connecting with OSDU."""
23
23
 
24
- __access_token = None
24
+ _access_token = None
25
25
 
26
26
  def __init__(self,
27
27
  client_id: str,
28
28
  client_secret: str,
29
29
  authority: str,
30
- scopes: str,
31
- client: ConfidentialClientApplication):
30
+ scopes: str):
32
31
  """Setup the new client
33
32
 
34
33
  Args:
@@ -37,32 +36,26 @@ class MsalNonInteractiveCredential(BaseCredentials):
37
36
  scopes (str): scopes to request
38
37
  """
39
38
  super().__init__()
40
- self._msal_confidential_client = client
41
39
  self._client_id = client_id
42
40
  self._client_secret = client_secret
43
41
  self._authority = authority
44
42
  self._scopes = scopes
43
+ self._app = ConfidentialClientApplication(
44
+ self._client_id, self._client_secret, self._authority
45
+ )
45
46
 
46
47
  @property
47
48
  def access_token(self) -> str:
48
- return self.__access_token
49
+ return self._access_token
49
50
 
50
- def refresh_token(self) -> str: # pylint: disable=inconsistent-return-statements
51
+ def refresh_token(self) -> str:
51
52
  """
52
53
  return access_token.
53
54
  """
54
- token = self._get_token()
55
- if 'access_token' in token:
56
- __access_token = token['access_token']
57
- return __access_token
55
+ response = self._app.acquire_token_for_client(scopes=[self._scopes])
56
+ if 'access_token' in response:
57
+ self._access_token = response['access_token']
58
+ else:
59
+ raise Exception("Failed to aquire token")
58
60
 
59
- def _get_token(self) -> dict:
60
- """Get token using msal confidential client.
61
-
62
- Returns:
63
- dict: Dictionary representing the returned token
64
- """
65
- result = self._msal_confidential_client.acquire_token_silent([self._scopes], account=None)
66
- if result:
67
- return result
68
- return self._msal_confidential_client.acquire_token_for_client([self._scopes])
61
+ return self._access_token
@@ -16,3 +16,4 @@ WELLBORE_DDMS_SERVICE_NAME = "Wellbore DDMS service"
16
16
  WELLBORE_DDMS_STATUS_PATH = "/about"
17
17
  WELLBORE_DDMS_SWAGGER_PATH = "https://community.opengroup.org/osdu/platform/domain-data-mgmt-services/wellbore/wellbore-domain-services/-/blob/master/spec/generated/openapi.json" # noqa: E501
18
18
  WELLBORE_DDMS_DOCUMENTATION = "https://community.opengroup.org/osdu/platform/domain-data-mgmt-services/wellbore/wellbore-domain-services/-/tree/master" # noqa: E501
19
+ WELLBORE_DDMS_WELL_LOG_PATH = "/ddms/v3/welllogs"
@@ -0,0 +1,42 @@
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
+ """Well Log add record command"""
13
+ import json
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
+ from osducli.commands.wellbore_ddms._const import WELLBORE_DDMS_WELL_LOG_PATH
20
+
21
+
22
+ # click entry point
23
+ @click.command(cls=CustomClickCommand, help="Add Well Log record")
24
+ @click.option("-f", "--file", "_file", help="WellLog record file to add", required=True)
25
+ @handle_cli_exceptions
26
+ @command_with_output("recordIds")
27
+ def _click_command(state: State, _file: str):
28
+ return add_record(state, _file)
29
+
30
+
31
+ def add_record(state: State, record_file: str):
32
+ """Add Well Log record"""
33
+ client = CliOsduClient(state.config)
34
+ wellbore_client = client.get_wellbore_ddms_client(url_extra_path=WELLBORE_DDMS_WELL_LOG_PATH)
35
+
36
+ with open(record_file) as file:
37
+ record_data = json.load(file)
38
+
39
+ record_data_list = "[" + json.dumps(record_data) + "]"
40
+ response = wellbore_client.create_well_log(record_data_list)
41
+ client.check_status_code(response)
42
+ return response.json()
@@ -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
+ """Wellbore DDMS Well Log data commands"""
@@ -0,0 +1,40 @@
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
+ """Well Log add data command"""
13
+ import click
14
+
15
+ from osducli.click_cli import CustomClickCommand, State, command_with_output
16
+ from osducli.cliclient import CliOsduClient, handle_cli_exceptions
17
+ from osducli.commands.wellbore_ddms._const import WELLBORE_DDMS_WELL_LOG_PATH
18
+
19
+
20
+ # click entry point
21
+ @click.command(cls=CustomClickCommand, help="Add Well Log data")
22
+ @click.option("-id", "--id", "_id", help="WellLog id to add data to", required=True)
23
+ @click.option("-f", "--file", "_file", help="WellLog data file to add", required=True)
24
+ @handle_cli_exceptions
25
+ @command_with_output("recordIds")
26
+ def _click_command(state: State, _id: str, _file: str):
27
+ return add_data(state, _id, _file)
28
+
29
+
30
+ def add_data(state: State, identifier: str, data_file: str):
31
+ """Well Log add data"""
32
+ client = CliOsduClient(state.config)
33
+ wellbore_client = client.get_wellbore_ddms_client(url_extra_path=WELLBORE_DDMS_WELL_LOG_PATH)
34
+
35
+ with open(data_file, 'rb') as file:
36
+ file_data = file.read()
37
+
38
+ response = wellbore_client.create_well_log_data(identifier, file_data)
39
+ client.check_status_code(response)
40
+ return response.json()
@@ -16,10 +16,11 @@ 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.commands.wellbore_ddms._const import WELLBORE_DDMS_WELL_LOG_PATH
19
20
 
20
21
 
21
22
  # click entry point
22
- @click.command(cls=CustomClickCommand)
23
+ @click.command(cls=CustomClickCommand, help="Get Well Log data by id")
23
24
  @click.option("-id", "--id", "_id", help="WellLog id to search for", required=True)
24
25
  @click.option("-f", "--file", "_file", help="File to save WellLog data", required=True)
25
26
  @handle_cli_exceptions
@@ -28,14 +29,14 @@ def _click_command(state: State, _id: str, _file: str):
28
29
  return get_data(state, _id, _file)
29
30
 
30
31
 
31
- def get_data(state: State, identifier: str, _file: str):
32
+ def get_data(state: State, identifier: str, out_file: str):
32
33
  """Get Well Log record by id"""
33
34
  client = CliOsduClient(state.config)
34
- wellbore_client = client.get_wellbore_ddms_client(url_extra_path="/ddms/v3/welllogs")
35
+ wellbore_client = client.get_wellbore_ddms_client(url_extra_path=WELLBORE_DDMS_WELL_LOG_PATH)
35
36
  response = wellbore_client.get_well_log_data(identifier)
36
37
  client.check_status_code(response)
37
38
 
38
- with open(_file, 'wb') as file:
39
+ with open(out_file, 'wb') as file:
39
40
  file.write(response.content)
40
41
 
41
42
  filename = os.path.abspath(file.name)
@@ -14,10 +14,11 @@ import click
14
14
 
15
15
  from osducli.click_cli import CustomClickCommand, State, command_with_output
16
16
  from osducli.cliclient import CliOsduClient, handle_cli_exceptions
17
+ from osducli.commands.wellbore_ddms._const import WELLBORE_DDMS_WELL_LOG_PATH
17
18
 
18
19
 
19
20
  # click entry point
20
- @click.command(cls=CustomClickCommand)
21
+ @click.command(cls=CustomClickCommand, help="Get Well Log record by id")
21
22
  @click.option("-id", "--id", "_id", help="WellLog id to search for", required=True)
22
23
  @handle_cli_exceptions
23
24
  @command_with_output()
@@ -28,7 +29,7 @@ def _click_command(state: State, _id: str):
28
29
  def get_record(state: State, identifier: str):
29
30
  """Get Well Log record by id"""
30
31
  client = CliOsduClient(state.config)
31
- wellbore_client = client.get_wellbore_ddms_client(url_extra_path="/ddms/v3/welllogs")
32
+ wellbore_client = client.get_wellbore_ddms_client(url_extra_path=WELLBORE_DDMS_WELL_LOG_PATH)
32
33
  response = wellbore_client.get_well_log(identifier)
33
34
  client.check_status_code(response)
34
35
  return response.json()
osducli/util/file.py CHANGED
@@ -11,8 +11,8 @@
11
11
  # limitations under the License.
12
12
 
13
13
  import errno
14
- import os
15
14
  import glob
15
+ import os
16
16
 
17
17
 
18
18
  def get_files_from_path(path: str) -> list:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: osducli
3
- Version: 0.0.44
3
+ Version: 0.0.45
4
4
  Summary: OSDU command line
5
5
  Author-email: Equinor ASA <mhew@equinor.com>
6
6
  License: Apache-2.0
@@ -17,7 +17,7 @@ Description-Content-Type: text/x-rst
17
17
  License-File: LICENSE.md
18
18
  Requires-Dist: click
19
19
  Requires-Dist: jmespath
20
- Requires-Dist: osdu-api[all]==0.28.0rc949
20
+ Requires-Dist: osdu-api[all]==0.28
21
21
  Requires-Dist: requests
22
22
  Requires-Dist: tabulate
23
23
  Requires-Dist: packaging
@@ -33,8 +33,6 @@ Requires-Dist: google-cloud-storage
33
33
  Provides-Extra: dev
34
34
  Requires-Dist: black; extra == "dev"
35
35
  Requires-Dist: isort; extra == "dev"
36
- Requires-Dist: flake8; extra == "dev"
37
- Requires-Dist: pep8; extra == "dev"
38
36
  Requires-Dist: pylint; extra == "dev"
39
37
  Requires-Dist: ruff; extra == "dev"
40
38
  Requires-Dist: pytest; extra == "dev"
@@ -83,6 +81,11 @@ For more information, specify the `-h` flag:
83
81
  Change Log
84
82
  ==========
85
83
 
84
+ 0.0.45
85
+ ------
86
+
87
+ - Fix msal_non_interactive authentication
88
+
86
89
  0.0.44
87
90
  ------
88
91
 
@@ -1,4 +1,4 @@
1
- osducli/__init__.py,sha256=ibjJ0fg460aSRsjskiE_LSNoQ5I7qcPYsI5C1Z7MFxI,615
1
+ osducli/__init__.py,sha256=wchj1xeJep01vDg-LwBaAJ8nEesYQ8UP6klHacXfTaY,615
2
2
  osducli/__main__.py,sha256=4HonhahSaS3Un0f93qnbs_pmJ5pbbVHU-qdhsssVkB0,3661
3
3
  osducli/click_cli.py,sha256=7lpYqufxRSMrNZM9M-VANOYKwP0wo-1oxt2eSVHSW_M,10845
4
4
  osducli/cliclient.py,sha256=sUQyIiomrf-WIcFn9C6UjISvHANLjijI-SVLxQ3T2MY,13242
@@ -8,9 +8,9 @@ osducli/state.py,sha256=b0GHH2oZ-4ogtmHenNkYwNRSE3OpSTL0XklbKVjUAKQ,3335
8
8
  osducli/wbddms_client.py,sha256=ANzhNCQ7TkM2OiPy18w4bJgL8CmveteUXsiDjlQyNTw,2686
9
9
  osducli/auth/__init__.py,sha256=p2bZquIGOPfofHV6GIzWRUv_b9O_pIH5BTyv_gfQT6c,553
10
10
  osducli/auth/aws_token_credential.py,sha256=awKDU2nA3iGXYdIR1NTBk6z64ImIC7okfYr8x7FOM-s,2322
11
- osducli/auth/credentials.py,sha256=ScDrhx1ye1Ks9kbgQPozyeEZ3Id17wBsrMZuAF_ptpw,3329
11
+ osducli/auth/credentials.py,sha256=ZhYHMmePr_vfzdcjc3UrEon8R26KYnZ9sfBLES6DLrA,3185
12
12
  osducli/auth/msal_interactive.py,sha256=IAoVIZJR7Q05GGdoXGtFBWC7CUe81olMZ4SANohXd1s,4313
13
- osducli/auth/msal_non_interactive.py,sha256=bebfSN7sfM1qslZsxwELF21GvWUbn_9B-l_PHOVEMGY,2289
13
+ osducli/auth/msal_non_interactive.py,sha256=qgI1Gj0uZS5-ixypiV7fFY-hRo05SoZJB5YHmF1jCB8,1970
14
14
  osducli/auth/token_credential.py,sha256=kYYGWx8lH_s9eyD53McBzSa1vaCK7qhj20fUt2W2ZcA,3488
15
15
  osducli/commands/__init__.py,sha256=p2bZquIGOPfofHV6GIzWRUv_b9O_pIH5BTyv_gfQT6c,553
16
16
  osducli/commands/config/__init__.py,sha256=dueEKDys38kNW9E9NMK7CqOImEX_IsN0wcCK1rNQteU,576
@@ -86,11 +86,14 @@ osducli/commands/unit/list.py,sha256=-5yEk0RHNZudeaaRzzCQexUHR6kCYAzM60YaO0EujVI
86
86
  osducli/commands/version/__init__.py,sha256=S8QUNV3WSGTJAWwzvPokDscvBP4m0BAwXV_JhSA0kD0,580
87
87
  osducli/commands/version/version.py,sha256=a_mpirlH5obnRhjUp9Ha4701Zj2rrU_NGQpQXRafHPY,4227
88
88
  osducli/commands/wellbore_ddms/__init__.py,sha256=AvXe60cTMl2ptWH6-wjaODGpzOiQazUJ05yrBkSlXYo,583
89
- osducli/commands/wellbore_ddms/_const.py,sha256=aYid5h2KeFo8O8eytiDjnBYoxf1n8y6WWbWQ5vXUrj0,1034
89
+ osducli/commands/wellbore_ddms/_const.py,sha256=XP4Cc19vBVG88N5qXDvPFhJEtSD4vKw05lnEwDTKRqM,1084
90
90
  osducli/commands/wellbore_ddms/info.py,sha256=Jeyt0uFpyWBKY9jAZK1AJUXiwgPhm0cPyagfwmRYFYQ,1417
91
91
  osducli/commands/wellbore_ddms/well_log/__init__.py,sha256=sKn5fM32pyXLNjqp3jqO90y_kdOFZXeDuXoZSCclEOU,592
92
- osducli/commands/wellbore_ddms/well_log/data.py,sha256=7BgbNOTJ5JjZM2N-cAWORPsga5wH7_jdtDX524dxmtc,1629
93
- osducli/commands/wellbore_ddms/well_log/record.py,sha256=FB-BHnrxcJydK33jAhrPgLva53JdxHCmZUFZt8KCbDk,1352
92
+ osducli/commands/wellbore_ddms/well_log/add.py,sha256=zMVLuVKqqDnHt4acjlu0EjvKQOIlt4swgC-_7RyArm0,1638
93
+ osducli/commands/wellbore_ddms/well_log/get.py,sha256=VLLWcXuv6QhQKvFUuIOxBtR-2I-FbLZTFnzMHeFnqF0,1472
94
+ osducli/commands/wellbore_ddms/well_log/data/__init__.py,sha256=CxanltK0srKAjEyDez6ZVDCjs-UnwuvvGLvz8gdAc4o,597
95
+ osducli/commands/wellbore_ddms/well_log/data/add.py,sha256=HUdU3SAySNEk1TfwcIe6pBxI0BTu-892kVhvp8U8yL8,1677
96
+ osducli/commands/wellbore_ddms/well_log/data/get.py,sha256=ArEPF3deQXrA9ZjIE724QW-X9Zdg2mYjFyyLUKYzo1M,1753
94
97
  osducli/commands/workflow/__init__.py,sha256=hZZscXSv0oIpS93g7TvtNaSCaEMDr0ON5uBNh-s_8oc,586
95
98
  osducli/commands/workflow/_const.py,sha256=IQDjvu7TBd8L68TAF1qotf1wi0q5-DaNu87TFxwuAU8,696
96
99
  osducli/commands/workflow/get.py,sha256=BsiWYzCa-RFXCl-9piBqfxdN2dZ_e8lNQo7ZWMi51Ic,1498
@@ -102,13 +105,13 @@ osducli/commands/workflow/status.py,sha256=GNSaJrAHrCBjLkYDP0rYtsGicHsvZYLX5otLb
102
105
  osducli/commands/workflow/unregister.py,sha256=lTh7yoRE8Sb3W-03L2v16cs0G-0QtfNqFf8fg2t97o4,1415
103
106
  osducli/util/__init__.py,sha256=p2bZquIGOPfofHV6GIzWRUv_b9O_pIH5BTyv_gfQT6c,553
104
107
  osducli/util/exceptions.py,sha256=VVvJqxLLyYSsitwe9SVfsR7iPXIRaOJzOm7uCxfELjg,790
105
- osducli/util/file.py,sha256=866XSn7AWFXWgQ9B6OvPZVhb5p8VELbv_wOsUzc55-o,1821
108
+ osducli/util/file.py,sha256=kfh6SLOI7X54gZ0hWF3kQ1npXPylNYgE1d1_w-fFyr0,1821
106
109
  osducli/util/prompt.py,sha256=0i3eNnxOHRQstvsvfiKnN0lIxXu6sEXIcU8txeYRhNs,7492
107
110
  osducli/util/pypi.py,sha256=-DW5CThkKKiOwLp2tg85BmrLKZzkMI9pu8DyWNPZH6E,1192
108
111
  osducli/util/service_info.py,sha256=YsVvoRoeG1osFjql2AgVkGoj1TePuhBZf3CQXl2a9As,2577
109
- osducli-0.0.44.dist-info/LICENSE.md,sha256=9xnGPjJkOAgd0kH4QLlvOIYKqY1M49gWUQpoUxAU-9Y,12788
110
- osducli-0.0.44.dist-info/METADATA,sha256=_9Md40hzE-qk91awyx96oZ-Op-MnlE-FK98chhGP6lQ,6190
111
- osducli-0.0.44.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
112
- osducli-0.0.44.dist-info/entry_points.txt,sha256=gASIcihV0BSJDZOUK-zTzb8RiccZCvKfVZMna9RsEIg,47
113
- osducli-0.0.44.dist-info/top_level.txt,sha256=lqiP5fuyH8lx7c2emYoIVZNxZAPX-bSwnMH789wxUAY,8
114
- osducli-0.0.44.dist-info/RECORD,,
112
+ osducli-0.0.45.dist-info/LICENSE.md,sha256=9xnGPjJkOAgd0kH4QLlvOIYKqY1M49gWUQpoUxAU-9Y,12788
113
+ osducli-0.0.45.dist-info/METADATA,sha256=duWD8sZg9w2B5bFsyARb37TdLRJVOJQOAhyRN4q4Lr4,6167
114
+ osducli-0.0.45.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
115
+ osducli-0.0.45.dist-info/entry_points.txt,sha256=gASIcihV0BSJDZOUK-zTzb8RiccZCvKfVZMna9RsEIg,47
116
+ osducli-0.0.45.dist-info/top_level.txt,sha256=lqiP5fuyH8lx7c2emYoIVZNxZAPX-bSwnMH789wxUAY,8
117
+ osducli-0.0.45.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (75.8.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5