Skip to content

Commit c09e807

Browse files
feat: POC to have legacy pilots sending logs
1 parent c824bf5 commit c09e807

File tree

33 files changed

+2055
-76
lines changed

33 files changed

+2055
-76
lines changed

diracx-client/src/diracx/client/_generated/_client.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@
1515
from . import models as _models
1616
from ._configuration import DiracConfiguration
1717
from ._utils.serialization import Deserializer, Serializer
18-
from .operations import AuthOperations, ConfigOperations, JobsOperations, PilotsOperations, WellKnownOperations
18+
from .operations import (
19+
AuthOperations,
20+
ConfigOperations,
21+
JobsOperations,
22+
PilotsLegacyOperations,
23+
PilotsOperations,
24+
WellKnownOperations,
25+
)
1926

2027

2128
class Dirac: # pylint: disable=client-accepts-api-version-keyword
@@ -31,6 +38,8 @@ class Dirac: # pylint: disable=client-accepts-api-version-keyword
3138
:vartype jobs: _generated.operations.JobsOperations
3239
:ivar pilots: PilotsOperations operations
3340
:vartype pilots: _generated.operations.PilotsOperations
41+
:ivar pilots_legacy: PilotsLegacyOperations operations
42+
:vartype pilots_legacy: _generated.operations.PilotsLegacyOperations
3443
:keyword endpoint: Service URL. Required. Default value is "".
3544
:paramtype endpoint: str
3645
"""
@@ -68,6 +77,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
6877
self.config = ConfigOperations(self._client, self._config, self._serialize, self._deserialize)
6978
self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize)
7079
self.pilots = PilotsOperations(self._client, self._config, self._serialize, self._deserialize)
80+
self.pilots_legacy = PilotsLegacyOperations(self._client, self._config, self._serialize, self._deserialize)
7181

7282
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
7383
"""Runs the network request through the client's chained policies.

diracx-client/src/diracx/client/_generated/aio/_client.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@
1515
from .. import models as _models
1616
from .._utils.serialization import Deserializer, Serializer
1717
from ._configuration import DiracConfiguration
18-
from .operations import AuthOperations, ConfigOperations, JobsOperations, PilotsOperations, WellKnownOperations
18+
from .operations import (
19+
AuthOperations,
20+
ConfigOperations,
21+
JobsOperations,
22+
PilotsLegacyOperations,
23+
PilotsOperations,
24+
WellKnownOperations,
25+
)
1926

2027

2128
class Dirac: # pylint: disable=client-accepts-api-version-keyword
@@ -31,6 +38,8 @@ class Dirac: # pylint: disable=client-accepts-api-version-keyword
3138
:vartype jobs: _generated.aio.operations.JobsOperations
3239
:ivar pilots: PilotsOperations operations
3340
:vartype pilots: _generated.aio.operations.PilotsOperations
41+
:ivar pilots_legacy: PilotsLegacyOperations operations
42+
:vartype pilots_legacy: _generated.aio.operations.PilotsLegacyOperations
3443
:keyword endpoint: Service URL. Required. Default value is "".
3544
:paramtype endpoint: str
3645
"""
@@ -68,6 +77,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
6877
self.config = ConfigOperations(self._client, self._config, self._serialize, self._deserialize)
6978
self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize)
7079
self.pilots = PilotsOperations(self._client, self._config, self._serialize, self._deserialize)
80+
self.pilots_legacy = PilotsLegacyOperations(self._client, self._config, self._serialize, self._deserialize)
7181

7282
def send_request(
7383
self, request: HttpRequest, *, stream: bool = False, **kwargs: Any

diracx-client/src/diracx/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 PilotsOperations # type: ignore
18+
from ._operations import PilotsLegacyOperations # type: ignore
1819

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

diracx-client/src/diracx/client/_generated/aio/operations/_operations.py

Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
build_pilots_add_pilot_stamps_request,
5656
build_pilots_delete_pilots_request,
5757
build_pilots_get_pilot_jobs_request,
58+
build_pilots_legacy_send_message_request,
59+
build_pilots_search_logs_request,
5860
build_pilots_search_request,
5961
build_pilots_summary_request,
6062
build_pilots_update_pilot_fields_request,
@@ -2649,6 +2651,143 @@ async def search(
26492651

26502652
return deserialized # type: ignore
26512653

2654+
@overload
2655+
async def search_logs(
2656+
self,
2657+
body: Optional[_models.SearchParams] = None,
2658+
*,
2659+
page: int = 1,
2660+
per_page: int = 100,
2661+
content_type: str = "application/json",
2662+
**kwargs: Any
2663+
) -> List[Dict[str, Any]]:
2664+
"""Search Logs.
2665+
2666+
Search Logs.
2667+
2668+
:param body: Default value is None.
2669+
:type body: ~_generated.models.SearchParams
2670+
:keyword page: Default value is 1.
2671+
:paramtype page: int
2672+
:keyword per_page: Default value is 100.
2673+
:paramtype per_page: int
2674+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
2675+
Default value is "application/json".
2676+
:paramtype content_type: str
2677+
:return: list of dict mapping str to any
2678+
:rtype: list[dict[str, any]]
2679+
:raises ~azure.core.exceptions.HttpResponseError:
2680+
"""
2681+
2682+
@overload
2683+
async def search_logs(
2684+
self,
2685+
body: Optional[IO[bytes]] = None,
2686+
*,
2687+
page: int = 1,
2688+
per_page: int = 100,
2689+
content_type: str = "application/json",
2690+
**kwargs: Any
2691+
) -> List[Dict[str, Any]]:
2692+
"""Search Logs.
2693+
2694+
Search Logs.
2695+
2696+
:param body: Default value is None.
2697+
:type body: IO[bytes]
2698+
:keyword page: Default value is 1.
2699+
:paramtype page: int
2700+
:keyword per_page: Default value is 100.
2701+
:paramtype per_page: int
2702+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
2703+
Default value is "application/json".
2704+
:paramtype content_type: str
2705+
:return: list of dict mapping str to any
2706+
:rtype: list[dict[str, any]]
2707+
:raises ~azure.core.exceptions.HttpResponseError:
2708+
"""
2709+
2710+
@distributed_trace_async
2711+
async def search_logs(
2712+
self,
2713+
body: Optional[Union[_models.SearchParams, IO[bytes]]] = None,
2714+
*,
2715+
page: int = 1,
2716+
per_page: int = 100,
2717+
**kwargs: Any
2718+
) -> List[Dict[str, Any]]:
2719+
"""Search Logs.
2720+
2721+
Search Logs.
2722+
2723+
:param body: Is either a SearchParams type or a IO[bytes] type. Default value is None.
2724+
:type body: ~_generated.models.SearchParams or IO[bytes]
2725+
:keyword page: Default value is 1.
2726+
:paramtype page: int
2727+
:keyword per_page: Default value is 100.
2728+
:paramtype per_page: int
2729+
:return: list of dict mapping str to any
2730+
:rtype: list[dict[str, any]]
2731+
:raises ~azure.core.exceptions.HttpResponseError:
2732+
"""
2733+
error_map: MutableMapping = {
2734+
401: ClientAuthenticationError,
2735+
404: ResourceNotFoundError,
2736+
409: ResourceExistsError,
2737+
304: ResourceNotModifiedError,
2738+
}
2739+
error_map.update(kwargs.pop("error_map", {}) or {})
2740+
2741+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
2742+
_params = kwargs.pop("params", {}) or {}
2743+
2744+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
2745+
cls: ClsType[List[Dict[str, Any]]] = kwargs.pop("cls", None)
2746+
2747+
content_type = content_type or "application/json"
2748+
_json = None
2749+
_content = None
2750+
if isinstance(body, (IOBase, bytes)):
2751+
_content = body
2752+
else:
2753+
if body is not None:
2754+
_json = self._serialize.body(body, "SearchParams")
2755+
else:
2756+
_json = None
2757+
2758+
_request = build_pilots_search_logs_request(
2759+
page=page,
2760+
per_page=per_page,
2761+
content_type=content_type,
2762+
json=_json,
2763+
content=_content,
2764+
headers=_headers,
2765+
params=_params,
2766+
)
2767+
_request.url = self._client.format_url(_request.url)
2768+
2769+
_stream = False
2770+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
2771+
_request, stream=_stream, **kwargs
2772+
)
2773+
2774+
response = pipeline_response.http_response
2775+
2776+
if response.status_code not in [200, 206]:
2777+
map_error(status_code=response.status_code, response=response, error_map=error_map)
2778+
raise HttpResponseError(response=response)
2779+
2780+
response_headers = {}
2781+
if response.status_code == 206:
2782+
response_headers["Content-Range"] = self._deserialize("str", response.headers.get("Content-Range"))
2783+
2784+
deserialized = self._deserialize("[{object}]", pipeline_response.http_response)
2785+
2786+
if cls:
2787+
return cls(pipeline_response, deserialized, response_headers) # type: ignore
2788+
2789+
return deserialized # type: ignore
2790+
26522791
@overload
26532792
async def summary(
26542793
self, body: _models.SummaryParams, *, content_type: str = "application/json", **kwargs: Any
@@ -2743,3 +2882,114 @@ async def summary(self, body: Union[_models.SummaryParams, IO[bytes]], **kwargs:
27432882
return cls(pipeline_response, deserialized, {}) # type: ignore
27442883

27452884
return deserialized # type: ignore
2885+
2886+
2887+
class PilotsLegacyOperations:
2888+
"""
2889+
.. warning::
2890+
**DO NOT** instantiate this class directly.
2891+
2892+
Instead, you should access the following operations through
2893+
:class:`~_generated.aio.Dirac`'s
2894+
:attr:`pilots_legacy` attribute.
2895+
"""
2896+
2897+
models = _models
2898+
2899+
def __init__(self, *args, **kwargs) -> None:
2900+
input_args = list(args)
2901+
self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
2902+
self._config: DiracConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
2903+
self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
2904+
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
2905+
2906+
@overload
2907+
async def send_message(
2908+
self, body: _models.BodyPilotsLegacySendMessage, *, content_type: str = "application/json", **kwargs: Any
2909+
) -> None:
2910+
"""Send Message.
2911+
2912+
Send logs with legacy pilot.
2913+
2914+
:param body: Required.
2915+
:type body: ~_generated.models.BodyPilotsLegacySendMessage
2916+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
2917+
Default value is "application/json".
2918+
:paramtype content_type: str
2919+
:return: None
2920+
:rtype: None
2921+
:raises ~azure.core.exceptions.HttpResponseError:
2922+
"""
2923+
2924+
@overload
2925+
async def send_message(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> None:
2926+
"""Send Message.
2927+
2928+
Send logs with legacy pilot.
2929+
2930+
:param body: Required.
2931+
:type body: IO[bytes]
2932+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
2933+
Default value is "application/json".
2934+
:paramtype content_type: str
2935+
:return: None
2936+
:rtype: None
2937+
:raises ~azure.core.exceptions.HttpResponseError:
2938+
"""
2939+
2940+
@distributed_trace_async
2941+
async def send_message(self, body: Union[_models.BodyPilotsLegacySendMessage, IO[bytes]], **kwargs: Any) -> None:
2942+
"""Send Message.
2943+
2944+
Send logs with legacy pilot.
2945+
2946+
:param body: Is either a BodyPilotsLegacySendMessage type or a IO[bytes] type. Required.
2947+
:type body: ~_generated.models.BodyPilotsLegacySendMessage or IO[bytes]
2948+
:return: None
2949+
:rtype: None
2950+
:raises ~azure.core.exceptions.HttpResponseError:
2951+
"""
2952+
error_map: MutableMapping = {
2953+
401: ClientAuthenticationError,
2954+
404: ResourceNotFoundError,
2955+
409: ResourceExistsError,
2956+
304: ResourceNotModifiedError,
2957+
}
2958+
error_map.update(kwargs.pop("error_map", {}) or {})
2959+
2960+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
2961+
_params = kwargs.pop("params", {}) or {}
2962+
2963+
content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
2964+
cls: ClsType[None] = kwargs.pop("cls", None)
2965+
2966+
content_type = content_type or "application/json"
2967+
_json = None
2968+
_content = None
2969+
if isinstance(body, (IOBase, bytes)):
2970+
_content = body
2971+
else:
2972+
_json = self._serialize.body(body, "BodyPilotsLegacySendMessage")
2973+
2974+
_request = build_pilots_legacy_send_message_request(
2975+
content_type=content_type,
2976+
json=_json,
2977+
content=_content,
2978+
headers=_headers,
2979+
params=_params,
2980+
)
2981+
_request.url = self._client.format_url(_request.url)
2982+
2983+
_stream = False
2984+
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
2985+
_request, stream=_stream, **kwargs
2986+
)
2987+
2988+
response = pipeline_response.http_response
2989+
2990+
if response.status_code not in [204]:
2991+
map_error(status_code=response.status_code, response=response, error_map=error_map)
2992+
raise HttpResponseError(response=response)
2993+
2994+
if cls:
2995+
return cls(pipeline_response, None, {}) # type: ignore

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
BodyAuthGetOidcToken,
1616
BodyAuthGetOidcTokenGrantType,
1717
BodyPilotsAddPilotStamps,
18+
BodyPilotsLegacySendMessage,
1819
BodyPilotsUpdatePilotFields,
1920
GroupInfo,
2021
HTTPValidationError,
@@ -23,6 +24,7 @@
2324
InsertedJob,
2425
JobCommand,
2526
JobStatusUpdate,
27+
LogLine,
2628
Metadata,
2729
OpenIDConfiguration,
2830
PilotFieldsMapping,
@@ -66,6 +68,7 @@
6668
"BodyAuthGetOidcToken",
6769
"BodyAuthGetOidcTokenGrantType",
6870
"BodyPilotsAddPilotStamps",
71+
"BodyPilotsLegacySendMessage",
6972
"BodyPilotsUpdatePilotFields",
7073
"GroupInfo",
7174
"HTTPValidationError",
@@ -74,6 +77,7 @@
7477
"InsertedJob",
7578
"JobCommand",
7679
"JobStatusUpdate",
80+
"LogLine",
7781
"Metadata",
7882
"OpenIDConfiguration",
7983
"PilotFieldsMapping",

0 commit comments

Comments
 (0)