Skip to content

Commit 5fe9f16

Browse files
IvanLHcopybara-github
authored andcommitted
chore: Created standalone converters for the Operations module.
PiperOrigin-RevId: 797965745
1 parent cc9e470 commit 5fe9f16

File tree

1 file changed

+308
-0
lines changed

1 file changed

+308
-0
lines changed
Lines changed: 308 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,308 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
# Code generated by the Google Gen AI SDK generator DO NOT EDIT.
17+
18+
from typing import Any, Optional, Union
19+
20+
from . import _transformers as t
21+
from ._common import get_value_by_path as getv
22+
from ._common import set_value_by_path as setv
23+
24+
25+
def _FetchPredictOperationParameters_to_mldev(
26+
from_object: Union[dict[str, Any], object],
27+
parent_object: Optional[dict[str, Any]] = None,
28+
) -> dict[str, Any]:
29+
to_object: dict[str, Any] = {}
30+
if getv(from_object, ['operation_name']) is not None:
31+
raise ValueError('operation_name parameter is not supported in Gemini API.')
32+
33+
if getv(from_object, ['resource_name']) is not None:
34+
raise ValueError('resource_name parameter is not supported in Gemini API.')
35+
36+
if getv(from_object, ['config']) is not None:
37+
raise ValueError('config parameter is not supported in Gemini API.')
38+
39+
return to_object
40+
41+
42+
def _GetOperationParameters_to_mldev(
43+
from_object: Union[dict[str, Any], object],
44+
parent_object: Optional[dict[str, Any]] = None,
45+
) -> dict[str, Any]:
46+
to_object: dict[str, Any] = {}
47+
if getv(from_object, ['operation_name']) is not None:
48+
setv(
49+
to_object,
50+
['_url', 'operationName'],
51+
getv(from_object, ['operation_name']),
52+
)
53+
54+
if getv(from_object, ['config']) is not None:
55+
setv(to_object, ['config'], getv(from_object, ['config']))
56+
57+
return to_object
58+
59+
60+
def _FetchPredictOperationParameters_to_vertex(
61+
from_object: Union[dict[str, Any], object],
62+
parent_object: Optional[dict[str, Any]] = None,
63+
) -> dict[str, Any]:
64+
to_object: dict[str, Any] = {}
65+
if getv(from_object, ['operation_name']) is not None:
66+
setv(to_object, ['operationName'], getv(from_object, ['operation_name']))
67+
68+
if getv(from_object, ['resource_name']) is not None:
69+
setv(
70+
to_object,
71+
['_url', 'resourceName'],
72+
getv(from_object, ['resource_name']),
73+
)
74+
75+
if getv(from_object, ['config']) is not None:
76+
setv(to_object, ['config'], getv(from_object, ['config']))
77+
78+
return to_object
79+
80+
81+
def _GetOperationParameters_to_vertex(
82+
from_object: Union[dict[str, Any], object],
83+
parent_object: Optional[dict[str, Any]] = None,
84+
) -> dict[str, Any]:
85+
to_object: dict[str, Any] = {}
86+
if getv(from_object, ['operation_name']) is not None:
87+
setv(
88+
to_object,
89+
['_url', 'operationName'],
90+
getv(from_object, ['operation_name']),
91+
)
92+
93+
if getv(from_object, ['config']) is not None:
94+
setv(to_object, ['config'], getv(from_object, ['config']))
95+
96+
return to_object
97+
98+
99+
def _Video_from_mldev(
100+
from_object: Union[dict[str, Any], object],
101+
parent_object: Optional[dict[str, Any]] = None,
102+
) -> dict[str, Any]:
103+
to_object: dict[str, Any] = {}
104+
if getv(from_object, ['video', 'uri']) is not None:
105+
setv(to_object, ['uri'], getv(from_object, ['video', 'uri']))
106+
107+
if getv(from_object, ['video', 'encodedVideo']) is not None:
108+
setv(
109+
to_object,
110+
['video_bytes'],
111+
t.t_bytes(getv(from_object, ['video', 'encodedVideo'])),
112+
)
113+
114+
if getv(from_object, ['encoding']) is not None:
115+
setv(to_object, ['mime_type'], getv(from_object, ['encoding']))
116+
117+
return to_object
118+
119+
120+
def _GeneratedVideo_from_mldev(
121+
from_object: Union[dict[str, Any], object],
122+
parent_object: Optional[dict[str, Any]] = None,
123+
) -> dict[str, Any]:
124+
to_object: dict[str, Any] = {}
125+
if getv(from_object, ['_self']) is not None:
126+
setv(
127+
to_object,
128+
['video'],
129+
_Video_from_mldev(getv(from_object, ['_self']), to_object),
130+
)
131+
132+
return to_object
133+
134+
135+
def _GenerateVideosResponse_from_mldev(
136+
from_object: Union[dict[str, Any], object],
137+
parent_object: Optional[dict[str, Any]] = None,
138+
) -> dict[str, Any]:
139+
to_object: dict[str, Any] = {}
140+
if getv(from_object, ['generatedSamples']) is not None:
141+
setv(
142+
to_object,
143+
['generated_videos'],
144+
[
145+
_GeneratedVideo_from_mldev(item, to_object)
146+
for item in getv(from_object, ['generatedSamples'])
147+
],
148+
)
149+
150+
if getv(from_object, ['raiMediaFilteredCount']) is not None:
151+
setv(
152+
to_object,
153+
['rai_media_filtered_count'],
154+
getv(from_object, ['raiMediaFilteredCount']),
155+
)
156+
157+
if getv(from_object, ['raiMediaFilteredReasons']) is not None:
158+
setv(
159+
to_object,
160+
['rai_media_filtered_reasons'],
161+
getv(from_object, ['raiMediaFilteredReasons']),
162+
)
163+
164+
return to_object
165+
166+
167+
def _GenerateVideosOperation_from_mldev(
168+
from_object: Union[dict[str, Any], object],
169+
parent_object: Optional[dict[str, Any]] = None,
170+
) -> dict[str, Any]:
171+
to_object: dict[str, Any] = {}
172+
if getv(from_object, ['name']) is not None:
173+
setv(to_object, ['name'], getv(from_object, ['name']))
174+
175+
if getv(from_object, ['metadata']) is not None:
176+
setv(to_object, ['metadata'], getv(from_object, ['metadata']))
177+
178+
if getv(from_object, ['done']) is not None:
179+
setv(to_object, ['done'], getv(from_object, ['done']))
180+
181+
if getv(from_object, ['error']) is not None:
182+
setv(to_object, ['error'], getv(from_object, ['error']))
183+
184+
if getv(from_object, ['response', 'generateVideoResponse']) is not None:
185+
setv(
186+
to_object,
187+
['response'],
188+
_GenerateVideosResponse_from_mldev(
189+
getv(from_object, ['response', 'generateVideoResponse']), to_object
190+
),
191+
)
192+
193+
if getv(from_object, ['response', 'generateVideoResponse']) is not None:
194+
setv(
195+
to_object,
196+
['result'],
197+
_GenerateVideosResponse_from_mldev(
198+
getv(from_object, ['response', 'generateVideoResponse']), to_object
199+
),
200+
)
201+
202+
return to_object
203+
204+
205+
def _Video_from_vertex(
206+
from_object: Union[dict[str, Any], object],
207+
parent_object: Optional[dict[str, Any]] = None,
208+
) -> dict[str, Any]:
209+
to_object: dict[str, Any] = {}
210+
if getv(from_object, ['gcsUri']) is not None:
211+
setv(to_object, ['uri'], getv(from_object, ['gcsUri']))
212+
213+
if getv(from_object, ['bytesBase64Encoded']) is not None:
214+
setv(
215+
to_object,
216+
['video_bytes'],
217+
t.t_bytes(getv(from_object, ['bytesBase64Encoded'])),
218+
)
219+
220+
if getv(from_object, ['mimeType']) is not None:
221+
setv(to_object, ['mime_type'], getv(from_object, ['mimeType']))
222+
223+
return to_object
224+
225+
226+
def _GeneratedVideo_from_vertex(
227+
from_object: Union[dict[str, Any], object],
228+
parent_object: Optional[dict[str, Any]] = None,
229+
) -> dict[str, Any]:
230+
to_object: dict[str, Any] = {}
231+
if getv(from_object, ['_self']) is not None:
232+
setv(
233+
to_object,
234+
['video'],
235+
_Video_from_vertex(getv(from_object, ['_self']), to_object),
236+
)
237+
238+
return to_object
239+
240+
241+
def _GenerateVideosResponse_from_vertex(
242+
from_object: Union[dict[str, Any], object],
243+
parent_object: Optional[dict[str, Any]] = None,
244+
) -> dict[str, Any]:
245+
to_object: dict[str, Any] = {}
246+
if getv(from_object, ['videos']) is not None:
247+
setv(
248+
to_object,
249+
['generated_videos'],
250+
[
251+
_GeneratedVideo_from_vertex(item, to_object)
252+
for item in getv(from_object, ['videos'])
253+
],
254+
)
255+
256+
if getv(from_object, ['raiMediaFilteredCount']) is not None:
257+
setv(
258+
to_object,
259+
['rai_media_filtered_count'],
260+
getv(from_object, ['raiMediaFilteredCount']),
261+
)
262+
263+
if getv(from_object, ['raiMediaFilteredReasons']) is not None:
264+
setv(
265+
to_object,
266+
['rai_media_filtered_reasons'],
267+
getv(from_object, ['raiMediaFilteredReasons']),
268+
)
269+
270+
return to_object
271+
272+
273+
def _GenerateVideosOperation_from_vertex(
274+
from_object: Union[dict[str, Any], object],
275+
parent_object: Optional[dict[str, Any]] = None,
276+
) -> dict[str, Any]:
277+
to_object: dict[str, Any] = {}
278+
if getv(from_object, ['name']) is not None:
279+
setv(to_object, ['name'], getv(from_object, ['name']))
280+
281+
if getv(from_object, ['metadata']) is not None:
282+
setv(to_object, ['metadata'], getv(from_object, ['metadata']))
283+
284+
if getv(from_object, ['done']) is not None:
285+
setv(to_object, ['done'], getv(from_object, ['done']))
286+
287+
if getv(from_object, ['error']) is not None:
288+
setv(to_object, ['error'], getv(from_object, ['error']))
289+
290+
if getv(from_object, ['response']) is not None:
291+
setv(
292+
to_object,
293+
['response'],
294+
_GenerateVideosResponse_from_vertex(
295+
getv(from_object, ['response']), to_object
296+
),
297+
)
298+
299+
if getv(from_object, ['response']) is not None:
300+
setv(
301+
to_object,
302+
['result'],
303+
_GenerateVideosResponse_from_vertex(
304+
getv(from_object, ['response']), to_object
305+
),
306+
)
307+
308+
return to_object

0 commit comments

Comments
 (0)