1use 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 => {
564 use crate::objects::audit_log_event_v1 as ev;
565 ev::CreateOrDropClusterReplicaReasonV1 {
566 reason: ev::CreateOrDropClusterReplicaReasonV1Reason::Manual(Empty {}),
567 }
568 }
569 CreateOrDropClusterReplicaReasonV1::Schedule => {
570 use crate::objects::audit_log_event_v1 as ev;
571 ev::CreateOrDropClusterReplicaReasonV1 {
572 reason: ev::CreateOrDropClusterReplicaReasonV1Reason::Schedule(Empty {}),
573 }
574 }
575 CreateOrDropClusterReplicaReasonV1::System => {
576 use crate::objects::audit_log_event_v1 as ev;
577 ev::CreateOrDropClusterReplicaReasonV1 {
578 reason: ev::CreateOrDropClusterReplicaReasonV1Reason::System(Empty {}),
579 }
580 }
581 }
582 }
583
584 fn from_proto(
585 proto: crate::objects::audit_log_event_v1::CreateOrDropClusterReplicaReasonV1,
586 ) -> Result<Self, TryFromProtoError> {
587 match proto.reason {
588 crate::objects::audit_log_event_v1::CreateOrDropClusterReplicaReasonV1Reason::Manual(
589 Empty {},
590 ) => Ok(CreateOrDropClusterReplicaReasonV1::Manual),
591 crate::objects::audit_log_event_v1::CreateOrDropClusterReplicaReasonV1Reason::Schedule(
592 Empty {},
593 ) => Ok(CreateOrDropClusterReplicaReasonV1::Schedule),
594 crate::objects::audit_log_event_v1::CreateOrDropClusterReplicaReasonV1Reason::System(
595 Empty {},
596 ) => Ok(CreateOrDropClusterReplicaReasonV1::System),
597 }
598 }
599}
600
601impl RustType<crate::objects::audit_log_event_v1::SchedulingDecisionsWithReasonsV1>
602 for SchedulingDecisionsWithReasonsV1
603{
604 fn into_proto(&self) -> crate::objects::audit_log_event_v1::SchedulingDecisionsWithReasonsV1 {
605 crate::objects::audit_log_event_v1::SchedulingDecisionsWithReasonsV1 {
606 on_refresh: self.on_refresh.into_proto(),
607 }
608 }
609
610 fn from_proto(
611 proto: crate::objects::audit_log_event_v1::SchedulingDecisionsWithReasonsV1,
612 ) -> Result<Self, TryFromProtoError> {
613 Ok(SchedulingDecisionsWithReasonsV1 {
614 on_refresh: proto.on_refresh.into_rust()?,
615 })
616 }
617}
618
619impl RustType<crate::objects::audit_log_event_v1::SchedulingDecisionsWithReasonsV2>
620 for SchedulingDecisionsWithReasonsV2
621{
622 fn into_proto(&self) -> crate::objects::audit_log_event_v1::SchedulingDecisionsWithReasonsV2 {
623 crate::objects::audit_log_event_v1::SchedulingDecisionsWithReasonsV2 {
624 on_refresh: self.on_refresh.into_proto(),
625 }
626 }
627
628 fn from_proto(
629 proto: crate::objects::audit_log_event_v1::SchedulingDecisionsWithReasonsV2,
630 ) -> Result<Self, TryFromProtoError> {
631 Ok(SchedulingDecisionsWithReasonsV2 {
632 on_refresh: proto.on_refresh.into_rust()?,
633 })
634 }
635}
636
637impl RustType<crate::objects::audit_log_event_v1::RefreshDecisionWithReasonV1>
638 for RefreshDecisionWithReasonV1
639{
640 fn into_proto(&self) -> crate::objects::audit_log_event_v1::RefreshDecisionWithReasonV1 {
641 let decision = match &self.decision {
642 SchedulingDecisionV1::On => {
643 crate::objects::audit_log_event_v1::RefreshDecision::On(Empty {})
644 }
645 SchedulingDecisionV1::Off => {
646 crate::objects::audit_log_event_v1::RefreshDecision::Off(Empty {})
647 }
648 };
649 crate::objects::audit_log_event_v1::RefreshDecisionWithReasonV1 {
650 decision,
651 objects_needing_refresh: self.objects_needing_refresh.clone(),
652 rehydration_time_estimate: self.hydration_time_estimate.clone(),
653 }
654 }
655
656 fn from_proto(
657 proto: crate::objects::audit_log_event_v1::RefreshDecisionWithReasonV1,
658 ) -> Result<Self, TryFromProtoError> {
659 let decision = match proto.decision {
660 crate::objects::audit_log_event_v1::RefreshDecision::On(Empty {}) => {
661 SchedulingDecisionV1::On
662 }
663 crate::objects::audit_log_event_v1::RefreshDecision::Off(Empty {}) => {
664 SchedulingDecisionV1::Off
665 }
666 };
667 Ok(RefreshDecisionWithReasonV1 {
668 decision,
669 objects_needing_refresh: proto.objects_needing_refresh,
670 hydration_time_estimate: proto.rehydration_time_estimate,
671 })
672 }
673}
674
675impl RustType<crate::objects::audit_log_event_v1::RefreshDecisionWithReasonV2>
676 for RefreshDecisionWithReasonV2
677{
678 fn into_proto(&self) -> crate::objects::audit_log_event_v1::RefreshDecisionWithReasonV2 {
679 let decision = match &self.decision {
680 SchedulingDecisionV1::On => {
681 crate::objects::audit_log_event_v1::RefreshDecision::On(Empty {})
682 }
683 SchedulingDecisionV1::Off => {
684 crate::objects::audit_log_event_v1::RefreshDecision::Off(Empty {})
685 }
686 };
687 crate::objects::audit_log_event_v1::RefreshDecisionWithReasonV2 {
688 decision,
689 objects_needing_refresh: self.objects_needing_refresh.clone(),
690 objects_needing_compaction: self.objects_needing_compaction.clone(),
691 rehydration_time_estimate: self.hydration_time_estimate.clone(),
692 }
693 }
694
695 fn from_proto(
696 proto: crate::objects::audit_log_event_v1::RefreshDecisionWithReasonV2,
697 ) -> Result<Self, TryFromProtoError> {
698 let decision = match proto.decision {
699 crate::objects::audit_log_event_v1::RefreshDecision::On(Empty {}) => {
700 SchedulingDecisionV1::On
701 }
702 crate::objects::audit_log_event_v1::RefreshDecision::Off(Empty {}) => {
703 SchedulingDecisionV1::Off
704 }
705 };
706 Ok(RefreshDecisionWithReasonV2 {
707 decision,
708 objects_needing_refresh: proto.objects_needing_refresh,
709 objects_needing_compaction: proto.objects_needing_compaction,
710 hydration_time_estimate: proto.rehydration_time_estimate,
711 })
712 }
713}
714
715impl RustType<crate::objects::audit_log_event_v1::CreateSourceSinkV1> for CreateSourceSinkV1 {
716 fn into_proto(&self) -> crate::objects::audit_log_event_v1::CreateSourceSinkV1 {
717 crate::objects::audit_log_event_v1::CreateSourceSinkV1 {
718 id: self.id.to_string(),
719 name: self.name.into_proto(),
720 size: self.size.as_ref().map(|s| crate::objects::StringWrapper {
721 inner: s.to_string(),
722 }),
723 }
724 }
725
726 fn from_proto(
727 proto: crate::objects::audit_log_event_v1::CreateSourceSinkV1,
728 ) -> Result<Self, TryFromProtoError> {
729 Ok(CreateSourceSinkV1 {
730 id: proto.id,
731 name: proto.name.into_rust()?,
732 size: proto.size.map(|s| s.inner),
733 })
734 }
735}
736
737impl RustType<crate::objects::audit_log_event_v1::CreateSourceSinkV2> for CreateSourceSinkV2 {
738 fn into_proto(&self) -> crate::objects::audit_log_event_v1::CreateSourceSinkV2 {
739 crate::objects::audit_log_event_v1::CreateSourceSinkV2 {
740 id: self.id.to_string(),
741 name: self.name.into_proto(),
742 size: self.size.as_ref().map(|s| crate::objects::StringWrapper {
743 inner: s.to_string(),
744 }),
745 external_type: self.external_type.to_string(),
746 }
747 }
748
749 fn from_proto(
750 proto: crate::objects::audit_log_event_v1::CreateSourceSinkV2,
751 ) -> Result<Self, TryFromProtoError> {
752 Ok(CreateSourceSinkV2 {
753 id: proto.id,
754 name: proto.name.into_rust()?,
755 size: proto.size.map(|s| s.inner),
756 external_type: proto.external_type,
757 })
758 }
759}
760
761impl RustType<crate::objects::audit_log_event_v1::CreateSourceSinkV3> for CreateSourceSinkV3 {
762 fn into_proto(&self) -> crate::objects::audit_log_event_v1::CreateSourceSinkV3 {
763 crate::objects::audit_log_event_v1::CreateSourceSinkV3 {
764 id: self.id.to_string(),
765 name: self.name.into_proto(),
766 external_type: self.external_type.to_string(),
767 }
768 }
769
770 fn from_proto(
771 proto: crate::objects::audit_log_event_v1::CreateSourceSinkV3,
772 ) -> Result<Self, TryFromProtoError> {
773 Ok(CreateSourceSinkV3 {
774 id: proto.id,
775 name: proto.name.into_rust()?,
776 external_type: proto.external_type,
777 })
778 }
779}
780
781impl RustType<crate::objects::audit_log_event_v1::CreateSourceSinkV4> for CreateSourceSinkV4 {
782 fn into_proto(&self) -> crate::objects::audit_log_event_v1::CreateSourceSinkV4 {
783 crate::objects::audit_log_event_v1::CreateSourceSinkV4 {
784 id: self.id.to_string(),
785 cluster_id: self
786 .cluster_id
787 .as_ref()
788 .map(|id| crate::objects::StringWrapper {
789 inner: id.to_string(),
790 }),
791 name: self.name.into_proto(),
792 external_type: self.external_type.to_string(),
793 }
794 }
795
796 fn from_proto(
797 proto: crate::objects::audit_log_event_v1::CreateSourceSinkV4,
798 ) -> Result<Self, TryFromProtoError> {
799 Ok(CreateSourceSinkV4 {
800 id: proto.id,
801 cluster_id: proto.cluster_id.map(|s| s.inner),
802 name: proto.name.into_rust()?,
803 external_type: proto.external_type,
804 })
805 }
806}
807
808impl RustType<crate::objects::audit_log_event_v1::CreateIndexV1> for CreateIndexV1 {
809 fn into_proto(&self) -> crate::objects::audit_log_event_v1::CreateIndexV1 {
810 crate::objects::audit_log_event_v1::CreateIndexV1 {
811 id: self.id.to_string(),
812 cluster_id: self.cluster_id.to_string(),
813 name: self.name.into_proto(),
814 }
815 }
816
817 fn from_proto(
818 proto: crate::objects::audit_log_event_v1::CreateIndexV1,
819 ) -> Result<Self, TryFromProtoError> {
820 Ok(CreateIndexV1 {
821 id: proto.id,
822 cluster_id: proto.cluster_id,
823 name: proto.name.into_rust()?,
824 })
825 }
826}
827
828impl RustType<crate::objects::audit_log_event_v1::CreateMaterializedViewV1>
829 for CreateMaterializedViewV1
830{
831 fn into_proto(&self) -> crate::objects::audit_log_event_v1::CreateMaterializedViewV1 {
832 crate::objects::audit_log_event_v1::CreateMaterializedViewV1 {
833 id: self.id.to_string(),
834 cluster_id: self.cluster_id.to_string(),
835 name: self.name.into_proto(),
836 replacement_target_id: self.replacement_target_id.into_proto(),
837 }
838 }
839
840 fn from_proto(
841 proto: crate::objects::audit_log_event_v1::CreateMaterializedViewV1,
842 ) -> Result<Self, TryFromProtoError> {
843 Ok(CreateMaterializedViewV1 {
844 id: proto.id,
845 cluster_id: proto.cluster_id,
846 name: proto.name.into_rust()?,
847 replacement_target_id: proto.replacement_target_id,
848 })
849 }
850}
851
852impl RustType<crate::objects::audit_log_event_v1::AlterApplyReplacementV1>
853 for AlterApplyReplacementV1
854{
855 fn into_proto(&self) -> crate::objects::audit_log_event_v1::AlterApplyReplacementV1 {
856 crate::objects::audit_log_event_v1::AlterApplyReplacementV1 {
857 target: self.target.into_proto(),
858 replacement: self.replacement.into_proto(),
859 }
860 }
861
862 fn from_proto(
863 proto: crate::objects::audit_log_event_v1::AlterApplyReplacementV1,
864 ) -> Result<Self, TryFromProtoError> {
865 Ok(AlterApplyReplacementV1 {
866 target: proto.target.into_rust()?,
867 replacement: proto.replacement.into_rust()?,
868 })
869 }
870}
871
872impl RustType<crate::objects::audit_log_event_v1::AlterSourceSinkV1> for AlterSourceSinkV1 {
873 fn into_proto(&self) -> crate::objects::audit_log_event_v1::AlterSourceSinkV1 {
874 crate::objects::audit_log_event_v1::AlterSourceSinkV1 {
875 id: self.id.to_string(),
876 name: self.name.into_proto(),
877 old_size: self
878 .old_size
879 .as_ref()
880 .map(|s| crate::objects::StringWrapper {
881 inner: s.to_string(),
882 }),
883 new_size: self
884 .new_size
885 .as_ref()
886 .map(|s| crate::objects::StringWrapper {
887 inner: s.to_string(),
888 }),
889 }
890 }
891
892 fn from_proto(
893 proto: crate::objects::audit_log_event_v1::AlterSourceSinkV1,
894 ) -> Result<Self, TryFromProtoError> {
895 Ok(AlterSourceSinkV1 {
896 id: proto.id,
897 name: proto.name.into_rust()?,
898 old_size: proto.old_size.map(|s| s.inner),
899 new_size: proto.new_size.map(|s| s.inner),
900 })
901 }
902}
903
904impl RustType<crate::objects::audit_log_event_v1::AlterSetClusterV1> for AlterSetClusterV1 {
905 fn into_proto(&self) -> crate::objects::audit_log_event_v1::AlterSetClusterV1 {
906 crate::objects::audit_log_event_v1::AlterSetClusterV1 {
907 id: self.id.to_string(),
908 name: self.name.into_proto(),
909 old_cluster_id: self.old_cluster_id.into_proto(),
910 new_cluster_id: self.new_cluster_id.into_proto(),
911 }
912 }
913
914 fn from_proto(
915 proto: crate::objects::audit_log_event_v1::AlterSetClusterV1,
916 ) -> Result<Self, TryFromProtoError> {
917 Ok(Self {
918 id: proto.id,
919 name: proto.name.into_rust()?,
920 old_cluster_id: proto.old_cluster_id,
921 new_cluster_id: proto.new_cluster_id,
922 })
923 }
924}
925
926impl RustType<crate::objects::audit_log_event_v1::GrantRoleV1> for GrantRoleV1 {
927 fn into_proto(&self) -> crate::objects::audit_log_event_v1::GrantRoleV1 {
928 crate::objects::audit_log_event_v1::GrantRoleV1 {
929 role_id: self.role_id.to_string(),
930 member_id: self.member_id.to_string(),
931 grantor_id: self.grantor_id.to_string(),
932 }
933 }
934
935 fn from_proto(
936 proto: crate::objects::audit_log_event_v1::GrantRoleV1,
937 ) -> Result<Self, TryFromProtoError> {
938 Ok(GrantRoleV1 {
939 role_id: proto.role_id,
940 member_id: proto.member_id,
941 grantor_id: proto.grantor_id,
942 })
943 }
944}
945
946impl RustType<crate::objects::audit_log_event_v1::GrantRoleV2> for GrantRoleV2 {
947 fn into_proto(&self) -> crate::objects::audit_log_event_v1::GrantRoleV2 {
948 crate::objects::audit_log_event_v1::GrantRoleV2 {
949 role_id: self.role_id.to_string(),
950 member_id: self.member_id.to_string(),
951 grantor_id: self.grantor_id.to_string(),
952 executed_by: self.executed_by.to_string(),
953 }
954 }
955
956 fn from_proto(
957 proto: crate::objects::audit_log_event_v1::GrantRoleV2,
958 ) -> Result<Self, TryFromProtoError> {
959 Ok(GrantRoleV2 {
960 role_id: proto.role_id,
961 member_id: proto.member_id,
962 grantor_id: proto.grantor_id,
963 executed_by: proto.executed_by,
964 })
965 }
966}
967
968impl RustType<crate::objects::audit_log_event_v1::RevokeRoleV1> for RevokeRoleV1 {
969 fn into_proto(&self) -> crate::objects::audit_log_event_v1::RevokeRoleV1 {
970 crate::objects::audit_log_event_v1::RevokeRoleV1 {
971 role_id: self.role_id.to_string(),
972 member_id: self.member_id.to_string(),
973 }
974 }
975
976 fn from_proto(
977 proto: crate::objects::audit_log_event_v1::RevokeRoleV1,
978 ) -> Result<Self, TryFromProtoError> {
979 Ok(RevokeRoleV1 {
980 role_id: proto.role_id,
981 member_id: proto.member_id,
982 })
983 }
984}
985
986impl RustType<crate::objects::audit_log_event_v1::RevokeRoleV2> for RevokeRoleV2 {
987 fn into_proto(&self) -> crate::objects::audit_log_event_v1::RevokeRoleV2 {
988 crate::objects::audit_log_event_v1::RevokeRoleV2 {
989 role_id: self.role_id.to_string(),
990 member_id: self.member_id.to_string(),
991 grantor_id: self.grantor_id.to_string(),
992 executed_by: self.executed_by.to_string(),
993 }
994 }
995
996 fn from_proto(
997 proto: crate::objects::audit_log_event_v1::RevokeRoleV2,
998 ) -> Result<Self, TryFromProtoError> {
999 Ok(RevokeRoleV2 {
1000 role_id: proto.role_id,
1001 member_id: proto.member_id,
1002 grantor_id: proto.grantor_id,
1003 executed_by: proto.executed_by,
1004 })
1005 }
1006}
1007
1008impl RustType<crate::objects::audit_log_event_v1::UpdatePrivilegeV1> for UpdatePrivilegeV1 {
1009 fn into_proto(&self) -> crate::objects::audit_log_event_v1::UpdatePrivilegeV1 {
1010 crate::objects::audit_log_event_v1::UpdatePrivilegeV1 {
1011 object_id: self.object_id.to_string(),
1012 grantee_id: self.grantee_id.to_string(),
1013 grantor_id: self.grantor_id.to_string(),
1014 privileges: self.privileges.to_string(),
1015 }
1016 }
1017
1018 fn from_proto(
1019 proto: crate::objects::audit_log_event_v1::UpdatePrivilegeV1,
1020 ) -> Result<Self, TryFromProtoError> {
1021 Ok(UpdatePrivilegeV1 {
1022 object_id: proto.object_id,
1023 grantee_id: proto.grantee_id,
1024 grantor_id: proto.grantor_id,
1025 privileges: proto.privileges,
1026 })
1027 }
1028}
1029
1030impl RustType<crate::objects::audit_log_event_v1::AlterDefaultPrivilegeV1>
1031 for AlterDefaultPrivilegeV1
1032{
1033 fn into_proto(&self) -> crate::objects::audit_log_event_v1::AlterDefaultPrivilegeV1 {
1034 crate::objects::audit_log_event_v1::AlterDefaultPrivilegeV1 {
1035 role_id: self.role_id.to_string(),
1036 database_id: self
1037 .database_id
1038 .as_ref()
1039 .map(|id| crate::objects::StringWrapper {
1040 inner: id.to_string(),
1041 }),
1042 schema_id: self
1043 .schema_id
1044 .as_ref()
1045 .map(|id| crate::objects::StringWrapper {
1046 inner: id.to_string(),
1047 }),
1048 grantee_id: self.grantee_id.to_string(),
1049 privileges: self.privileges.to_string(),
1050 }
1051 }
1052
1053 fn from_proto(
1054 proto: crate::objects::audit_log_event_v1::AlterDefaultPrivilegeV1,
1055 ) -> Result<Self, TryFromProtoError> {
1056 Ok(AlterDefaultPrivilegeV1 {
1057 role_id: proto.role_id,
1058 database_id: proto.database_id.map(|id| id.inner),
1059 schema_id: proto.schema_id.map(|id| id.inner),
1060 grantee_id: proto.grantee_id,
1061 privileges: proto.privileges,
1062 })
1063 }
1064}
1065
1066impl RustType<crate::objects::audit_log_event_v1::UpdateOwnerV1> for UpdateOwnerV1 {
1067 fn into_proto(&self) -> crate::objects::audit_log_event_v1::UpdateOwnerV1 {
1068 crate::objects::audit_log_event_v1::UpdateOwnerV1 {
1069 object_id: self.object_id.to_string(),
1070 old_owner_id: self.old_owner_id.to_string(),
1071 new_owner_id: self.new_owner_id.to_string(),
1072 }
1073 }
1074
1075 fn from_proto(
1076 proto: crate::objects::audit_log_event_v1::UpdateOwnerV1,
1077 ) -> Result<Self, TryFromProtoError> {
1078 Ok(UpdateOwnerV1 {
1079 object_id: proto.object_id,
1080 old_owner_id: proto.old_owner_id,
1081 new_owner_id: proto.new_owner_id,
1082 })
1083 }
1084}
1085
1086impl RustType<crate::objects::audit_log_event_v1::SchemaV1> for SchemaV1 {
1087 fn into_proto(&self) -> crate::objects::audit_log_event_v1::SchemaV1 {
1088 crate::objects::audit_log_event_v1::SchemaV1 {
1089 id: self.id.to_string(),
1090 name: self.name.to_string(),
1091 database_name: self.database_name.to_string(),
1092 }
1093 }
1094
1095 fn from_proto(
1096 proto: crate::objects::audit_log_event_v1::SchemaV1,
1097 ) -> Result<Self, TryFromProtoError> {
1098 Ok(SchemaV1 {
1099 id: proto.id,
1100 name: proto.name,
1101 database_name: proto.database_name,
1102 })
1103 }
1104}
1105
1106impl RustType<crate::objects::audit_log_event_v1::SchemaV2> for SchemaV2 {
1107 fn into_proto(&self) -> crate::objects::audit_log_event_v1::SchemaV2 {
1108 crate::objects::audit_log_event_v1::SchemaV2 {
1109 id: self.id.to_string(),
1110 name: self.name.to_string(),
1111 database_name: self
1112 .database_name
1113 .as_ref()
1114 .map(|d| crate::objects::StringWrapper {
1115 inner: d.to_string(),
1116 }),
1117 }
1118 }
1119
1120 fn from_proto(
1121 proto: crate::objects::audit_log_event_v1::SchemaV2,
1122 ) -> Result<Self, TryFromProtoError> {
1123 Ok(SchemaV2 {
1124 id: proto.id,
1125 name: proto.name,
1126 database_name: proto.database_name.map(|d| d.inner),
1127 })
1128 }
1129}
1130
1131impl RustType<crate::objects::audit_log_event_v1::RenameSchemaV1> for RenameSchemaV1 {
1132 fn into_proto(&self) -> crate::objects::audit_log_event_v1::RenameSchemaV1 {
1133 crate::objects::audit_log_event_v1::RenameSchemaV1 {
1134 id: self.id.to_string(),
1135 database_name: self.database_name.clone(),
1136 old_name: self.old_name.clone(),
1137 new_name: self.new_name.clone(),
1138 }
1139 }
1140
1141 fn from_proto(
1142 proto: crate::objects::audit_log_event_v1::RenameSchemaV1,
1143 ) -> Result<Self, TryFromProtoError> {
1144 Ok(RenameSchemaV1 {
1145 id: proto.id,
1146 database_name: proto.database_name,
1147 old_name: proto.old_name,
1148 new_name: proto.new_name,
1149 })
1150 }
1151}
1152
1153impl RustType<crate::objects::audit_log_event_v1::UpdateItemV1> for UpdateItemV1 {
1154 fn into_proto(&self) -> crate::objects::audit_log_event_v1::UpdateItemV1 {
1155 crate::objects::audit_log_event_v1::UpdateItemV1 {
1156 id: self.id.to_string(),
1157 name: self.name.into_proto(),
1158 }
1159 }
1160
1161 fn from_proto(
1162 proto: crate::objects::audit_log_event_v1::UpdateItemV1,
1163 ) -> Result<Self, TryFromProtoError> {
1164 Ok(UpdateItemV1 {
1165 id: proto.id,
1166 name: proto.name.into_rust()?,
1167 })
1168 }
1169}
1170
1171impl RustType<crate::objects::audit_log_event_v1::AlterRetainHistoryV1> for AlterRetainHistoryV1 {
1172 fn into_proto(&self) -> crate::objects::audit_log_event_v1::AlterRetainHistoryV1 {
1173 crate::objects::audit_log_event_v1::AlterRetainHistoryV1 {
1174 id: self.id.to_string(),
1175 old_history: self.old_history.clone(),
1176 new_history: self.new_history.clone(),
1177 }
1178 }
1179
1180 fn from_proto(
1181 proto: crate::objects::audit_log_event_v1::AlterRetainHistoryV1,
1182 ) -> Result<Self, TryFromProtoError> {
1183 Ok(AlterRetainHistoryV1 {
1184 id: proto.id,
1185 old_history: proto.old_history,
1186 new_history: proto.new_history,
1187 })
1188 }
1189}
1190
1191impl RustType<crate::objects::audit_log_event_v1::ToNewIdV1> for ToNewIdV1 {
1192 fn into_proto(&self) -> crate::objects::audit_log_event_v1::ToNewIdV1 {
1193 crate::objects::audit_log_event_v1::ToNewIdV1 {
1194 id: self.id.to_string(),
1195 new_id: self.new_id.to_string(),
1196 }
1197 }
1198
1199 fn from_proto(
1200 proto: crate::objects::audit_log_event_v1::ToNewIdV1,
1201 ) -> Result<Self, TryFromProtoError> {
1202 Ok(ToNewIdV1 {
1203 id: proto.id,
1204 new_id: proto.new_id,
1205 })
1206 }
1207}
1208
1209impl RustType<crate::objects::audit_log_event_v1::FromPreviousIdV1> for FromPreviousIdV1 {
1210 fn into_proto(&self) -> crate::objects::audit_log_event_v1::FromPreviousIdV1 {
1211 crate::objects::audit_log_event_v1::FromPreviousIdV1 {
1212 id: self.id.to_string(),
1213 previous_id: self.previous_id.to_string(),
1214 }
1215 }
1216
1217 fn from_proto(
1218 proto: crate::objects::audit_log_event_v1::FromPreviousIdV1,
1219 ) -> Result<Self, TryFromProtoError> {
1220 Ok(FromPreviousIdV1 {
1221 id: proto.id,
1222 previous_id: proto.previous_id,
1223 })
1224 }
1225}
1226
1227impl RustType<crate::objects::audit_log_event_v1::SetV1> for SetV1 {
1228 fn into_proto(&self) -> crate::objects::audit_log_event_v1::SetV1 {
1229 crate::objects::audit_log_event_v1::SetV1 {
1230 name: self.name.clone(),
1231 value: self.value.clone(),
1232 }
1233 }
1234
1235 fn from_proto(
1236 proto: crate::objects::audit_log_event_v1::SetV1,
1237 ) -> Result<Self, TryFromProtoError> {
1238 Ok(SetV1 {
1239 name: proto.name,
1240 value: proto.value,
1241 })
1242 }
1243}
1244
1245impl RustType<crate::objects::audit_log_event_v1::RotateKeysV1> for RotateKeysV1 {
1246 fn into_proto(&self) -> crate::objects::audit_log_event_v1::RotateKeysV1 {
1247 crate::objects::audit_log_event_v1::RotateKeysV1 {
1248 id: self.id.clone(),
1249 name: self.name.clone(),
1250 }
1251 }
1252
1253 fn from_proto(
1254 proto: crate::objects::audit_log_event_v1::RotateKeysV1,
1255 ) -> Result<Self, TryFromProtoError> {
1256 Ok(RotateKeysV1 {
1257 id: proto.id,
1258 name: proto.name,
1259 })
1260 }
1261}
1262
1263impl RustType<crate::objects::audit_log_event_v1::Details> for EventDetails {
1264 fn into_proto(&self) -> crate::objects::audit_log_event_v1::Details {
1265 use crate::objects::audit_log_event_v1::Details::*;
1266
1267 match self {
1268 EventDetails::CreateClusterReplicaV1(details) => {
1269 CreateClusterReplicaV1(details.into_proto())
1270 }
1271 EventDetails::CreateClusterReplicaV2(details) => {
1272 CreateClusterReplicaV2(details.into_proto())
1273 }
1274 EventDetails::CreateClusterReplicaV3(details) => {
1275 CreateClusterReplicaV3(details.into_proto())
1276 }
1277 EventDetails::CreateClusterReplicaV4(details) => {
1278 CreateClusterReplicaV4(details.into_proto())
1279 }
1280 EventDetails::DropClusterReplicaV1(details) => {
1281 DropClusterReplicaV1(details.into_proto())
1282 }
1283 EventDetails::DropClusterReplicaV2(details) => {
1284 DropClusterReplicaV2(details.into_proto())
1285 }
1286 EventDetails::DropClusterReplicaV3(details) => {
1287 DropClusterReplicaV3(details.into_proto())
1288 }
1289 EventDetails::CreateSourceSinkV1(details) => CreateSourceSinkV1(details.into_proto()),
1290 EventDetails::CreateSourceSinkV2(details) => CreateSourceSinkV2(details.into_proto()),
1291 EventDetails::CreateSourceSinkV3(details) => CreateSourceSinkV3(details.into_proto()),
1292 EventDetails::CreateSourceSinkV4(details) => CreateSourceSinkV4(details.into_proto()),
1293 EventDetails::CreateIndexV1(details) => CreateIndexV1(details.into_proto()),
1294 EventDetails::CreateMaterializedViewV1(details) => {
1295 CreateMaterializedViewV1(details.into_proto())
1296 }
1297 EventDetails::AlterApplyReplacementV1(details) => {
1298 AlterApplyReplacementV1(details.into_proto())
1299 }
1300 EventDetails::AlterSourceSinkV1(details) => AlterSourceSinkV1(details.into_proto()),
1301 EventDetails::AlterSetClusterV1(details) => AlterSetClusterV1(details.into_proto()),
1302 EventDetails::GrantRoleV1(details) => GrantRoleV1(details.into_proto()),
1303 EventDetails::GrantRoleV2(details) => GrantRoleV2(details.into_proto()),
1304 EventDetails::RevokeRoleV1(details) => RevokeRoleV1(details.into_proto()),
1305 EventDetails::RevokeRoleV2(details) => RevokeRoleV2(details.into_proto()),
1306 EventDetails::UpdatePrivilegeV1(details) => UpdatePrivilegeV1(details.into_proto()),
1307 EventDetails::AlterDefaultPrivilegeV1(details) => {
1308 AlterDefaultPrivilegeV1(details.into_proto())
1309 }
1310 EventDetails::UpdateOwnerV1(details) => UpdateOwnerV1(details.into_proto()),
1311 EventDetails::IdFullNameV1(details) => IdFullNameV1(details.into_proto()),
1312 EventDetails::RenameClusterV1(details) => RenameClusterV1(details.into_proto()),
1313 EventDetails::RenameClusterReplicaV1(details) => {
1314 RenameClusterReplicaV1(details.into_proto())
1315 }
1316 EventDetails::RenameItemV1(details) => RenameItemV1(details.into_proto()),
1317 EventDetails::IdNameV1(details) => IdNameV1(details.into_proto()),
1318 EventDetails::SchemaV1(details) => SchemaV1(details.into_proto()),
1319 EventDetails::SchemaV2(details) => SchemaV2(details.into_proto()),
1320 EventDetails::RenameSchemaV1(details) => RenameSchemaV1(details.into_proto()),
1321 EventDetails::UpdateItemV1(details) => UpdateItemV1(details.into_proto()),
1322 EventDetails::AlterRetainHistoryV1(details) => {
1323 AlterRetainHistoryV1(details.into_proto())
1324 }
1325 EventDetails::ToNewIdV1(details) => ToNewIdV1(details.into_proto()),
1326 EventDetails::FromPreviousIdV1(details) => FromPreviousIdV1(details.into_proto()),
1327 EventDetails::SetV1(details) => SetV1(details.into_proto()),
1328 EventDetails::ResetAllV1 => ResetAllV1(Empty {}),
1329 EventDetails::RotateKeysV1(details) => RotateKeysV1(details.into_proto()),
1330 }
1331 }
1332
1333 fn from_proto(
1334 proto: crate::objects::audit_log_event_v1::Details,
1335 ) -> Result<Self, TryFromProtoError> {
1336 use crate::objects::audit_log_event_v1::Details::*;
1337
1338 match proto {
1339 CreateClusterReplicaV1(details) => {
1340 Ok(EventDetails::CreateClusterReplicaV1(details.into_rust()?))
1341 }
1342 CreateClusterReplicaV2(details) => {
1343 Ok(EventDetails::CreateClusterReplicaV2(details.into_rust()?))
1344 }
1345 CreateClusterReplicaV3(details) => {
1346 Ok(EventDetails::CreateClusterReplicaV3(details.into_rust()?))
1347 }
1348 CreateClusterReplicaV4(details) => {
1349 Ok(EventDetails::CreateClusterReplicaV4(details.into_rust()?))
1350 }
1351 DropClusterReplicaV1(details) => {
1352 Ok(EventDetails::DropClusterReplicaV1(details.into_rust()?))
1353 }
1354 DropClusterReplicaV2(details) => {
1355 Ok(EventDetails::DropClusterReplicaV2(details.into_rust()?))
1356 }
1357 DropClusterReplicaV3(details) => {
1358 Ok(EventDetails::DropClusterReplicaV3(details.into_rust()?))
1359 }
1360 CreateSourceSinkV1(details) => {
1361 Ok(EventDetails::CreateSourceSinkV1(details.into_rust()?))
1362 }
1363 CreateSourceSinkV2(details) => {
1364 Ok(EventDetails::CreateSourceSinkV2(details.into_rust()?))
1365 }
1366 CreateSourceSinkV3(details) => {
1367 Ok(EventDetails::CreateSourceSinkV3(details.into_rust()?))
1368 }
1369 CreateSourceSinkV4(details) => {
1370 Ok(EventDetails::CreateSourceSinkV4(details.into_rust()?))
1371 }
1372 CreateIndexV1(details) => Ok(EventDetails::CreateIndexV1(details.into_rust()?)),
1373 CreateMaterializedViewV1(details) => {
1374 Ok(EventDetails::CreateMaterializedViewV1(details.into_rust()?))
1375 }
1376 AlterApplyReplacementV1(details) => {
1377 Ok(EventDetails::AlterApplyReplacementV1(details.into_rust()?))
1378 }
1379 AlterSourceSinkV1(details) => Ok(EventDetails::AlterSourceSinkV1(details.into_rust()?)),
1380 AlterSetClusterV1(details) => Ok(EventDetails::AlterSetClusterV1(details.into_rust()?)),
1381 GrantRoleV1(details) => Ok(EventDetails::GrantRoleV1(details.into_rust()?)),
1382 GrantRoleV2(details) => Ok(EventDetails::GrantRoleV2(details.into_rust()?)),
1383 RevokeRoleV1(details) => Ok(EventDetails::RevokeRoleV1(details.into_rust()?)),
1384 RevokeRoleV2(details) => Ok(EventDetails::RevokeRoleV2(details.into_rust()?)),
1385 UpdatePrivilegeV1(details) => Ok(EventDetails::UpdatePrivilegeV1(details.into_rust()?)),
1386 AlterDefaultPrivilegeV1(details) => {
1387 Ok(EventDetails::AlterDefaultPrivilegeV1(details.into_rust()?))
1388 }
1389 UpdateOwnerV1(details) => Ok(EventDetails::UpdateOwnerV1(details.into_rust()?)),
1390 IdFullNameV1(details) => Ok(EventDetails::IdFullNameV1(details.into_rust()?)),
1391 RenameClusterV1(details) => Ok(EventDetails::RenameClusterV1(details.into_rust()?)),
1392 RenameClusterReplicaV1(details) => {
1393 Ok(EventDetails::RenameClusterReplicaV1(details.into_rust()?))
1394 }
1395 RenameItemV1(details) => Ok(EventDetails::RenameItemV1(details.into_rust()?)),
1396 IdNameV1(details) => Ok(EventDetails::IdNameV1(details.into_rust()?)),
1397 SchemaV1(details) => Ok(EventDetails::SchemaV1(details.into_rust()?)),
1398 SchemaV2(details) => Ok(EventDetails::SchemaV2(details.into_rust()?)),
1399 RenameSchemaV1(details) => Ok(EventDetails::RenameSchemaV1(details.into_rust()?)),
1400 UpdateItemV1(details) => Ok(EventDetails::UpdateItemV1(details.into_rust()?)),
1401 AlterRetainHistoryV1(details) => {
1402 Ok(EventDetails::AlterRetainHistoryV1(details.into_rust()?))
1403 }
1404 ToNewIdV1(details) => Ok(EventDetails::ToNewIdV1(details.into_rust()?)),
1405 FromPreviousIdV1(details) => Ok(EventDetails::FromPreviousIdV1(details.into_rust()?)),
1406 SetV1(details) => Ok(EventDetails::SetV1(details.into_rust()?)),
1407 ResetAllV1(Empty {}) => Ok(EventDetails::ResetAllV1),
1408 RotateKeysV1(details) => Ok(EventDetails::RotateKeysV1(details.into_rust()?)),
1409 }
1410 }
1411}
1412
1413impl RustType<crate::objects::AuditLogEventV1> for EventV1 {
1414 fn into_proto(&self) -> crate::objects::AuditLogEventV1 {
1415 crate::objects::AuditLogEventV1 {
1416 id: self.id,
1417 event_type: self.event_type.into_proto(),
1418 object_type: self.object_type.into_proto(),
1419 user: self.user.as_ref().map(|u| crate::objects::StringWrapper {
1420 inner: u.to_string(),
1421 }),
1422 occurred_at: crate::objects::EpochMillis {
1423 millis: self.occurred_at,
1424 },
1425 details: self.details.into_proto(),
1426 }
1427 }
1428
1429 fn from_proto(proto: crate::objects::AuditLogEventV1) -> Result<Self, TryFromProtoError> {
1430 Ok(EventV1 {
1431 id: proto.id,
1432 event_type: proto.event_type.into_rust()?,
1433 object_type: proto.object_type.into_rust()?,
1434 details: proto.details.into_rust()?,
1435 user: proto.user.map(|u| u.inner),
1436 occurred_at: proto.occurred_at.into_rust()?,
1437 })
1438 }
1439}