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