lockss-pyclient 0.1.0.dev2__py3-none-any.whl → 0.1.0.dev3__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.
- lockss/pyclient/__init__.py +8 -29
- lockss/pyclient/__main__.py +37 -0
- lockss/pyclient/_internal_common.py +395 -0
- lockss/pyclient/_internal_config.py +207 -0
- lockss/pyclient/_internal_crawler.py +251 -0
- lockss/pyclient/_internal_md.py +111 -0
- lockss/pyclient/_internal_poller.py +174 -0
- lockss/pyclient/_internal_rs.py +232 -0
- lockss/pyclient/cli.py +839 -0
- lockss/pyclient/config/__init__.py +15 -0
- lockss/pyclient/config/api/aus_api.py +14 -6
- lockss/pyclient/config/api/config_api.py +12 -12
- lockss/pyclient/config/api/utils_api.py +2 -2
- lockss/pyclient/config/configuration.py +1 -1
- lockss/pyclient/config/models/__init__.py +15 -0
- lockss/pyclient/config/models/access_type.py +90 -0
- lockss/pyclient/config/models/au_agreements.py +136 -0
- lockss/pyclient/config/models/au_config_page_info.py +140 -0
- lockss/pyclient/config/models/au_state_bean.py +942 -0
- lockss/pyclient/config/models/au_status.py +837 -8
- lockss/pyclient/config/models/au_suspect_url_versions.py +136 -0
- lockss/pyclient/config/models/check_substance_result.py +6 -22
- lockss/pyclient/config/models/dated_peer_id_set_impl.py +162 -0
- lockss/pyclient/config/models/hash_result.py +136 -0
- lockss/pyclient/config/models/page_info.py +226 -0
- lockss/pyclient/config/models/peer_agreement.py +188 -0
- lockss/pyclient/config/models/peer_agreements.py +136 -0
- lockss/pyclient/config/models/platform_configuration_ws_result.py +421 -8
- lockss/pyclient/config/models/platform_configuration_ws_result_daemon_version.py +188 -0
- lockss/pyclient/config/models/platform_configuration_ws_result_java_version.py +188 -0
- lockss/pyclient/config/models/platform_configuration_ws_result_platform.py +162 -0
- lockss/pyclient/config/models/substance_checker_state.py +91 -0
- lockss/pyclient/config/models/suspect_url_version.py +214 -0
- lockss/pyclient/config/swagger.yaml +2031 -0
- lockss/pyclient/crawler/__init__.py +1 -0
- lockss/pyclient/crawler/api/crawls_api.py +2 -2
- lockss/pyclient/crawler/configuration.py +1 -1
- lockss/pyclient/crawler/models/__init__.py +1 -0
- lockss/pyclient/crawler/models/crawl_desc.py +4 -12
- lockss/pyclient/crawler/models/crawl_kind_enum.py +90 -0
- lockss/pyclient/crawler/models/page_info.py +22 -24
- lockss/pyclient/crawler/swagger.yaml +1197 -0
- lockss/pyclient/md/configuration.py +1 -1
- lockss/pyclient/md/models/page_info.py +22 -24
- lockss/pyclient/md/swagger.yaml +583 -0
- lockss/pyclient/output.py +131 -0
- lockss/pyclient/poller/__init__.py +11 -5
- lockss/pyclient/poller/api/export_api.py +5 -5
- lockss/pyclient/poller/api/hash_api.py +3 -3
- lockss/pyclient/poller/api/poll_detail_api.py +42 -42
- lockss/pyclient/poller/api/poller_polls_api.py +18 -18
- lockss/pyclient/poller/api/service_api.py +2 -2
- lockss/pyclient/poller/api/voter_polls_api.py +18 -18
- lockss/pyclient/poller/configuration.py +1 -1
- lockss/pyclient/poller/models/__init__.py +11 -5
- lockss/pyclient/poller/models/export_file_type_enum.py +93 -0
- lockss/pyclient/poller/models/export_filename_translation_enum.py +91 -0
- lockss/pyclient/poller/models/page_info.py +226 -0
- lockss/pyclient/poller/models/poll_desc.py +3 -11
- lockss/pyclient/poller/models/poll_variant_enum.py +92 -0
- lockss/pyclient/poller/models/poller_page_info.py +140 -0
- lockss/pyclient/poller/models/repair_page_info.py +140 -0
- lockss/pyclient/poller/models/repair_type_enum.py +91 -0
- lockss/pyclient/poller/models/tally_type_enum.py +93 -0
- lockss/pyclient/poller/models/url_page_info.py +140 -0
- lockss/pyclient/poller/models/voter_page_info.py +140 -0
- lockss/pyclient/poller/models/voter_urls_enum.py +92 -0
- lockss/pyclient/poller/swagger.yaml +1658 -0
- lockss/pyclient/rs/__init__.py +6 -0
- lockss/pyclient/rs/api/artifacts_api.py +20 -20
- lockss/pyclient/rs/api/aus_api.py +5 -5
- lockss/pyclient/rs/api/repo_api.py +4 -4
- lockss/pyclient/rs/api/status_api.py +1 -1
- lockss/pyclient/rs/api/wayback_api.py +12 -12
- lockss/pyclient/rs/configuration.py +8 -1
- lockss/pyclient/rs/models/__init__.py +6 -0
- lockss/pyclient/rs/models/artifact.py +111 -81
- lockss/pyclient/rs/models/au_size.py +6 -0
- lockss/pyclient/rs/models/auid_page_info.py +2 -2
- lockss/pyclient/rs/models/bulk_au_op_enum.py +90 -0
- lockss/pyclient/rs/models/include_content_enum.py +91 -0
- lockss/pyclient/rs/models/page_info.py +26 -29
- lockss/pyclient/rs/models/pywb_match_enum.py +93 -0
- lockss/pyclient/rs/models/pywb_output_enum.py +90 -0
- lockss/pyclient/rs/models/pywb_sort_enum.py +91 -0
- lockss/pyclient/rs/models/storage_info.py +131 -80
- lockss/pyclient/rs/models/versions_enum.py +90 -0
- lockss/pyclient/rs/swagger.yaml +1306 -0
- {lockss_pyclient-0.1.0.dev2.dist-info → lockss_pyclient-0.1.0.dev3.dist-info}/METADATA +10 -3
- {lockss_pyclient-0.1.0.dev2.dist-info → lockss_pyclient-0.1.0.dev3.dist-info}/RECORD +93 -45
- {lockss_pyclient-0.1.0.dev2.dist-info → lockss_pyclient-0.1.0.dev3.dist-info}/WHEEL +1 -1
- lockss_pyclient-0.1.0.dev3.dist-info/entry_points.txt +3 -0
- {lockss_pyclient-0.1.0.dev2.dist-info → lockss_pyclient-0.1.0.dev3.dist-info/licenses}/LICENSE +0 -0
lockss/pyclient/__init__.py
CHANGED
|
@@ -1,38 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2000-2025, Board of Trustees of Leland Stanford Jr. University
|
|
4
|
-
#
|
|
5
|
-
# Redistribution and use in source and binary forms, with or without
|
|
6
|
-
# modification, are permitted provided that the following conditions are met:
|
|
7
|
-
#
|
|
8
|
-
# 1. Redistributions of source code must retain the above copyright notice,
|
|
9
|
-
# this list of conditions and the following disclaimer.
|
|
10
|
-
#
|
|
11
|
-
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
-
# this list of conditions and the following disclaimer in the documentation
|
|
13
|
-
# and/or other materials provided with the distribution.
|
|
14
|
-
#
|
|
15
|
-
# 3. Neither the name of the copyright holder nor the names of its contributors
|
|
16
|
-
# may be used to endorse or promote products derived from this software without
|
|
17
|
-
# specific prior written permission.
|
|
18
|
-
#
|
|
19
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
22
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
23
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
24
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
25
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
26
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
27
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
28
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
29
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
-
|
|
31
3
|
"""
|
|
32
4
|
LOCKSS Python clients
|
|
33
5
|
"""
|
|
34
6
|
|
|
35
|
-
__version__ = '0.1.0-
|
|
7
|
+
__version__ = '0.1.0-dev3'
|
|
36
8
|
|
|
37
9
|
__copyright__ = '''
|
|
38
10
|
Copyright (c) 2000-2025, Board of Trustees of Leland Stanford Jr. University
|
|
@@ -65,3 +37,10 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
65
37
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
66
38
|
POSSIBILITY OF SUCH DAMAGE.
|
|
67
39
|
'''.strip()
|
|
40
|
+
|
|
41
|
+
from ._internal_common import *
|
|
42
|
+
from ._internal_config import *
|
|
43
|
+
from ._internal_crawler import *
|
|
44
|
+
from ._internal_md import *
|
|
45
|
+
from ._internal_poller import *
|
|
46
|
+
from ._internal_rs import *
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2000-2025, Board of Trustees of Leland Stanford Jr. University
|
|
4
|
+
#
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
#
|
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
9
|
+
# this list of conditions and the following disclaimer.
|
|
10
|
+
#
|
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
# and/or other materials provided with the distribution.
|
|
14
|
+
#
|
|
15
|
+
# 3. Neither the name of the copyright holder nor the names of its contributors
|
|
16
|
+
# may be used to endorse or promote products derived from this software without
|
|
17
|
+
# specific prior written permission.
|
|
18
|
+
#
|
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
23
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
24
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
25
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
26
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
27
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
28
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
29
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
+
|
|
31
|
+
"""
|
|
32
|
+
Entry point for the ``lockss.pyclient`` module.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
from .cli import main
|
|
36
|
+
|
|
37
|
+
main()
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2000-2025, Board of Trustees of Leland Stanford Jr. University
|
|
4
|
+
#
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
#
|
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
9
|
+
# this list of conditions and the following disclaimer.
|
|
10
|
+
#
|
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
# and/or other materials provided with the distribution.
|
|
14
|
+
#
|
|
15
|
+
# 3. Neither the name of the copyright holder nor the names of its contributors
|
|
16
|
+
# may be used to endorse or promote products derived from this software without
|
|
17
|
+
# specific prior written permission.
|
|
18
|
+
#
|
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
23
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
24
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
25
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
26
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
27
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
28
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
29
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
+
|
|
31
|
+
"""
|
|
32
|
+
Base of the lockss.pyclient package.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
# Remove in Python 3.14; see https://stackoverflow.com/a/33533514
|
|
36
|
+
from __future__ import annotations
|
|
37
|
+
|
|
38
|
+
from collections.abc import Callable, Iterable, Iterator
|
|
39
|
+
from getpass import getpass
|
|
40
|
+
from importlib import resources
|
|
41
|
+
from io import BytesIO
|
|
42
|
+
from typing import Any, ClassVar, Optional, TypeVar, Union
|
|
43
|
+
|
|
44
|
+
from jsonpath import query
|
|
45
|
+
from multipart import MultipartParser
|
|
46
|
+
import yaml
|
|
47
|
+
|
|
48
|
+
from . import config, crawler, md, poller, rs
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
YamlT = Any
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _load_swagger(package) -> YamlT:
|
|
55
|
+
with resources.path(package, 'swagger.yaml') as p:
|
|
56
|
+
with p.open('rb') as f:
|
|
57
|
+
return yaml.safe_load(f)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
_CONFIG = _load_swagger(config)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
_CRAWLER = _load_swagger(crawler)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
_MD = _load_swagger(md)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
_POLLER = _load_swagger(poller)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
_RS = _load_swagger(rs)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _first(data: YamlT, json_path: str) -> Any:
|
|
76
|
+
return query(json_path, data).first_one().value
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _param_default(data: YamlT, path: str, method: str, param_name: str) -> Any:
|
|
80
|
+
return _first(data, f'$.paths["{path}"].{method}.parameters[?(@.name == "{param_name}")].schema.default')
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _schema_default(data: YamlT, schema_name: str) -> Any:
|
|
84
|
+
return _first(data, f'$.components.schemas.{schema_name}.default')
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
__JSON_PATH_DEFAULT_PORT = '$.servers[0].variables.port.default'
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
CONFIG_DEFAULT_PORT: int = _first(_CONFIG, __JSON_PATH_DEFAULT_PORT)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
CRAWLER_DEFAULT_PORT: int = _first(_CRAWLER, __JSON_PATH_DEFAULT_PORT)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
MD_DEFAULT_PORT: int = _first(_MD, __JSON_PATH_DEFAULT_PORT)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
POLLER_DEFAULT_PORT: int = _first(_POLLER, __JSON_PATH_DEFAULT_PORT)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
RS_DEFAULT_PORT: int = _first(_RS, __JSON_PATH_DEFAULT_PORT)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
ConfT = Union[
|
|
106
|
+
config.Configuration,
|
|
107
|
+
crawler.Configuration,
|
|
108
|
+
md.Configuration,
|
|
109
|
+
poller.Configuration,
|
|
110
|
+
rs.Configuration,
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
ConfSupplier = Callable[[], ConfT]
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
PortGetter = Callable[..., int]
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
StrSupplier = Callable[[], str]
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class Node(object):
|
|
124
|
+
|
|
125
|
+
DEFAULT_PROTOCOL: ClassVar[str] = 'http'
|
|
126
|
+
|
|
127
|
+
# DECORATOR
|
|
128
|
+
@staticmethod
|
|
129
|
+
def _make_conf_template(make_conf: ConfSupplier,
|
|
130
|
+
get_port: PortGetter):
|
|
131
|
+
def decorate(f):
|
|
132
|
+
def decorated_make_conf(self: Node,
|
|
133
|
+
needs_auth: bool = True) -> ConfT:
|
|
134
|
+
conf = make_conf()
|
|
135
|
+
conf.host = f'{self.get_host()}:{get_port(self)}'
|
|
136
|
+
if needs_auth:
|
|
137
|
+
conf.username = self.get_username()
|
|
138
|
+
conf.password = self.get_password()()
|
|
139
|
+
return conf
|
|
140
|
+
return decorated_make_conf
|
|
141
|
+
return decorate
|
|
142
|
+
|
|
143
|
+
# DECORATOR
|
|
144
|
+
@staticmethod
|
|
145
|
+
def _set_port_template(port_name: str):
|
|
146
|
+
def decorate(f):
|
|
147
|
+
def decorated_set_port(self: Node,
|
|
148
|
+
port: int) -> Node:
|
|
149
|
+
setattr(self, port_name, port)
|
|
150
|
+
return self
|
|
151
|
+
return decorated_set_port
|
|
152
|
+
return decorate
|
|
153
|
+
|
|
154
|
+
# DECORATOR
|
|
155
|
+
@staticmethod
|
|
156
|
+
def _get_port_template(port_name: str,
|
|
157
|
+
default_port: int):
|
|
158
|
+
def decorate(f):
|
|
159
|
+
def decorated_get_port(self: Node) -> int:
|
|
160
|
+
return getattr(self, port_name, default_port)
|
|
161
|
+
return decorated_get_port
|
|
162
|
+
return decorate
|
|
163
|
+
|
|
164
|
+
def __init__(self,
|
|
165
|
+
node_reference: str,
|
|
166
|
+
username: Optional[str] = None,
|
|
167
|
+
password: Optional[StrSupplier] = None,
|
|
168
|
+
interactive: bool = True,
|
|
169
|
+
config_port: int = CONFIG_DEFAULT_PORT,
|
|
170
|
+
crawler_port: int = CRAWLER_DEFAULT_PORT,
|
|
171
|
+
md_port: int = MD_DEFAULT_PORT,
|
|
172
|
+
poller_port: int = POLLER_DEFAULT_PORT,
|
|
173
|
+
rs_port: int = RS_DEFAULT_PORT):
|
|
174
|
+
super().__init__()
|
|
175
|
+
self._host: str = Node._compute_host(node_reference)
|
|
176
|
+
self._username: Optional[str] = username
|
|
177
|
+
self._password: Optional[StrSupplier] = password
|
|
178
|
+
self._interactive: bool = interactive
|
|
179
|
+
self._config_port = config_port
|
|
180
|
+
self._crawler_port = crawler_port
|
|
181
|
+
self._md_port: int = md_port
|
|
182
|
+
self._poller_port: int = poller_port
|
|
183
|
+
self._rs_port: int = rs_port
|
|
184
|
+
|
|
185
|
+
@_get_port_template('_config_port', CONFIG_DEFAULT_PORT)
|
|
186
|
+
def get_config_port(self: Node) -> int:
|
|
187
|
+
pass
|
|
188
|
+
|
|
189
|
+
@_get_port_template('_crawler_port', CRAWLER_DEFAULT_PORT)
|
|
190
|
+
def get_crawler_port(self: Node) -> int:
|
|
191
|
+
pass
|
|
192
|
+
|
|
193
|
+
def get_host(self) -> str:
|
|
194
|
+
return self._host
|
|
195
|
+
|
|
196
|
+
@_get_port_template('_md_port', MD_DEFAULT_PORT)
|
|
197
|
+
def get_md_port(self: Node) -> int:
|
|
198
|
+
pass
|
|
199
|
+
|
|
200
|
+
@_get_port_template('_poller_port', POLLER_DEFAULT_PORT)
|
|
201
|
+
def get_poller_port(self: Node) -> int:
|
|
202
|
+
pass
|
|
203
|
+
|
|
204
|
+
@_get_port_template('_rs_port', RS_DEFAULT_PORT)
|
|
205
|
+
def get_rs_port(self: Node) -> int:
|
|
206
|
+
pass
|
|
207
|
+
|
|
208
|
+
def get_username(self) -> str:
|
|
209
|
+
return self._username
|
|
210
|
+
|
|
211
|
+
def get_password(self) -> Optional[StrSupplier]:
|
|
212
|
+
if not self._password:
|
|
213
|
+
if not self._interactive:
|
|
214
|
+
raise RuntimeError('interactive prompts not allowed')
|
|
215
|
+
_p = getpass(f'Password ({self.get_host().partition("://")[2]}): ')
|
|
216
|
+
self._password = lambda: _p
|
|
217
|
+
return self._password
|
|
218
|
+
|
|
219
|
+
@_make_conf_template(config.Configuration, get_config_port)
|
|
220
|
+
def make_config_conf(self, needs_auth: bool = True) -> config.Configuration:
|
|
221
|
+
pass
|
|
222
|
+
|
|
223
|
+
@_make_conf_template(crawler.Configuration, get_crawler_port)
|
|
224
|
+
def make_crawler_conf(self, needs_auth: bool = True) -> crawler.Configuration:
|
|
225
|
+
pass
|
|
226
|
+
|
|
227
|
+
@_make_conf_template(md.Configuration, get_md_port)
|
|
228
|
+
def make_md_conf(self, needs_auth: bool = True) -> md.Configuration:
|
|
229
|
+
pass
|
|
230
|
+
|
|
231
|
+
@_make_conf_template(poller.Configuration, get_poller_port)
|
|
232
|
+
def make_poller_conf(self, needs_auth: bool = True) -> poller.Configuration:
|
|
233
|
+
pass
|
|
234
|
+
|
|
235
|
+
@_make_conf_template(rs.Configuration, get_rs_port)
|
|
236
|
+
def make_rs_conf(self, needs_auth: bool = True) -> rs.Configuration:
|
|
237
|
+
pass
|
|
238
|
+
|
|
239
|
+
@_set_port_template('_config_port')
|
|
240
|
+
def set_config_port(self, port: int) -> Node:
|
|
241
|
+
pass
|
|
242
|
+
|
|
243
|
+
@_set_port_template('_crawler_port')
|
|
244
|
+
def set_crawler_port(self, port: int) -> Node:
|
|
245
|
+
pass
|
|
246
|
+
|
|
247
|
+
@_set_port_template('_md_port')
|
|
248
|
+
def set_md_port(self, port: int) -> Node:
|
|
249
|
+
pass
|
|
250
|
+
|
|
251
|
+
@_set_port_template('_poller_port')
|
|
252
|
+
def set_poller_port(self, port: int) -> Node:
|
|
253
|
+
pass
|
|
254
|
+
|
|
255
|
+
@_set_port_template('_rs_port')
|
|
256
|
+
def set_rs_port(self, port: int) -> Node:
|
|
257
|
+
pass
|
|
258
|
+
|
|
259
|
+
def set_username(self, username: str) -> Node:
|
|
260
|
+
self._username = username
|
|
261
|
+
return self
|
|
262
|
+
|
|
263
|
+
@staticmethod
|
|
264
|
+
def _compute_host(node_reference: str) -> str:
|
|
265
|
+
if node_reference.endswith('/'):
|
|
266
|
+
node_reference = node_reference[:-1]
|
|
267
|
+
x, y, z = node_reference.rpartition(':')
|
|
268
|
+
if z.isdigit():
|
|
269
|
+
node_reference = x # Ignore port if passed in
|
|
270
|
+
if '://' not in node_reference:
|
|
271
|
+
node_reference = f'{Node.DEFAULT_PROTOCOL}://{node_reference}'
|
|
272
|
+
return node_reference
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
ConfFunction = Callable[..., ConfT]
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
ApiClientT = Union[
|
|
279
|
+
config.ApiClient,
|
|
280
|
+
crawler.ApiClient,
|
|
281
|
+
md.ApiClient,
|
|
282
|
+
poller.ApiClient,
|
|
283
|
+
rs.ApiClient,
|
|
284
|
+
]
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
ApiClientFunction = Callable[..., ApiClientT]
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
ApiInstanceT = Union[
|
|
291
|
+
config.AusApi, config.ConfigApi, config.PluginsApi, config.StatusApi, config.TdbApi, config.UsersApi, config.UtilsApi,
|
|
292
|
+
crawler.CrawlersApi, crawler.CrawlsApi, crawler.JobsApi, crawler.StatusApi, crawler.WsApi,
|
|
293
|
+
md.MdupdatesApi, md.MetadataApi, md.StatusApi, md.UrlsApi,
|
|
294
|
+
poller.ExportApi, poller.HashApi, poller.ImportApi, poller.PollDetailApi, poller.PollerPollsApi, poller.RepoApi, poller.ServiceApi, poller.VoterPollsApi,
|
|
295
|
+
rs.ArtifactsApi, rs.AusApi, rs.RepoApi, rs.StatusApi, rs.WaybackApi,
|
|
296
|
+
]
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
ApiInstanceFunction = Callable[[ApiClientT], ApiInstanceT]
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
ApiResultT = TypeVar('ApiResultT')
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
ApiResultFunction = Callable[..., ApiResultT]
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
ResultT = TypeVar('ResultT')
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
ResultFunction = Callable[[ApiResultT], ResultT]
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
def _single_request_template(make_conf: ConfFunction,
|
|
315
|
+
make_api_client: ApiClientFunction,
|
|
316
|
+
make_api_instance: ApiInstanceFunction,
|
|
317
|
+
api_operation: ApiResultFunction,
|
|
318
|
+
needs_auth: bool = True,
|
|
319
|
+
remove_kwargs: Optional[list[str]] = None,
|
|
320
|
+
transform_result: ResultFunction = lambda x: x,
|
|
321
|
+
transform_raw_result: Optional[Any] = None):
|
|
322
|
+
def decorate(f):
|
|
323
|
+
def decorated_single_request(node: Node, *args, **kwargs) -> ResultT:
|
|
324
|
+
if needs_auth:
|
|
325
|
+
conf: ConfT = make_conf(node)
|
|
326
|
+
api_client: ApiClientT = make_api_client(conf, "Authorization", conf.get_basic_auth_token())
|
|
327
|
+
else:
|
|
328
|
+
conf: ConfT = make_conf(node, needs_auth=False)
|
|
329
|
+
api_client: ApiClientT = make_api_client(conf)
|
|
330
|
+
api_instance: ApiInstanceT = make_api_instance(api_client)
|
|
331
|
+
for remove in [key for key, val in kwargs.items() if key in (remove_kwargs or []) and val is None]:
|
|
332
|
+
kwargs.pop(remove, None)
|
|
333
|
+
if transform_raw_result:
|
|
334
|
+
kwargs['_preload_content'] = False
|
|
335
|
+
api_response: ApiResultT = api_operation(api_instance, *args, **kwargs)
|
|
336
|
+
if transform_raw_result:
|
|
337
|
+
result = api_client.deserialize(api_response, transform_raw_result)
|
|
338
|
+
else:
|
|
339
|
+
result: ResultT = transform_result(api_response)
|
|
340
|
+
return result
|
|
341
|
+
return decorated_single_request
|
|
342
|
+
return decorate
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
PageInfoResultT = Union[
|
|
346
|
+
config.AuConfigPageInfo,
|
|
347
|
+
crawler.CrawlPager, crawler.JobPager, crawler.UrlPager,
|
|
348
|
+
md.AuMetadataPageInfo, md.JobPageInfo,
|
|
349
|
+
poller.PollerPageInfo, poller.RepairPageInfo, poller.UrlPageInfo,
|
|
350
|
+
rs.ArtifactPageInfo, rs.AuidPageInfo,
|
|
351
|
+
]
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
PageInfoResultFunction = Callable[..., PageInfoResultT]
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
PageInfoAccessorFunction = Callable[[PageInfoResultT], Iterable[ResultT]]
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
def _paged_request_iterator_template(single_request: PageInfoResultFunction,
|
|
361
|
+
item_accessor: PageInfoAccessorFunction,
|
|
362
|
+
remove_kwargs: Optional[list[str]] = None,
|
|
363
|
+
default_limit: int = 100):
|
|
364
|
+
def decorate(f):
|
|
365
|
+
def decorated_paged_request_iterator(*args, **kwargs) -> Iterator[ResultT]:
|
|
366
|
+
for remove in [key for key, val in kwargs.items() if key in (remove_kwargs or []) and val is None]:
|
|
367
|
+
kwargs.pop(remove, None)
|
|
368
|
+
token = None
|
|
369
|
+
while True:
|
|
370
|
+
if token:
|
|
371
|
+
kwargs['continuation_token'] = token
|
|
372
|
+
else:
|
|
373
|
+
kwargs.pop('continuation_token', None)
|
|
374
|
+
if kwargs.get('limit') is None:
|
|
375
|
+
kwargs['limit'] = default_limit
|
|
376
|
+
result_page: PageInfoResultT = single_request(*args, **kwargs)
|
|
377
|
+
token = result_page.page_info.continuation_token
|
|
378
|
+
for result in item_accessor(result_page):
|
|
379
|
+
result_t: ResultT = result
|
|
380
|
+
yield result_t
|
|
381
|
+
if token is None:
|
|
382
|
+
break
|
|
383
|
+
return decorated_paged_request_iterator
|
|
384
|
+
return decorate
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
def bytes_repr_to_multipart(bytes_repr: str) -> MultipartParser:
|
|
388
|
+
byte_input: bytes = eval(bytes_repr)
|
|
389
|
+
boundary: bytes = byte_input.partition(b'\r\n')[0].partition(b'--')[2]
|
|
390
|
+
return MultipartParser(BytesIO(byte_input), boundary)
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
def bytes_repr_to_string(bytes_repr: str) -> str:
|
|
394
|
+
byte_input: bytes = eval(bytes_repr)
|
|
395
|
+
return byte_input.decode()
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2000-2025, Board of Trustees of Leland Stanford Jr. University
|
|
4
|
+
#
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
#
|
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
|
9
|
+
# this list of conditions and the following disclaimer.
|
|
10
|
+
#
|
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
# and/or other materials provided with the distribution.
|
|
14
|
+
#
|
|
15
|
+
# 3. Neither the name of the copyright holder nor the names of its contributors
|
|
16
|
+
# may be used to endorse or promote products derived from this software without
|
|
17
|
+
# specific prior written permission.
|
|
18
|
+
#
|
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
23
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
24
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
25
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
26
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
27
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
28
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
29
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
+
|
|
31
|
+
"""
|
|
32
|
+
Base of the lockss.pyclient package (configuration service).
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
from collections.abc import Iterable
|
|
36
|
+
from datetime import datetime
|
|
37
|
+
from typing import Optional
|
|
38
|
+
|
|
39
|
+
from multipart import MultipartParser
|
|
40
|
+
|
|
41
|
+
from ._internal_common import Node, bytes_repr_to_multipart, _paged_request_iterator_template, _single_request_template
|
|
42
|
+
from . import config
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@_single_request_template(Node.make_config_conf,
|
|
46
|
+
config.ApiClient,
|
|
47
|
+
config.AusApi,
|
|
48
|
+
config.AusApi.get_au_agreements,
|
|
49
|
+
transform_raw_result=config.AuAgreements)
|
|
50
|
+
def config_get_au_agreements(node: Node,
|
|
51
|
+
auid: str) -> config.AuAgreements:
|
|
52
|
+
pass
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@_single_request_template(Node.make_config_conf,
|
|
56
|
+
config.ApiClient,
|
|
57
|
+
config.AusApi,
|
|
58
|
+
config.AusApi.get_au_config)
|
|
59
|
+
def config_get_au_config(node: Node,
|
|
60
|
+
auid: str) -> config.AuConfiguration:
|
|
61
|
+
pass
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@_single_request_template(Node.make_config_conf,
|
|
65
|
+
config.ApiClient,
|
|
66
|
+
config.AusApi,
|
|
67
|
+
config.AusApi.get_all_au_config)
|
|
68
|
+
def config_get_au_configs_page(node: Node,
|
|
69
|
+
limit: Optional[int] = None,
|
|
70
|
+
continuation_token: Optional[str] = None) -> config.AuConfigPageInfo:
|
|
71
|
+
pass
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@_paged_request_iterator_template(config_get_au_configs_page,
|
|
75
|
+
lambda x: x.au_configs)
|
|
76
|
+
def config_get_au_configs(node: Node,
|
|
77
|
+
limit: Optional[int] = None) -> Iterable[config.AuConfiguration]:
|
|
78
|
+
pass
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@_single_request_template(Node.make_config_conf,
|
|
82
|
+
config.ApiClient,
|
|
83
|
+
config.AusApi,
|
|
84
|
+
config.AusApi.get_au_state,
|
|
85
|
+
transform_raw_result=config.AuStateBean)
|
|
86
|
+
def config_get_au_state(node: Node,
|
|
87
|
+
auid: str) -> config.AuStateBean:
|
|
88
|
+
pass
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@_single_request_template(Node.make_config_conf,
|
|
92
|
+
config.ApiClient,
|
|
93
|
+
config.AusApi,
|
|
94
|
+
config.AusApi.get_au_suspect_url_versions,
|
|
95
|
+
transform_raw_result=config.AuSuspectUrlVersions)
|
|
96
|
+
def config_get_au_suspect_url_versions(node: Node,
|
|
97
|
+
auid: str) -> config.AuSuspectUrlVersions:
|
|
98
|
+
pass
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@_single_request_template(Node.make_config_conf,
|
|
102
|
+
config.ApiClient,
|
|
103
|
+
config.AusApi,
|
|
104
|
+
config.AusApi.get_au_status)
|
|
105
|
+
def config_get_au_status(node: Node,
|
|
106
|
+
auid: str) -> config.AuStatus:
|
|
107
|
+
pass
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
@_single_request_template(Node.make_config_conf,
|
|
111
|
+
config.ApiClient,
|
|
112
|
+
config.ConfigApi,
|
|
113
|
+
config.ConfigApi.get_loaded_url_list)
|
|
114
|
+
def config_get_loaded_urls(node: Node) -> list[str]:
|
|
115
|
+
pass
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
@_single_request_template(Node.make_config_conf,
|
|
119
|
+
config.ApiClient,
|
|
120
|
+
config.AusApi,
|
|
121
|
+
config.AusApi.get_no_au_peers,
|
|
122
|
+
transform_raw_result=config.DatedPeerIdSetImpl)
|
|
123
|
+
def config_get_no_au_peer_set(node: Node,
|
|
124
|
+
auid: str) -> config.DatedPeerIdSetImpl:
|
|
125
|
+
pass
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
@_single_request_template(Node.make_config_conf,
|
|
129
|
+
config.ApiClient,
|
|
130
|
+
config.ConfigApi,
|
|
131
|
+
config.ConfigApi.get_platform_config)
|
|
132
|
+
def config_get_platform_config(node: Node) -> config.PlatformConfigurationWsResult:
|
|
133
|
+
pass
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
@_single_request_template(Node.make_config_conf,
|
|
137
|
+
config.ApiClient,
|
|
138
|
+
config.StatusApi,
|
|
139
|
+
config.StatusApi.get_status,
|
|
140
|
+
needs_auth=False)
|
|
141
|
+
def config_get_status(node: Node) -> config.ApiStatus:
|
|
142
|
+
pass
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
@_single_request_template(Node.make_config_conf,
|
|
146
|
+
config.ApiClient,
|
|
147
|
+
config.ConfigApi,
|
|
148
|
+
config.ConfigApi.get_section_config,
|
|
149
|
+
remove_kwargs=['if_match', 'if_modified_since', 'if_none_match', 'if_unmodified_since'],
|
|
150
|
+
transform_result=bytes_repr_to_multipart)
|
|
151
|
+
def config_get_section(node: Node,
|
|
152
|
+
section_name: str,
|
|
153
|
+
if_match: str = None,
|
|
154
|
+
if_modified_since: str = None,
|
|
155
|
+
if_none_match: str = None,
|
|
156
|
+
if_unmodified_since: str = None) -> MultipartParser:
|
|
157
|
+
pass
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
@_single_request_template(Node.make_config_conf,
|
|
161
|
+
config.ApiClient,
|
|
162
|
+
config.ConfigApi,
|
|
163
|
+
config.ConfigApi.get_url_config,
|
|
164
|
+
remove_kwargs=['if_match', 'if_modified_since', 'if_none_match', 'if_unmodified_since'],
|
|
165
|
+
transform_result=bytes_repr_to_multipart)
|
|
166
|
+
def config_get_url(node: Node,
|
|
167
|
+
url: str,
|
|
168
|
+
if_match: str = None,
|
|
169
|
+
if_modified_since: str = None,
|
|
170
|
+
if_none_match: str = None,
|
|
171
|
+
if_unmodified_since: str = None) -> MultipartParser:
|
|
172
|
+
pass
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
@_single_request_template(Node.make_config_conf,
|
|
176
|
+
config.ApiClient,
|
|
177
|
+
config.UsersApi,
|
|
178
|
+
config.UsersApi.get_user_account)
|
|
179
|
+
def config_get_user_account(node: Node,
|
|
180
|
+
username: str) -> str:
|
|
181
|
+
pass
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
@_single_request_template(Node.make_config_conf,
|
|
185
|
+
config.ApiClient,
|
|
186
|
+
config.UsersApi,
|
|
187
|
+
config.UsersApi.get_user_account_names)
|
|
188
|
+
def config_get_usernames(node: Node) -> list[str]:
|
|
189
|
+
pass
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
@_single_request_template(Node.make_config_conf,
|
|
193
|
+
config.ApiClient,
|
|
194
|
+
config.UtilsApi,
|
|
195
|
+
config.UtilsApi.normalize_url)
|
|
196
|
+
def config_normalize_url(node: Node,
|
|
197
|
+
url: str) -> list[str]:
|
|
198
|
+
pass
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
@_single_request_template(Node.make_config_conf,
|
|
202
|
+
config.ApiClient,
|
|
203
|
+
config.ConfigApi,
|
|
204
|
+
config.ConfigApi.get_last_update_time)
|
|
205
|
+
def config_last_update_time(node: Node,
|
|
206
|
+
url: str) -> datetime:
|
|
207
|
+
pass
|