Skip to content

Commit 76687d7

Browse files
author
Robin VAN DE MERGHEL
committed
feat: Add vacuum case (equiv dirac-admin-add-pilot)
1 parent af32236 commit 76687d7

File tree

13 files changed

+456
-141
lines changed

13 files changed

+456
-141
lines changed

diracx-client/src/diracx/client/_generated/aio/operations/_operations.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -863,14 +863,16 @@ async def complete_authorization_flow(self, *, code: str, state: str, **kwargs:
863863

864864
@overload
865865
async def perform_secret_exchange(
866-
self, body: _models.BodyAuthPerformSecretExchange, *, content_type: str = "application/json", **kwargs: Any
866+
self, body: _models.PilotCredentials, *, content_type: str = "application/json", **kwargs: Any
867867
) -> _models.TokenResponse:
868868
"""Perform Secret Exchange.
869869
870870
This endpoint is used by the pilot to exchange a secret for a token.
871871
872+
This endpoint also acts as DIRAC's ``dirac-admin-add-pilot``.
873+
872874
:param body: Required.
873-
:type body: ~_generated.models.BodyAuthPerformSecretExchange
875+
:type body: ~_generated.models.PilotCredentials
874876
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
875877
Default value is "application/json".
876878
:paramtype content_type: str
@@ -887,6 +889,8 @@ async def perform_secret_exchange(
887889
888890
This endpoint is used by the pilot to exchange a secret for a token.
889891
892+
This endpoint also acts as DIRAC's ``dirac-admin-add-pilot``.
893+
890894
:param body: Required.
891895
:type body: IO[bytes]
892896
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
@@ -899,14 +903,16 @@ async def perform_secret_exchange(
899903

900904
@distributed_trace_async
901905
async def perform_secret_exchange(
902-
self, body: Union[_models.BodyAuthPerformSecretExchange, IO[bytes]], **kwargs: Any
906+
self, body: Union[_models.PilotCredentials, IO[bytes]], **kwargs: Any
903907
) -> _models.TokenResponse:
904908
"""Perform Secret Exchange.
905909
906910
This endpoint is used by the pilot to exchange a secret for a token.
907911
908-
:param body: Is either a BodyAuthPerformSecretExchange type or a IO[bytes] type. Required.
909-
:type body: ~_generated.models.BodyAuthPerformSecretExchange or IO[bytes]
912+
This endpoint also acts as DIRAC's ``dirac-admin-add-pilot``.
913+
914+
:param body: Is either a PilotCredentials type or a IO[bytes] type. Required.
915+
:type body: ~_generated.models.PilotCredentials or IO[bytes]
910916
:return: TokenResponse
911917
:rtype: ~_generated.models.TokenResponse
912918
:raises ~azure.core.exceptions.HttpResponseError:
@@ -931,7 +937,7 @@ async def perform_secret_exchange(
931937
if isinstance(body, (IOBase, bytes)):
932938
_content = body
933939
else:
934-
_json = self._serialize.body(body, "BodyAuthPerformSecretExchange")
940+
_json = self._serialize.body(body, "PilotCredentials")
935941

936942
_request = build_auth_perform_secret_exchange_request(
937943
content_type=content_type,

diracx-client/src/diracx/client/_generated/models/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from ._models import ( # type: ignore
1515
BodyAuthGetOidcToken,
1616
BodyAuthGetOidcTokenGrantType,
17-
BodyAuthPerformSecretExchange,
1817
BodyAuthRefreshPilotTokens,
1918
BodyPilotsAddJobsToPilot,
2019
BodyPilotsAddPilotStamps,
@@ -31,6 +30,8 @@
3130
JobSummaryParamsSearchItem,
3231
Metadata,
3332
OpenIDConfiguration,
33+
PilotAuthCredentials,
34+
PilotCredentials,
3435
PilotCredentialsInfo,
3536
PilotFieldsMapping,
3637
PilotInfo,
@@ -50,6 +51,7 @@
5051
TokenResponse,
5152
UserInfoResponse,
5253
VOInfo,
54+
VacuumPilotAuth,
5355
ValidationError,
5456
ValidationErrorLocItem,
5557
VectorSearchSpec,
@@ -73,7 +75,6 @@
7375
__all__ = [
7476
"BodyAuthGetOidcToken",
7577
"BodyAuthGetOidcTokenGrantType",
76-
"BodyAuthPerformSecretExchange",
7778
"BodyAuthRefreshPilotTokens",
7879
"BodyPilotsAddJobsToPilot",
7980
"BodyPilotsAddPilotStamps",
@@ -90,6 +91,8 @@
9091
"JobSummaryParamsSearchItem",
9192
"Metadata",
9293
"OpenIDConfiguration",
94+
"PilotAuthCredentials",
95+
"PilotCredentials",
9396
"PilotCredentialsInfo",
9497
"PilotFieldsMapping",
9598
"PilotInfo",
@@ -109,6 +112,7 @@
109112
"TokenResponse",
110113
"UserInfoResponse",
111114
"VOInfo",
115+
"VacuumPilotAuth",
112116
"ValidationError",
113117
"ValidationErrorLocItem",
114118
"VectorSearchSpec",

diracx-client/src/diracx/client/_generated/models/_models.py

Lines changed: 118 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -94,39 +94,6 @@ class BodyAuthGetOidcTokenGrantType(_serialization.Model):
9494
"""OAuth2 Grant type."""
9595

9696

97-
class BodyAuthPerformSecretExchange(_serialization.Model):
98-
"""Body_auth_perform_secret_exchange.
99-
100-
All required parameters must be populated in order to send to server.
101-
102-
:ivar pilot_stamp: Stamp used by a pilot to login. Required.
103-
:vartype pilot_stamp: str
104-
:ivar pilot_secret: Pilot secret given by Dirac/DiracX. Required.
105-
:vartype pilot_secret: str
106-
"""
107-
108-
_validation = {
109-
"pilot_stamp": {"required": True},
110-
"pilot_secret": {"required": True},
111-
}
112-
113-
_attribute_map = {
114-
"pilot_stamp": {"key": "pilot_stamp", "type": "str"},
115-
"pilot_secret": {"key": "pilot_secret", "type": "str"},
116-
}
117-
118-
def __init__(self, *, pilot_stamp: str, pilot_secret: str, **kwargs: Any) -> None:
119-
"""
120-
:keyword pilot_stamp: Stamp used by a pilot to login. Required.
121-
:paramtype pilot_stamp: str
122-
:keyword pilot_secret: Pilot secret given by Dirac/DiracX. Required.
123-
:paramtype pilot_secret: str
124-
"""
125-
super().__init__(**kwargs)
126-
self.pilot_stamp = pilot_stamp
127-
self.pilot_secret = pilot_secret
128-
129-
13097
class BodyAuthRefreshPilotTokens(_serialization.Model):
13198
"""Body_auth_refresh_pilot_tokens.
13299
@@ -304,33 +271,42 @@ class BodyPilotsCreatePilotSecrets(_serialization.Model):
304271
:vartype expiration_minutes: int
305272
:ivar pilot_secret_use_count_max: Number of times that we can use a secret. Required.
306273
:vartype pilot_secret_use_count_max: int
274+
:ivar vo: Only VO that can access a secret. Required.
275+
:vartype vo: str
307276
"""
308277

309278
_validation = {
310279
"n": {"required": True},
311280
"expiration_minutes": {"required": True},
312281
"pilot_secret_use_count_max": {"required": True},
282+
"vo": {"required": True},
313283
}
314284

315285
_attribute_map = {
316286
"n": {"key": "n", "type": "int"},
317287
"expiration_minutes": {"key": "expiration_minutes", "type": "int"},
318288
"pilot_secret_use_count_max": {"key": "pilot_secret_use_count_max", "type": "int"},
289+
"vo": {"key": "vo", "type": "str"},
319290
}
320291

321-
def __init__(self, *, n: int, expiration_minutes: int, pilot_secret_use_count_max: int, **kwargs: Any) -> None:
292+
def __init__(
293+
self, *, n: int, expiration_minutes: int, pilot_secret_use_count_max: int, vo: str, **kwargs: Any
294+
) -> None:
322295
"""
323296
:keyword n: Number of secrets to create. Required.
324297
:paramtype n: int
325298
:keyword expiration_minutes: Time in minutes before expiring. Required.
326299
:paramtype expiration_minutes: int
327300
:keyword pilot_secret_use_count_max: Number of times that we can use a secret. Required.
328301
:paramtype pilot_secret_use_count_max: int
302+
:keyword vo: Only VO that can access a secret. Required.
303+
:paramtype vo: str
329304
"""
330305
super().__init__(**kwargs)
331306
self.n = n
332307
self.expiration_minutes = expiration_minutes
333308
self.pilot_secret_use_count_max = pilot_secret_use_count_max
309+
self.vo = vo
334310

335311

336312
class BodyPilotsPerformSecretExchange(_serialization.Model):
@@ -939,6 +915,43 @@ def __init__(
939915
self.code_challenge_methods_supported = code_challenge_methods_supported
940916

941917

918+
class PilotAuthCredentials(_serialization.Model):
919+
"""PilotAuthCredentials.
920+
921+
All required parameters must be populated in order to send to server.
922+
923+
:ivar pilot_stamp: Pilot Stamp. Required.
924+
:vartype pilot_stamp: str
925+
:ivar pilot_secret: Pilot Secret. Required.
926+
:vartype pilot_secret: str
927+
"""
928+
929+
_validation = {
930+
"pilot_stamp": {"required": True},
931+
"pilot_secret": {"required": True},
932+
}
933+
934+
_attribute_map = {
935+
"pilot_stamp": {"key": "pilot_stamp", "type": "str"},
936+
"pilot_secret": {"key": "pilot_secret", "type": "str"},
937+
}
938+
939+
def __init__(self, *, pilot_stamp: str, pilot_secret: str, **kwargs: Any) -> None:
940+
"""
941+
:keyword pilot_stamp: Pilot Stamp. Required.
942+
:paramtype pilot_stamp: str
943+
:keyword pilot_secret: Pilot Secret. Required.
944+
:paramtype pilot_secret: str
945+
"""
946+
super().__init__(**kwargs)
947+
self.pilot_stamp = pilot_stamp
948+
self.pilot_secret = pilot_secret
949+
950+
951+
class PilotCredentials(_serialization.Model):
952+
"""Pilot credentials (stamp and secret)."""
953+
954+
942955
class PilotCredentialsInfo(_serialization.Model):
943956
"""PilotCredentialsInfo.
944957
@@ -1725,6 +1738,77 @@ def __init__(
17251738
self.preferred_username = preferred_username
17261739

17271740

1741+
class VacuumPilotAuth(_serialization.Model):
1742+
"""VacuumPilotAuth.
1743+
1744+
All required parameters must be populated in order to send to server.
1745+
1746+
:ivar pilot_stamp: Pilot Stamp. Required.
1747+
:vartype pilot_stamp: str
1748+
:ivar pilot_secret: Pilot Secret. Required.
1749+
:vartype pilot_secret: str
1750+
:ivar vo: Vo. Required.
1751+
:vartype vo: str
1752+
:ivar grid_type: Grid Type. Required.
1753+
:vartype grid_type: str
1754+
:ivar grid_site: Grid Site. Required.
1755+
:vartype grid_site: str
1756+
:ivar status: Status. Required.
1757+
:vartype status: str
1758+
"""
1759+
1760+
_validation = {
1761+
"pilot_stamp": {"required": True},
1762+
"pilot_secret": {"required": True},
1763+
"vo": {"required": True},
1764+
"grid_type": {"required": True},
1765+
"grid_site": {"required": True},
1766+
"status": {"required": True},
1767+
}
1768+
1769+
_attribute_map = {
1770+
"pilot_stamp": {"key": "pilot_stamp", "type": "str"},
1771+
"pilot_secret": {"key": "pilot_secret", "type": "str"},
1772+
"vo": {"key": "vo", "type": "str"},
1773+
"grid_type": {"key": "grid_type", "type": "str"},
1774+
"grid_site": {"key": "grid_site", "type": "str"},
1775+
"status": {"key": "status", "type": "str"},
1776+
}
1777+
1778+
def __init__(
1779+
self,
1780+
*,
1781+
pilot_stamp: str,
1782+
pilot_secret: str,
1783+
vo: str,
1784+
grid_type: str,
1785+
grid_site: str,
1786+
status: str,
1787+
**kwargs: Any
1788+
) -> None:
1789+
"""
1790+
:keyword pilot_stamp: Pilot Stamp. Required.
1791+
:paramtype pilot_stamp: str
1792+
:keyword pilot_secret: Pilot Secret. Required.
1793+
:paramtype pilot_secret: str
1794+
:keyword vo: Vo. Required.
1795+
:paramtype vo: str
1796+
:keyword grid_type: Grid Type. Required.
1797+
:paramtype grid_type: str
1798+
:keyword grid_site: Grid Site. Required.
1799+
:paramtype grid_site: str
1800+
:keyword status: Status. Required.
1801+
:paramtype status: str
1802+
"""
1803+
super().__init__(**kwargs)
1804+
self.pilot_stamp = pilot_stamp
1805+
self.pilot_secret = pilot_secret
1806+
self.vo = vo
1807+
self.grid_type = grid_type
1808+
self.grid_site = grid_site
1809+
self.status = status
1810+
1811+
17281812
class ValidationError(_serialization.Model):
17291813
"""ValidationError.
17301814

diracx-client/src/diracx/client/_generated/operations/_operations.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,14 +1577,16 @@ def complete_authorization_flow(self, *, code: str, state: str, **kwargs: Any) -
15771577

15781578
@overload
15791579
def perform_secret_exchange(
1580-
self, body: _models.BodyAuthPerformSecretExchange, *, content_type: str = "application/json", **kwargs: Any
1580+
self, body: _models.PilotCredentials, *, content_type: str = "application/json", **kwargs: Any
15811581
) -> _models.TokenResponse:
15821582
"""Perform Secret Exchange.
15831583
15841584
This endpoint is used by the pilot to exchange a secret for a token.
15851585
1586+
This endpoint also acts as DIRAC's ``dirac-admin-add-pilot``.
1587+
15861588
:param body: Required.
1587-
:type body: ~_generated.models.BodyAuthPerformSecretExchange
1589+
:type body: ~_generated.models.PilotCredentials
15881590
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
15891591
Default value is "application/json".
15901592
:paramtype content_type: str
@@ -1601,6 +1603,8 @@ def perform_secret_exchange(
16011603
16021604
This endpoint is used by the pilot to exchange a secret for a token.
16031605
1606+
This endpoint also acts as DIRAC's ``dirac-admin-add-pilot``.
1607+
16041608
:param body: Required.
16051609
:type body: IO[bytes]
16061610
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
@@ -1613,14 +1617,16 @@ def perform_secret_exchange(
16131617

16141618
@distributed_trace
16151619
def perform_secret_exchange(
1616-
self, body: Union[_models.BodyAuthPerformSecretExchange, IO[bytes]], **kwargs: Any
1620+
self, body: Union[_models.PilotCredentials, IO[bytes]], **kwargs: Any
16171621
) -> _models.TokenResponse:
16181622
"""Perform Secret Exchange.
16191623
16201624
This endpoint is used by the pilot to exchange a secret for a token.
16211625
1622-
:param body: Is either a BodyAuthPerformSecretExchange type or a IO[bytes] type. Required.
1623-
:type body: ~_generated.models.BodyAuthPerformSecretExchange or IO[bytes]
1626+
This endpoint also acts as DIRAC's ``dirac-admin-add-pilot``.
1627+
1628+
:param body: Is either a PilotCredentials type or a IO[bytes] type. Required.
1629+
:type body: ~_generated.models.PilotCredentials or IO[bytes]
16241630
:return: TokenResponse
16251631
:rtype: ~_generated.models.TokenResponse
16261632
:raises ~azure.core.exceptions.HttpResponseError:
@@ -1645,7 +1651,7 @@ def perform_secret_exchange(
16451651
if isinstance(body, (IOBase, bytes)):
16461652
_content = body
16471653
else:
1648-
_json = self._serialize.body(body, "BodyAuthPerformSecretExchange")
1654+
_json = self._serialize.body(body, "PilotCredentials")
16491655

16501656
_request = build_auth_perform_secret_exchange_request(
16511657
content_type=content_type,

diracx-core/src/diracx/core/models.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,3 +378,15 @@ class PilotRefreshTokenPayload(BaseTokenPayload):
378378

379379
class PilotCredentialsInfo(PilotSecretsInfo):
380380
pilot_stamp: str
381+
382+
383+
class PilotAuthCredentials(TypedDict):
384+
pilot_stamp: str
385+
pilot_secret: str
386+
387+
388+
class VacuumPilotAuth(PilotAuthCredentials):
389+
vo: str
390+
grid_type: str
391+
grid_site: str
392+
status: str

0 commit comments

Comments
 (0)