|
| 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 | +from . import _base_transformers as base_t |
| 20 | +from ._common import get_value_by_path as getv |
| 21 | +from ._common import set_value_by_path as setv |
| 22 | + |
| 23 | + |
| 24 | +def _FetchPredictOperationParameters_to_mldev( |
| 25 | + from_object: Union[dict[str, Any], object], |
| 26 | + parent_object: Optional[dict[str, Any]] = None, |
| 27 | +) -> dict[str, Any]: |
| 28 | + to_object: dict[str, Any] = {} |
| 29 | + if getv(from_object, ['operation_name']) is not None: |
| 30 | + raise ValueError('operation_name parameter is not supported in Gemini API.') |
| 31 | + |
| 32 | + if getv(from_object, ['resource_name']) is not None: |
| 33 | + raise ValueError('resource_name parameter is not supported in Gemini API.') |
| 34 | + |
| 35 | + if getv(from_object, ['config']) is not None: |
| 36 | + raise ValueError('config parameter is not supported in Gemini API.') |
| 37 | + |
| 38 | + return to_object |
| 39 | + |
| 40 | + |
| 41 | +def _GetOperationParameters_to_mldev( |
| 42 | + from_object: Union[dict[str, Any], object], |
| 43 | + parent_object: Optional[dict[str, Any]] = None, |
| 44 | +) -> dict[str, Any]: |
| 45 | + to_object: dict[str, Any] = {} |
| 46 | + if getv(from_object, ['operation_name']) is not None: |
| 47 | + setv( |
| 48 | + to_object, |
| 49 | + ['_url', 'operationName'], |
| 50 | + getv(from_object, ['operation_name']), |
| 51 | + ) |
| 52 | + |
| 53 | + if getv(from_object, ['config']) is not None: |
| 54 | + setv(to_object, ['config'], getv(from_object, ['config'])) |
| 55 | + |
| 56 | + return to_object |
| 57 | + |
| 58 | + |
| 59 | +def _FetchPredictOperationParameters_to_vertex( |
| 60 | + from_object: Union[dict[str, Any], object], |
| 61 | + parent_object: Optional[dict[str, Any]] = None, |
| 62 | +) -> dict[str, Any]: |
| 63 | + to_object: dict[str, Any] = {} |
| 64 | + if getv(from_object, ['operation_name']) is not None: |
| 65 | + setv(to_object, ['operationName'], getv(from_object, ['operation_name'])) |
| 66 | + |
| 67 | + if getv(from_object, ['resource_name']) is not None: |
| 68 | + setv( |
| 69 | + to_object, |
| 70 | + ['_url', 'resourceName'], |
| 71 | + getv(from_object, ['resource_name']), |
| 72 | + ) |
| 73 | + |
| 74 | + if getv(from_object, ['config']) is not None: |
| 75 | + setv(to_object, ['config'], getv(from_object, ['config'])) |
| 76 | + |
| 77 | + return to_object |
| 78 | + |
| 79 | + |
| 80 | +def _GetOperationParameters_to_vertex( |
| 81 | + from_object: Union[dict[str, Any], object], |
| 82 | + parent_object: Optional[dict[str, Any]] = None, |
| 83 | +) -> dict[str, Any]: |
| 84 | + to_object: dict[str, Any] = {} |
| 85 | + if getv(from_object, ['operation_name']) is not None: |
| 86 | + setv( |
| 87 | + to_object, |
| 88 | + ['_url', 'operationName'], |
| 89 | + getv(from_object, ['operation_name']), |
| 90 | + ) |
| 91 | + |
| 92 | + if getv(from_object, ['config']) is not None: |
| 93 | + setv(to_object, ['config'], getv(from_object, ['config'])) |
| 94 | + |
| 95 | + return to_object |
| 96 | + |
| 97 | + |
| 98 | +def _Video_from_mldev( |
| 99 | + from_object: Union[dict[str, Any], object], |
| 100 | + parent_object: Optional[dict[str, Any]] = None, |
| 101 | +) -> dict[str, Any]: |
| 102 | + to_object: dict[str, Any] = {} |
| 103 | + if getv(from_object, ['video', 'uri']) is not None: |
| 104 | + setv(to_object, ['uri'], getv(from_object, ['video', 'uri'])) |
| 105 | + |
| 106 | + if getv(from_object, ['video', 'encodedVideo']) is not None: |
| 107 | + setv( |
| 108 | + to_object, |
| 109 | + ['video_bytes'], |
| 110 | + base_t.t_bytes(getv(from_object, ['video', 'encodedVideo'])), |
| 111 | + ) |
| 112 | + |
| 113 | + if getv(from_object, ['encoding']) is not None: |
| 114 | + setv(to_object, ['mime_type'], getv(from_object, ['encoding'])) |
| 115 | + |
| 116 | + return to_object |
| 117 | + |
| 118 | + |
| 119 | +def _GeneratedVideo_from_mldev( |
| 120 | + from_object: Union[dict[str, Any], object], |
| 121 | + parent_object: Optional[dict[str, Any]] = None, |
| 122 | +) -> dict[str, Any]: |
| 123 | + to_object: dict[str, Any] = {} |
| 124 | + if getv(from_object, ['_self']) is not None: |
| 125 | + setv( |
| 126 | + to_object, |
| 127 | + ['video'], |
| 128 | + _Video_from_mldev(getv(from_object, ['_self']), to_object), |
| 129 | + ) |
| 130 | + |
| 131 | + return to_object |
| 132 | + |
| 133 | + |
| 134 | +def _GenerateVideosResponse_from_mldev( |
| 135 | + from_object: Union[dict[str, Any], object], |
| 136 | + parent_object: Optional[dict[str, Any]] = None, |
| 137 | +) -> dict[str, Any]: |
| 138 | + to_object: dict[str, Any] = {} |
| 139 | + if getv(from_object, ['generatedSamples']) is not None: |
| 140 | + setv( |
| 141 | + to_object, |
| 142 | + ['generated_videos'], |
| 143 | + [ |
| 144 | + _GeneratedVideo_from_mldev(item, to_object) |
| 145 | + for item in getv(from_object, ['generatedSamples']) |
| 146 | + ], |
| 147 | + ) |
| 148 | + |
| 149 | + if getv(from_object, ['raiMediaFilteredCount']) is not None: |
| 150 | + setv( |
| 151 | + to_object, |
| 152 | + ['rai_media_filtered_count'], |
| 153 | + getv(from_object, ['raiMediaFilteredCount']), |
| 154 | + ) |
| 155 | + |
| 156 | + if getv(from_object, ['raiMediaFilteredReasons']) is not None: |
| 157 | + setv( |
| 158 | + to_object, |
| 159 | + ['rai_media_filtered_reasons'], |
| 160 | + getv(from_object, ['raiMediaFilteredReasons']), |
| 161 | + ) |
| 162 | + |
| 163 | + return to_object |
| 164 | + |
| 165 | + |
| 166 | +def _GenerateVideosOperation_from_mldev( |
| 167 | + from_object: Union[dict[str, Any], object], |
| 168 | + parent_object: Optional[dict[str, Any]] = None, |
| 169 | +) -> dict[str, Any]: |
| 170 | + to_object: dict[str, Any] = {} |
| 171 | + if getv(from_object, ['name']) is not None: |
| 172 | + setv(to_object, ['name'], getv(from_object, ['name'])) |
| 173 | + |
| 174 | + if getv(from_object, ['metadata']) is not None: |
| 175 | + setv(to_object, ['metadata'], getv(from_object, ['metadata'])) |
| 176 | + |
| 177 | + if getv(from_object, ['done']) is not None: |
| 178 | + setv(to_object, ['done'], getv(from_object, ['done'])) |
| 179 | + |
| 180 | + if getv(from_object, ['error']) is not None: |
| 181 | + setv(to_object, ['error'], getv(from_object, ['error'])) |
| 182 | + |
| 183 | + if getv(from_object, ['response', 'generateVideoResponse']) is not None: |
| 184 | + setv( |
| 185 | + to_object, |
| 186 | + ['response'], |
| 187 | + _GenerateVideosResponse_from_mldev( |
| 188 | + getv(from_object, ['response', 'generateVideoResponse']), to_object |
| 189 | + ), |
| 190 | + ) |
| 191 | + |
| 192 | + if getv(from_object, ['response', 'generateVideoResponse']) is not None: |
| 193 | + setv( |
| 194 | + to_object, |
| 195 | + ['result'], |
| 196 | + _GenerateVideosResponse_from_mldev( |
| 197 | + getv(from_object, ['response', 'generateVideoResponse']), to_object |
| 198 | + ), |
| 199 | + ) |
| 200 | + |
| 201 | + return to_object |
| 202 | + |
| 203 | + |
| 204 | +def _Video_from_vertex( |
| 205 | + from_object: Union[dict[str, Any], object], |
| 206 | + parent_object: Optional[dict[str, Any]] = None, |
| 207 | +) -> dict[str, Any]: |
| 208 | + to_object: dict[str, Any] = {} |
| 209 | + if getv(from_object, ['gcsUri']) is not None: |
| 210 | + setv(to_object, ['uri'], getv(from_object, ['gcsUri'])) |
| 211 | + |
| 212 | + if getv(from_object, ['bytesBase64Encoded']) is not None: |
| 213 | + setv( |
| 214 | + to_object, |
| 215 | + ['video_bytes'], |
| 216 | + base_t.t_bytes(getv(from_object, ['bytesBase64Encoded'])), |
| 217 | + ) |
| 218 | + |
| 219 | + if getv(from_object, ['mimeType']) is not None: |
| 220 | + setv(to_object, ['mime_type'], getv(from_object, ['mimeType'])) |
| 221 | + |
| 222 | + return to_object |
| 223 | + |
| 224 | + |
| 225 | +def _GeneratedVideo_from_vertex( |
| 226 | + from_object: Union[dict[str, Any], object], |
| 227 | + parent_object: Optional[dict[str, Any]] = None, |
| 228 | +) -> dict[str, Any]: |
| 229 | + to_object: dict[str, Any] = {} |
| 230 | + if getv(from_object, ['_self']) is not None: |
| 231 | + setv( |
| 232 | + to_object, |
| 233 | + ['video'], |
| 234 | + _Video_from_vertex(getv(from_object, ['_self']), to_object), |
| 235 | + ) |
| 236 | + |
| 237 | + return to_object |
| 238 | + |
| 239 | + |
| 240 | +def _GenerateVideosResponse_from_vertex( |
| 241 | + from_object: Union[dict[str, Any], object], |
| 242 | + parent_object: Optional[dict[str, Any]] = None, |
| 243 | +) -> dict[str, Any]: |
| 244 | + to_object: dict[str, Any] = {} |
| 245 | + if getv(from_object, ['videos']) is not None: |
| 246 | + setv( |
| 247 | + to_object, |
| 248 | + ['generated_videos'], |
| 249 | + [ |
| 250 | + _GeneratedVideo_from_vertex(item, to_object) |
| 251 | + for item in getv(from_object, ['videos']) |
| 252 | + ], |
| 253 | + ) |
| 254 | + |
| 255 | + if getv(from_object, ['raiMediaFilteredCount']) is not None: |
| 256 | + setv( |
| 257 | + to_object, |
| 258 | + ['rai_media_filtered_count'], |
| 259 | + getv(from_object, ['raiMediaFilteredCount']), |
| 260 | + ) |
| 261 | + |
| 262 | + if getv(from_object, ['raiMediaFilteredReasons']) is not None: |
| 263 | + setv( |
| 264 | + to_object, |
| 265 | + ['rai_media_filtered_reasons'], |
| 266 | + getv(from_object, ['raiMediaFilteredReasons']), |
| 267 | + ) |
| 268 | + |
| 269 | + return to_object |
| 270 | + |
| 271 | + |
| 272 | +def _GenerateVideosOperation_from_vertex( |
| 273 | + from_object: Union[dict[str, Any], object], |
| 274 | + parent_object: Optional[dict[str, Any]] = None, |
| 275 | +) -> dict[str, Any]: |
| 276 | + to_object: dict[str, Any] = {} |
| 277 | + if getv(from_object, ['name']) is not None: |
| 278 | + setv(to_object, ['name'], getv(from_object, ['name'])) |
| 279 | + |
| 280 | + if getv(from_object, ['metadata']) is not None: |
| 281 | + setv(to_object, ['metadata'], getv(from_object, ['metadata'])) |
| 282 | + |
| 283 | + if getv(from_object, ['done']) is not None: |
| 284 | + setv(to_object, ['done'], getv(from_object, ['done'])) |
| 285 | + |
| 286 | + if getv(from_object, ['error']) is not None: |
| 287 | + setv(to_object, ['error'], getv(from_object, ['error'])) |
| 288 | + |
| 289 | + if getv(from_object, ['response']) is not None: |
| 290 | + setv( |
| 291 | + to_object, |
| 292 | + ['response'], |
| 293 | + _GenerateVideosResponse_from_vertex( |
| 294 | + getv(from_object, ['response']), to_object |
| 295 | + ), |
| 296 | + ) |
| 297 | + |
| 298 | + if getv(from_object, ['response']) is not None: |
| 299 | + setv( |
| 300 | + to_object, |
| 301 | + ['result'], |
| 302 | + _GenerateVideosResponse_from_vertex( |
| 303 | + getv(from_object, ['response']), to_object |
| 304 | + ), |
| 305 | + ) |
| 306 | + |
| 307 | + return to_object |
0 commit comments