@@ -166,7 +166,10 @@ def get_custom_tag_usage_analytics(
166166 return CustomTagUsageReport .from_json (json )
167167
168168 def create_developer_key (
169- self , * , label : Optional [str ] = None
169+ self ,
170+ * ,
171+ label : Optional [str ] = None ,
172+ extra_body_parameters : Optional [dict ] = None ,
170173 ) -> DeveloperKey :
171174 """Creates a developer key in the organization. The request is only
172175 retried if it cannot have been processed (HTTP 429 or a DNS
@@ -175,11 +178,15 @@ def create_developer_key(
175178
176179 :param label: (Optional) Label for the new key. The API uses
177180 "DeepL API Key" if no label is given.
181+ :param extra_body_parameters: (Optional) Additional key/value pairs to
182+ include in the JSON request body sent to the API. They are added
183+ last and replace keys of the same name that the client sets.
178184 :return: DeveloperKey describing the created key.
179185 """
180186 request_data = {}
181187 if label is not None :
182188 request_data ["label" ] = label
189+ _add_extra_body_parameters (request_data , extra_body_parameters )
183190
184191 status , content , json = self ._api_call (
185192 "v2/admin/developer-keys" ,
@@ -208,36 +215,54 @@ def list_developer_keys(self) -> List[DeveloperKey]:
208215 ]
209216
210217 def deactivate_developer_key (
211- self , key : Union [str , DeveloperKey ]
218+ self ,
219+ key : Union [str , DeveloperKey ],
220+ * ,
221+ extra_body_parameters : Optional [dict ] = None ,
212222 ) -> DeveloperKey :
213223 """Deactivates a developer key. Deactivation is permanent.
214224
215225 :param key: Key ID or DeveloperKey to deactivate.
226+ :param extra_body_parameters: (Optional) Additional key/value pairs to
227+ include in the JSON request body sent to the API. They are added
228+ last and replace keys of the same name that the client sets.
216229 :return: DeveloperKey describing the deactivated key.
217230 """
218231 return self ._put_developer_key (
219- "v2/admin/developer-keys/deactivate" , {"key_id" : _key_id (key )}
232+ "v2/admin/developer-keys/deactivate" ,
233+ {"key_id" : _key_id (key )},
234+ extra_body_parameters ,
220235 )
221236
222237 def rename_developer_key (
223- self , key : Union [str , DeveloperKey ], label : str
238+ self ,
239+ key : Union [str , DeveloperKey ],
240+ label : str ,
241+ * ,
242+ extra_body_parameters : Optional [dict ] = None ,
224243 ) -> DeveloperKey :
225244 """Changes the label of a developer key.
226245
227246 :param key: Key ID or DeveloperKey to rename.
228247 :param label: New label for the key.
248+ :param extra_body_parameters: (Optional) Additional key/value pairs to
249+ include in the JSON request body sent to the API. They are added
250+ last and replace keys of the same name that the client sets.
229251 :return: DeveloperKey describing the renamed key.
230252 """
231253 key_id = _key_id (key )
232254 return self ._put_developer_key (
233255 "v2/admin/developer-keys/label" ,
234256 {"key_id" : key_id , "label" : label },
257+ extra_body_parameters ,
235258 )
236259
237260 def set_developer_key_usage_limits (
238261 self ,
239262 key : Union [str , DeveloperKey ],
240263 limits : DeveloperKeyUsageLimitsUpdate ,
264+ * ,
265+ extra_body_parameters : Optional [dict ] = None ,
241266 ) -> DeveloperKey :
242267 """Changes the monthly usage limits of a developer key. Only the
243268 limits set in `limits` are changed; the others keep their current
@@ -247,22 +272,40 @@ def set_developer_key_usage_limits(
247272 :param limits: DeveloperKeyUsageLimitsUpdate with the limits to
248273 change. None removes a limit (unlimited usage) and 0 blocks that
249274 usage.
275+ :param extra_body_parameters: (Optional) Additional key/value pairs to
276+ include in the JSON request body sent to the API. They are added
277+ last and replace keys of the same name that the client sets.
250278 :return: DeveloperKey describing the modified key.
251279 """
252280 key_id = _key_id (key )
253281 return self ._put_developer_key (
254282 "v2/admin/developer-keys/limits" ,
255283 {"key_id" : key_id , ** limits ._to_request_dict ()},
284+ extra_body_parameters ,
256285 )
257286
258- def _put_developer_key (self , url : str , request_data : dict ) -> DeveloperKey :
287+ def _put_developer_key (
288+ self ,
289+ url : str ,
290+ request_data : dict ,
291+ extra_body_parameters : Optional [dict ],
292+ ) -> DeveloperKey :
293+ _add_extra_body_parameters (request_data , extra_body_parameters )
259294 status , content , json = self ._api_call (
260295 url , method = "PUT" , json = request_data
261296 )
262297 self ._raise_for_status (status , content , json )
263298 return _parse_key (json )
264299
265300
301+ def _add_extra_body_parameters (
302+ request_data : dict , extra_body_parameters : Optional [dict ]
303+ ) -> None :
304+ # Entries replace keys of the same name set by the client.
305+ if extra_body_parameters :
306+ request_data .update (extra_body_parameters )
307+
308+
266309def _date_range_params (
267310 start_date : Union [datetime .date , str ], end_date : Union [datetime .date , str ]
268311) -> Dict [str , str ]:
0 commit comments