oscar-python 1.0.4__tar.gz → 1.1.0__tar.gz

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.
Files changed (21) hide show
  1. {oscar_python-1.0.4 → oscar_python-1.1.0}/PKG-INFO +1 -1
  2. {oscar_python-1.0.4 → oscar_python-1.1.0}/oscar_python/_utils.py +13 -8
  3. {oscar_python-1.0.4 → oscar_python-1.1.0}/oscar_python/client.py +43 -13
  4. {oscar_python-1.0.4 → oscar_python-1.1.0}/oscar_python.egg-info/PKG-INFO +1 -1
  5. {oscar_python-1.0.4 → oscar_python-1.1.0}/LICENSE +0 -0
  6. {oscar_python-1.0.4 → oscar_python-1.1.0}/README.md +0 -0
  7. {oscar_python-1.0.4 → oscar_python-1.1.0}/oscar_python/__init__.py +0 -0
  8. {oscar_python-1.0.4 → oscar_python-1.1.0}/oscar_python/_providers/_minio.py +0 -0
  9. {oscar_python-1.0.4 → oscar_python-1.1.0}/oscar_python/_providers/_onedata.py +0 -0
  10. {oscar_python-1.0.4 → oscar_python-1.1.0}/oscar_python/_providers/_providers_base.py +0 -0
  11. {oscar_python-1.0.4 → oscar_python-1.1.0}/oscar_python/_providers/_s3.py +0 -0
  12. {oscar_python-1.0.4 → oscar_python-1.1.0}/oscar_python/_providers/_webdav.py +0 -0
  13. {oscar_python-1.0.4 → oscar_python-1.1.0}/oscar_python/local_test.py +0 -0
  14. {oscar_python-1.0.4 → oscar_python-1.1.0}/oscar_python/storage.py +0 -0
  15. {oscar_python-1.0.4 → oscar_python-1.1.0}/oscar_python.egg-info/SOURCES.txt +0 -0
  16. {oscar_python-1.0.4 → oscar_python-1.1.0}/oscar_python.egg-info/dependency_links.txt +0 -0
  17. {oscar_python-1.0.4 → oscar_python-1.1.0}/oscar_python.egg-info/not-zip-safe +0 -0
  18. {oscar_python-1.0.4 → oscar_python-1.1.0}/oscar_python.egg-info/requires.txt +0 -0
  19. {oscar_python-1.0.4 → oscar_python-1.1.0}/oscar_python.egg-info/top_level.txt +0 -0
  20. {oscar_python-1.0.4 → oscar_python-1.1.0}/setup.cfg +0 -0
  21. {oscar_python-1.0.4 → oscar_python-1.1.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oscar_python
3
- Version: 1.0.4
3
+ Version: 1.1.0
4
4
  Summary: OSCAR API for python
5
5
  Home-page: https://github.com/grycap/oscar_python
6
6
  Author: GRyCAP - Universitat Politecnica de Valencia
@@ -13,17 +13,16 @@
13
13
  # limitations under the License.
14
14
 
15
15
  import base64
16
- import json
17
16
  import os
18
17
  import requests
19
- _DEFAULT_TIMEOUT = 30
18
+ import liboidcagent as agent
19
+ _DEFAULT_TIMEOUT = 60
20
20
 
21
21
  """ Generic http request """
22
22
  def make_request(c , path, method, **kwargs):
23
23
 
24
24
  if "timeout" in kwargs.keys() and kwargs["timeout"]:
25
25
  timeout = kwargs["timeout"]
26
- print("timeout set to: ", timeout)
27
26
  else:
28
27
  timeout = _DEFAULT_TIMEOUT
29
28
 
@@ -43,11 +42,17 @@ def make_request(c , path, method, **kwargs):
43
42
  result.raise_for_status()
44
43
  return result
45
44
 
46
- """ Function to generate headers with basic authentication """
45
+ """ Function to generate headers with basic authentication or OIDC """
47
46
  def get_headers(c):
48
- usr_pass_as_bytes = bytes(c.user+":"+c.password,"utf-8")
49
- usr_pass_base_64 = base64.b64encode(usr_pass_as_bytes).decode("utf-8")
50
- return {"Authorization": "Basic "+ usr_pass_base_64}
47
+ if c._AUTH_TYPE == "basicauth":
48
+ usr_pass_as_bytes = bytes(c.user+":"+c.password,"utf-8")
49
+ usr_pass_base_64 = base64.b64encode(usr_pass_as_bytes).decode("utf-8")
50
+ return {"Authorization": "Basic "+ usr_pass_base_64}
51
+ if c._AUTH_TYPE == "oidc-agent":
52
+ token = agent.get_access_token(c.shortname)
53
+ return get_headers_with_token(token)
54
+ if c._AUTH_TYPE == "oidc":
55
+ return get_headers_with_token(c.oidc_token)
51
56
 
52
57
  """ Function to generate headers with token auth """
53
58
  def get_headers_with_token(token):
@@ -104,4 +109,4 @@ def decode_output(output, file_path):
104
109
  write_text_file(output,file_path)
105
110
  return
106
111
 
107
-
112
+
@@ -13,9 +13,9 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- import os
17
16
  import json
18
17
  import yaml
18
+ import liboidcagent as agent
19
19
  import oscar_python._utils as utils
20
20
  from oscar_python.storage import Storage
21
21
 
@@ -26,25 +26,55 @@ _LOGS_PATH = "/system/logs"
26
26
  _RUN_PATH = "/run"
27
27
  #_JOB_PATH = "/job"
28
28
 
29
- _MINIO = "minio"
30
- _S3 = "s3"
31
- _ONE_DATA = "onedata"
32
- _WEBDAV = "webdav"
33
29
 
34
30
  _GET = "get"
35
31
  _POST = "post"
36
32
  _PUT = "put"
37
33
  _DELETE = "delete"
38
- _DEFAULT_TIMEOUT = 30
39
34
 
40
35
  class Client:
41
36
  #Cluster info
42
- def __init__(self, id, endpoint, user, password, ssl) -> None:
43
- self.id = id
44
- self.endpoint = endpoint
45
- self.user = user
46
- self.password = password
47
- self.ssl = ssl
37
+ def __init__(self, options) -> None:
38
+ self.set_auth_type(options)
39
+ if self._AUTH_TYPE == 'basicauth':
40
+ self.basic_auth_client(options)
41
+ if self._AUTH_TYPE == 'oidc-agent':
42
+ self.oidc_agent_client(options)
43
+ if self._AUTH_TYPE == 'oidc':
44
+ self.oidc_client(options)
45
+
46
+ def basic_auth_client(self, options):
47
+ self.id = options['cluster_id']
48
+ self.endpoint = options['endpoint']
49
+ self.user = options['user']
50
+ self.password = options['password']
51
+ self.ssl = bool(options['ssl'])
52
+
53
+ def oidc_agent_client(self, options):
54
+ self.id = options['cluster_id']
55
+ self.endpoint = options['endpoint']
56
+ self.shortname = options['shortname']
57
+ self.ssl = bool(options['ssl'])
58
+
59
+ def oidc_client(self, options):
60
+ self.id = options['cluster_id']
61
+ self.endpoint = options['endpoint']
62
+ self.oidc_token = options['oidc_token']
63
+ self.ssl = bool(options['ssl'])
64
+
65
+ def set_auth_type(self, options):
66
+ if 'user' in options:
67
+ self._AUTH_TYPE = "basicauth"
68
+ elif 'shortname' in options:
69
+ self._AUTH_TYPE = "oidc-agent"
70
+ try:
71
+ agent.get_access_token(options['shortname'])
72
+ except agent.OidcAgentError as e:
73
+ print("ERROR oidc-agent: {}".format(e))
74
+ elif 'oidc_token' in options:
75
+ self._AUTH_TYPE = "oidc"
76
+ else:
77
+ raise ValueError("Unrecognized authentication credentials in options")
48
78
 
49
79
  """ Creates a generic storage client to interact with the storage providers
50
80
  defined on a specific service of the refered OSCAR cluster """
@@ -123,7 +153,7 @@ class Client:
123
153
  send_data = utils.encode_input(exec_input)
124
154
 
125
155
  if "timeout" in kwargs.keys() and kwargs["timeout"]:
126
- response = utils.make_request(self, _RUN_PATH+"/"+name, _POST, data=send_data, token=token, timeout=kwargs["timeout"])
156
+ response = utils._make_request(self, _RUN_PATH+"/"+name, _POST, data=send_data, token=token, timeout=kwargs["timeout"])
127
157
  else:
128
158
  response = utils.make_request(self, _RUN_PATH+"/"+name, _POST, data=send_data, token=token)
129
159
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oscar-python
3
- Version: 1.0.4
3
+ Version: 1.1.0
4
4
  Summary: OSCAR API for python
5
5
  Home-page: https://github.com/grycap/oscar_python
6
6
  Author: GRyCAP - Universitat Politecnica de Valencia
File without changes
File without changes
File without changes
File without changes