Skip to content

Commit 15d9fe6

Browse files
feat: We can add a number of use max for the secret in pilot registration
1 parent 4549203 commit 15d9fe6

File tree

10 files changed

+1033
-288
lines changed

10 files changed

+1033
-288
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ class BodyPilotsRegisterNewPilotsToDb(_serialization.Model):
263263
:vartype pilot_references: dict[str, any]
264264
:ivar generate_secrets: Boolean to allow secret creation or not.
265265
:vartype generate_secrets: bool
266+
:ivar pilot_secret_use_count_max: Number of times we can use a secret.
267+
:vartype pilot_secret_use_count_max: int
266268
"""
267269

268270
_validation = {
@@ -276,6 +278,10 @@ class BodyPilotsRegisterNewPilotsToDb(_serialization.Model):
276278
"grid_type": {"key": "grid_type", "type": "str"},
277279
"pilot_references": {"key": "pilot_references", "type": "{object}"},
278280
"generate_secrets": {"key": "generate_secrets", "type": "bool"},
281+
"pilot_secret_use_count_max": {
282+
"key": "pilot_secret_use_count_max",
283+
"type": "int",
284+
},
279285
}
280286

281287
def __init__(
@@ -286,6 +292,7 @@ def __init__(
286292
grid_type: str = "Dirac",
287293
pilot_references: Optional[Dict[str, Any]] = None,
288294
generate_secrets: bool = True,
295+
pilot_secret_use_count_max: int = 1,
289296
**kwargs: Any,
290297
) -> None:
291298
"""
@@ -299,13 +306,16 @@ def __init__(
299306
:paramtype pilot_references: dict[str, any]
300307
:keyword generate_secrets: Boolean to allow secret creation or not.
301308
:paramtype generate_secrets: bool
309+
:keyword pilot_secret_use_count_max: Number of times we can use a secret.
310+
:paramtype pilot_secret_use_count_max: int
302311
"""
303312
super().__init__(**kwargs)
304313
self.pilot_stamps = pilot_stamps
305314
self.vo = vo
306315
self.grid_type = grid_type
307316
self.pilot_references = pilot_references
308317
self.generate_secrets = generate_secrets
318+
self.pilot_secret_use_count_max = pilot_secret_use_count_max
309319

310320

311321
class GroupInfo(_serialization.Model):

diracx-routers/src/diracx/routers/pilots/credentials.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ async def register_new_pilots_to_db(
5959
generate_secrets: Annotated[
6060
bool, Body(description="Boolean to allow secret creation or not.")
6161
] = True,
62+
pilot_secret_use_count_max: Annotated[
63+
int, Body(description="Number of times we can use a secret.")
64+
] = 1,
6265
) -> list[PilotStampInfo] | list[PilotCredentialsInfo]:
6366
"""Endpoint where a you can create pilots with their references.
6467
It will return the pilot secrets as well as an expiration date.
@@ -80,7 +83,11 @@ async def register_new_pilots_to_db(
8083

8184
if generate_secrets:
8285
credentials, expiration_dates = await add_pilot_credentials(
83-
pilot_stamps=pilot_stamps, pilot_db=pilot_db, settings=settings, vo=vo
86+
pilot_stamps=pilot_stamps,
87+
pilot_db=pilot_db,
88+
settings=settings,
89+
vo=vo,
90+
pilot_secret_use_count_max=pilot_secret_use_count_max,
8491
)
8592
# Logs credentials creation
8693
logger.debug(f"{user_info.preferred_username} added {len(pilot_stamps)} pilots.")

extensions/gubbins/gubbins-client/src/gubbins/client/_generated/_client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
ConfigOperations,
2121
JobsOperations,
2222
LollygagOperations,
23+
PilotsOperations,
2324
WellKnownOperations,
2425
)
2526

@@ -37,6 +38,8 @@ class Dirac: # pylint: disable=client-accepts-api-version-keyword
3738
:vartype jobs: _generated.operations.JobsOperations
3839
:ivar lollygag: LollygagOperations operations
3940
:vartype lollygag: _generated.operations.LollygagOperations
41+
:ivar pilots: PilotsOperations operations
42+
:vartype pilots: _generated.operations.PilotsOperations
4043
:keyword endpoint: Service URL. Required. Default value is "".
4144
:paramtype endpoint: str
4245
"""
@@ -92,6 +95,9 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
9295
self.lollygag = LollygagOperations(
9396
self._client, self._config, self._serialize, self._deserialize
9497
)
98+
self.pilots = PilotsOperations(
99+
self._client, self._config, self._serialize, self._deserialize
100+
)
95101

96102
def send_request(
97103
self, request: HttpRequest, *, stream: bool = False, **kwargs: Any

extensions/gubbins/gubbins-client/src/gubbins/client/_generated/aio/_client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
ConfigOperations,
2121
JobsOperations,
2222
LollygagOperations,
23+
PilotsOperations,
2324
WellKnownOperations,
2425
)
2526

@@ -37,6 +38,8 @@ class Dirac: # pylint: disable=client-accepts-api-version-keyword
3738
:vartype jobs: _generated.aio.operations.JobsOperations
3839
:ivar lollygag: LollygagOperations operations
3940
:vartype lollygag: _generated.aio.operations.LollygagOperations
41+
:ivar pilots: PilotsOperations operations
42+
:vartype pilots: _generated.aio.operations.PilotsOperations
4043
:keyword endpoint: Service URL. Required. Default value is "".
4144
:paramtype endpoint: str
4245
"""
@@ -92,6 +95,9 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
9295
self.lollygag = LollygagOperations(
9396
self._client, self._config, self._serialize, self._deserialize
9497
)
98+
self.pilots = PilotsOperations(
99+
self._client, self._config, self._serialize, self._deserialize
100+
)
95101

96102
def send_request(
97103
self, request: HttpRequest, *, stream: bool = False, **kwargs: Any

extensions/gubbins/gubbins-client/src/gubbins/client/_generated/aio/operations/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from ._operations import ConfigOperations # type: ignore
1616
from ._operations import JobsOperations # type: ignore
1717
from ._operations import LollygagOperations # type: ignore
18+
from ._operations import PilotsOperations # type: ignore
1819

1920
from ._patch import __all__ as _patch_all
2021
from ._patch import *
@@ -26,6 +27,7 @@
2627
"ConfigOperations",
2728
"JobsOperations",
2829
"LollygagOperations",
30+
"PilotsOperations",
2931
]
3032
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
3133
_patch_sdk()

0 commit comments

Comments
 (0)