7
7
"SearchKwargs" ,
8
8
"make_summary_body" ,
9
9
"SummaryKwargs" ,
10
+ "AddPilotStampsKwargs" ,
11
+ "make_add_pilot_stamps_body" ,
12
+ "UpdatePilotFieldsKwargs" ,
13
+ "make_update_pilot_fields_body"
10
14
]
11
15
12
16
import json
13
17
from io import BytesIO
14
18
from typing import Any , IO , TypedDict , Unpack , cast , Literal
15
19
16
- from diracx .core .models import SearchSpec
20
+ from diracx .core .models import SearchSpec , PilotStatus , PilotFieldsMapping
17
21
18
22
19
23
class ResponseExtra (TypedDict , total = False ):
@@ -23,6 +27,7 @@ class ResponseExtra(TypedDict, total=False):
23
27
cls : Any
24
28
25
29
30
+ # ------------------ Search ------------------
26
31
class SearchBody (TypedDict , total = False ):
27
32
parameters : list [str ] | None
28
33
search : list [SearchSpec ] | None
@@ -56,6 +61,7 @@ def make_search_body(**kwargs: Unpack[SearchKwargs]) -> UnderlyingSearchArgs:
56
61
result .update (cast (SearchExtra , kwargs ))
57
62
return result
58
63
64
+ # ------------------ Summary ------------------
59
65
60
66
class SummaryBody (TypedDict , total = False ):
61
67
grouping : list [str ]
@@ -83,3 +89,57 @@ def make_summary_body(**kwargs: Unpack[SummaryKwargs]) -> UnderlyingSummaryArgs:
83
89
result : UnderlyingSummaryArgs = {"body" : BytesIO (json .dumps (body ).encode ("utf-8" ))}
84
90
result .update (cast (ResponseExtra , kwargs ))
85
91
return result
92
+
93
+ # ------------------ AddPilotStamps ------------------
94
+
95
+ class AddPilotStampsBody (TypedDict , total = False ):
96
+ pilot_stamps : list [str ]
97
+ grid_type : str
98
+ grid_site : str
99
+ pilot_references : dict [str , str ]
100
+ pilot_status : PilotStatus
101
+
102
+ class AddPilotStampsKwargs (AddPilotStampsBody , ResponseExtra ): ...
103
+
104
+ class UnderlyingAddPilotStampsArgs (ResponseExtra , total = False ):
105
+ # FIXME: The autorest-generated has a bug that it expected IO[bytes] despite
106
+ # the code being generated to support IO[bytes] | bytes.
107
+ body : IO [bytes ]
108
+
109
+ def make_add_pilot_stamps_body (** kwargs : Unpack [AddPilotStampsKwargs ]) -> UnderlyingAddPilotStampsArgs :
110
+ body : AddPilotStampsBody = {}
111
+ for key in AddPilotStampsBody .__optional_keys__ :
112
+ if key not in kwargs :
113
+ continue
114
+ key = cast (Literal ["pilot_stamps" , "grid_type" , "grid_site" , "pilot_references" , "pilot_status" ], key )
115
+ value = kwargs .pop (key )
116
+ if value is not None :
117
+ body [key ] = value
118
+ result : UnderlyingAddPilotStampsArgs = {"body" : BytesIO (json .dumps (body ).encode ("utf-8" ))}
119
+ result .update (cast (ResponseExtra , kwargs ))
120
+ return result
121
+
122
+ # ------------------ UpdatePilotFields ------------------
123
+
124
+ class UpdatePilotFieldsBody (TypedDict , total = False ):
125
+ pilot_stamps_to_fields_mapping : list [PilotFieldsMapping ]
126
+
127
+ class UpdatePilotFieldsKwargs (UpdatePilotFieldsBody , ResponseExtra ): ...
128
+
129
+ class UnderlyingUpdatePilotFields (ResponseExtra , total = False ):
130
+ # FIXME: The autorest-generated has a bug that it expected IO[bytes] despite
131
+ # the code being generated to support IO[bytes] | bytes.
132
+ body : IO [bytes ]
133
+
134
+ def make_update_pilot_fields_body (** kwargs : Unpack [UpdatePilotFieldsKwargs ]) -> UnderlyingUpdatePilotFields :
135
+ body : UpdatePilotFieldsBody = {}
136
+ for key in UpdatePilotFieldsBody .__optional_keys__ :
137
+ if key not in kwargs :
138
+ continue
139
+ key = cast (Literal ["pilot_stamps_to_fields_mapping" ], key )
140
+ value = kwargs .pop (key )
141
+ if value is not None :
142
+ body [key ] = value
143
+ result : UnderlyingUpdatePilotFields = {"body" : BytesIO (json .dumps (body ).encode ("utf-8" ))}
144
+ result .update (cast (ResponseExtra , kwargs ))
145
+ return result
0 commit comments