arkindex-client 1.0.11__tar.gz → 1.0.12__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 (20) hide show
  1. {arkindex-client-1.0.11 → arkindex-client-1.0.12}/PKG-INFO +1 -1
  2. arkindex-client-1.0.12/VERSION +1 -0
  3. {arkindex-client-1.0.11 → arkindex-client-1.0.12}/arkindex/client.py +34 -4
  4. {arkindex-client-1.0.11 → arkindex-client-1.0.12}/arkindex_client.egg-info/PKG-INFO +1 -1
  5. arkindex-client-1.0.11/VERSION +0 -1
  6. {arkindex-client-1.0.11 → arkindex-client-1.0.12}/MANIFEST.in +0 -0
  7. {arkindex-client-1.0.11 → arkindex-client-1.0.12}/README.rst +0 -0
  8. {arkindex-client-1.0.11 → arkindex-client-1.0.12}/arkindex/__init__.py +0 -0
  9. {arkindex-client-1.0.11 → arkindex-client-1.0.12}/arkindex/auth.py +0 -0
  10. {arkindex-client-1.0.11 → arkindex-client-1.0.12}/arkindex/exceptions.py +0 -0
  11. {arkindex-client-1.0.11 → arkindex-client-1.0.12}/arkindex/mock.py +0 -0
  12. {arkindex-client-1.0.11 → arkindex-client-1.0.12}/arkindex/pagination.py +0 -0
  13. {arkindex-client-1.0.11 → arkindex-client-1.0.12}/arkindex/transports.py +0 -0
  14. {arkindex-client-1.0.11 → arkindex-client-1.0.12}/arkindex_client.egg-info/SOURCES.txt +0 -0
  15. {arkindex-client-1.0.11 → arkindex-client-1.0.12}/arkindex_client.egg-info/dependency_links.txt +0 -0
  16. {arkindex-client-1.0.11 → arkindex-client-1.0.12}/arkindex_client.egg-info/requires.txt +0 -0
  17. {arkindex-client-1.0.11 → arkindex-client-1.0.12}/arkindex_client.egg-info/top_level.txt +0 -0
  18. {arkindex-client-1.0.11 → arkindex-client-1.0.12}/requirements.txt +0 -0
  19. {arkindex-client-1.0.11 → arkindex-client-1.0.12}/setup.cfg +0 -0
  20. {arkindex-client-1.0.11 → arkindex-client-1.0.12}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: arkindex-client
3
- Version: 1.0.11
3
+ Version: 1.0.12
4
4
  Summary: API client for the Arkindex project
5
5
  Home-page: https://gitlab.com/teklia/arkindex/api-client
6
6
  Author: Teklia <contact@teklia.com>
@@ -0,0 +1 @@
1
+ 1.0.12
@@ -32,9 +32,18 @@ def options_from_env():
32
32
  Get API client keyword arguments from environment variables.
33
33
  """
34
34
  options = {}
35
- if "ARKINDEX_API_TOKEN" in os.environ:
35
+ # ARKINDEX_TASK_TOKEN takes priority over ARKINDEX_API_TOKEN
36
+ if "ARKINDEX_TASK_TOKEN" in os.environ:
37
+ options["auth_scheme"] = "Ponos"
38
+ options["token"] = os.environ.get("ARKINDEX_TASK_TOKEN")
39
+ elif "ARKINDEX_API_TOKEN" in os.environ:
40
+ options["auth_scheme"] = "Token"
36
41
  options["token"] = os.environ.get("ARKINDEX_API_TOKEN")
37
42
 
43
+ # Allow overriding the default auth schemes
44
+ if "ARKINDEX_API_AUTH_SCHEME" in os.environ:
45
+ options["auth_scheme"] = os.environ.get("ARKINDEX_API_AUTH_SCHEME")
46
+
38
47
  if "ARKINDEX_API_URL" in os.environ:
39
48
  options["base_url"] = os.environ.get("ARKINDEX_API_URL")
40
49
 
@@ -63,6 +72,7 @@ class ArkindexClient(apistar.Client):
63
72
  def __init__(
64
73
  self,
65
74
  token=None,
75
+ auth_scheme="Token",
66
76
  base_url=DEFAULT_BASE_URL,
67
77
  schema_url=None,
68
78
  csrf_cookie=None,
@@ -139,7 +149,11 @@ class ArkindexClient(apistar.Client):
139
149
  csrf_cookie = csrf_cookies.get(split_base_url.netloc) or "arkindex.csrf"
140
150
 
141
151
  self.configure(
142
- token=token, base_url=base_url, csrf_cookie=csrf_cookie, sleep=sleep
152
+ token=token,
153
+ auth_scheme=auth_scheme,
154
+ base_url=base_url,
155
+ csrf_cookie=csrf_cookie,
156
+ sleep=sleep,
143
157
  )
144
158
 
145
159
  def __repr__(self):
@@ -151,12 +165,25 @@ class ArkindexClient(apistar.Client):
151
165
  def init_transport(self, *args, **kwargs):
152
166
  return ArkindexHTTPTransport(*args, **kwargs)
153
167
 
154
- def configure(self, token=None, base_url=None, csrf_cookie=None, sleep=None):
168
+ def configure(
169
+ self,
170
+ token=None,
171
+ auth_scheme="Token",
172
+ base_url=None,
173
+ csrf_cookie=None,
174
+ sleep=None,
175
+ ):
155
176
  """
156
177
  Reconfigure the API client.
157
178
 
158
179
  :param token: An API token to use. If omitted, access is restricted to public endpoints.
159
180
  :type token: str or None
181
+ :param auth_scheme:
182
+ An authentication scheme to use. This is added in the HTTP header before the token:
183
+ ``Authorization: [scheme] [token]``.
184
+ This should use ``Token`` to authenticate as a regular user and ``Ponos`` to authenticate as a Ponos task.
185
+ If omitted, this defaults to ``Token``.
186
+ :type auth_scheme: str or None
160
187
  :param base_url: A custom base URL for the client. If omitted, defaults to the Arkindex main server.
161
188
  :type base_url: str or None
162
189
  :param csrf_cookie: Use a custom CSRF cookie name. Falls back to ``arkindex.csrf``.
@@ -167,7 +194,9 @@ class ArkindexClient(apistar.Client):
167
194
  if not csrf_cookie:
168
195
  csrf_cookie = "arkindex.csrf"
169
196
  self.transport.session.auth = TokenSessionAuthentication(
170
- token, csrf_cookie_name=csrf_cookie
197
+ token,
198
+ csrf_cookie_name=csrf_cookie,
199
+ scheme=auth_scheme,
171
200
  )
172
201
 
173
202
  if not sleep or not isinstance(sleep, float) or sleep < 0:
@@ -200,6 +229,7 @@ class ArkindexClient(apistar.Client):
200
229
  """
201
230
  resp = self.request("Login", body={"email": email, "password": password})
202
231
  if "auth_token" in resp:
232
+ self.transport.session.auth.scheme = "Token"
203
233
  self.transport.session.auth.token = resp["auth_token"]
204
234
  return resp
205
235
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: arkindex-client
3
- Version: 1.0.11
3
+ Version: 1.0.12
4
4
  Summary: API client for the Arkindex project
5
5
  Home-page: https://gitlab.com/teklia/arkindex/api-client
6
6
  Author: Teklia <contact@teklia.com>
@@ -1 +0,0 @@
1
- 1.0.11