rucio-clients 37.0.0rc1__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 (104) hide show
  1. rucio/__init__.py +17 -0
  2. rucio/alembicrevision.py +15 -0
  3. rucio/cli/__init__.py +14 -0
  4. rucio/cli/account.py +216 -0
  5. rucio/cli/bin_legacy/__init__.py +13 -0
  6. rucio/cli/bin_legacy/rucio.py +2825 -0
  7. rucio/cli/bin_legacy/rucio_admin.py +2500 -0
  8. rucio/cli/command.py +272 -0
  9. rucio/cli/config.py +72 -0
  10. rucio/cli/did.py +191 -0
  11. rucio/cli/download.py +128 -0
  12. rucio/cli/lifetime_exception.py +33 -0
  13. rucio/cli/replica.py +162 -0
  14. rucio/cli/rse.py +293 -0
  15. rucio/cli/rule.py +158 -0
  16. rucio/cli/scope.py +40 -0
  17. rucio/cli/subscription.py +73 -0
  18. rucio/cli/upload.py +60 -0
  19. rucio/cli/utils.py +226 -0
  20. rucio/client/__init__.py +15 -0
  21. rucio/client/accountclient.py +432 -0
  22. rucio/client/accountlimitclient.py +183 -0
  23. rucio/client/baseclient.py +983 -0
  24. rucio/client/client.py +120 -0
  25. rucio/client/configclient.py +126 -0
  26. rucio/client/credentialclient.py +59 -0
  27. rucio/client/didclient.py +868 -0
  28. rucio/client/diracclient.py +56 -0
  29. rucio/client/downloadclient.py +1783 -0
  30. rucio/client/exportclient.py +44 -0
  31. rucio/client/fileclient.py +50 -0
  32. rucio/client/importclient.py +42 -0
  33. rucio/client/lifetimeclient.py +90 -0
  34. rucio/client/lockclient.py +109 -0
  35. rucio/client/metaconventionsclient.py +140 -0
  36. rucio/client/pingclient.py +44 -0
  37. rucio/client/replicaclient.py +452 -0
  38. rucio/client/requestclient.py +125 -0
  39. rucio/client/richclient.py +317 -0
  40. rucio/client/rseclient.py +746 -0
  41. rucio/client/ruleclient.py +294 -0
  42. rucio/client/scopeclient.py +90 -0
  43. rucio/client/subscriptionclient.py +173 -0
  44. rucio/client/touchclient.py +82 -0
  45. rucio/client/uploadclient.py +969 -0
  46. rucio/common/__init__.py +13 -0
  47. rucio/common/bittorrent.py +234 -0
  48. rucio/common/cache.py +111 -0
  49. rucio/common/checksum.py +168 -0
  50. rucio/common/client.py +122 -0
  51. rucio/common/config.py +788 -0
  52. rucio/common/constants.py +217 -0
  53. rucio/common/constraints.py +17 -0
  54. rucio/common/didtype.py +237 -0
  55. rucio/common/exception.py +1208 -0
  56. rucio/common/extra.py +31 -0
  57. rucio/common/logging.py +420 -0
  58. rucio/common/pcache.py +1409 -0
  59. rucio/common/plugins.py +185 -0
  60. rucio/common/policy.py +93 -0
  61. rucio/common/schema/__init__.py +200 -0
  62. rucio/common/schema/generic.py +416 -0
  63. rucio/common/schema/generic_multi_vo.py +395 -0
  64. rucio/common/stomp_utils.py +423 -0
  65. rucio/common/stopwatch.py +55 -0
  66. rucio/common/test_rucio_server.py +154 -0
  67. rucio/common/types.py +483 -0
  68. rucio/common/utils.py +1688 -0
  69. rucio/rse/__init__.py +96 -0
  70. rucio/rse/protocols/__init__.py +13 -0
  71. rucio/rse/protocols/bittorrent.py +194 -0
  72. rucio/rse/protocols/cache.py +111 -0
  73. rucio/rse/protocols/dummy.py +100 -0
  74. rucio/rse/protocols/gfal.py +708 -0
  75. rucio/rse/protocols/globus.py +243 -0
  76. rucio/rse/protocols/http_cache.py +82 -0
  77. rucio/rse/protocols/mock.py +123 -0
  78. rucio/rse/protocols/ngarc.py +209 -0
  79. rucio/rse/protocols/posix.py +250 -0
  80. rucio/rse/protocols/protocol.py +361 -0
  81. rucio/rse/protocols/rclone.py +365 -0
  82. rucio/rse/protocols/rfio.py +145 -0
  83. rucio/rse/protocols/srm.py +338 -0
  84. rucio/rse/protocols/ssh.py +414 -0
  85. rucio/rse/protocols/storm.py +195 -0
  86. rucio/rse/protocols/webdav.py +594 -0
  87. rucio/rse/protocols/xrootd.py +302 -0
  88. rucio/rse/rsemanager.py +881 -0
  89. rucio/rse/translation.py +260 -0
  90. rucio/vcsversion.py +11 -0
  91. rucio/version.py +45 -0
  92. rucio_clients-37.0.0rc1.data/data/etc/rse-accounts.cfg.template +25 -0
  93. rucio_clients-37.0.0rc1.data/data/etc/rucio.cfg.atlas.client.template +43 -0
  94. rucio_clients-37.0.0rc1.data/data/etc/rucio.cfg.template +241 -0
  95. rucio_clients-37.0.0rc1.data/data/requirements.client.txt +19 -0
  96. rucio_clients-37.0.0rc1.data/data/rucio_client/merge_rucio_configs.py +144 -0
  97. rucio_clients-37.0.0rc1.data/scripts/rucio +133 -0
  98. rucio_clients-37.0.0rc1.data/scripts/rucio-admin +97 -0
  99. rucio_clients-37.0.0rc1.dist-info/METADATA +54 -0
  100. rucio_clients-37.0.0rc1.dist-info/RECORD +104 -0
  101. rucio_clients-37.0.0rc1.dist-info/WHEEL +5 -0
  102. rucio_clients-37.0.0rc1.dist-info/licenses/AUTHORS.rst +100 -0
  103. rucio_clients-37.0.0rc1.dist-info/licenses/LICENSE +201 -0
  104. rucio_clients-37.0.0rc1.dist-info/top_level.txt +1 -0
rucio/client/client.py ADDED
@@ -0,0 +1,120 @@
1
+ # Copyright European Organization for Nuclear Research (CERN) since 2012
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """
16
+ Client class for callers of the Rucio system
17
+ """
18
+
19
+ from rucio.client.accountclient import AccountClient
20
+ from rucio.client.accountlimitclient import AccountLimitClient
21
+ from rucio.client.configclient import ConfigClient
22
+ from rucio.client.credentialclient import CredentialClient
23
+ from rucio.client.didclient import DIDClient
24
+ from rucio.client.diracclient import DiracClient
25
+ from rucio.client.exportclient import ExportClient
26
+ from rucio.client.importclient import ImportClient
27
+ from rucio.client.lifetimeclient import LifetimeClient
28
+ from rucio.client.lockclient import LockClient
29
+ from rucio.client.metaconventionsclient import MetaConventionClient
30
+ from rucio.client.pingclient import PingClient
31
+ from rucio.client.replicaclient import ReplicaClient
32
+ from rucio.client.requestclient import RequestClient
33
+ from rucio.client.rseclient import RSEClient
34
+ from rucio.client.ruleclient import RuleClient
35
+ from rucio.client.scopeclient import ScopeClient
36
+ from rucio.client.subscriptionclient import SubscriptionClient
37
+ from rucio.client.touchclient import TouchClient
38
+
39
+
40
+ class Client(AccountClient,
41
+ AccountLimitClient,
42
+ MetaConventionClient,
43
+ PingClient,
44
+ ReplicaClient,
45
+ RequestClient,
46
+ RSEClient,
47
+ ScopeClient,
48
+ DIDClient,
49
+ RuleClient,
50
+ SubscriptionClient,
51
+ LockClient,
52
+ ConfigClient,
53
+ TouchClient,
54
+ ImportClient,
55
+ ExportClient,
56
+ CredentialClient,
57
+ DiracClient,
58
+ LifetimeClient):
59
+
60
+ """
61
+ Main client class for accessing Rucio resources. Handles the authentication.
62
+
63
+ Note:
64
+ Used to access all client methods. Each entity client *can* be used to access methods, but using the main client class is recommended for ease of use.
65
+
66
+ For using general methods -
67
+
68
+
69
+ ```
70
+ from rucio.client import Client
71
+
72
+ client = Client() # authenticate with config or environ settings
73
+ client.add_replication_rule(...)
74
+
75
+ client = Client(
76
+ rucio_host = "my_host",
77
+ auth_host = "my_auth_host",
78
+ account = "jdoe12345",
79
+ auth_type = "userpass",
80
+ creds = {
81
+ "username": "jdoe12345",
82
+ "password": "******",
83
+ }
84
+ ) # authenticate with kwargs
85
+ client.list_replicas(...)
86
+ ```
87
+
88
+ For using the upload and download clients -
89
+
90
+ ```
91
+ from rucio.client import Client
92
+ from rucio.client.uploadclient import UploadClient
93
+ from rucio.client.downloadclient import DownloadClient
94
+
95
+ client = Client(...) # Initialize a client using your preferred method
96
+
97
+ upload_client = UploadClient(client) # Pass forward the initialized client
98
+ upload_client.upload(items=...)
99
+
100
+ download_client = DownloadClient(client)
101
+ download_client.download_dids(items=...)
102
+ ```
103
+
104
+ """
105
+
106
+ def __init__(self, **args):
107
+ """
108
+ Constructor for the Rucio main client class.
109
+
110
+ :param rucio_host: the host of the rucio system.
111
+ :param auth_host: the host of the rucio authentication server.
112
+ :param account: the rucio account that should be used to interact with the rucio system.
113
+ :param ca_cert: the certificate to verify the server.
114
+ :param auth_type: the type of authentication to use (e.g. userpass, x509 ...)
115
+ :param creds: credentials needed for authentication.
116
+ :param timeout: Float describes the timeout of the request (in seconds).
117
+ :param vo: The vo that the client will interact with.
118
+ :param logger: Logger instance to use (optional)
119
+ """
120
+ super(Client, self).__init__(**args)
@@ -0,0 +1,126 @@
1
+ # Copyright European Organization for Nuclear Research (CERN) since 2012
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from json import dumps
16
+ from typing import Any, Optional
17
+
18
+ from requests.status_codes import codes
19
+
20
+ from rucio.client.baseclient import BaseClient, choice
21
+ from rucio.common.utils import build_url
22
+
23
+
24
+ class ConfigClient(BaseClient):
25
+
26
+ """Client class for working with the configuration"""
27
+
28
+ CONFIG_BASEURL = 'config'
29
+
30
+ def get_config(
31
+ self,
32
+ section: Optional[str] = None,
33
+ option: Optional[str] = None
34
+ ) -> dict[str, Any]:
35
+ """
36
+ Sends the request to get the matching configuration.
37
+
38
+ :param section: the optional name of the section.
39
+ :param option: the optional option within the section.
40
+ :return: dictionary containing the configuration.
41
+ """
42
+
43
+ if section is None and option is not None:
44
+ raise ValueError('--section not specified')
45
+
46
+ path = self.CONFIG_BASEURL
47
+ if section is not None and option is None:
48
+ path += '/' + section
49
+ elif section is not None and option is not None:
50
+ path += '/'.join(['', section, option])
51
+
52
+ url = build_url(choice(self.list_hosts), path=path)
53
+
54
+ r = self._send_request(url, type_='GET')
55
+ if r.status_code == codes.ok:
56
+ return r.json()
57
+ else:
58
+ exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
59
+ raise exc_cls(exc_msg)
60
+
61
+ def set_config_option(
62
+ self,
63
+ section: str,
64
+ option: str,
65
+ value: Any,
66
+ use_body_for_params: bool = True
67
+ ) -> bool:
68
+ """
69
+ Sends the request to create or set an option within a section. Missing sections will be created.
70
+
71
+ :param section: the name of the section.
72
+ :param option: the name of the option.
73
+ :param value: the value to set on the config option
74
+ :param use_body_for_params: send parameters in a json-encoded request body instead of url-encoded
75
+ TODO: remove this parameter
76
+ The format of the /config endpoint was recently changed. We migrated from performing a PUT on
77
+ "/config/<section>/<option>/<value>" to sending the parameters using a json-encoded body.
78
+ This was done to fix multiple un-wanted side effects related to how the middleware treats
79
+ values encoded in a path.
80
+ For a smooth transition, we allow both cases for now, but we should migrate to only passing
81
+ values via the request body.
82
+ :return: True if option was removed successfully. False otherwise.
83
+ """
84
+
85
+ if use_body_for_params:
86
+ url = build_url(choice(self.list_hosts), path=self.CONFIG_BASEURL)
87
+ data = dumps({
88
+ section: {
89
+ option: value
90
+ }
91
+ })
92
+ r = self._send_request(url, type_='POST', data=data)
93
+ else:
94
+ path = '/'.join([self.CONFIG_BASEURL, section, option, value])
95
+ url = build_url(choice(self.list_hosts), path=path)
96
+ r = self._send_request(url, type_='PUT')
97
+
98
+ if r.status_code == codes.created:
99
+ return True
100
+ else:
101
+ exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
102
+ raise exc_cls(exc_msg)
103
+
104
+ def delete_config_option(
105
+ self,
106
+ section: str,
107
+ option: str
108
+ ) -> bool:
109
+ """
110
+ Sends the request to remove an option from a section
111
+
112
+ :param section: the name of the section.
113
+ :param option: the name of the option.
114
+ :return: True if option was removed successfully. False otherwise.
115
+ """
116
+
117
+ path = '/'.join([self.CONFIG_BASEURL, section, option])
118
+ url = build_url(choice(self.list_hosts), path=path)
119
+
120
+ r = self._send_request(url, type_='DEL')
121
+
122
+ if r.status_code == codes.ok:
123
+ return True
124
+ else:
125
+ exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
126
+ raise exc_cls(exc_msg)
@@ -0,0 +1,59 @@
1
+ # Copyright European Organization for Nuclear Research (CERN) since 2012
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from requests.status_codes import codes
16
+
17
+ from rucio.client.baseclient import BaseClient, choice
18
+ from rucio.common.utils import build_url
19
+
20
+
21
+ class CredentialClient(BaseClient):
22
+ """Credential client class for working with URL signing"""
23
+
24
+ CREDENTIAL_BASEURL = 'credentials'
25
+
26
+ def get_signed_url(
27
+ self,
28
+ rse: str,
29
+ service: str,
30
+ operation: str,
31
+ url: str,
32
+ lifetime: int = 3600
33
+ ) -> str:
34
+ """
35
+ Return a signed version of the given URL for the given operation.
36
+
37
+ :param rse: The name of the RSE the URL points to.
38
+ :param service: The service the URL points to (gcs, s3, swift)
39
+ :param operation: The desired operation (read, write, delete)
40
+ :param url: The URL to sign
41
+ :param lifetime: The desired lifetime of the URL in seconds
42
+
43
+ :return: The signed URL string
44
+ """
45
+ path = '/'.join([self.CREDENTIAL_BASEURL, 'signurl'])
46
+ params = {}
47
+ params['lifetime'] = lifetime
48
+ params['rse'] = rse
49
+ params['svc'] = service
50
+ params['op'] = operation
51
+ params['url'] = url
52
+ rurl = build_url(choice(self.list_hosts), path=path, params=params)
53
+ r = self._send_request(rurl, type_='GET')
54
+
55
+ if r.status_code == codes.ok:
56
+ return r.text
57
+
58
+ exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
59
+ raise exc_cls(exc_msg)