rucio-clients 38.2.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.
- rucio/cli/bin_legacy/rucio.py +26 -23
- rucio/cli/command.py +36 -26
- rucio/cli/config.py +22 -7
- rucio/cli/did.py +2 -2
- rucio/cli/download.py +1 -1
- rucio/cli/opendata.py +78 -10
- rucio/cli/utils.py +13 -1
- rucio/client/accountclient.py +20 -19
- rucio/client/accountlimitclient.py +5 -4
- rucio/client/baseclient.py +25 -25
- rucio/client/configclient.py +29 -5
- rucio/client/credentialclient.py +2 -1
- rucio/client/didclient.py +33 -32
- rucio/client/diracclient.py +2 -1
- rucio/client/exportclient.py +2 -1
- rucio/client/importclient.py +2 -1
- rucio/client/lifetimeclient.py +3 -2
- rucio/client/lockclient.py +4 -3
- rucio/client/metaconventionsclient.py +5 -4
- rucio/client/opendataclient.py +8 -7
- rucio/client/pingclient.py +2 -1
- rucio/client/replicaclient.py +27 -26
- rucio/client/requestclient.py +8 -8
- rucio/client/richclient.py +6 -0
- rucio/client/rseclient.py +31 -28
- rucio/client/ruleclient.py +13 -12
- rucio/client/scopeclient.py +4 -3
- rucio/client/subscriptionclient.py +6 -5
- rucio/common/constants.py +23 -0
- rucio/common/exception.py +30 -0
- rucio/common/plugins.py +33 -15
- rucio/common/utils.py +3 -3
- rucio/rse/protocols/webdav.py +5 -2
- rucio/rse/translation.py +3 -3
- rucio/vcsversion.py +3 -3
- {rucio_clients-38.2.0.dist-info → rucio_clients-38.4.0.dist-info}/METADATA +1 -1
- {rucio_clients-38.2.0.dist-info → rucio_clients-38.4.0.dist-info}/RECORD +48 -48
- {rucio_clients-38.2.0.data → rucio_clients-38.4.0.data}/data/etc/rse-accounts.cfg.template +0 -0
- {rucio_clients-38.2.0.data → rucio_clients-38.4.0.data}/data/etc/rucio.cfg.atlas.client.template +0 -0
- {rucio_clients-38.2.0.data → rucio_clients-38.4.0.data}/data/etc/rucio.cfg.template +0 -0
- {rucio_clients-38.2.0.data → rucio_clients-38.4.0.data}/data/requirements.client.txt +0 -0
- {rucio_clients-38.2.0.data → rucio_clients-38.4.0.data}/data/rucio_client/merge_rucio_configs.py +0 -0
- {rucio_clients-38.2.0.data → rucio_clients-38.4.0.data}/scripts/rucio +0 -0
- {rucio_clients-38.2.0.data → rucio_clients-38.4.0.data}/scripts/rucio-admin +0 -0
- {rucio_clients-38.2.0.dist-info → rucio_clients-38.4.0.dist-info}/WHEEL +0 -0
- {rucio_clients-38.2.0.dist-info → rucio_clients-38.4.0.dist-info}/licenses/AUTHORS.rst +0 -0
- {rucio_clients-38.2.0.dist-info → rucio_clients-38.4.0.dist-info}/licenses/LICENSE +0 -0
- {rucio_clients-38.2.0.dist-info → rucio_clients-38.4.0.dist-info}/top_level.txt +0 -0
rucio/client/baseclient.py
CHANGED
|
@@ -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,
|
|
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
|
|
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" % (
|
|
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
|
|
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
|
|
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
|
|
486
|
+
elif method == HTTPMethod.PUT:
|
|
487
487
|
result = self.session.put(url, headers=hds, data=data, verify=verify, timeout=self.timeout)
|
|
488
|
-
elif
|
|
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
|
|
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" % (
|
|
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,
|
|
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,
|
|
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,
|
|
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!')
|
rucio/client/configclient.py
CHANGED
|
@@ -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,
|
|
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
|
|
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,
|
|
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,
|
|
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,30 @@ 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,
|
|
144
|
+
r = self._send_request(url, method=HTTPMethod.DELETE)
|
|
145
|
+
|
|
146
|
+
if r.status_code == codes.ok:
|
|
147
|
+
return True
|
|
148
|
+
else:
|
|
149
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
150
|
+
raise exc_cls(exc_msg)
|
|
151
|
+
|
|
152
|
+
def delete_config_section(self, section: str):
|
|
153
|
+
"""
|
|
154
|
+
Delete a whole section from the config
|
|
155
|
+
|
|
156
|
+
Parameters
|
|
157
|
+
----------
|
|
158
|
+
section :
|
|
159
|
+
The name of the section.
|
|
160
|
+
|
|
161
|
+
Returns
|
|
162
|
+
-------
|
|
163
|
+
True if option was removed successfully.
|
|
164
|
+
"""
|
|
165
|
+
path = '/'.join([self.CONFIG_BASEURL, section])
|
|
166
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
167
|
+
r = self._send_request(url, method=HTTPMethod.DELETE)
|
|
144
168
|
|
|
145
169
|
if r.status_code == codes.ok:
|
|
146
170
|
return True
|
rucio/client/credentialclient.py
CHANGED
|
@@ -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,
|
|
64
|
+
r = self._send_request(rurl, method=HTTPMethod.GET)
|
|
64
65
|
|
|
65
66
|
if r.status_code == codes.ok:
|
|
66
67
|
return r.text
|
rucio/client/didclient.py
CHANGED
|
@@ -20,6 +20,7 @@ from urllib.parse import quote_plus
|
|
|
20
20
|
from requests.status_codes import codes
|
|
21
21
|
|
|
22
22
|
from rucio.client.baseclient import BaseClient, choice
|
|
23
|
+
from rucio.common.constants import HTTPMethod
|
|
23
24
|
from rucio.common.exception import DeprecationError
|
|
24
25
|
from rucio.common.utils import build_url, date_to_str, render_json
|
|
25
26
|
|
|
@@ -28,7 +29,6 @@ if TYPE_CHECKING:
|
|
|
28
29
|
|
|
29
30
|
|
|
30
31
|
class DIDClient(BaseClient):
|
|
31
|
-
|
|
32
32
|
"""DataIdentifier client class for working with data identifiers"""
|
|
33
33
|
|
|
34
34
|
DIDS_BASEURL = 'dids'
|
|
@@ -64,7 +64,7 @@ class DIDClient(BaseClient):
|
|
|
64
64
|
path = '/'.join([self.DIDS_BASEURL, quote_plus(scope), 'dids', 'search'])
|
|
65
65
|
|
|
66
66
|
# stringify dates.
|
|
67
|
-
if isinstance(filters, dict):
|
|
67
|
+
if isinstance(filters, dict): # backwards compatibility for filters as single {}
|
|
68
68
|
filters = [filters]
|
|
69
69
|
for or_group in filters:
|
|
70
70
|
for key, value in or_group.items():
|
|
@@ -80,7 +80,7 @@ class DIDClient(BaseClient):
|
|
|
80
80
|
|
|
81
81
|
url = build_url(choice(self.list_hosts), path=path, params=payload)
|
|
82
82
|
|
|
83
|
-
r = self._send_request(url,
|
|
83
|
+
r = self._send_request(url, method=HTTPMethod.GET)
|
|
84
84
|
|
|
85
85
|
if r.status_code == codes.ok:
|
|
86
86
|
dids = self._load_json_data(r)
|
|
@@ -148,7 +148,7 @@ class DIDClient(BaseClient):
|
|
|
148
148
|
data['dids'] = dids
|
|
149
149
|
if rse:
|
|
150
150
|
data['rse'] = rse
|
|
151
|
-
r = self._send_request(url,
|
|
151
|
+
r = self._send_request(url, method=HTTPMethod.POST, data=render_json(**data))
|
|
152
152
|
if r.status_code == codes.created:
|
|
153
153
|
return True
|
|
154
154
|
else:
|
|
@@ -161,7 +161,7 @@ class DIDClient(BaseClient):
|
|
|
161
161
|
"""
|
|
162
162
|
path = '/'.join([self.DIDS_BASEURL])
|
|
163
163
|
url = build_url(choice(self.list_hosts), path=path)
|
|
164
|
-
r = self._send_request(url,
|
|
164
|
+
r = self._send_request(url, method=HTTPMethod.POST, data=render_json(dids))
|
|
165
165
|
if r.status_code == codes.created:
|
|
166
166
|
return True
|
|
167
167
|
else:
|
|
@@ -245,7 +245,8 @@ class DIDClient(BaseClient):
|
|
|
245
245
|
lifetime :
|
|
246
246
|
DID's lifetime (in seconds).
|
|
247
247
|
"""
|
|
248
|
-
return self.add_did(scope=scope, name=name, did_type='CONTAINER', statuses=statuses, meta=meta, rules=rules,
|
|
248
|
+
return self.add_did(scope=scope, name=name, did_type='CONTAINER', statuses=statuses, meta=meta, rules=rules,
|
|
249
|
+
lifetime=lifetime)
|
|
249
250
|
|
|
250
251
|
def add_containers(self, cnts: "Sequence[dict[str, Any]]") -> bool:
|
|
251
252
|
"""
|
|
@@ -284,7 +285,7 @@ class DIDClient(BaseClient):
|
|
|
284
285
|
data: dict[str, Any] = {'dids': dids}
|
|
285
286
|
if rse:
|
|
286
287
|
data['rse'] = rse
|
|
287
|
-
r = self._send_request(url,
|
|
288
|
+
r = self._send_request(url, method=HTTPMethod.POST, data=render_json(**data))
|
|
288
289
|
if r.status_code == codes.created:
|
|
289
290
|
return True
|
|
290
291
|
else:
|
|
@@ -313,7 +314,7 @@ class DIDClient(BaseClient):
|
|
|
313
314
|
path = '/'.join([self.DIDS_BASEURL, quote_plus(scope), quote_plus(name), 'dids'])
|
|
314
315
|
url = build_url(choice(self.list_hosts), path=path)
|
|
315
316
|
data = {'dids': dids}
|
|
316
|
-
r = self._send_request(url,
|
|
317
|
+
r = self._send_request(url, method=HTTPMethod.DELETE, data=render_json(**data))
|
|
317
318
|
if r.status_code == codes.ok:
|
|
318
319
|
return True
|
|
319
320
|
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
@@ -339,7 +340,7 @@ class DIDClient(BaseClient):
|
|
|
339
340
|
path = '/'.join([self.DIDS_BASEURL, 'attachments'])
|
|
340
341
|
url = build_url(choice(self.list_hosts), path=path)
|
|
341
342
|
data = {'ignore_duplicate': ignore_duplicate, 'attachments': attachments}
|
|
342
|
-
r = self._send_request(url,
|
|
343
|
+
r = self._send_request(url, method=HTTPMethod.POST, data=dumps(data))
|
|
343
344
|
if r.status_code in (codes.ok, codes.no_content, codes.created):
|
|
344
345
|
return True
|
|
345
346
|
|
|
@@ -482,9 +483,9 @@ class DIDClient(BaseClient):
|
|
|
482
483
|
return self.attach_dids(scope=scope, name=name, dids=cnts)
|
|
483
484
|
|
|
484
485
|
def list_content(
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
486
|
+
self,
|
|
487
|
+
scope: str,
|
|
488
|
+
name: str
|
|
488
489
|
) -> "Iterator[dict[str, Any]]":
|
|
489
490
|
"""
|
|
490
491
|
List data identifier contents.
|
|
@@ -499,7 +500,7 @@ class DIDClient(BaseClient):
|
|
|
499
500
|
|
|
500
501
|
path = '/'.join([self.DIDS_BASEURL, quote_plus(scope), quote_plus(name), 'dids'])
|
|
501
502
|
url = build_url(choice(self.list_hosts), path=path)
|
|
502
|
-
r = self._send_request(url,
|
|
503
|
+
r = self._send_request(url, method=HTTPMethod.GET)
|
|
503
504
|
if r.status_code == codes.ok:
|
|
504
505
|
return self._load_json_data(r)
|
|
505
506
|
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
@@ -524,7 +525,7 @@ class DIDClient(BaseClient):
|
|
|
524
525
|
|
|
525
526
|
path = '/'.join([self.DIDS_BASEURL, quote_plus(scope), quote_plus(name), 'dids', 'history'])
|
|
526
527
|
url = build_url(choice(self.list_hosts), path=path)
|
|
527
|
-
r = self._send_request(url,
|
|
528
|
+
r = self._send_request(url, method=HTTPMethod.GET)
|
|
528
529
|
if r.status_code == codes.ok:
|
|
529
530
|
return self._load_json_data(r)
|
|
530
531
|
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
@@ -555,7 +556,7 @@ class DIDClient(BaseClient):
|
|
|
555
556
|
payload['long'] = True
|
|
556
557
|
url = build_url(choice(self.list_hosts), path=path, params=payload)
|
|
557
558
|
|
|
558
|
-
r = self._send_request(url,
|
|
559
|
+
r = self._send_request(url, method=HTTPMethod.GET)
|
|
559
560
|
if r.status_code == codes.ok:
|
|
560
561
|
return self._load_json_data(r)
|
|
561
562
|
else:
|
|
@@ -576,7 +577,7 @@ class DIDClient(BaseClient):
|
|
|
576
577
|
path = '/'.join([self.DIDS_BASEURL, 'bulkfiles'])
|
|
577
578
|
url = build_url(choice(self.list_hosts), path=path)
|
|
578
579
|
|
|
579
|
-
r = self._send_request(url,
|
|
580
|
+
r = self._send_request(url, method=HTTPMethod.POST, data=dumps(data), stream=True)
|
|
580
581
|
if r.status_code == codes.ok:
|
|
581
582
|
return self._load_json_data(r)
|
|
582
583
|
else:
|
|
@@ -613,7 +614,7 @@ class DIDClient(BaseClient):
|
|
|
613
614
|
elif dynamic:
|
|
614
615
|
params['dynamic_depth'] = 'FILE'
|
|
615
616
|
url = build_url(choice(self.list_hosts), path=path, params=params)
|
|
616
|
-
r = self._send_request(url,
|
|
617
|
+
r = self._send_request(url, method=HTTPMethod.GET)
|
|
617
618
|
if r.status_code == codes.ok:
|
|
618
619
|
return next(self._load_json_data(r))
|
|
619
620
|
else:
|
|
@@ -642,7 +643,7 @@ class DIDClient(BaseClient):
|
|
|
642
643
|
url = build_url(choice(self.list_hosts), path=path)
|
|
643
644
|
payload = {}
|
|
644
645
|
payload['plugin'] = plugin
|
|
645
|
-
r = self._send_request(url,
|
|
646
|
+
r = self._send_request(url, method=HTTPMethod.GET, params=payload)
|
|
646
647
|
if r.status_code == codes.ok:
|
|
647
648
|
meta = self._load_json_data(r)
|
|
648
649
|
return next(meta)
|
|
@@ -670,7 +671,7 @@ class DIDClient(BaseClient):
|
|
|
670
671
|
data = {'dids': dids, 'inherit': inherit, 'plugin': plugin}
|
|
671
672
|
path = '/'.join([self.DIDS_BASEURL, 'bulkmeta'])
|
|
672
673
|
url = build_url(choice(self.list_hosts), path=path)
|
|
673
|
-
r = self._send_request(url,
|
|
674
|
+
r = self._send_request(url, method=HTTPMethod.POST, data=dumps(data))
|
|
674
675
|
if r.status_code == codes.ok:
|
|
675
676
|
return self._load_json_data(r)
|
|
676
677
|
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
@@ -703,7 +704,7 @@ class DIDClient(BaseClient):
|
|
|
703
704
|
path = '/'.join([self.DIDS_BASEURL, quote_plus(scope), quote_plus(name), 'meta', key])
|
|
704
705
|
url = build_url(choice(self.list_hosts), path=path)
|
|
705
706
|
data = dumps({'value': value, 'recursive': recursive})
|
|
706
|
-
r = self._send_request(url,
|
|
707
|
+
r = self._send_request(url, method=HTTPMethod.POST, data=data)
|
|
707
708
|
if r.status_code == codes.created:
|
|
708
709
|
return True
|
|
709
710
|
else:
|
|
@@ -734,7 +735,7 @@ class DIDClient(BaseClient):
|
|
|
734
735
|
path = '/'.join([self.DIDS_BASEURL, quote_plus(scope), quote_plus(name), 'meta'])
|
|
735
736
|
url = build_url(choice(self.list_hosts), path=path)
|
|
736
737
|
data = dumps({'meta': meta, 'recursive': recursive})
|
|
737
|
-
r = self._send_request(url,
|
|
738
|
+
r = self._send_request(url, method=HTTPMethod.POST, data=data)
|
|
738
739
|
if r.status_code == codes.created:
|
|
739
740
|
return True
|
|
740
741
|
else:
|
|
@@ -760,7 +761,7 @@ class DIDClient(BaseClient):
|
|
|
760
761
|
path = '/'.join([self.DIDS_BASEURL, 'bulkdidsmeta'])
|
|
761
762
|
url = build_url(choice(self.list_hosts), path=path)
|
|
762
763
|
data = dumps({'dids': dids, 'recursive': recursive})
|
|
763
|
-
r = self._send_request(url,
|
|
764
|
+
r = self._send_request(url, method=HTTPMethod.POST, data=data)
|
|
764
765
|
if r.status_code == codes.created:
|
|
765
766
|
return True
|
|
766
767
|
else:
|
|
@@ -788,7 +789,7 @@ class DIDClient(BaseClient):
|
|
|
788
789
|
path = '/'.join([self.DIDS_BASEURL, quote_plus(scope), quote_plus(name), 'status'])
|
|
789
790
|
url = build_url(choice(self.list_hosts), path=path)
|
|
790
791
|
data = dumps(kwargs)
|
|
791
|
-
r = self._send_request(url,
|
|
792
|
+
r = self._send_request(url, method=HTTPMethod.PUT, data=data)
|
|
792
793
|
if r.status_code in (codes.ok, codes.no_content, codes.created):
|
|
793
794
|
return True
|
|
794
795
|
|
|
@@ -833,7 +834,7 @@ class DIDClient(BaseClient):
|
|
|
833
834
|
path = '/'.join([self.DIDS_BASEURL, quote_plus(scope), quote_plus(name), 'meta'])
|
|
834
835
|
url = build_url(choice(self.list_hosts), path=path, params={'key': key})
|
|
835
836
|
|
|
836
|
-
r = self._send_request(url,
|
|
837
|
+
r = self._send_request(url, method=HTTPMethod.DELETE)
|
|
837
838
|
if r.status_code == codes.ok:
|
|
838
839
|
return True
|
|
839
840
|
else:
|
|
@@ -858,7 +859,7 @@ class DIDClient(BaseClient):
|
|
|
858
859
|
|
|
859
860
|
path = '/'.join([self.DIDS_BASEURL, quote_plus(scope), quote_plus(name), 'rules'])
|
|
860
861
|
url = build_url(choice(self.list_hosts), path=path)
|
|
861
|
-
r = self._send_request(url,
|
|
862
|
+
r = self._send_request(url, method=HTTPMethod.GET)
|
|
862
863
|
if r.status_code == codes.ok:
|
|
863
864
|
return self._load_json_data(r)
|
|
864
865
|
else:
|
|
@@ -883,7 +884,7 @@ class DIDClient(BaseClient):
|
|
|
883
884
|
|
|
884
885
|
path = '/'.join([self.DIDS_BASEURL, quote_plus(scope), quote_plus(name), 'associated_rules'])
|
|
885
886
|
url = build_url(choice(self.list_hosts), path=path)
|
|
886
|
-
r = self._send_request(url,
|
|
887
|
+
r = self._send_request(url, method=HTTPMethod.GET)
|
|
887
888
|
if r.status_code == codes.ok:
|
|
888
889
|
return self._load_json_data(r)
|
|
889
890
|
else:
|
|
@@ -907,7 +908,7 @@ class DIDClient(BaseClient):
|
|
|
907
908
|
|
|
908
909
|
path = '/'.join([self.DIDS_BASEURL, guid, 'guid'])
|
|
909
910
|
url = build_url(choice(self.list_hosts), path=path)
|
|
910
|
-
r = self._send_request(url,
|
|
911
|
+
r = self._send_request(url, method=HTTPMethod.GET)
|
|
911
912
|
if r.status_code == codes.ok:
|
|
912
913
|
return self._load_json_data(r)
|
|
913
914
|
else:
|
|
@@ -941,7 +942,7 @@ class DIDClient(BaseClient):
|
|
|
941
942
|
payload['recursive'] = True
|
|
942
943
|
url = build_url(choice(self.list_hosts), path=path, params=payload)
|
|
943
944
|
|
|
944
|
-
r = self._send_request(url,
|
|
945
|
+
r = self._send_request(url, method=HTTPMethod.GET)
|
|
945
946
|
if r.status_code == codes.ok:
|
|
946
947
|
return self._load_json_data(r)
|
|
947
948
|
else:
|
|
@@ -967,7 +968,7 @@ class DIDClient(BaseClient):
|
|
|
967
968
|
path = '/'.join([self.DIDS_BASEURL, quote_plus(scope), quote_plus(name), 'parents'])
|
|
968
969
|
url = build_url(choice(self.list_hosts), path=path)
|
|
969
970
|
|
|
970
|
-
r = self._send_request(url,
|
|
971
|
+
r = self._send_request(url, method=HTTPMethod.GET)
|
|
971
972
|
if r.status_code == codes.ok:
|
|
972
973
|
return self._load_json_data(r)
|
|
973
974
|
else:
|
|
@@ -1007,7 +1008,7 @@ class DIDClient(BaseClient):
|
|
|
1007
1008
|
'nbfiles': str(nbfiles)
|
|
1008
1009
|
})
|
|
1009
1010
|
url = build_url(choice(self.list_hosts), path=path)
|
|
1010
|
-
r = self._send_request(url,
|
|
1011
|
+
r = self._send_request(url, method=HTTPMethod.POST, data=data)
|
|
1011
1012
|
if r.status_code == codes.created:
|
|
1012
1013
|
return True
|
|
1013
1014
|
else:
|
|
@@ -1025,7 +1026,7 @@ class DIDClient(BaseClient):
|
|
|
1025
1026
|
"""
|
|
1026
1027
|
path = '/'.join([self.DIDS_BASEURL, 'resurrect'])
|
|
1027
1028
|
url = build_url(choice(self.list_hosts), path=path)
|
|
1028
|
-
r = self._send_request(url,
|
|
1029
|
+
r = self._send_request(url, method=HTTPMethod.POST, data=dumps(dids))
|
|
1029
1030
|
if r.status_code == codes.created:
|
|
1030
1031
|
return True
|
|
1031
1032
|
else:
|
|
@@ -1049,7 +1050,7 @@ class DIDClient(BaseClient):
|
|
|
1049
1050
|
path = '/'.join([self.ARCHIVES_BASEURL, quote_plus(scope), quote_plus(name), 'files'])
|
|
1050
1051
|
url = build_url(choice(self.list_hosts), path=path)
|
|
1051
1052
|
|
|
1052
|
-
r = self._send_request(url,
|
|
1053
|
+
r = self._send_request(url, method=HTTPMethod.GET)
|
|
1053
1054
|
if r.status_code == codes.ok:
|
|
1054
1055
|
return self._load_json_data(r)
|
|
1055
1056
|
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
rucio/client/diracclient.py
CHANGED
|
@@ -18,6 +18,7 @@ from typing import TYPE_CHECKING, Any, Literal, 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
|
if TYPE_CHECKING:
|
|
@@ -113,7 +114,7 @@ class DiracClient(BaseClient):
|
|
|
113
114
|
|
|
114
115
|
r = self._send_request(
|
|
115
116
|
url,
|
|
116
|
-
|
|
117
|
+
method=HTTPMethod.POST,
|
|
117
118
|
data=dumps({'lfns': lfns, 'ignore_availability': ignore_availability, 'parents_metadata': parents_metadata})
|
|
118
119
|
)
|
|
119
120
|
|
rucio/client/exportclient.py
CHANGED
|
@@ -17,6 +17,7 @@ from typing import Any
|
|
|
17
17
|
from requests.status_codes import codes
|
|
18
18
|
|
|
19
19
|
from rucio.client.baseclient import BaseClient, choice
|
|
20
|
+
from rucio.common.constants import HTTPMethod
|
|
20
21
|
from rucio.common.utils import build_url, parse_response
|
|
21
22
|
|
|
22
23
|
|
|
@@ -83,7 +84,7 @@ class ExportClient(BaseClient):
|
|
|
83
84
|
path = '/'.join([self.EXPORT_BASEURL])
|
|
84
85
|
url = build_url(choice(self.list_hosts), path=path, params=payload)
|
|
85
86
|
|
|
86
|
-
r = self._send_request(url,
|
|
87
|
+
r = self._send_request(url, method=HTTPMethod.GET)
|
|
87
88
|
if r.status_code == codes.ok:
|
|
88
89
|
return parse_response(r.text)
|
|
89
90
|
else:
|
rucio/client/importclient.py
CHANGED
|
@@ -17,6 +17,7 @@ from typing import Any
|
|
|
17
17
|
from requests.status_codes import codes
|
|
18
18
|
|
|
19
19
|
from rucio.client.baseclient import BaseClient, choice
|
|
20
|
+
from rucio.common.constants import HTTPMethod
|
|
20
21
|
from rucio.common.utils import build_url, render_json
|
|
21
22
|
|
|
22
23
|
|
|
@@ -37,7 +38,7 @@ class ImportClient(BaseClient):
|
|
|
37
38
|
path = '/'.join([self.IMPORT_BASEURL])
|
|
38
39
|
url = build_url(choice(self.list_hosts), path=path)
|
|
39
40
|
|
|
40
|
-
r = self._send_request(url,
|
|
41
|
+
r = self._send_request(url, method=HTTPMethod.POST, data=render_json(**data))
|
|
41
42
|
if r.status_code == codes.created:
|
|
42
43
|
return r.text
|
|
43
44
|
else:
|
rucio/client/lifetimeclient.py
CHANGED
|
@@ -18,6 +18,7 @@ from typing import TYPE_CHECKING, 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, render_json
|
|
22
23
|
|
|
23
24
|
if TYPE_CHECKING:
|
|
@@ -81,7 +82,7 @@ class LifetimeClient(BaseClient):
|
|
|
81
82
|
params['states'] = exception_id
|
|
82
83
|
url = build_url(choice(self.list_hosts), path=path, params=params)
|
|
83
84
|
|
|
84
|
-
result = self._send_request(url)
|
|
85
|
+
result = self._send_request(url, method=HTTPMethod.GET)
|
|
85
86
|
if result.status_code == codes.ok:
|
|
86
87
|
lifetime_exceptions = self._load_json_data(result)
|
|
87
88
|
return lifetime_exceptions
|
|
@@ -133,7 +134,7 @@ class LifetimeClient(BaseClient):
|
|
|
133
134
|
path = self.LIFETIME_BASEURL + '/'
|
|
134
135
|
url = build_url(choice(self.list_hosts), path=path)
|
|
135
136
|
data = {'dids': dids, 'account': account, 'pattern': pattern, 'comments': comments, 'expires_at': expires_at}
|
|
136
|
-
result = self._send_request(url,
|
|
137
|
+
result = self._send_request(url, method=HTTPMethod.POST, data=render_json(**data))
|
|
137
138
|
if result.status_code == codes.created:
|
|
138
139
|
return loads(result.text)
|
|
139
140
|
exc_cls, exc_msg = self._get_exception(headers=result.headers, status_code=result.status_code, data=result.content)
|
rucio/client/lockclient.py
CHANGED
|
@@ -18,6 +18,7 @@ from urllib.parse import quote_plus
|
|
|
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, render_json
|
|
22
23
|
|
|
23
24
|
if TYPE_CHECKING:
|
|
@@ -50,7 +51,7 @@ class LockClient(BaseClient):
|
|
|
50
51
|
path = '/'.join([self.LOCKS_BASEURL, quote_plus(scope), quote_plus(name)])
|
|
51
52
|
url = build_url(choice(self.list_hosts), path=path, params={'did_type': 'dataset'})
|
|
52
53
|
|
|
53
|
-
result = self._send_request(url)
|
|
54
|
+
result = self._send_request(url, method=HTTPMethod.GET)
|
|
54
55
|
if result.status_code == codes.ok: # pylint: disable-msg=E1101
|
|
55
56
|
locks = self._load_json_data(result)
|
|
56
57
|
return locks
|
|
@@ -87,7 +88,7 @@ class LockClient(BaseClient):
|
|
|
87
88
|
path = '/'.join([self.LOCKS_BASEURL, "bulk_locks_for_dids"])
|
|
88
89
|
url = build_url(choice(self.list_hosts), path=path)
|
|
89
90
|
|
|
90
|
-
result = self._send_request(url,
|
|
91
|
+
result = self._send_request(url, method=HTTPMethod.POST, data=render_json(dids=dids))
|
|
91
92
|
if result.status_code == codes.ok: # pylint: disable-msg=E1101
|
|
92
93
|
out = []
|
|
93
94
|
for lock in self._load_json_data(result):
|
|
@@ -113,7 +114,7 @@ class LockClient(BaseClient):
|
|
|
113
114
|
path = '/'.join([self.LOCKS_BASEURL, rse])
|
|
114
115
|
url = build_url(choice(self.list_hosts), path=path, params={'did_type': 'dataset'})
|
|
115
116
|
|
|
116
|
-
result = self._send_request(url)
|
|
117
|
+
result = self._send_request(url, method=HTTPMethod.GET)
|
|
117
118
|
if result.status_code == codes.ok: # pylint: disable-msg=E1101
|
|
118
119
|
locks = self._load_json_data(result)
|
|
119
120
|
return locks
|