Skip to main content

mz_catalog_protos/
audit_log.rs

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