1use mz_audit_log::{
17 AlterDefaultPrivilegeV1, AlterRetainHistoryV1, AlterSetClusterV1, AlterSourceSinkV1,
18 CreateClusterReplicaV1, CreateClusterReplicaV2, CreateClusterReplicaV3, CreateClusterReplicaV4,
19 CreateIndexV1, CreateMaterializedViewV1, CreateOrDropClusterReplicaReasonV1,
20 CreateSourceSinkV1, CreateSourceSinkV2, CreateSourceSinkV3, CreateSourceSinkV4,
21 DropClusterReplicaV1, DropClusterReplicaV2, DropClusterReplicaV3, EventDetails, EventType,
22 EventV1, FromPreviousIdV1, FullNameV1, GrantRoleV1, GrantRoleV2, IdFullNameV1, IdNameV1,
23 RefreshDecisionWithReasonV1, RefreshDecisionWithReasonV2, RenameClusterReplicaV1,
24 RenameClusterV1, RenameItemV1, RenameSchemaV1, RevokeRoleV1, RevokeRoleV2, RotateKeysV1,
25 SchedulingDecisionV1, SchedulingDecisionsWithReasonsV1, SchedulingDecisionsWithReasonsV2,
26 SchemaV1, SchemaV2, SetV1, ToNewIdV1, UpdateItemV1, UpdateOwnerV1, UpdatePrivilegeV1,
27 VersionedEvent,
28};
29use mz_proto::{IntoRustIfSome, ProtoType, RustType, TryFromProtoError};
30
31use crate::objects::Empty;
32
33impl RustType<crate::objects::audit_log_key::Event> for VersionedEvent {
34 fn into_proto(&self) -> crate::objects::audit_log_key::Event {
35 match self {
36 VersionedEvent::V1(event) => {
37 crate::objects::audit_log_key::Event::V1(event.into_proto())
38 }
39 }
40 }
41
42 fn from_proto(proto: crate::objects::audit_log_key::Event) -> Result<Self, TryFromProtoError> {
43 match proto {
44 crate::objects::audit_log_key::Event::V1(event) => {
45 Ok(VersionedEvent::V1(event.into_rust()?))
46 }
47 }
48 }
49}
50
51impl RustType<crate::objects::audit_log_event_v1::EventType> for EventType {
52 fn into_proto(&self) -> crate::objects::audit_log_event_v1::EventType {
53 match self {
54 EventType::Create => crate::objects::audit_log_event_v1::EventType::Create,
55 EventType::Drop => crate::objects::audit_log_event_v1::EventType::Drop,
56 EventType::Alter => crate::objects::audit_log_event_v1::EventType::Alter,
57 EventType::Grant => crate::objects::audit_log_event_v1::EventType::Grant,
58 EventType::Revoke => crate::objects::audit_log_event_v1::EventType::Revoke,
59 EventType::Comment => crate::objects::audit_log_event_v1::EventType::Comment,
60 }
61 }
62
63 fn from_proto(
64 proto: crate::objects::audit_log_event_v1::EventType,
65 ) -> Result<Self, TryFromProtoError> {
66 match proto {
67 crate::objects::audit_log_event_v1::EventType::Create => Ok(EventType::Create),
68 crate::objects::audit_log_event_v1::EventType::Drop => Ok(EventType::Drop),
69 crate::objects::audit_log_event_v1::EventType::Alter => Ok(EventType::Alter),
70 crate::objects::audit_log_event_v1::EventType::Grant => Ok(EventType::Grant),
71 crate::objects::audit_log_event_v1::EventType::Revoke => Ok(EventType::Revoke),
72 crate::objects::audit_log_event_v1::EventType::Comment => Ok(EventType::Comment),
73 crate::objects::audit_log_event_v1::EventType::Unknown => Err(
74 TryFromProtoError::unknown_enum_variant("EventType::Unknown"),
75 ),
76 }
77 }
78}
79
80impl RustType<crate::objects::audit_log_event_v1::ObjectType> for mz_audit_log::ObjectType {
81 fn into_proto(&self) -> crate::objects::audit_log_event_v1::ObjectType {
82 match self {
83 mz_audit_log::ObjectType::Cluster => {
84 crate::objects::audit_log_event_v1::ObjectType::Cluster
85 }
86 mz_audit_log::ObjectType::ClusterReplica => {
87 crate::objects::audit_log_event_v1::ObjectType::ClusterReplica
88 }
89 mz_audit_log::ObjectType::Connection => {
90 crate::objects::audit_log_event_v1::ObjectType::Connection
91 }
92 mz_audit_log::ObjectType::ContinualTask => {
93 crate::objects::audit_log_event_v1::ObjectType::ContinualTask
94 }
95 mz_audit_log::ObjectType::Database => {
96 crate::objects::audit_log_event_v1::ObjectType::Database
97 }
98 mz_audit_log::ObjectType::Func => crate::objects::audit_log_event_v1::ObjectType::Func,
99 mz_audit_log::ObjectType::Index => {
100 crate::objects::audit_log_event_v1::ObjectType::Index
101 }
102 mz_audit_log::ObjectType::MaterializedView => {
103 crate::objects::audit_log_event_v1::ObjectType::MaterializedView
104 }
105 mz_audit_log::ObjectType::NetworkPolicy => {
106 crate::objects::audit_log_event_v1::ObjectType::NetworkPolicy
107 }
108 mz_audit_log::ObjectType::Role => crate::objects::audit_log_event_v1::ObjectType::Role,
109 mz_audit_log::ObjectType::Secret => {
110 crate::objects::audit_log_event_v1::ObjectType::Secret
111 }
112 mz_audit_log::ObjectType::Schema => {
113 crate::objects::audit_log_event_v1::ObjectType::Schema
114 }
115 mz_audit_log::ObjectType::Sink => crate::objects::audit_log_event_v1::ObjectType::Sink,
116 mz_audit_log::ObjectType::Source => {
117 crate::objects::audit_log_event_v1::ObjectType::Source
118 }
119 mz_audit_log::ObjectType::System => {
120 crate::objects::audit_log_event_v1::ObjectType::System
121 }
122 mz_audit_log::ObjectType::Table => {
123 crate::objects::audit_log_event_v1::ObjectType::Table
124 }
125 mz_audit_log::ObjectType::Type => crate::objects::audit_log_event_v1::ObjectType::Type,
126 mz_audit_log::ObjectType::View => crate::objects::audit_log_event_v1::ObjectType::View,
127 }
128 }
129
130 fn from_proto(
131 proto: crate::objects::audit_log_event_v1::ObjectType,
132 ) -> Result<Self, TryFromProtoError> {
133 match proto {
134 crate::objects::audit_log_event_v1::ObjectType::Cluster => {
135 Ok(mz_audit_log::ObjectType::Cluster)
136 }
137 crate::objects::audit_log_event_v1::ObjectType::ClusterReplica => {
138 Ok(mz_audit_log::ObjectType::ClusterReplica)
139 }
140 crate::objects::audit_log_event_v1::ObjectType::Connection => {
141 Ok(mz_audit_log::ObjectType::Connection)
142 }
143 crate::objects::audit_log_event_v1::ObjectType::ContinualTask => {
144 Ok(mz_audit_log::ObjectType::ContinualTask)
145 }
146 crate::objects::audit_log_event_v1::ObjectType::Database => {
147 Ok(mz_audit_log::ObjectType::Database)
148 }
149 crate::objects::audit_log_event_v1::ObjectType::Func => {
150 Ok(mz_audit_log::ObjectType::Func)
151 }
152 crate::objects::audit_log_event_v1::ObjectType::Index => {
153 Ok(mz_audit_log::ObjectType::Index)
154 }
155 crate::objects::audit_log_event_v1::ObjectType::MaterializedView => {
156 Ok(mz_audit_log::ObjectType::MaterializedView)
157 }
158 crate::objects::audit_log_event_v1::ObjectType::NetworkPolicy => {
159 Ok(mz_audit_log::ObjectType::NetworkPolicy)
160 }
161 crate::objects::audit_log_event_v1::ObjectType::Role => {
162 Ok(mz_audit_log::ObjectType::Role)
163 }
164 crate::objects::audit_log_event_v1::ObjectType::Secret => {
165 Ok(mz_audit_log::ObjectType::Secret)
166 }
167 crate::objects::audit_log_event_v1::ObjectType::Schema => {
168 Ok(mz_audit_log::ObjectType::Schema)
169 }
170 crate::objects::audit_log_event_v1::ObjectType::Sink => {
171 Ok(mz_audit_log::ObjectType::Sink)
172 }
173 crate::objects::audit_log_event_v1::ObjectType::Source => {
174 Ok(mz_audit_log::ObjectType::Source)
175 }
176 crate::objects::audit_log_event_v1::ObjectType::System => {
177 Ok(mz_audit_log::ObjectType::System)
178 }
179 crate::objects::audit_log_event_v1::ObjectType::Table => {
180 Ok(mz_audit_log::ObjectType::Table)
181 }
182 crate::objects::audit_log_event_v1::ObjectType::Type => {
183 Ok(mz_audit_log::ObjectType::Type)
184 }
185 crate::objects::audit_log_event_v1::ObjectType::View => {
186 Ok(mz_audit_log::ObjectType::View)
187 }
188 crate::objects::audit_log_event_v1::ObjectType::Unknown => Err(
189 TryFromProtoError::unknown_enum_variant("ObjectType::Unknown"),
190 ),
191 }
192 }
193}
194
195impl RustType<crate::objects::audit_log_event_v1::IdFullNameV1> for IdFullNameV1 {
196 fn into_proto(&self) -> crate::objects::audit_log_event_v1::IdFullNameV1 {
197 crate::objects::audit_log_event_v1::IdFullNameV1 {
198 id: self.id.to_string(),
199 name: Some(self.name.into_proto()),
200 }
201 }
202
203 fn from_proto(
204 proto: crate::objects::audit_log_event_v1::IdFullNameV1,
205 ) -> Result<Self, TryFromProtoError> {
206 Ok(IdFullNameV1 {
207 id: proto.id,
208 name: proto.name.into_rust_if_some("IdFullNameV1::name")?,
209 })
210 }
211}
212
213impl RustType<crate::objects::audit_log_event_v1::FullNameV1> for FullNameV1 {
214 fn into_proto(&self) -> crate::objects::audit_log_event_v1::FullNameV1 {
215 crate::objects::audit_log_event_v1::FullNameV1 {
216 database: self.database.to_string(),
217 schema: self.schema.to_string(),
218 item: self.item.to_string(),
219 }
220 }
221
222 fn from_proto(
223 proto: crate::objects::audit_log_event_v1::FullNameV1,
224 ) -> Result<Self, TryFromProtoError> {
225 Ok(FullNameV1 {
226 database: proto.database,
227 schema: proto.schema,
228 item: proto.item,
229 })
230 }
231}
232
233impl RustType<crate::objects::audit_log_event_v1::IdNameV1> for IdNameV1 {
234 fn into_proto(&self) -> crate::objects::audit_log_event_v1::IdNameV1 {
235 crate::objects::audit_log_event_v1::IdNameV1 {
236 id: self.id.to_string(),
237 name: self.name.to_string(),
238 }
239 }
240
241 fn from_proto(
242 proto: crate::objects::audit_log_event_v1::IdNameV1,
243 ) -> Result<Self, TryFromProtoError> {
244 Ok(IdNameV1 {
245 id: proto.id,
246 name: proto.name,
247 })
248 }
249}
250
251impl RustType<crate::objects::audit_log_event_v1::RenameItemV1> for RenameItemV1 {
252 fn into_proto(&self) -> crate::objects::audit_log_event_v1::RenameItemV1 {
253 crate::objects::audit_log_event_v1::RenameItemV1 {
254 id: self.id.to_string(),
255 old_name: Some(self.old_name.into_proto()),
256 new_name: Some(self.new_name.into_proto()),
257 }
258 }
259
260 fn from_proto(
261 proto: crate::objects::audit_log_event_v1::RenameItemV1,
262 ) -> Result<Self, TryFromProtoError> {
263 Ok(RenameItemV1 {
264 id: proto.id,
265 old_name: proto.old_name.into_rust_if_some("RenameItemV1::old_name")?,
266 new_name: proto.new_name.into_rust_if_some("RenameItemV1::new_name")?,
267 })
268 }
269}
270
271impl RustType<crate::objects::audit_log_event_v1::RenameClusterV1> for RenameClusterV1 {
272 fn into_proto(&self) -> crate::objects::audit_log_event_v1::RenameClusterV1 {
273 crate::objects::audit_log_event_v1::RenameClusterV1 {
274 id: self.id.to_string(),
275 old_name: self.old_name.into_proto(),
276 new_name: self.new_name.into_proto(),
277 }
278 }
279
280 fn from_proto(
281 proto: crate::objects::audit_log_event_v1::RenameClusterV1,
282 ) -> Result<Self, TryFromProtoError> {
283 Ok(RenameClusterV1 {
284 id: proto.id,
285 old_name: proto.old_name,
286 new_name: proto.new_name,
287 })
288 }
289}
290
291impl RustType<crate::objects::audit_log_event_v1::RenameClusterReplicaV1>
292 for RenameClusterReplicaV1
293{
294 fn into_proto(&self) -> crate::objects::audit_log_event_v1::RenameClusterReplicaV1 {
295 crate::objects::audit_log_event_v1::RenameClusterReplicaV1 {
296 cluster_id: self.cluster_id.to_string(),
297 replica_id: self.replica_id.to_string(),
298 old_name: self.old_name.into_proto(),
299 new_name: self.new_name.into_proto(),
300 }
301 }
302
303 fn from_proto(
304 proto: crate::objects::audit_log_event_v1::RenameClusterReplicaV1,
305 ) -> Result<Self, TryFromProtoError> {
306 Ok(RenameClusterReplicaV1 {
307 cluster_id: proto.cluster_id,
308 replica_id: proto.replica_id,
309 old_name: proto.old_name,
310 new_name: proto.new_name,
311 })
312 }
313}
314
315impl RustType<crate::objects::audit_log_event_v1::DropClusterReplicaV1> for DropClusterReplicaV1 {
316 fn into_proto(&self) -> crate::objects::audit_log_event_v1::DropClusterReplicaV1 {
317 crate::objects::audit_log_event_v1::DropClusterReplicaV1 {
318 cluster_id: self.cluster_id.to_string(),
319 cluster_name: self.cluster_name.to_string(),
320 replica_id: self
321 .replica_id
322 .as_ref()
323 .map(|id| crate::objects::StringWrapper {
324 inner: id.to_string(),
325 }),
326 replica_name: self.replica_name.to_string(),
327 }
328 }
329
330 fn from_proto(
331 proto: crate::objects::audit_log_event_v1::DropClusterReplicaV1,
332 ) -> Result<Self, TryFromProtoError> {
333 Ok(DropClusterReplicaV1 {
334 cluster_id: proto.cluster_id,
335 cluster_name: proto.cluster_name,
336 replica_id: proto.replica_id.map(|s| s.inner),
337 replica_name: proto.replica_name,
338 })
339 }
340}
341
342impl RustType<crate::objects::audit_log_event_v1::DropClusterReplicaV2> for DropClusterReplicaV2 {
343 fn into_proto(&self) -> crate::objects::audit_log_event_v1::DropClusterReplicaV2 {
344 crate::objects::audit_log_event_v1::DropClusterReplicaV2 {
345 cluster_id: self.cluster_id.to_string(),
346 cluster_name: self.cluster_name.to_string(),
347 replica_id: self
348 .replica_id
349 .as_ref()
350 .map(|id| crate::objects::StringWrapper {
351 inner: id.to_string(),
352 }),
353 replica_name: self.replica_name.to_string(),
354 reason: Some(self.reason.into_proto()),
355 scheduling_policies: self.scheduling_policies.into_proto(),
356 }
357 }
358
359 fn from_proto(
360 proto: crate::objects::audit_log_event_v1::DropClusterReplicaV2,
361 ) -> Result<Self, TryFromProtoError> {
362 Ok(DropClusterReplicaV2 {
363 cluster_id: proto.cluster_id,
364 cluster_name: proto.cluster_name,
365 replica_id: proto.replica_id.map(|s| s.inner),
366 replica_name: proto.replica_name,
367 reason: proto
368 .reason
369 .into_rust_if_some("DropClusterReplicaV2::reason")?,
370 scheduling_policies: proto.scheduling_policies.into_rust()?,
371 })
372 }
373}
374
375impl RustType<crate::objects::audit_log_event_v1::DropClusterReplicaV3> for DropClusterReplicaV3 {
376 fn into_proto(&self) -> crate::objects::audit_log_event_v1::DropClusterReplicaV3 {
377 crate::objects::audit_log_event_v1::DropClusterReplicaV3 {
378 cluster_id: self.cluster_id.to_string(),
379 cluster_name: self.cluster_name.to_string(),
380 replica_id: self
381 .replica_id
382 .as_ref()
383 .map(|id| crate::objects::StringWrapper {
384 inner: id.to_string(),
385 }),
386 replica_name: self.replica_name.to_string(),
387 reason: Some(self.reason.into_proto()),
388 scheduling_policies: self.scheduling_policies.into_proto(),
389 }
390 }
391
392 fn from_proto(
393 proto: crate::objects::audit_log_event_v1::DropClusterReplicaV3,
394 ) -> Result<Self, TryFromProtoError> {
395 Ok(DropClusterReplicaV3 {
396 cluster_id: proto.cluster_id,
397 cluster_name: proto.cluster_name,
398 replica_id: proto.replica_id.map(|s| s.inner),
399 replica_name: proto.replica_name,
400 reason: proto
401 .reason
402 .into_rust_if_some("DropClusterReplicaV3::reason")?,
403 scheduling_policies: proto.scheduling_policies.into_rust()?,
404 })
405 }
406}
407
408impl RustType<crate::objects::audit_log_event_v1::CreateClusterReplicaV1>
409 for CreateClusterReplicaV1
410{
411 fn into_proto(&self) -> crate::objects::audit_log_event_v1::CreateClusterReplicaV1 {
412 crate::objects::audit_log_event_v1::CreateClusterReplicaV1 {
413 cluster_id: self.cluster_id.to_string(),
414 cluster_name: self.cluster_name.to_string(),
415 replica_id: self
416 .replica_id
417 .as_ref()
418 .map(|id| crate::objects::StringWrapper {
419 inner: id.to_string(),
420 }),
421 replica_name: self.replica_name.to_string(),
422 logical_size: self.logical_size.to_string(),
423 disk: self.disk,
424 billed_as: self.billed_as.clone(),
425 internal: self.internal,
426 }
427 }
428
429 fn from_proto(
430 proto: crate::objects::audit_log_event_v1::CreateClusterReplicaV1,
431 ) -> Result<Self, TryFromProtoError> {
432 Ok(CreateClusterReplicaV1 {
433 cluster_id: proto.cluster_id,
434 cluster_name: proto.cluster_name,
435 replica_id: proto.replica_id.map(|id| id.inner),
436 replica_name: proto.replica_name,
437 logical_size: proto.logical_size,
438 disk: proto.disk,
439 billed_as: proto.billed_as,
440 internal: proto.internal,
441 })
442 }
443}
444
445impl RustType<crate::objects::audit_log_event_v1::CreateClusterReplicaV2>
446 for CreateClusterReplicaV2
447{
448 fn into_proto(&self) -> crate::objects::audit_log_event_v1::CreateClusterReplicaV2 {
449 crate::objects::audit_log_event_v1::CreateClusterReplicaV2 {
450 cluster_id: self.cluster_id.to_string(),
451 cluster_name: self.cluster_name.to_string(),
452 replica_id: self
453 .replica_id
454 .as_ref()
455 .map(|id| crate::objects::StringWrapper {
456 inner: id.to_string(),
457 }),
458 replica_name: self.replica_name.to_string(),
459 logical_size: self.logical_size.to_string(),
460 disk: self.disk,
461 billed_as: self.billed_as.clone(),
462 internal: self.internal,
463 reason: Some(self.reason.into_proto()),
464 scheduling_policies: self.scheduling_policies.into_proto(),
465 }
466 }
467
468 fn from_proto(
469 proto: crate::objects::audit_log_event_v1::CreateClusterReplicaV2,
470 ) -> Result<Self, TryFromProtoError> {
471 Ok(CreateClusterReplicaV2 {
472 cluster_id: proto.cluster_id,
473 cluster_name: proto.cluster_name,
474 replica_id: proto.replica_id.map(|id| id.inner),
475 replica_name: proto.replica_name,
476 logical_size: proto.logical_size,
477 disk: proto.disk,
478 billed_as: proto.billed_as,
479 internal: proto.internal,
480 reason: proto
481 .reason
482 .into_rust_if_some("DropClusterReplicaV2::reason")?,
483 scheduling_policies: proto.scheduling_policies.into_rust()?,
484 })
485 }
486}
487
488impl RustType<crate::objects::audit_log_event_v1::CreateClusterReplicaV3>
489 for CreateClusterReplicaV3
490{
491 fn into_proto(&self) -> crate::objects::audit_log_event_v1::CreateClusterReplicaV3 {
492 crate::objects::audit_log_event_v1::CreateClusterReplicaV3 {
493 cluster_id: self.cluster_id.to_string(),
494 cluster_name: self.cluster_name.to_string(),
495 replica_id: self
496 .replica_id
497 .as_ref()
498 .map(|id| crate::objects::StringWrapper {
499 inner: id.to_string(),
500 }),
501 replica_name: self.replica_name.to_string(),
502 logical_size: self.logical_size.to_string(),
503 disk: self.disk,
504 billed_as: self.billed_as.clone(),
505 internal: self.internal,
506 reason: Some(self.reason.into_proto()),
507 scheduling_policies: self.scheduling_policies.into_proto(),
508 }
509 }
510
511 fn from_proto(
512 proto: crate::objects::audit_log_event_v1::CreateClusterReplicaV3,
513 ) -> Result<Self, TryFromProtoError> {
514 Ok(CreateClusterReplicaV3 {
515 cluster_id: proto.cluster_id,
516 cluster_name: proto.cluster_name,
517 replica_id: proto.replica_id.map(|id| id.inner),
518 replica_name: proto.replica_name,
519 logical_size: proto.logical_size,
520 disk: proto.disk,
521 billed_as: proto.billed_as,
522 internal: proto.internal,
523 reason: proto
524 .reason
525 .into_rust_if_some("CreateClusterReplicaV3::reason")?,
526 scheduling_policies: proto.scheduling_policies.into_rust()?,
527 })
528 }
529}
530
531impl RustType<crate::objects::audit_log_event_v1::CreateClusterReplicaV4>
532 for CreateClusterReplicaV4
533{
534 fn into_proto(&self) -> crate::objects::audit_log_event_v1::CreateClusterReplicaV4 {
535 crate::objects::audit_log_event_v1::CreateClusterReplicaV4 {
536 cluster_id: self.cluster_id.to_string(),
537 cluster_name: self.cluster_name.to_string(),
538 replica_id: self
539 .replica_id
540 .as_ref()
541 .map(|id| crate::objects::StringWrapper {
542 inner: id.to_string(),
543 }),
544 replica_name: self.replica_name.to_string(),
545 logical_size: self.logical_size.to_string(),
546 billed_as: self.billed_as.clone(),
547 internal: self.internal,
548 reason: Some(self.reason.into_proto()),
549 scheduling_policies: self.scheduling_policies.into_proto(),
550 }
551 }
552
553 fn from_proto(
554 proto: crate::objects::audit_log_event_v1::CreateClusterReplicaV4,
555 ) -> Result<Self, TryFromProtoError> {
556 Ok(CreateClusterReplicaV4 {
557 cluster_id: proto.cluster_id,
558 cluster_name: proto.cluster_name,
559 replica_id: proto.replica_id.map(|id| id.inner),
560 replica_name: proto.replica_name,
561 logical_size: proto.logical_size,
562 billed_as: proto.billed_as,
563 internal: proto.internal,
564 reason: proto
565 .reason
566 .into_rust_if_some("CreateClusterReplicaV4::reason")?,
567 scheduling_policies: proto.scheduling_policies.into_rust()?,
568 })
569 }
570}
571
572impl RustType<crate::objects::audit_log_event_v1::CreateOrDropClusterReplicaReasonV1>
573 for CreateOrDropClusterReplicaReasonV1
574{
575 fn into_proto(&self) -> crate::objects::audit_log_event_v1::CreateOrDropClusterReplicaReasonV1 {
576 match self {
577 CreateOrDropClusterReplicaReasonV1::Manual => crate::objects::audit_log_event_v1::CreateOrDropClusterReplicaReasonV1 {
578 reason: Some(crate::objects::audit_log_event_v1::create_or_drop_cluster_replica_reason_v1::Reason::Manual(Empty {}))
579 },
580 CreateOrDropClusterReplicaReasonV1::Schedule => crate::objects::audit_log_event_v1::CreateOrDropClusterReplicaReasonV1 {
581 reason: Some(crate::objects::audit_log_event_v1::create_or_drop_cluster_replica_reason_v1::Reason::Schedule(Empty {}))
582 },
583 CreateOrDropClusterReplicaReasonV1::System => crate::objects::audit_log_event_v1::CreateOrDropClusterReplicaReasonV1 {
584 reason: Some(crate::objects::audit_log_event_v1::create_or_drop_cluster_replica_reason_v1::Reason::System(Empty {}))
585 },
586 }
587 }
588
589 fn from_proto(
590 proto: crate::objects::audit_log_event_v1::CreateOrDropClusterReplicaReasonV1,
591 ) -> Result<Self, TryFromProtoError> {
592 match proto.reason {
593 None => Err(TryFromProtoError::missing_field("CreateOrDropClusterReplicaReasonV1::reason")),
594 Some(crate::objects::audit_log_event_v1::create_or_drop_cluster_replica_reason_v1::Reason::Manual(Empty {})) => Ok(CreateOrDropClusterReplicaReasonV1::Manual),
595 Some(crate::objects::audit_log_event_v1::create_or_drop_cluster_replica_reason_v1::Reason::Schedule(Empty {})) => Ok(CreateOrDropClusterReplicaReasonV1::Schedule),
596 Some(crate::objects::audit_log_event_v1::create_or_drop_cluster_replica_reason_v1::Reason::System(Empty {})) => Ok(CreateOrDropClusterReplicaReasonV1::System),
597 }
598 }
599}
600
601impl RustType<crate::objects::audit_log_event_v1::SchedulingDecisionsWithReasonsV1>
602 for SchedulingDecisionsWithReasonsV1
603{
604 fn into_proto(&self) -> crate::objects::audit_log_event_v1::SchedulingDecisionsWithReasonsV1 {
605 crate::objects::audit_log_event_v1::SchedulingDecisionsWithReasonsV1 {
606 on_refresh: Some(self.on_refresh.into_proto()),
607 }
608 }
609
610 fn from_proto(
611 proto: crate::objects::audit_log_event_v1::SchedulingDecisionsWithReasonsV1,
612 ) -> Result<Self, TryFromProtoError> {
613 Ok(SchedulingDecisionsWithReasonsV1 {
614 on_refresh: proto
615 .on_refresh
616 .into_rust_if_some("SchedulingDecisionsWithReasonsV1::on_refresh")?,
617 })
618 }
619}
620
621impl RustType<crate::objects::audit_log_event_v1::SchedulingDecisionsWithReasonsV2>
622 for SchedulingDecisionsWithReasonsV2
623{
624 fn into_proto(&self) -> crate::objects::audit_log_event_v1::SchedulingDecisionsWithReasonsV2 {
625 crate::objects::audit_log_event_v1::SchedulingDecisionsWithReasonsV2 {
626 on_refresh: Some(self.on_refresh.into_proto()),
627 }
628 }
629
630 fn from_proto(
631 proto: crate::objects::audit_log_event_v1::SchedulingDecisionsWithReasonsV2,
632 ) -> Result<Self, TryFromProtoError> {
633 Ok(SchedulingDecisionsWithReasonsV2 {
634 on_refresh: proto
635 .on_refresh
636 .into_rust_if_some("SchedulingDecisionsWithReasonsV2::on_refresh")?,
637 })
638 }
639}
640
641impl RustType<crate::objects::audit_log_event_v1::RefreshDecisionWithReasonV1>
642 for RefreshDecisionWithReasonV1
643{
644 fn into_proto(&self) -> crate::objects::audit_log_event_v1::RefreshDecisionWithReasonV1 {
645 let decision = match &self.decision {
646 SchedulingDecisionV1::On => {
647 crate::objects::audit_log_event_v1::refresh_decision_with_reason_v1::Decision::On(
648 Empty {},
649 )
650 }
651 SchedulingDecisionV1::Off => {
652 crate::objects::audit_log_event_v1::refresh_decision_with_reason_v1::Decision::Off(
653 Empty {},
654 )
655 }
656 };
657 crate::objects::audit_log_event_v1::RefreshDecisionWithReasonV1 {
658 decision: Some(decision),
659 objects_needing_refresh: self.objects_needing_refresh.clone(),
660 rehydration_time_estimate: self.hydration_time_estimate.clone(),
661 }
662 }
663
664 fn from_proto(
665 proto: crate::objects::audit_log_event_v1::RefreshDecisionWithReasonV1,
666 ) -> Result<Self, TryFromProtoError> {
667 let decision = match proto.decision {
668 None => {
669 return Err(TryFromProtoError::missing_field(
670 "CreateOrDropClusterReplicaReasonV1::reason",
671 ));
672 }
673 Some(
674 crate::objects::audit_log_event_v1::refresh_decision_with_reason_v1::Decision::On(
675 Empty {},
676 ),
677 ) => SchedulingDecisionV1::On,
678 Some(
679 crate::objects::audit_log_event_v1::refresh_decision_with_reason_v1::Decision::Off(
680 Empty {},
681 ),
682 ) => SchedulingDecisionV1::Off,
683 };
684 Ok(RefreshDecisionWithReasonV1 {
685 decision,
686 objects_needing_refresh: proto.objects_needing_refresh,
687 hydration_time_estimate: proto.rehydration_time_estimate,
688 })
689 }
690}
691
692impl RustType<crate::objects::audit_log_event_v1::RefreshDecisionWithReasonV2>
693 for RefreshDecisionWithReasonV2
694{
695 fn into_proto(&self) -> crate::objects::audit_log_event_v1::RefreshDecisionWithReasonV2 {
696 let decision = match &self.decision {
697 SchedulingDecisionV1::On => {
698 crate::objects::audit_log_event_v1::refresh_decision_with_reason_v2::Decision::On(
699 Empty {},
700 )
701 }
702 SchedulingDecisionV1::Off => {
703 crate::objects::audit_log_event_v1::refresh_decision_with_reason_v2::Decision::Off(
704 Empty {},
705 )
706 }
707 };
708 crate::objects::audit_log_event_v1::RefreshDecisionWithReasonV2 {
709 decision: Some(decision),
710 objects_needing_refresh: self.objects_needing_refresh.clone(),
711 objects_needing_compaction: self.objects_needing_compaction.clone(),
712 rehydration_time_estimate: self.hydration_time_estimate.clone(),
713 }
714 }
715
716 fn from_proto(
717 proto: crate::objects::audit_log_event_v1::RefreshDecisionWithReasonV2,
718 ) -> Result<Self, TryFromProtoError> {
719 let decision = match proto.decision {
720 None => {
721 return Err(TryFromProtoError::missing_field(
722 "CreateOrDropClusterReplicaReasonV2::reason",
723 ));
724 }
725 Some(
726 crate::objects::audit_log_event_v1::refresh_decision_with_reason_v2::Decision::On(
727 Empty {},
728 ),
729 ) => SchedulingDecisionV1::On,
730 Some(
731 crate::objects::audit_log_event_v1::refresh_decision_with_reason_v2::Decision::Off(
732 Empty {},
733 ),
734 ) => SchedulingDecisionV1::Off,
735 };
736 Ok(RefreshDecisionWithReasonV2 {
737 decision,
738 objects_needing_refresh: proto.objects_needing_refresh,
739 objects_needing_compaction: proto.objects_needing_compaction,
740 hydration_time_estimate: proto.rehydration_time_estimate,
741 })
742 }
743}
744
745impl RustType<crate::objects::audit_log_event_v1::CreateSourceSinkV1> for CreateSourceSinkV1 {
746 fn into_proto(&self) -> crate::objects::audit_log_event_v1::CreateSourceSinkV1 {
747 crate::objects::audit_log_event_v1::CreateSourceSinkV1 {
748 id: self.id.to_string(),
749 name: Some(self.name.into_proto()),
750 size: self.size.as_ref().map(|s| crate::objects::StringWrapper {
751 inner: s.to_string(),
752 }),
753 }
754 }
755
756 fn from_proto(
757 proto: crate::objects::audit_log_event_v1::CreateSourceSinkV1,
758 ) -> Result<Self, TryFromProtoError> {
759 Ok(CreateSourceSinkV1 {
760 id: proto.id,
761 name: proto.name.into_rust_if_some("CreateSourceSinkV1::name")?,
762 size: proto.size.map(|s| s.inner),
763 })
764 }
765}
766
767impl RustType<crate::objects::audit_log_event_v1::CreateSourceSinkV2> for CreateSourceSinkV2 {
768 fn into_proto(&self) -> crate::objects::audit_log_event_v1::CreateSourceSinkV2 {
769 crate::objects::audit_log_event_v1::CreateSourceSinkV2 {
770 id: self.id.to_string(),
771 name: Some(self.name.into_proto()),
772 size: self.size.as_ref().map(|s| crate::objects::StringWrapper {
773 inner: s.to_string(),
774 }),
775 external_type: self.external_type.to_string(),
776 }
777 }
778
779 fn from_proto(
780 proto: crate::objects::audit_log_event_v1::CreateSourceSinkV2,
781 ) -> Result<Self, TryFromProtoError> {
782 Ok(CreateSourceSinkV2 {
783 id: proto.id,
784 name: proto.name.into_rust_if_some("CreateSourceSinkV2::name")?,
785 size: proto.size.map(|s| s.inner),
786 external_type: proto.external_type,
787 })
788 }
789}
790
791impl RustType<crate::objects::audit_log_event_v1::CreateSourceSinkV3> for CreateSourceSinkV3 {
792 fn into_proto(&self) -> crate::objects::audit_log_event_v1::CreateSourceSinkV3 {
793 crate::objects::audit_log_event_v1::CreateSourceSinkV3 {
794 id: self.id.to_string(),
795 name: Some(self.name.into_proto()),
796 external_type: self.external_type.to_string(),
797 }
798 }
799
800 fn from_proto(
801 proto: crate::objects::audit_log_event_v1::CreateSourceSinkV3,
802 ) -> Result<Self, TryFromProtoError> {
803 Ok(CreateSourceSinkV3 {
804 id: proto.id,
805 name: proto.name.into_rust_if_some("CreateSourceSinkV2::name")?,
806 external_type: proto.external_type,
807 })
808 }
809}
810
811impl RustType<crate::objects::audit_log_event_v1::CreateSourceSinkV4> for CreateSourceSinkV4 {
812 fn into_proto(&self) -> crate::objects::audit_log_event_v1::CreateSourceSinkV4 {
813 crate::objects::audit_log_event_v1::CreateSourceSinkV4 {
814 id: self.id.to_string(),
815 cluster_id: self
816 .cluster_id
817 .as_ref()
818 .map(|id| crate::objects::StringWrapper {
819 inner: id.to_string(),
820 }),
821 name: Some(self.name.into_proto()),
822 external_type: self.external_type.to_string(),
823 }
824 }
825
826 fn from_proto(
827 proto: crate::objects::audit_log_event_v1::CreateSourceSinkV4,
828 ) -> Result<Self, TryFromProtoError> {
829 Ok(CreateSourceSinkV4 {
830 id: proto.id,
831 cluster_id: proto.cluster_id.map(|s| s.inner),
832 name: proto.name.into_rust_if_some("CreateSourceSinkV4::name")?,
833 external_type: proto.external_type,
834 })
835 }
836}
837
838impl RustType<crate::objects::audit_log_event_v1::CreateIndexV1> for CreateIndexV1 {
839 fn into_proto(&self) -> crate::objects::audit_log_event_v1::CreateIndexV1 {
840 crate::objects::audit_log_event_v1::CreateIndexV1 {
841 id: self.id.to_string(),
842 cluster_id: self.cluster_id.to_string(),
843 name: Some(self.name.into_proto()),
844 }
845 }
846
847 fn from_proto(
848 proto: crate::objects::audit_log_event_v1::CreateIndexV1,
849 ) -> Result<Self, TryFromProtoError> {
850 Ok(CreateIndexV1 {
851 id: proto.id,
852 cluster_id: proto.cluster_id,
853 name: proto.name.into_rust_if_some("CreateIndexV1::name")?,
854 })
855 }
856}
857
858impl RustType<crate::objects::audit_log_event_v1::CreateMaterializedViewV1>
859 for CreateMaterializedViewV1
860{
861 fn into_proto(&self) -> crate::objects::audit_log_event_v1::CreateMaterializedViewV1 {
862 crate::objects::audit_log_event_v1::CreateMaterializedViewV1 {
863 id: self.id.to_string(),
864 cluster_id: self.cluster_id.to_string(),
865 name: Some(self.name.into_proto()),
866 }
867 }
868
869 fn from_proto(
870 proto: crate::objects::audit_log_event_v1::CreateMaterializedViewV1,
871 ) -> Result<Self, TryFromProtoError> {
872 Ok(CreateMaterializedViewV1 {
873 id: proto.id,
874 cluster_id: proto.cluster_id,
875 name: proto
876 .name
877 .into_rust_if_some("CreateMaterializedViewV1::name")?,
878 })
879 }
880}
881
882impl RustType<crate::objects::audit_log_event_v1::AlterSourceSinkV1> for AlterSourceSinkV1 {
883 fn into_proto(&self) -> crate::objects::audit_log_event_v1::AlterSourceSinkV1 {
884 crate::objects::audit_log_event_v1::AlterSourceSinkV1 {
885 id: self.id.to_string(),
886 name: Some(self.name.into_proto()),
887 old_size: self
888 .old_size
889 .as_ref()
890 .map(|s| crate::objects::StringWrapper {
891 inner: s.to_string(),
892 }),
893 new_size: self
894 .new_size
895 .as_ref()
896 .map(|s| crate::objects::StringWrapper {
897 inner: s.to_string(),
898 }),
899 }
900 }
901
902 fn from_proto(
903 proto: crate::objects::audit_log_event_v1::AlterSourceSinkV1,
904 ) -> Result<Self, TryFromProtoError> {
905 Ok(AlterSourceSinkV1 {
906 id: proto.id,
907 name: proto.name.into_rust_if_some("AlterSourceSinkV1::name")?,
908 old_size: proto.old_size.map(|s| s.inner),
909 new_size: proto.new_size.map(|s| s.inner),
910 })
911 }
912}
913
914impl RustType<crate::objects::audit_log_event_v1::AlterSetClusterV1> for AlterSetClusterV1 {
915 fn into_proto(&self) -> crate::objects::audit_log_event_v1::AlterSetClusterV1 {
916 crate::objects::audit_log_event_v1::AlterSetClusterV1 {
917 id: self.id.to_string(),
918 name: Some(self.name.into_proto()),
919 old_cluster: self
920 .old_cluster
921 .as_ref()
922 .map(|s| crate::objects::StringWrapper {
923 inner: s.to_string(),
924 }),
925 new_cluster: self
926 .new_cluster
927 .as_ref()
928 .map(|s| crate::objects::StringWrapper {
929 inner: s.to_string(),
930 }),
931 }
932 }
933
934 fn from_proto(
935 proto: crate::objects::audit_log_event_v1::AlterSetClusterV1,
936 ) -> Result<Self, TryFromProtoError> {
937 Ok(Self {
938 id: proto.id,
939 name: proto.name.into_rust_if_some("AlterSetClusterV1::name")?,
940 old_cluster: proto.old_cluster.map(|s| s.inner),
941 new_cluster: proto.new_cluster.map(|s| s.inner),
942 })
943 }
944}
945
946impl RustType<crate::objects::audit_log_event_v1::GrantRoleV1> for GrantRoleV1 {
947 fn into_proto(&self) -> crate::objects::audit_log_event_v1::GrantRoleV1 {
948 crate::objects::audit_log_event_v1::GrantRoleV1 {
949 role_id: self.role_id.to_string(),
950 member_id: self.member_id.to_string(),
951 grantor_id: self.grantor_id.to_string(),
952 }
953 }
954
955 fn from_proto(
956 proto: crate::objects::audit_log_event_v1::GrantRoleV1,
957 ) -> Result<Self, TryFromProtoError> {
958 Ok(GrantRoleV1 {
959 role_id: proto.role_id,
960 member_id: proto.member_id,
961 grantor_id: proto.grantor_id,
962 })
963 }
964}
965
966impl RustType<crate::objects::audit_log_event_v1::GrantRoleV2> for GrantRoleV2 {
967 fn into_proto(&self) -> crate::objects::audit_log_event_v1::GrantRoleV2 {
968 crate::objects::audit_log_event_v1::GrantRoleV2 {
969 role_id: self.role_id.to_string(),
970 member_id: self.member_id.to_string(),
971 grantor_id: self.grantor_id.to_string(),
972 executed_by: self.executed_by.to_string(),
973 }
974 }
975
976 fn from_proto(
977 proto: crate::objects::audit_log_event_v1::GrantRoleV2,
978 ) -> Result<Self, TryFromProtoError> {
979 Ok(GrantRoleV2 {
980 role_id: proto.role_id,
981 member_id: proto.member_id,
982 grantor_id: proto.grantor_id,
983 executed_by: proto.executed_by,
984 })
985 }
986}
987
988impl RustType<crate::objects::audit_log_event_v1::RevokeRoleV1> for RevokeRoleV1 {
989 fn into_proto(&self) -> crate::objects::audit_log_event_v1::RevokeRoleV1 {
990 crate::objects::audit_log_event_v1::RevokeRoleV1 {
991 role_id: self.role_id.to_string(),
992 member_id: self.member_id.to_string(),
993 }
994 }
995
996 fn from_proto(
997 proto: crate::objects::audit_log_event_v1::RevokeRoleV1,
998 ) -> Result<Self, TryFromProtoError> {
999 Ok(RevokeRoleV1 {
1000 role_id: proto.role_id,
1001 member_id: proto.member_id,
1002 })
1003 }
1004}
1005
1006impl RustType<crate::objects::audit_log_event_v1::RevokeRoleV2> for RevokeRoleV2 {
1007 fn into_proto(&self) -> crate::objects::audit_log_event_v1::RevokeRoleV2 {
1008 crate::objects::audit_log_event_v1::RevokeRoleV2 {
1009 role_id: self.role_id.to_string(),
1010 member_id: self.member_id.to_string(),
1011 grantor_id: self.grantor_id.to_string(),
1012 executed_by: self.executed_by.to_string(),
1013 }
1014 }
1015
1016 fn from_proto(
1017 proto: crate::objects::audit_log_event_v1::RevokeRoleV2,
1018 ) -> Result<Self, TryFromProtoError> {
1019 Ok(RevokeRoleV2 {
1020 role_id: proto.role_id,
1021 member_id: proto.member_id,
1022 grantor_id: proto.grantor_id,
1023 executed_by: proto.executed_by,
1024 })
1025 }
1026}
1027
1028impl RustType<crate::objects::audit_log_event_v1::UpdatePrivilegeV1> for UpdatePrivilegeV1 {
1029 fn into_proto(&self) -> crate::objects::audit_log_event_v1::UpdatePrivilegeV1 {
1030 crate::objects::audit_log_event_v1::UpdatePrivilegeV1 {
1031 object_id: self.object_id.to_string(),
1032 grantee_id: self.grantee_id.to_string(),
1033 grantor_id: self.grantor_id.to_string(),
1034 privileges: self.privileges.to_string(),
1035 }
1036 }
1037
1038 fn from_proto(
1039 proto: crate::objects::audit_log_event_v1::UpdatePrivilegeV1,
1040 ) -> Result<Self, TryFromProtoError> {
1041 Ok(UpdatePrivilegeV1 {
1042 object_id: proto.object_id,
1043 grantee_id: proto.grantee_id,
1044 grantor_id: proto.grantor_id,
1045 privileges: proto.privileges,
1046 })
1047 }
1048}
1049
1050impl RustType<crate::objects::audit_log_event_v1::AlterDefaultPrivilegeV1>
1051 for AlterDefaultPrivilegeV1
1052{
1053 fn into_proto(&self) -> crate::objects::audit_log_event_v1::AlterDefaultPrivilegeV1 {
1054 crate::objects::audit_log_event_v1::AlterDefaultPrivilegeV1 {
1055 role_id: self.role_id.to_string(),
1056 database_id: self
1057 .database_id
1058 .as_ref()
1059 .map(|id| crate::objects::StringWrapper {
1060 inner: id.to_string(),
1061 }),
1062 schema_id: self
1063 .schema_id
1064 .as_ref()
1065 .map(|id| crate::objects::StringWrapper {
1066 inner: id.to_string(),
1067 }),
1068 grantee_id: self.grantee_id.to_string(),
1069 privileges: self.privileges.to_string(),
1070 }
1071 }
1072
1073 fn from_proto(
1074 proto: crate::objects::audit_log_event_v1::AlterDefaultPrivilegeV1,
1075 ) -> Result<Self, TryFromProtoError> {
1076 Ok(AlterDefaultPrivilegeV1 {
1077 role_id: proto.role_id,
1078 database_id: proto.database_id.map(|id| id.inner),
1079 schema_id: proto.schema_id.map(|id| id.inner),
1080 grantee_id: proto.grantee_id,
1081 privileges: proto.privileges,
1082 })
1083 }
1084}
1085
1086impl RustType<crate::objects::audit_log_event_v1::UpdateOwnerV1> for UpdateOwnerV1 {
1087 fn into_proto(&self) -> crate::objects::audit_log_event_v1::UpdateOwnerV1 {
1088 crate::objects::audit_log_event_v1::UpdateOwnerV1 {
1089 object_id: self.object_id.to_string(),
1090 old_owner_id: self.old_owner_id.to_string(),
1091 new_owner_id: self.new_owner_id.to_string(),
1092 }
1093 }
1094
1095 fn from_proto(
1096 proto: crate::objects::audit_log_event_v1::UpdateOwnerV1,
1097 ) -> Result<Self, TryFromProtoError> {
1098 Ok(UpdateOwnerV1 {
1099 object_id: proto.object_id,
1100 old_owner_id: proto.old_owner_id,
1101 new_owner_id: proto.new_owner_id,
1102 })
1103 }
1104}
1105
1106impl RustType<crate::objects::audit_log_event_v1::SchemaV1> for SchemaV1 {
1107 fn into_proto(&self) -> crate::objects::audit_log_event_v1::SchemaV1 {
1108 crate::objects::audit_log_event_v1::SchemaV1 {
1109 id: self.id.to_string(),
1110 name: self.name.to_string(),
1111 database_name: self.database_name.to_string(),
1112 }
1113 }
1114
1115 fn from_proto(
1116 proto: crate::objects::audit_log_event_v1::SchemaV1,
1117 ) -> Result<Self, TryFromProtoError> {
1118 Ok(SchemaV1 {
1119 id: proto.id,
1120 name: proto.name,
1121 database_name: proto.database_name,
1122 })
1123 }
1124}
1125
1126impl RustType<crate::objects::audit_log_event_v1::SchemaV2> for SchemaV2 {
1127 fn into_proto(&self) -> crate::objects::audit_log_event_v1::SchemaV2 {
1128 crate::objects::audit_log_event_v1::SchemaV2 {
1129 id: self.id.to_string(),
1130 name: self.name.to_string(),
1131 database_name: self
1132 .database_name
1133 .as_ref()
1134 .map(|d| crate::objects::StringWrapper {
1135 inner: d.to_string(),
1136 }),
1137 }
1138 }
1139
1140 fn from_proto(
1141 proto: crate::objects::audit_log_event_v1::SchemaV2,
1142 ) -> Result<Self, TryFromProtoError> {
1143 Ok(SchemaV2 {
1144 id: proto.id,
1145 name: proto.name,
1146 database_name: proto.database_name.map(|d| d.inner),
1147 })
1148 }
1149}
1150
1151impl RustType<crate::objects::audit_log_event_v1::RenameSchemaV1> for RenameSchemaV1 {
1152 fn into_proto(&self) -> crate::objects::audit_log_event_v1::RenameSchemaV1 {
1153 crate::objects::audit_log_event_v1::RenameSchemaV1 {
1154 id: self.id.to_string(),
1155 database_name: self.database_name.clone(),
1156 old_name: self.old_name.clone(),
1157 new_name: self.new_name.clone(),
1158 }
1159 }
1160
1161 fn from_proto(
1162 proto: crate::objects::audit_log_event_v1::RenameSchemaV1,
1163 ) -> Result<Self, TryFromProtoError> {
1164 Ok(RenameSchemaV1 {
1165 id: proto.id,
1166 database_name: proto.database_name,
1167 old_name: proto.old_name,
1168 new_name: proto.new_name,
1169 })
1170 }
1171}
1172
1173impl RustType<crate::objects::audit_log_event_v1::UpdateItemV1> for UpdateItemV1 {
1174 fn into_proto(&self) -> crate::objects::audit_log_event_v1::UpdateItemV1 {
1175 crate::objects::audit_log_event_v1::UpdateItemV1 {
1176 id: self.id.to_string(),
1177 name: Some(self.name.into_proto()),
1178 }
1179 }
1180
1181 fn from_proto(
1182 proto: crate::objects::audit_log_event_v1::UpdateItemV1,
1183 ) -> Result<Self, TryFromProtoError> {
1184 Ok(UpdateItemV1 {
1185 id: proto.id,
1186 name: proto.name.into_rust_if_some("UpdateItemV1::name")?,
1187 })
1188 }
1189}
1190
1191impl RustType<crate::objects::audit_log_event_v1::AlterRetainHistoryV1> for AlterRetainHistoryV1 {
1192 fn into_proto(&self) -> crate::objects::audit_log_event_v1::AlterRetainHistoryV1 {
1193 crate::objects::audit_log_event_v1::AlterRetainHistoryV1 {
1194 id: self.id.to_string(),
1195 old_history: self.old_history.clone(),
1196 new_history: self.new_history.clone(),
1197 }
1198 }
1199
1200 fn from_proto(
1201 proto: crate::objects::audit_log_event_v1::AlterRetainHistoryV1,
1202 ) -> Result<Self, TryFromProtoError> {
1203 Ok(AlterRetainHistoryV1 {
1204 id: proto.id,
1205 old_history: proto.old_history,
1206 new_history: proto.new_history,
1207 })
1208 }
1209}
1210
1211impl RustType<crate::objects::audit_log_event_v1::ToNewIdV1> for ToNewIdV1 {
1212 fn into_proto(&self) -> crate::objects::audit_log_event_v1::ToNewIdV1 {
1213 crate::objects::audit_log_event_v1::ToNewIdV1 {
1214 id: self.id.to_string(),
1215 new_id: self.new_id.to_string(),
1216 }
1217 }
1218
1219 fn from_proto(
1220 proto: crate::objects::audit_log_event_v1::ToNewIdV1,
1221 ) -> Result<Self, TryFromProtoError> {
1222 Ok(ToNewIdV1 {
1223 id: proto.id,
1224 new_id: proto.new_id,
1225 })
1226 }
1227}
1228
1229impl RustType<crate::objects::audit_log_event_v1::FromPreviousIdV1> for FromPreviousIdV1 {
1230 fn into_proto(&self) -> crate::objects::audit_log_event_v1::FromPreviousIdV1 {
1231 crate::objects::audit_log_event_v1::FromPreviousIdV1 {
1232 id: self.id.to_string(),
1233 previous_id: self.previous_id.to_string(),
1234 }
1235 }
1236
1237 fn from_proto(
1238 proto: crate::objects::audit_log_event_v1::FromPreviousIdV1,
1239 ) -> Result<Self, TryFromProtoError> {
1240 Ok(FromPreviousIdV1 {
1241 id: proto.id,
1242 previous_id: proto.previous_id,
1243 })
1244 }
1245}
1246
1247impl RustType<crate::objects::audit_log_event_v1::SetV1> for SetV1 {
1248 fn into_proto(&self) -> crate::objects::audit_log_event_v1::SetV1 {
1249 crate::objects::audit_log_event_v1::SetV1 {
1250 name: self.name.clone(),
1251 value: self.value.clone(),
1252 }
1253 }
1254
1255 fn from_proto(
1256 proto: crate::objects::audit_log_event_v1::SetV1,
1257 ) -> Result<Self, TryFromProtoError> {
1258 Ok(SetV1 {
1259 name: proto.name,
1260 value: proto.value,
1261 })
1262 }
1263}
1264
1265impl RustType<crate::objects::audit_log_event_v1::RotateKeysV1> for RotateKeysV1 {
1266 fn into_proto(&self) -> crate::objects::audit_log_event_v1::RotateKeysV1 {
1267 crate::objects::audit_log_event_v1::RotateKeysV1 {
1268 id: self.id.clone(),
1269 name: self.name.clone(),
1270 }
1271 }
1272
1273 fn from_proto(
1274 proto: crate::objects::audit_log_event_v1::RotateKeysV1,
1275 ) -> Result<Self, TryFromProtoError> {
1276 Ok(RotateKeysV1 {
1277 id: proto.id,
1278 name: proto.name,
1279 })
1280 }
1281}
1282
1283impl RustType<crate::objects::audit_log_event_v1::Details> for EventDetails {
1284 fn into_proto(&self) -> crate::objects::audit_log_event_v1::Details {
1285 use crate::objects::audit_log_event_v1::Details::*;
1286
1287 match self {
1288 EventDetails::CreateClusterReplicaV1(details) => {
1289 CreateClusterReplicaV1(details.into_proto())
1290 }
1291 EventDetails::CreateClusterReplicaV2(details) => {
1292 CreateClusterReplicaV2(details.into_proto())
1293 }
1294 EventDetails::CreateClusterReplicaV3(details) => {
1295 CreateClusterReplicaV3(details.into_proto())
1296 }
1297 EventDetails::CreateClusterReplicaV4(details) => {
1298 CreateClusterReplicaV4(details.into_proto())
1299 }
1300 EventDetails::DropClusterReplicaV1(details) => {
1301 DropClusterReplicaV1(details.into_proto())
1302 }
1303 EventDetails::DropClusterReplicaV2(details) => {
1304 DropClusterReplicaV2(details.into_proto())
1305 }
1306 EventDetails::DropClusterReplicaV3(details) => {
1307 DropClusterReplicaV3(details.into_proto())
1308 }
1309 EventDetails::CreateSourceSinkV1(details) => CreateSourceSinkV1(details.into_proto()),
1310 EventDetails::CreateSourceSinkV2(details) => CreateSourceSinkV2(details.into_proto()),
1311 EventDetails::CreateSourceSinkV3(details) => CreateSourceSinkV3(details.into_proto()),
1312 EventDetails::CreateSourceSinkV4(details) => CreateSourceSinkV4(details.into_proto()),
1313 EventDetails::CreateIndexV1(details) => CreateIndexV1(details.into_proto()),
1314 EventDetails::CreateMaterializedViewV1(details) => {
1315 CreateMaterializedViewV1(details.into_proto())
1316 }
1317 EventDetails::AlterSourceSinkV1(details) => AlterSourceSinkV1(details.into_proto()),
1318 EventDetails::AlterSetClusterV1(details) => AlterSetClusterV1(details.into_proto()),
1319 EventDetails::GrantRoleV1(details) => GrantRoleV1(details.into_proto()),
1320 EventDetails::GrantRoleV2(details) => GrantRoleV2(details.into_proto()),
1321 EventDetails::RevokeRoleV1(details) => RevokeRoleV1(details.into_proto()),
1322 EventDetails::RevokeRoleV2(details) => RevokeRoleV2(details.into_proto()),
1323 EventDetails::UpdatePrivilegeV1(details) => UpdatePrivilegeV1(details.into_proto()),
1324 EventDetails::AlterDefaultPrivilegeV1(details) => {
1325 AlterDefaultPrivilegeV1(details.into_proto())
1326 }
1327 EventDetails::UpdateOwnerV1(details) => UpdateOwnerV1(details.into_proto()),
1328 EventDetails::IdFullNameV1(details) => IdFullNameV1(details.into_proto()),
1329 EventDetails::RenameClusterV1(details) => RenameClusterV1(details.into_proto()),
1330 EventDetails::RenameClusterReplicaV1(details) => {
1331 RenameClusterReplicaV1(details.into_proto())
1332 }
1333 EventDetails::RenameItemV1(details) => RenameItemV1(details.into_proto()),
1334 EventDetails::IdNameV1(details) => IdNameV1(details.into_proto()),
1335 EventDetails::SchemaV1(details) => SchemaV1(details.into_proto()),
1336 EventDetails::SchemaV2(details) => SchemaV2(details.into_proto()),
1337 EventDetails::RenameSchemaV1(details) => RenameSchemaV1(details.into_proto()),
1338 EventDetails::UpdateItemV1(details) => UpdateItemV1(details.into_proto()),
1339 EventDetails::AlterRetainHistoryV1(details) => {
1340 AlterRetainHistoryV1(details.into_proto())
1341 }
1342 EventDetails::ToNewIdV1(details) => ToNewIdV1(details.into_proto()),
1343 EventDetails::FromPreviousIdV1(details) => FromPreviousIdV1(details.into_proto()),
1344 EventDetails::SetV1(details) => SetV1(details.into_proto()),
1345 EventDetails::ResetAllV1 => ResetAllV1(Empty {}),
1346 EventDetails::RotateKeysV1(details) => RotateKeysV1(details.into_proto()),
1347 }
1348 }
1349
1350 fn from_proto(
1351 proto: crate::objects::audit_log_event_v1::Details,
1352 ) -> Result<Self, TryFromProtoError> {
1353 use crate::objects::audit_log_event_v1::Details::*;
1354
1355 match proto {
1356 CreateClusterReplicaV1(details) => {
1357 Ok(EventDetails::CreateClusterReplicaV1(details.into_rust()?))
1358 }
1359 CreateClusterReplicaV2(details) => {
1360 Ok(EventDetails::CreateClusterReplicaV2(details.into_rust()?))
1361 }
1362 CreateClusterReplicaV3(details) => {
1363 Ok(EventDetails::CreateClusterReplicaV3(details.into_rust()?))
1364 }
1365 CreateClusterReplicaV4(details) => {
1366 Ok(EventDetails::CreateClusterReplicaV4(details.into_rust()?))
1367 }
1368 DropClusterReplicaV1(details) => {
1369 Ok(EventDetails::DropClusterReplicaV1(details.into_rust()?))
1370 }
1371 DropClusterReplicaV2(details) => {
1372 Ok(EventDetails::DropClusterReplicaV2(details.into_rust()?))
1373 }
1374 DropClusterReplicaV3(details) => {
1375 Ok(EventDetails::DropClusterReplicaV3(details.into_rust()?))
1376 }
1377 CreateSourceSinkV1(details) => {
1378 Ok(EventDetails::CreateSourceSinkV1(details.into_rust()?))
1379 }
1380 CreateSourceSinkV2(details) => {
1381 Ok(EventDetails::CreateSourceSinkV2(details.into_rust()?))
1382 }
1383 CreateSourceSinkV3(details) => {
1384 Ok(EventDetails::CreateSourceSinkV3(details.into_rust()?))
1385 }
1386 CreateSourceSinkV4(details) => {
1387 Ok(EventDetails::CreateSourceSinkV4(details.into_rust()?))
1388 }
1389 CreateIndexV1(details) => Ok(EventDetails::CreateIndexV1(details.into_rust()?)),
1390 CreateMaterializedViewV1(details) => {
1391 Ok(EventDetails::CreateMaterializedViewV1(details.into_rust()?))
1392 }
1393 AlterSourceSinkV1(details) => Ok(EventDetails::AlterSourceSinkV1(details.into_rust()?)),
1394 AlterSetClusterV1(details) => Ok(EventDetails::AlterSetClusterV1(details.into_rust()?)),
1395 GrantRoleV1(details) => Ok(EventDetails::GrantRoleV1(details.into_rust()?)),
1396 GrantRoleV2(details) => Ok(EventDetails::GrantRoleV2(details.into_rust()?)),
1397 RevokeRoleV1(details) => Ok(EventDetails::RevokeRoleV1(details.into_rust()?)),
1398 RevokeRoleV2(details) => Ok(EventDetails::RevokeRoleV2(details.into_rust()?)),
1399 UpdatePrivilegeV1(details) => Ok(EventDetails::UpdatePrivilegeV1(details.into_rust()?)),
1400 AlterDefaultPrivilegeV1(details) => {
1401 Ok(EventDetails::AlterDefaultPrivilegeV1(details.into_rust()?))
1402 }
1403 UpdateOwnerV1(details) => Ok(EventDetails::UpdateOwnerV1(details.into_rust()?)),
1404 IdFullNameV1(details) => Ok(EventDetails::IdFullNameV1(details.into_rust()?)),
1405 RenameClusterV1(details) => Ok(EventDetails::RenameClusterV1(details.into_rust()?)),
1406 RenameClusterReplicaV1(details) => {
1407 Ok(EventDetails::RenameClusterReplicaV1(details.into_rust()?))
1408 }
1409 RenameItemV1(details) => Ok(EventDetails::RenameItemV1(details.into_rust()?)),
1410 IdNameV1(details) => Ok(EventDetails::IdNameV1(details.into_rust()?)),
1411 SchemaV1(details) => Ok(EventDetails::SchemaV1(details.into_rust()?)),
1412 SchemaV2(details) => Ok(EventDetails::SchemaV2(details.into_rust()?)),
1413 RenameSchemaV1(details) => Ok(EventDetails::RenameSchemaV1(details.into_rust()?)),
1414 UpdateItemV1(details) => Ok(EventDetails::UpdateItemV1(details.into_rust()?)),
1415 AlterRetainHistoryV1(details) => {
1416 Ok(EventDetails::AlterRetainHistoryV1(details.into_rust()?))
1417 }
1418 ToNewIdV1(details) => Ok(EventDetails::ToNewIdV1(details.into_rust()?)),
1419 FromPreviousIdV1(details) => Ok(EventDetails::FromPreviousIdV1(details.into_rust()?)),
1420 SetV1(details) => Ok(EventDetails::SetV1(details.into_rust()?)),
1421 ResetAllV1(Empty {}) => Ok(EventDetails::ResetAllV1),
1422 RotateKeysV1(details) => Ok(EventDetails::RotateKeysV1(details.into_rust()?)),
1423 }
1424 }
1425}
1426
1427impl RustType<crate::objects::AuditLogEventV1> for EventV1 {
1428 fn into_proto(&self) -> crate::objects::AuditLogEventV1 {
1429 crate::objects::AuditLogEventV1 {
1430 id: self.id,
1431 event_type: self.event_type.into_proto().into(),
1432 object_type: self.object_type.into_proto().into(),
1433 user: self.user.as_ref().map(|u| crate::objects::StringWrapper {
1434 inner: u.to_string(),
1435 }),
1436 occurred_at: Some(crate::objects::EpochMillis {
1437 millis: self.occurred_at,
1438 }),
1439 details: Some(self.details.into_proto()),
1440 }
1441 }
1442
1443 fn from_proto(proto: crate::objects::AuditLogEventV1) -> Result<Self, TryFromProtoError> {
1444 let event_type = crate::objects::audit_log_event_v1::EventType::try_from(proto.event_type)
1445 .map_err(|_| TryFromProtoError::unknown_enum_variant("EventType"))?;
1446 let object_type =
1447 crate::objects::audit_log_event_v1::ObjectType::try_from(proto.object_type)
1448 .map_err(|_| TryFromProtoError::unknown_enum_variant("ObjectType"))?;
1449 Ok(EventV1 {
1450 id: proto.id,
1451 event_type: event_type.into_rust()?,
1452 object_type: object_type.into_rust()?,
1453 details: proto
1454 .details
1455 .into_rust_if_some("AuditLogEventV1::details")?,
1456 user: proto.user.map(|u| u.inner),
1457 occurred_at: proto
1458 .occurred_at
1459 .into_rust_if_some("AuditLogEventV1::occurred_at")?,
1460 })
1461 }
1462}