pdmv-http-client 2.1.0__py3-none-any.whl → 2.2.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pdmv-http-client
3
- Version: 2.1.0
3
+ Version: 2.2.0
4
4
  Summary: A HTTP client wrapper to handle authenticated requests to CERN internal applications
5
5
  Maintainer-email: PdmV Service <pdmv.service@cern.ch>, PPD Technical Support <cms-PPD-technical-support@cern.ch>
6
6
  License-Expression: MIT
@@ -1,12 +1,16 @@
1
- pdmv_http_client-2.1.0.dist-info/licenses/LICENSE,sha256=RYl3foijZoW2abvncpHax5Prn4sgcSFNuqMBVylpsqU,1083
2
- rest/__init__.py,sha256=4acKnG3HT8j7UDNpvvjTRh5aidulJmlvHQ43L1AKjqQ,315
3
- rest/_version.py,sha256=6G8yJbldQAMT0M9ZiFAqGo5OVqUMxGB1aeWeKmrwNIE,704
1
+ pdmv_http_client-2.2.0.dist-info/licenses/LICENSE,sha256=RYl3foijZoW2abvncpHax5Prn4sgcSFNuqMBVylpsqU,1083
2
+ rest/__init__.py,sha256=_LrCrM2KcwyXCFNXbmcbP_LVtr0l_9jH1i7RFXEPrkw,420
3
+ rest/_version.py,sha256=6OGz4a0gjMGlckPyPCNiJDWyFDO-tWO8O_ZNx4ajT2Y,704
4
4
  rest/applications/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  rest/applications/base.py,sha256=uKwX1Xd2PfiuBDM90bz2EnXsuYiHbUTCBb7c1uwR0OU,8865
6
6
  rest/applications/mcm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  rest/applications/mcm/core.py,sha256=3RbNac2Y3fEEJc3KhqUImk4jzTSMQE6JvEkoC2A_GLw,9465
8
8
  rest/applications/mcm/invalidate_request.py,sha256=IfxTG5j0NToNQQNm93XqEjReuFDfnOrKtbws8_bDLuQ,15679
9
9
  rest/applications/mcm/resubmission.py,sha256=-5ScoFBAS7qKlbBe5sHu_QQ7aRAe8ilNMqTgN7SfwDY,17531
10
+ rest/applications/relmon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ rest/applications/relmon/core.py,sha256=CtVq9R35rcgSUyJx08IMKC1h9q3wnex683wTlbERBdA,2458
12
+ rest/applications/relval/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ rest/applications/relval/core.py,sha256=oDP4Bkfw3FmeU08zOyhsrOOECt-sF0j7PFa3RCNPu4E,3561
10
14
  rest/applications/rereco/core.py,sha256=g1jZpY_NMG2LpXlRdgu48kYrD2MGoNwDtakjhaAVMZI,2243
11
15
  rest/applications/stats/core.py,sha256=Bm7kZNrTMCwyBS7cgo8bcUb16u-U9FjGKrleJolGXhM,2737
12
16
  rest/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -20,7 +24,7 @@ rest/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
24
  rest/utils/logger.py,sha256=OOE7ktIERtV91_GuxUKmLz9c6RQR_tcZ1ugdkeG2wZM,1013
21
25
  rest/utils/miscellaneous.py,sha256=r6Wmf6M3W1oZX41d0pj_4yqg8VoSncXTkAAEyk228_g,1247
22
26
  rest/utils/shell.py,sha256=HlUjyLZbhkKoktR0um4Ig4cNI1F0sLEc5xvjc2xHILQ,1438
23
- pdmv_http_client-2.1.0.dist-info/METADATA,sha256=LarL6koytstCDOI6SriHoRTuJjYY3akJ7hptP5oeDNU,2431
24
- pdmv_http_client-2.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
- pdmv_http_client-2.1.0.dist-info/top_level.txt,sha256=0QXYxm_ASalsWNLMGOoXHpjHuompr6ZCXwA-QrTZCZE,5
26
- pdmv_http_client-2.1.0.dist-info/RECORD,,
27
+ pdmv_http_client-2.2.0.dist-info/METADATA,sha256=-rd_BUjSkN4uRJXA33heiM1i4k-GbUavPD1UwBEhUdQ,2431
28
+ pdmv_http_client-2.2.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
29
+ pdmv_http_client-2.2.0.dist-info/top_level.txt,sha256=0QXYxm_ASalsWNLMGOoXHpjHuompr6ZCXwA-QrTZCZE,5
30
+ pdmv_http_client-2.2.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
rest/__init__.py CHANGED
@@ -6,5 +6,7 @@ Just to keep backward compatibility.
6
6
 
7
7
  from rest.applications.base import BaseClient
8
8
  from rest.applications.mcm.core import McM
9
+ from rest.applications.relmon.core import RelMonService
10
+ from rest.applications.relval.core import RelVal
9
11
  from rest.applications.rereco.core import ReReco
10
12
  from rest.applications.stats.core import Stats2
rest/_version.py CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '2.1.0'
32
- __version_tuple__ = version_tuple = (2, 1, 0)
31
+ __version__ = version = '2.2.0'
32
+ __version_tuple__ = version_tuple = (2, 2, 0)
33
33
 
34
34
  __commit_id__ = commit_id = None
File without changes
@@ -0,0 +1,95 @@
1
+ """
2
+ REST client for the RelMonService application.
3
+ """
4
+
5
+ from typing import Any, Dict, Optional, Union
6
+ from urllib.parse import urlencode
7
+
8
+ from rest.applications.base import BaseClient
9
+
10
+
11
+ class RelMonService(BaseClient):
12
+ """
13
+ Initializes an HTTP client for querying RelMonService.
14
+ """
15
+
16
+ def __init__(
17
+ self,
18
+ id: str = BaseClient.SSO,
19
+ debug: bool = False,
20
+ cookie: Union[str, None] = None,
21
+ dev: bool = True,
22
+ client_id: str = "",
23
+ client_secret: str = "",
24
+ ):
25
+ super().__init__(
26
+ app="relmonservice",
27
+ id=id,
28
+ debug=debug,
29
+ cookie=cookie,
30
+ dev=dev,
31
+ client_id=client_id,
32
+ client_secret=client_secret,
33
+ )
34
+
35
+ # -----------------
36
+ # RelMonService APIs
37
+ # -----------------
38
+
39
+ def get_relmons(
40
+ self,
41
+ page: int = 0,
42
+ limit: Optional[int] = None,
43
+ query: Optional[str] = None,
44
+ ) -> Dict[str, Any]:
45
+ """
46
+ Fetch RelMons from database.
47
+ """
48
+ params = {"page": page}
49
+ if limit is not None:
50
+ params["limit"] = limit
51
+ if query:
52
+ params["q"] = query
53
+
54
+ qs = f"?{urlencode(params)}" if params else ""
55
+ return self._get(url=f"api/get_relmons{qs}")
56
+
57
+ def create(self, relmon: Dict[str, Any]) -> Dict[str, Any]:
58
+ """
59
+ Create a new RelMon.
60
+ """
61
+ return self._post(url="api/create", data=relmon)
62
+
63
+ def reset(self, relmon_id: str) -> Dict[str, Any]:
64
+ """
65
+ Reset a RelMon by ID.
66
+ """
67
+ return self._post(url="api/reset", data={"id": relmon_id})
68
+
69
+ def delete(self, relmon_id: str) -> Dict[str, Any]:
70
+ """
71
+ Delete a RelMon by ID.
72
+ """
73
+ request_body = {"id": relmon_id}
74
+ request_endpoint = f"{self.server}api/delete"
75
+ response = self.session.delete(url=request_endpoint, json=request_body)
76
+ response.raise_for_status()
77
+ return response.json()
78
+
79
+ def edit(self, relmon: Dict[str, Any]) -> Dict[str, Any]:
80
+ """
81
+ Edit an existing RelMon.
82
+ """
83
+ return self._post(url="api/edit", data=relmon)
84
+
85
+ def tick(self) -> Dict[str, Any]:
86
+ """
87
+ Trigger a controller tick.
88
+ """
89
+ return self._get(url="api/tick")
90
+
91
+ def user(self) -> Dict[str, Any]:
92
+ """
93
+ Get user info.
94
+ """
95
+ return self._get(url="api/user")
File without changes
@@ -0,0 +1,129 @@
1
+ """
2
+ REST client for the RelVal application.
3
+ """
4
+
5
+ from typing import Union
6
+
7
+ from rest.applications.base import BaseClient
8
+
9
+
10
+ class RelVal(BaseClient):
11
+ """
12
+ Initializes an HTTP client for querying RelVal.
13
+ """
14
+
15
+ def __init__(
16
+ self,
17
+ id: str = BaseClient.SSO,
18
+ debug: bool = False,
19
+ cookie: Union[str, None] = None,
20
+ dev: bool = True,
21
+ client_id: str = "",
22
+ client_secret: str = "",
23
+ ):
24
+ # Set the HTTP session
25
+ super().__init__(
26
+ app="relval",
27
+ id=id,
28
+ debug=debug,
29
+ cookie=cookie,
30
+ dev=dev,
31
+ client_id=client_id,
32
+ client_secret=client_secret,
33
+ )
34
+
35
+ # RelVal methods
36
+
37
+ def create(self, data):
38
+ """
39
+ Create a new RelVal.
40
+ Requires manager role.
41
+ """
42
+ return self._put(url="api/relvals/create", data=data)
43
+
44
+ def delete(self, data):
45
+ """
46
+ Delete one or multiple RelVals.
47
+ Requires manager role.
48
+ """
49
+ response = self.session.delete(
50
+ url=f"{self.server}api/relvals/delete", json=data
51
+ )
52
+ response.raise_for_status()
53
+ return response.json()
54
+
55
+ def update(self, data):
56
+ """
57
+ Update one or multiple RelVals.
58
+ Requires manager role.
59
+ """
60
+ return self._post(url="api/relvals/update", data=data)
61
+
62
+ def get_relval(self, prepid: str):
63
+ """
64
+ Retrieve a single RelVal by its prepid.
65
+ """
66
+ return self._get(url=f"api/relvals/get/{prepid}")
67
+
68
+ def get_editable(self, prepid: str = None):
69
+ """
70
+ Get information on which RelVal fields are editable.
71
+ If prepid is given, return for a specific RelVal.
72
+ """
73
+ url = "api/relvals/get_editable"
74
+ if prepid:
75
+ url += f"/{prepid}"
76
+ return self._get(url=url)
77
+
78
+ def get_cmsdriver(self, prepid: str):
79
+ """
80
+ Get a bash script with cmsDriver.py commands of RelVal.
81
+ """
82
+ response = self.session.get(
83
+ url=f"{self.server}api/relvals/get_cmsdriver/{prepid}"
84
+ )
85
+ response.raise_for_status()
86
+ return response.text
87
+
88
+ def get_config_upload(self, prepid: str):
89
+ """
90
+ Get a bash script to upload configs to ReqMgr config cache.
91
+ """
92
+ response = self.session.get(
93
+ url=f"{self.server}api/relvals/get_config_upload/{prepid}"
94
+ )
95
+ response.raise_for_status()
96
+ return response.text
97
+
98
+ def get_dict(self, prepid: str):
99
+ """
100
+ Get a dictionary with job information for ReqMgr2.
101
+ """
102
+ return self._get(url=f"api/relvals/get_dict/{prepid}")
103
+
104
+ def get_default_step(self):
105
+ """
106
+ Get a default (empty) step that could be used as a template.
107
+ """
108
+ return self._get(url="api/relvals/get_default_step")
109
+
110
+ def next_status(self, data):
111
+ """
112
+ Move one or multiple RelVals to next status.
113
+ Requires manager role.
114
+ """
115
+ return self._post(url="api/relvals/next_status", data=data)
116
+
117
+ def previous_status(self, data):
118
+ """
119
+ Move one or multiple RelVals to previous status.
120
+ Requires manager role.
121
+ """
122
+ return self._post(url="api/relvals/previous_status", data=data)
123
+
124
+ def update_workflows(self, data):
125
+ """
126
+ Trigger one or multiple RelVal updates from Stats2 (ReqMgr2 + DBS).
127
+ Requires manager role.
128
+ """
129
+ return self._post(url="api/relvals/update_workflows", data=data)