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