@@ -601,7 +601,7 @@ def build_pilots_add_pilot_stamps_request(**kwargs: Any) -> HttpRequest:
601
601
accept = _headers .pop ("Accept" , "application/json" )
602
602
603
603
# Construct URL
604
- _url = "/api/pilots/management/pilot "
604
+ _url = "/api/pilots/"
605
605
606
606
# Construct headers
607
607
if content_type is not None :
@@ -611,14 +611,25 @@ def build_pilots_add_pilot_stamps_request(**kwargs: Any) -> HttpRequest:
611
611
return HttpRequest (method = "POST" , url = _url , headers = _headers , ** kwargs )
612
612
613
613
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 :
615
621
_params = case_insensitive_dict (kwargs .pop ("params" , {}) or {})
616
622
617
623
# Construct URL
618
- _url = "/api/pilots/management/pilot "
624
+ _url = "/api/pilots/"
619
625
620
626
# 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" )
622
633
623
634
return HttpRequest (method = "DELETE" , url = _url , params = _params , ** kwargs )
624
635
@@ -628,7 +639,7 @@ def build_pilots_update_pilot_fields_request(**kwargs: Any) -> HttpRequest:
628
639
629
640
content_type : Optional [str ] = kwargs .pop ("content_type" , _headers .pop ("Content-Type" , None ))
630
641
# Construct URL
631
- _url = "/api/pilots/management/pilot "
642
+ _url = "/api/pilots/metadata "
632
643
633
644
# Construct headers
634
645
if content_type is not None :
@@ -637,28 +648,29 @@ def build_pilots_update_pilot_fields_request(**kwargs: Any) -> HttpRequest:
637
648
return HttpRequest (method = "PATCH" , url = _url , headers = _headers , ** kwargs )
638
649
639
650
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" )
644
656
645
657
# Construct URL
646
- _url = "/api/pilots/management/pilot/interval "
658
+ _url = "/api/pilots/jobs "
647
659
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 " )
652
664
653
- return HttpRequest (method = "DELETE " , url = _url , params = _params , ** kwargs )
665
+ return HttpRequest (method = "GET " , url = _url , headers = _headers , content = content , ** kwargs )
654
666
655
667
656
668
def build_pilots_add_jobs_to_pilot_request (** kwargs : Any ) -> HttpRequest :
657
669
_headers = case_insensitive_dict (kwargs .pop ("headers" , {}) or {})
658
670
659
671
content_type : Optional [str ] = kwargs .pop ("content_type" , _headers .pop ("Content-Type" , None ))
660
672
# Construct URL
661
- _url = "/api/pilots/management/ jobs"
673
+ _url = "/api/pilots/jobs"
662
674
663
675
# Construct headers
664
676
if content_type is not None :
@@ -2913,16 +2925,35 @@ def add_pilot_stamps(self, body: Union[_models.BodyPilotsAddPilotStamps, IO[byte
2913
2925
2914
2926
@distributed_trace
2915
2927
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
2917
2934
) -> None :
2918
2935
"""Delete Pilots.
2919
2936
2920
2937
Endpoint to delete a pilot.
2921
2938
2922
- If at least one pilot is not found, it WILL rollback.
2939
+ Two features:
2940
+
2923
2941
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.
2925
2948
: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
2926
2957
:return: None
2927
2958
:rtype: None
2928
2959
:raises ~azure.core.exceptions.HttpResponseError:
@@ -2942,6 +2973,8 @@ def delete_pilots( # pylint: disable=inconsistent-return-statements
2942
2973
2943
2974
_request = build_pilots_delete_pilots_request (
2944
2975
pilot_stamps = pilot_stamps ,
2976
+ age_in_days = age_in_days ,
2977
+ delete_only_aborted = delete_only_aborted ,
2945
2978
headers = _headers ,
2946
2979
params = _params ,
2947
2980
)
@@ -3061,22 +3094,15 @@ def update_pilot_fields( # pylint: disable=inconsistent-return-statements
3061
3094
return cls (pipeline_response , None , {}) # type: ignore
3062
3095
3063
3096
@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.
3068
3099
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 .
3070
3101
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]
3080
3106
:raises ~azure.core.exceptions.HttpResponseError:
3081
3107
"""
3082
3108
error_map : MutableMapping = {
@@ -3087,14 +3113,17 @@ def clear_pilots( # pylint: disable=inconsistent-return-statements
3087
3113
}
3088
3114
error_map .update (kwargs .pop ("error_map" , {}) or {})
3089
3115
3090
- _headers = kwargs .pop ("headers" , {}) or {}
3116
+ _headers = case_insensitive_dict ( kwargs .pop ("headers" , {}) or {})
3091
3117
_params = kwargs .pop ("params" , {}) or {}
3092
3118
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 )
3094
3121
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 ,
3098
3127
headers = _headers ,
3099
3128
params = _params ,
3100
3129
)
@@ -3107,12 +3136,16 @@ def clear_pilots( # pylint: disable=inconsistent-return-statements
3107
3136
3108
3137
response = pipeline_response .http_response
3109
3138
3110
- if response .status_code not in [204 ]:
3139
+ if response .status_code not in [200 ]:
3111
3140
map_error (status_code = response .status_code , response = response , error_map = error_map )
3112
3141
raise HttpResponseError (response = response )
3113
3142
3143
+ deserialized = self ._deserialize ("[int]" , pipeline_response .http_response )
3144
+
3114
3145
if cls :
3115
- return cls (pipeline_response , None , {}) # type: ignore
3146
+ return cls (pipeline_response , deserialized , {}) # type: ignore
3147
+
3148
+ return deserialized # type: ignore
3116
3149
3117
3150
@overload
3118
3151
def add_jobs_to_pilot (
0 commit comments