@@ -601,7 +601,7 @@ def build_pilots_add_pilot_stamps_request(**kwargs: Any) -> HttpRequest:
601601 accept = _headers .pop ("Accept" , "application/json" )
602602
603603 # Construct URL
604- _url = "/api/pilots/management/pilot "
604+ _url = "/api/pilots/"
605605
606606 # Construct headers
607607 if content_type is not None :
@@ -611,14 +611,25 @@ def build_pilots_add_pilot_stamps_request(**kwargs: Any) -> HttpRequest:
611611 return HttpRequest (method = "POST" , url = _url , headers = _headers , ** kwargs )
612612
613613
614- def build_pilots_delete_pilots_request (* , pilot_stamps : List [str ], ** kwargs : Any ) -> HttpRequest :
614+ def build_pilots_delete_pilots_request (
615+ * ,
616+ pilot_stamps : Optional [List [str ]] = None ,
617+ age_in_days : Optional [int ] = None ,
618+ delete_only_aborted : bool = False ,
619+ ** kwargs : Any
620+ ) -> HttpRequest :
615621 _params = case_insensitive_dict (kwargs .pop ("params" , {}) or {})
616622
617623 # Construct URL
618- _url = "/api/pilots/management/pilot "
624+ _url = "/api/pilots/"
619625
620626 # Construct parameters
621- _params ["pilot_stamps" ] = _SERIALIZER .query ("pilot_stamps" , pilot_stamps , "[str]" )
627+ if pilot_stamps is not None :
628+ _params ["pilot_stamps" ] = _SERIALIZER .query ("pilot_stamps" , pilot_stamps , "[str]" )
629+ if age_in_days is not None :
630+ _params ["age_in_days" ] = _SERIALIZER .query ("age_in_days" , age_in_days , "int" )
631+ if delete_only_aborted is not None :
632+ _params ["delete_only_aborted" ] = _SERIALIZER .query ("delete_only_aborted" , delete_only_aborted , "bool" )
622633
623634 return HttpRequest (method = "DELETE" , url = _url , params = _params , ** kwargs )
624635
@@ -628,7 +639,7 @@ def build_pilots_update_pilot_fields_request(**kwargs: Any) -> HttpRequest:
628639
629640 content_type : Optional [str ] = kwargs .pop ("content_type" , _headers .pop ("Content-Type" , None ))
630641 # Construct URL
631- _url = "/api/pilots/management/pilot "
642+ _url = "/api/pilots/metadata "
632643
633644 # Construct headers
634645 if content_type is not None :
@@ -637,28 +648,29 @@ def build_pilots_update_pilot_fields_request(**kwargs: Any) -> HttpRequest:
637648 return HttpRequest (method = "PATCH" , url = _url , headers = _headers , ** kwargs )
638649
639650
640- def build_pilots_clear_pilots_request (
641- * , age_in_days : int , delete_only_aborted : bool = False , ** kwargs : Any
642- ) -> HttpRequest :
643- _params = case_insensitive_dict (kwargs .pop ("params" , {}) or {})
651+ def build_pilots_get_pilot_jobs_request (* , content : str , ** kwargs : Any ) -> HttpRequest :
652+ _headers = case_insensitive_dict (kwargs .pop ("headers" , {}) or {})
653+
654+ content_type : Optional [str ] = kwargs .pop ("content_type" , _headers .pop ("Content-Type" , None ))
655+ accept = _headers .pop ("Accept" , "application/json" )
644656
645657 # Construct URL
646- _url = "/api/pilots/management/pilot/interval "
658+ _url = "/api/pilots/jobs "
647659
648- # Construct parameters
649- _params [ "age_in_days" ] = _SERIALIZER . query ( "age_in_days" , age_in_days , "int" )
650- if delete_only_aborted is not None :
651- _params [ "delete_only_aborted " ] = _SERIALIZER .query ( "delete_only_aborted " , delete_only_aborted , "bool " )
660+ # Construct headers
661+ if content_type is not None :
662+ _headers [ "Content-Type" ] = _SERIALIZER . header ( "content_type" , content_type , "str" )
663+ _headers [ "Accept " ] = _SERIALIZER .header ( "accept " , accept , "str " )
652664
653- return HttpRequest (method = "DELETE " , url = _url , params = _params , ** kwargs )
665+ return HttpRequest (method = "GET " , url = _url , headers = _headers , content = content , ** kwargs )
654666
655667
656668def build_pilots_add_jobs_to_pilot_request (** kwargs : Any ) -> HttpRequest :
657669 _headers = case_insensitive_dict (kwargs .pop ("headers" , {}) or {})
658670
659671 content_type : Optional [str ] = kwargs .pop ("content_type" , _headers .pop ("Content-Type" , None ))
660672 # Construct URL
661- _url = "/api/pilots/management/ jobs"
673+ _url = "/api/pilots/jobs"
662674
663675 # Construct headers
664676 if content_type is not None :
@@ -2913,16 +2925,35 @@ def add_pilot_stamps(self, body: Union[_models.BodyPilotsAddPilotStamps, IO[byte
29132925
29142926 @distributed_trace
29152927 def delete_pilots ( # pylint: disable=inconsistent-return-statements
2916- self , * , pilot_stamps : List [str ], ** kwargs : Any
2928+ self ,
2929+ * ,
2930+ pilot_stamps : Optional [List [str ]] = None ,
2931+ age_in_days : Optional [int ] = None ,
2932+ delete_only_aborted : bool = False ,
2933+ ** kwargs : Any
29172934 ) -> None :
29182935 """Delete Pilots.
29192936
29202937 Endpoint to delete a pilot.
29212938
2922- If at least one pilot is not found, it WILL rollback.
2939+ Two features:
2940+
29232941
2924- :keyword pilot_stamps: Stamps of the pilots we want to delete. Required.
2942+ #. Or you provide pilot_stamps, so you can delete pilots by their stamp
2943+ #. Or you provide age_in_days, so you can delete pilots that lived more than age_in_days days.
2944+
2945+ If deleting by stamps, if at least one pilot is not found, it WILL rollback.
2946+
2947+ :keyword pilot_stamps: Stamps of the pilots we want to delete. Default value is None.
29252948 :paramtype pilot_stamps: list[str]
2949+ :keyword age_in_days: The number of days that define the maximum age of pilots to be
2950+ deleted.Pilots older than this age will be considered for deletion. Default value is None.
2951+ :paramtype age_in_days: int
2952+ :keyword delete_only_aborted: Flag indicating whether to only delete pilots whose status is
2953+ 'Aborted'.If set to True, only pilots with the 'Aborted' status will be deleted.It is set by
2954+ default as True to avoid any mistake.This flag is only used for deletion by time. Default value
2955+ is False.
2956+ :paramtype delete_only_aborted: bool
29262957 :return: None
29272958 :rtype: None
29282959 :raises ~azure.core.exceptions.HttpResponseError:
@@ -2942,6 +2973,8 @@ def delete_pilots( # pylint: disable=inconsistent-return-statements
29422973
29432974 _request = build_pilots_delete_pilots_request (
29442975 pilot_stamps = pilot_stamps ,
2976+ age_in_days = age_in_days ,
2977+ delete_only_aborted = delete_only_aborted ,
29452978 headers = _headers ,
29462979 params = _params ,
29472980 )
@@ -3061,22 +3094,15 @@ def update_pilot_fields( # pylint: disable=inconsistent-return-statements
30613094 return cls (pipeline_response , None , {}) # type: ignore
30623095
30633096 @distributed_trace
3064- def clear_pilots ( # pylint: disable=inconsistent-return-statements
3065- self , * , age_in_days : int , delete_only_aborted : bool = False , ** kwargs : Any
3066- ) -> None :
3067- """Clear Pilots.
3097+ def get_pilot_jobs (self , body : str , ** kwargs : Any ) -> List [int ]:
3098+ """Get Pilot Jobs.
30683099
3069- Endpoint for DIRAC to delete all pilots that lived more than age_in_days .
3100+ Endpoint only for DIRAC services, to get jobs of a pilot .
30703101
3071- :keyword age_in_days: The number of days that define the maximum age of pilots to be
3072- deleted.Pilots older than this age will be considered for deletion. Required.
3073- :paramtype age_in_days: int
3074- :keyword delete_only_aborted: Flag indicating whether to only delete pilots whose status is
3075- 'Aborted'.If set to True, only pilots with the 'Aborted' status will be deleted.It is set by
3076- default as True to avoid any mistake. Default value is False.
3077- :paramtype delete_only_aborted: bool
3078- :return: None
3079- :rtype: None
3102+ :param body: Required.
3103+ :type body: str
3104+ :return: list of int
3105+ :rtype: list[int]
30803106 :raises ~azure.core.exceptions.HttpResponseError:
30813107 """
30823108 error_map : MutableMapping = {
@@ -3087,14 +3113,17 @@ def clear_pilots( # pylint: disable=inconsistent-return-statements
30873113 }
30883114 error_map .update (kwargs .pop ("error_map" , {}) or {})
30893115
3090- _headers = kwargs .pop ("headers" , {}) or {}
3116+ _headers = case_insensitive_dict ( kwargs .pop ("headers" , {}) or {})
30913117 _params = kwargs .pop ("params" , {}) or {}
30923118
3093- cls : ClsType [None ] = kwargs .pop ("cls" , None )
3119+ content_type : str = kwargs .pop ("content_type" , _headers .pop ("Content-Type" , "application/json" ))
3120+ cls : ClsType [List [int ]] = kwargs .pop ("cls" , None )
30943121
3095- _request = build_pilots_clear_pilots_request (
3096- age_in_days = age_in_days ,
3097- delete_only_aborted = delete_only_aborted ,
3122+ _content = self ._serialize .body (body , "str" )
3123+
3124+ _request = build_pilots_get_pilot_jobs_request (
3125+ content_type = content_type ,
3126+ content = _content ,
30983127 headers = _headers ,
30993128 params = _params ,
31003129 )
@@ -3107,12 +3136,16 @@ def clear_pilots( # pylint: disable=inconsistent-return-statements
31073136
31083137 response = pipeline_response .http_response
31093138
3110- if response .status_code not in [204 ]:
3139+ if response .status_code not in [200 ]:
31113140 map_error (status_code = response .status_code , response = response , error_map = error_map )
31123141 raise HttpResponseError (response = response )
31133142
3143+ deserialized = self ._deserialize ("[int]" , pipeline_response .http_response )
3144+
31143145 if cls :
3115- return cls (pipeline_response , None , {}) # type: ignore
3146+ return cls (pipeline_response , deserialized , {}) # type: ignore
3147+
3148+ return deserialized # type: ignore
31163149
31173150 @overload
31183151 def add_jobs_to_pilot (
0 commit comments