rucio-clients 38.3.0__py3-none-any.whl → 38.4.0__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.

Potentially problematic release.


This version of rucio-clients might be problematic. Click here for more details.

Files changed (40) hide show
  1. rucio/cli/did.py +1 -1
  2. rucio/cli/opendata.py +19 -2
  3. rucio/client/accountclient.py +20 -19
  4. rucio/client/accountlimitclient.py +5 -4
  5. rucio/client/baseclient.py +25 -25
  6. rucio/client/configclient.py +7 -6
  7. rucio/client/credentialclient.py +2 -1
  8. rucio/client/didclient.py +33 -32
  9. rucio/client/diracclient.py +2 -1
  10. rucio/client/exportclient.py +2 -1
  11. rucio/client/importclient.py +2 -1
  12. rucio/client/lifetimeclient.py +3 -2
  13. rucio/client/lockclient.py +4 -3
  14. rucio/client/metaconventionsclient.py +5 -4
  15. rucio/client/opendataclient.py +8 -7
  16. rucio/client/pingclient.py +2 -1
  17. rucio/client/replicaclient.py +27 -26
  18. rucio/client/requestclient.py +8 -8
  19. rucio/client/rseclient.py +31 -28
  20. rucio/client/ruleclient.py +13 -12
  21. rucio/client/scopeclient.py +4 -3
  22. rucio/client/subscriptionclient.py +6 -5
  23. rucio/common/constants.py +18 -0
  24. rucio/common/exception.py +20 -0
  25. rucio/common/plugins.py +9 -7
  26. rucio/rse/protocols/webdav.py +5 -2
  27. rucio/vcsversion.py +3 -3
  28. {rucio_clients-38.3.0.dist-info → rucio_clients-38.4.0.dist-info}/METADATA +1 -1
  29. {rucio_clients-38.3.0.dist-info → rucio_clients-38.4.0.dist-info}/RECORD +40 -40
  30. {rucio_clients-38.3.0.data → rucio_clients-38.4.0.data}/data/etc/rse-accounts.cfg.template +0 -0
  31. {rucio_clients-38.3.0.data → rucio_clients-38.4.0.data}/data/etc/rucio.cfg.atlas.client.template +0 -0
  32. {rucio_clients-38.3.0.data → rucio_clients-38.4.0.data}/data/etc/rucio.cfg.template +0 -0
  33. {rucio_clients-38.3.0.data → rucio_clients-38.4.0.data}/data/requirements.client.txt +0 -0
  34. {rucio_clients-38.3.0.data → rucio_clients-38.4.0.data}/data/rucio_client/merge_rucio_configs.py +0 -0
  35. {rucio_clients-38.3.0.data → rucio_clients-38.4.0.data}/scripts/rucio +0 -0
  36. {rucio_clients-38.3.0.data → rucio_clients-38.4.0.data}/scripts/rucio-admin +0 -0
  37. {rucio_clients-38.3.0.dist-info → rucio_clients-38.4.0.dist-info}/WHEEL +0 -0
  38. {rucio_clients-38.3.0.dist-info → rucio_clients-38.4.0.dist-info}/licenses/AUTHORS.rst +0 -0
  39. {rucio_clients-38.3.0.dist-info → rucio_clients-38.4.0.dist-info}/licenses/LICENSE +0 -0
  40. {rucio_clients-38.3.0.dist-info → rucio_clients-38.4.0.dist-info}/top_level.txt +0 -0
rucio/cli/did.py CHANGED
@@ -35,7 +35,7 @@ def did():
35
35
  """,
36
36
  ) # TODO Shorten this help and make supplying this easier
37
37
  @click.option("--short", is_flag=True, default=False, help="Just dump the list of DIDs.")
38
- @click.argument("did-pattern", nargs=-1)
38
+ @click.argument("did-pattern", nargs=-1, required=True)
39
39
  @click.option("--parent", default=False, is_flag=True, help="List the parents of the DID - must use a full DID scope and name")
40
40
  @click.pass_context
41
41
  def list_(ctx, did_pattern, recursive, filter_, short, parent):
rucio/cli/opendata.py CHANGED
@@ -175,9 +175,26 @@ def update_opendata_did(ctx: "Context", did: str, meta: Optional[str],
175
175
  Update an existing Opendata DID in the Opendata catalog.
176
176
  """
177
177
 
178
- client = ctx.obj.client
179
178
  if not any([meta, state, doi]):
180
179
  raise ValueError("At least one of --meta, --state, or --doi must be provided.")
181
180
 
181
+ client = ctx.obj.client
182
+ spinner = ctx.obj.spinner
183
+ console = ctx.obj.console
184
+
182
185
  scope, name = extract_scope(did)
183
- client.update_opendata_did(scope=scope, name=name, meta=meta, state=state, doi=doi)
186
+ info = client.update_opendata_did(scope=scope, name=name, meta=meta, state=state, doi=doi)
187
+
188
+ if cli_config == 'rich':
189
+ spinner.update(status='Fetching Opendata DID stats')
190
+ spinner.start()
191
+ keyword_styles = {**CLITheme.BOOLEAN, **CLITheme.OPENDATA_DID_STATE}
192
+
193
+ table_data = [(k, Text(str(v), style=keyword_styles.get(str(v), 'default'))) for (k, v) in
194
+ sorted(info.items())]
195
+ table = generate_table(table_data, row_styles=['none'], col_alignments=['left', 'left'])
196
+ spinner.stop()
197
+ print_output(table, console=console, no_pager=ctx.obj.no_pager)
198
+ else:
199
+ table = [(k + ':', str(v)) for (k, v) in sorted(info.items())]
200
+ print(tabulate(table, tablefmt='plain', disable_numparse=True))
@@ -19,6 +19,7 @@ from urllib.parse import quote_plus
19
19
  from requests.status_codes import codes
20
20
 
21
21
  from rucio.client.baseclient import BaseClient, choice
22
+ from rucio.common.constants import HTTPMethod
22
23
  from rucio.common.utils import build_url
23
24
 
24
25
  if TYPE_CHECKING:
@@ -59,7 +60,7 @@ class AccountClient(BaseClient):
59
60
  path = '/'.join([self.ACCOUNTS_BASEURL, account])
60
61
  url = build_url(choice(self.list_hosts), path=path)
61
62
 
62
- res = self._send_request(url, type_='POST', data=data)
63
+ res = self._send_request(url, method=HTTPMethod.POST, data=data)
63
64
  if res.status_code == codes.created:
64
65
  return True
65
66
  exc_cls, exc_msg = self._get_exception(headers=res.headers, status_code=res.status_code, data=res.content)
@@ -88,7 +89,7 @@ class AccountClient(BaseClient):
88
89
  path = '/'.join([self.ACCOUNTS_BASEURL, account])
89
90
  url = build_url(choice(self.list_hosts), path=path)
90
91
 
91
- res = self._send_request(url, type_='DEL')
92
+ res = self._send_request(url, method=HTTPMethod.DELETE)
92
93
 
93
94
  if res.status_code == codes.ok:
94
95
  return True
@@ -118,7 +119,7 @@ class AccountClient(BaseClient):
118
119
  path = '/'.join([self.ACCOUNTS_BASEURL, account])
119
120
  url = build_url(choice(self.list_hosts), path=path)
120
121
 
121
- res = self._send_request(url)
122
+ res = self._send_request(url, method=HTTPMethod.GET)
122
123
  if res.status_code == codes.ok:
123
124
  acc = self._load_json_data(res)
124
125
  return next(acc)
@@ -152,7 +153,7 @@ class AccountClient(BaseClient):
152
153
  path = '/'.join([self.ACCOUNTS_BASEURL, account])
153
154
  url = build_url(choice(self.list_hosts), path=path)
154
155
 
155
- res = self._send_request(url, type_='PUT', data=data)
156
+ res = self._send_request(url, method=HTTPMethod.PUT, data=data)
156
157
 
157
158
  if res.status_code == codes.ok:
158
159
  return True
@@ -199,7 +200,7 @@ class AccountClient(BaseClient):
199
200
  for key in filters:
200
201
  params[key] = filters[key]
201
202
 
202
- res = self._send_request(url, params=params)
203
+ res = self._send_request(url, method=HTTPMethod.GET, params=params)
203
204
 
204
205
  if res.status_code == codes.ok:
205
206
  accounts = self._load_json_data(res)
@@ -263,7 +264,7 @@ class AccountClient(BaseClient):
263
264
 
264
265
  url = build_url(choice(self.list_hosts), path=path)
265
266
 
266
- res = self._send_request(url, type_='POST', data=data)
267
+ res = self._send_request(url, method=HTTPMethod.POST, data=data)
267
268
 
268
269
  if res.status_code == codes.created:
269
270
  return True
@@ -300,7 +301,7 @@ class AccountClient(BaseClient):
300
301
 
301
302
  url = build_url(choice(self.list_hosts), path=path)
302
303
 
303
- res = self._send_request(url, type_='DEL', data=data)
304
+ res = self._send_request(url, method=HTTPMethod.DELETE, data=data)
304
305
 
305
306
  if res.status_code == codes.ok:
306
307
  return True
@@ -319,7 +320,7 @@ class AccountClient(BaseClient):
319
320
  """
320
321
  path = '/'.join([self.ACCOUNTS_BASEURL, account, 'identities'])
321
322
  url = build_url(choice(self.list_hosts), path=path)
322
- res = self._send_request(url)
323
+ res = self._send_request(url, method=HTTPMethod.GET)
323
324
  if res.status_code == codes.ok:
324
325
  identities = self._load_json_data(res)
325
326
  return identities
@@ -340,7 +341,7 @@ class AccountClient(BaseClient):
340
341
 
341
342
  path = '/'.join([self.ACCOUNTS_BASEURL, account, 'rules'])
342
343
  url = build_url(choice(self.list_hosts), path=path)
343
- res = self._send_request(url, type_='GET')
344
+ res = self._send_request(url, method=HTTPMethod.GET)
344
345
  if res.status_code == codes.ok:
345
346
  return self._load_json_data(res)
346
347
  else:
@@ -385,7 +386,7 @@ class AccountClient(BaseClient):
385
386
 
386
387
  path = '/'.join([self.ACCOUNTS_BASEURL, account, 'limits', 'global', quote_plus(rse_expression)])
387
388
  url = build_url(choice(self.list_hosts), path=path)
388
- res = self._send_request(url, type_='GET')
389
+ res = self._send_request(url, method=HTTPMethod.GET)
389
390
  if res.status_code == codes.ok:
390
391
  return next(self._load_json_data(res))
391
392
  exc_cls, exc_msg = self._get_exception(headers=res.headers, status_code=res.status_code, data=res.content)
@@ -403,7 +404,7 @@ class AccountClient(BaseClient):
403
404
 
404
405
  path = '/'.join([self.ACCOUNTS_BASEURL, account, 'limits', 'global'])
405
406
  url = build_url(choice(self.list_hosts), path=path)
406
- res = self._send_request(url, type_='GET')
407
+ res = self._send_request(url, method=HTTPMethod.GET)
407
408
  if res.status_code == codes.ok:
408
409
  return next(self._load_json_data(res))
409
410
  exc_cls, exc_msg = self._get_exception(headers=res.headers, status_code=res.status_code, data=res.content)
@@ -421,7 +422,7 @@ class AccountClient(BaseClient):
421
422
 
422
423
  path = '/'.join([self.ACCOUNTS_BASEURL, account, 'limits', 'local'])
423
424
  url = build_url(choice(self.list_hosts), path=path)
424
- res = self._send_request(url, type_='GET')
425
+ res = self._send_request(url, method=HTTPMethod.GET)
425
426
  if res.status_code == codes.ok:
426
427
  return next(self._load_json_data(res))
427
428
  exc_cls, exc_msg = self._get_exception(headers=res.headers, status_code=res.status_code, data=res.content)
@@ -441,7 +442,7 @@ class AccountClient(BaseClient):
441
442
 
442
443
  path = '/'.join([self.ACCOUNTS_BASEURL, account, 'limits', 'local', rse])
443
444
  url = build_url(choice(self.list_hosts), path=path)
444
- res = self._send_request(url, type_='GET')
445
+ res = self._send_request(url, method=HTTPMethod.GET)
445
446
  if res.status_code == codes.ok:
446
447
  return next(self._load_json_data(res))
447
448
  exc_cls, exc_msg = self._get_exception(headers=res.headers, status_code=res.status_code, data=res.content)
@@ -463,7 +464,7 @@ class AccountClient(BaseClient):
463
464
  else:
464
465
  path = '/'.join([self.ACCOUNTS_BASEURL, account, 'usage', 'local'])
465
466
  url = build_url(choice(self.list_hosts), path=path)
466
- res = self._send_request(url, type_='GET')
467
+ res = self._send_request(url, method=HTTPMethod.GET)
467
468
  if res.status_code == codes.ok:
468
469
  return self._load_json_data(res)
469
470
  else:
@@ -486,7 +487,7 @@ class AccountClient(BaseClient):
486
487
  else:
487
488
  path = '/'.join([self.ACCOUNTS_BASEURL, account, 'usage', 'global'])
488
489
  url = build_url(choice(self.list_hosts), path=path)
489
- res = self._send_request(url, type_='GET')
490
+ res = self._send_request(url, method=HTTPMethod.GET)
490
491
  if res.status_code == codes.ok:
491
492
  return self._load_json_data(res)
492
493
  else:
@@ -506,7 +507,7 @@ class AccountClient(BaseClient):
506
507
  """
507
508
  path = '/'.join([self.ACCOUNTS_BASEURL, account, 'usage/history', rse])
508
509
  url = build_url(choice(self.list_hosts), path=path)
509
- res = self._send_request(url, type_='GET')
510
+ res = self._send_request(url, method=HTTPMethod.GET)
510
511
  if res.status_code == codes.ok:
511
512
  return next(self._load_json_data(res))
512
513
  else:
@@ -524,7 +525,7 @@ class AccountClient(BaseClient):
524
525
  """
525
526
  path = '/'.join([self.ACCOUNTS_BASEURL, account, 'attr/'])
526
527
  url = build_url(choice(self.list_hosts), path=path)
527
- res = self._send_request(url, type_='GET')
528
+ res = self._send_request(url, method=HTTPMethod.GET)
528
529
  if res.status_code == codes.ok:
529
530
  return self._load_json_data(res)
530
531
  else:
@@ -548,7 +549,7 @@ class AccountClient(BaseClient):
548
549
  data = dumps({'key': key, 'value': value})
549
550
  path = '/'.join([self.ACCOUNTS_BASEURL, account, 'attr', key])
550
551
  url = build_url(choice(self.list_hosts), path=path)
551
- res = self._send_request(url, type_='POST', data=data)
552
+ res = self._send_request(url, method=HTTPMethod.POST, data=data)
552
553
  if res.status_code == codes.created:
553
554
  return True
554
555
  else:
@@ -569,7 +570,7 @@ class AccountClient(BaseClient):
569
570
 
570
571
  path = '/'.join([self.ACCOUNTS_BASEURL, account, 'attr', key])
571
572
  url = build_url(choice(self.list_hosts), path=path)
572
- res = self._send_request(url, type_='DEL', data=None)
573
+ res = self._send_request(url, method=HTTPMethod.DELETE, data=None)
573
574
  if res.status_code == codes.ok:
574
575
  return True
575
576
  else:
@@ -19,6 +19,7 @@ from urllib.parse import quote_plus
19
19
  from requests.status_codes import codes
20
20
 
21
21
  from rucio.client.baseclient import BaseClient, choice
22
+ from rucio.common.constants import HTTPMethod
22
23
  from rucio.common.utils import build_url
23
24
 
24
25
 
@@ -123,7 +124,7 @@ class AccountLimitClient(BaseClient):
123
124
  path = '/'.join([self.ACCOUNTLIMIT_BASEURL, 'local', account, rse])
124
125
  url = build_url(choice(self.list_hosts), path=path)
125
126
 
126
- r = self._send_request(url, type_='POST', data=data)
127
+ r = self._send_request(url, method=HTTPMethod.POST, data=data)
127
128
 
128
129
  if r.status_code == codes.created:
129
130
  return True
@@ -160,7 +161,7 @@ class AccountLimitClient(BaseClient):
160
161
  path = '/'.join([self.ACCOUNTLIMIT_BASEURL, 'local', account, rse])
161
162
  url = build_url(choice(self.list_hosts), path=path)
162
163
 
163
- r = self._send_request(url, type_='DEL')
164
+ r = self._send_request(url, method=HTTPMethod.DELETE)
164
165
 
165
166
  if r.status_code == codes.ok:
166
167
  return True
@@ -196,7 +197,7 @@ class AccountLimitClient(BaseClient):
196
197
  path = '/'.join([self.ACCOUNTLIMIT_BASEURL, 'global', account, quote_plus(rse_expression)])
197
198
  url = build_url(choice(self.list_hosts), path=path)
198
199
 
199
- r = self._send_request(url, type_='POST', data=data)
200
+ r = self._send_request(url, method=HTTPMethod.POST, data=data)
200
201
 
201
202
  if r.status_code == codes.created:
202
203
  return True
@@ -233,7 +234,7 @@ class AccountLimitClient(BaseClient):
233
234
  path = '/'.join([self.ACCOUNTLIMIT_BASEURL, 'global', account, quote_plus(rse_expression)])
234
235
  url = build_url(choice(self.list_hosts), path=path)
235
236
 
236
- r = self._send_request(url, type_='DEL')
237
+ r = self._send_request(url, method=HTTPMethod.DELETE)
237
238
 
238
239
  if r.status_code == codes.ok:
239
240
  return True
@@ -38,7 +38,7 @@ from requests.status_codes import codes
38
38
  from rucio import version
39
39
  from rucio.common import exception
40
40
  from rucio.common.config import config_get, config_get_bool, config_get_int, config_has_section
41
- from rucio.common.constants import DEFAULT_VO
41
+ from rucio.common.constants import DEFAULT_VO, HTTPMethod
42
42
  from rucio.common.exception import CannotAuthenticate, ClientProtocolNotFound, ClientProtocolNotSupported, ConfigNotFound, MissingClientParameter, MissingModuleException, NoAuthInformation, ServerConnectionException
43
43
  from rucio.common.extra import import_extras
44
44
  from rucio.common.utils import build_url, get_tmp_dir, my_key_generator, parse_response, setup_logger, ssh_sign, wlcg_token_discovery
@@ -440,14 +440,14 @@ class BaseClient:
440
440
  self.logger.warning("Waiting {}s due to reason: {} ".format(sleep_time, reason))
441
441
  time.sleep(sleep_time)
442
442
 
443
- def _send_request(self, url, headers=None, type_='GET', data=None, params=None, stream=False, get_token=False,
443
+ def _send_request(self, url, method, headers=None, data=None, params=None, stream=False, get_token=False,
444
444
  cert=None, auth=None, verify=None):
445
445
  """
446
446
  Helper method to send requests to the rucio server. Gets a new token and retries if an unauthorized error is returned.
447
447
 
448
448
  :param url: the http url to use.
449
449
  :param headers: additional http headers to send.
450
- :param type_: the http request type to use.
450
+ :param method: the http request type to use.
451
451
  :param data: post data.
452
452
  :param params: (optional) Dictionary or bytes to be sent in the url query string.
453
453
  :param get_token: (optional) if it is called from a _get_token function.
@@ -469,28 +469,28 @@ class BaseClient:
469
469
  if verify is None:
470
470
  verify = self.ca_cert or False # Maybe unnecessary but make sure to convert "" -> False
471
471
 
472
- self.logger.debug("HTTP request: %s %s" % (type_, url))
472
+ self.logger.debug("HTTP request: %s %s" % (method.value, url))
473
473
  for h, v in hds.items():
474
474
  if h == 'X-Rucio-Auth-Token':
475
475
  v = "[hidden]"
476
476
  self.logger.debug("HTTP header: %s: %s" % (h, v))
477
- if type_ != "GET" and data:
477
+ if method != HTTPMethod.GET and data:
478
478
  text = self._reduce_data(data)
479
479
  self.logger.debug("Request data (length=%d): [%s]" % (len(data), text))
480
480
 
481
481
  result = None
482
482
  for retry in range(self.AUTH_RETRIES + 1):
483
483
  try:
484
- if type_ == 'GET':
484
+ if method == HTTPMethod.GET:
485
485
  result = self.session.get(url, headers=hds, verify=verify, timeout=self.timeout, params=params, stream=True, cert=cert, auth=auth)
486
- elif type_ == 'PUT':
486
+ elif method == HTTPMethod.PUT:
487
487
  result = self.session.put(url, headers=hds, data=data, verify=verify, timeout=self.timeout)
488
- elif type_ == 'POST':
488
+ elif method == HTTPMethod.POST:
489
489
  result = self.session.post(url, headers=hds, data=data, verify=verify, timeout=self.timeout, stream=stream)
490
- elif type_ == 'DEL':
490
+ elif method == HTTPMethod.DELETE:
491
491
  result = self.session.delete(url, headers=hds, data=data, verify=verify, timeout=self.timeout)
492
492
  else:
493
- self.logger.debug("Unknown request type %s. Request was not sent" % (type_,))
493
+ self.logger.debug("Unknown request type %s. Request was not sent" % (method,))
494
494
  return None
495
495
  self.logger.debug("HTTP Response: %s %s" % (result.status_code, result.reason))
496
496
  if result.status_code in STATUS_CODES_TO_RETRY:
@@ -537,7 +537,7 @@ class BaseClient:
537
537
 
538
538
  url = build_url(self.auth_host, path='auth/userpass')
539
539
 
540
- result = self._send_request(url, headers=headers, get_token=True)
540
+ result = self._send_request(url, method=HTTPMethod.GET, headers=headers, get_token=True)
541
541
 
542
542
  if not result:
543
543
  # result is either None or not OK.
@@ -590,7 +590,7 @@ class BaseClient:
590
590
  return False
591
591
 
592
592
  request_refresh_url = build_url(self.auth_host, path='auth/oidc_refresh')
593
- refresh_result = self._send_request(request_refresh_url, get_token=True)
593
+ refresh_result = self._send_request(request_refresh_url,method=HTTPMethod.GET, get_token=True)
594
594
  if refresh_result.status_code == codes.ok:
595
595
  if 'X-Rucio-Auth-Token-Expires' not in refresh_result.headers or \
596
596
  'X-Rucio-Auth-Token' not in refresh_result.headers:
@@ -644,7 +644,7 @@ class BaseClient:
644
644
  request_auth_url = build_url(self.auth_host, path='auth/oidc')
645
645
  # requesting authorization URL specific to the user & Rucio OIDC Client
646
646
  self.logger.debug("Initial auth URL request headers %s to files" % str(headers))
647
- oidc_auth_res = self._send_request(request_auth_url, headers=headers, get_token=True)
647
+ oidc_auth_res = self._send_request(request_auth_url, method=HTTPMethod.GET, headers=headers, get_token=True)
648
648
  self.logger.debug("Response headers %s and text %s" % (str(oidc_auth_res.headers), str(oidc_auth_res.text)))
649
649
  # with the obtained authorization URL we will contact the Identity Provider to get to the login page
650
650
  if 'X-Rucio-OIDC-Auth-URL' not in oidc_auth_res.headers:
@@ -665,7 +665,7 @@ class BaseClient:
665
665
  \nthe Rucio authentication server for a token.")
666
666
  print("----------------------------------------------")
667
667
  while time.time() - start < timeout:
668
- result = self._send_request(auth_url, headers=headers, get_token=True)
668
+ result = self._send_request(auth_url, method=HTTPMethod.GET, headers=headers, get_token=True)
669
669
  if 'X-Rucio-Auth-Token' in result.headers and result.status_code == codes.ok:
670
670
  break
671
671
  time.sleep(2)
@@ -675,7 +675,7 @@ class BaseClient:
675
675
  while count < 3:
676
676
  fetchcode = input()
677
677
  fetch_url = build_url(self.auth_host, path='auth/oidc_redirect', params=fetchcode)
678
- result = self._send_request(fetch_url, headers=headers, get_token=True)
678
+ result = self._send_request(fetch_url, method=HTTPMethod.GET, headers=headers, get_token=True)
679
679
  if 'X-Rucio-Auth-Token' in result.headers and result.status_code == codes.ok:
680
680
  break
681
681
  else:
@@ -688,11 +688,11 @@ class BaseClient:
688
688
  + "your password with any 3rd party application, therefore, \n" # NOQA: W503
689
689
  + "we strongly discourage you from following this --oidc-auto approach.") # NOQA: W503
690
690
  print("-------------------------------------------------------------------------")
691
- auth_res = self._send_request(auth_url, get_token=True)
691
+ auth_res = self._send_request(auth_url, method=HTTPMethod.GET, get_token=True)
692
692
  # getting the login URL and logging in the user
693
693
  login_url = auth_res.url
694
694
  start = time.time()
695
- result = self._send_request(login_url, type_='POST', data=userpass)
695
+ result = self._send_request(login_url, method=HTTPMethod.POST, data=userpass)
696
696
 
697
697
  # if the Rucio OIDC Client configuration does not match the one registered at the Identity Provider
698
698
  # the user will get an OAuth error
@@ -714,7 +714,7 @@ class BaseClient:
714
714
  self.logger.warning('Automatically authorising request of the following info on behalf of user: %s',
715
715
  str(form_data))
716
716
  # authorizing info request on behalf of the user until he/she revokes this authorization !
717
- result = self._send_request(result.url, type_='POST', data=form_data)
717
+ result = self._send_request(result.url, method=HTTPMethod.POST, data=form_data)
718
718
 
719
719
  if not result:
720
720
  self.logger.error('Cannot retrieve authentication token!')
@@ -767,7 +767,7 @@ class BaseClient:
767
767
  else:
768
768
  cert = (client_cert, client_key)
769
769
 
770
- result = self._send_request(url, get_token=True, cert=cert)
770
+ result = self._send_request(url, method=HTTPMethod.GET, get_token=True, cert=cert)
771
771
 
772
772
  # Note a response object for a failed request evaluates to false, so we cannot
773
773
  # use "not result" here
@@ -802,7 +802,7 @@ class BaseClient:
802
802
 
803
803
  url = build_url(self.auth_host, path='auth/ssh_challenge_token')
804
804
 
805
- result = self._send_request(url, get_token=True)
805
+ result = self._send_request(url, method=HTTPMethod.GET, get_token=True)
806
806
 
807
807
  if not result:
808
808
  self.logger.error('cannot get ssh_challenge_token')
@@ -825,7 +825,7 @@ class BaseClient:
825
825
 
826
826
  url = build_url(self.auth_host, path='auth/ssh')
827
827
 
828
- result = self._send_request(url, headers=headers, get_token=True)
828
+ result = self._send_request(url, method=HTTPMethod.GET, headers=headers, get_token=True)
829
829
 
830
830
  if not result:
831
831
  self.logger.error('Cannot retrieve authentication token!')
@@ -851,7 +851,7 @@ class BaseClient:
851
851
 
852
852
  url = build_url(self.auth_host, path='auth/gss')
853
853
 
854
- result = self._send_request(url, get_token=True, auth=HTTPKerberosAuth())
854
+ result = self._send_request(url, method=HTTPMethod.GET, get_token=True, auth=HTTPKerberosAuth())
855
855
 
856
856
  if not result:
857
857
  self.logger.error('Cannot retrieve authentication token!')
@@ -876,12 +876,12 @@ class BaseClient:
876
876
  url = build_url(self.auth_host, path='auth/saml')
877
877
 
878
878
  result = None
879
- saml_auth_result = self._send_request(url, get_token=True)
879
+ saml_auth_result = self._send_request(url, method=HTTPMethod.GET, get_token=True)
880
880
  if saml_auth_result.headers['X-Rucio-Auth-Token']:
881
881
  return saml_auth_result.headers['X-Rucio-Auth-Token']
882
882
  saml_auth_url = saml_auth_result.headers['X-Rucio-SAML-Auth-URL']
883
- result = self._send_request(saml_auth_url, type_='POST', data=userpass, verify=False)
884
- result = self._send_request(url, get_token=True)
883
+ result = self._send_request(saml_auth_url, method=HTTPMethod.POST, data=userpass, verify=False)
884
+ result = self._send_request(url, method=HTTPMethod.GET, get_token=True)
885
885
 
886
886
  if not result:
887
887
  self.logger.error('Cannot retrieve authentication token!')
@@ -18,6 +18,7 @@ from typing import Any, Optional
18
18
  from requests.status_codes import codes
19
19
 
20
20
  from rucio.client.baseclient import BaseClient, choice
21
+ from rucio.common.constants import HTTPMethod
21
22
  from rucio.common.utils import build_url
22
23
 
23
24
 
@@ -54,7 +55,7 @@ class ConfigClient(BaseClient):
54
55
 
55
56
  url = build_url(choice(self.list_hosts), path=path)
56
57
 
57
- r = self._send_request(url, type_='GET')
58
+ r = self._send_request(url, method=HTTPMethod.GET)
58
59
  if r.status_code == codes.ok:
59
60
  return r.json()
60
61
  else:
@@ -90,7 +91,7 @@ class ConfigClient(BaseClient):
90
91
  Note:
91
92
  ------
92
93
  The format of the /config endpoint was recently changed. We migrated from performing a PUT on
93
- "/config/<section>/<option>/<value>" to sending the parameters using a json-encoded body.
94
+ "/config/{section}/{option}/{value}" to sending the parameters using a json-encoded body.
94
95
  This was done to fix multiple un-wanted side effects related to how the middleware treats
95
96
  values encoded in a path.
96
97
  For a smooth transition, we allow both cases for now, but we should migrate to only passing
@@ -104,11 +105,11 @@ class ConfigClient(BaseClient):
104
105
  option: value
105
106
  }
106
107
  })
107
- r = self._send_request(url, type_='POST', data=data)
108
+ r = self._send_request(url, method=HTTPMethod.POST, data=data)
108
109
  else:
109
110
  path = '/'.join([self.CONFIG_BASEURL, section, option, value])
110
111
  url = build_url(choice(self.list_hosts), path=path)
111
- r = self._send_request(url, type_='PUT')
112
+ r = self._send_request(url, method=HTTPMethod.PUT)
112
113
 
113
114
  if r.status_code == codes.created:
114
115
  return True
@@ -140,7 +141,7 @@ class ConfigClient(BaseClient):
140
141
  path = '/'.join([self.CONFIG_BASEURL, section, option])
141
142
  url = build_url(choice(self.list_hosts), path=path)
142
143
 
143
- r = self._send_request(url, type_='DEL')
144
+ r = self._send_request(url, method=HTTPMethod.DELETE)
144
145
 
145
146
  if r.status_code == codes.ok:
146
147
  return True
@@ -163,7 +164,7 @@ class ConfigClient(BaseClient):
163
164
  """
164
165
  path = '/'.join([self.CONFIG_BASEURL, section])
165
166
  url = build_url(choice(self.list_hosts), path=path)
166
- r = self._send_request(url, type_='DEL')
167
+ r = self._send_request(url, method=HTTPMethod.DELETE)
167
168
 
168
169
  if r.status_code == codes.ok:
169
170
  return True
@@ -15,6 +15,7 @@
15
15
  from requests.status_codes import codes
16
16
 
17
17
  from rucio.client.baseclient import BaseClient, choice
18
+ from rucio.common.constants import HTTPMethod
18
19
  from rucio.common.utils import build_url
19
20
 
20
21
 
@@ -60,7 +61,7 @@ class CredentialClient(BaseClient):
60
61
  params['op'] = operation
61
62
  params['url'] = url
62
63
  rurl = build_url(choice(self.list_hosts), path=path, params=params)
63
- r = self._send_request(rurl, type_='GET')
64
+ r = self._send_request(rurl, method=HTTPMethod.GET)
64
65
 
65
66
  if r.status_code == codes.ok:
66
67
  return r.text