1use mz_audit_log::{
17 AlterAddColumnV1, AlterApplyReplacementV1, AlterDefaultPrivilegeV1, AlterRetainHistoryV1,
18 AlterSetClusterV1, AlterSourceSinkV1, AlterSourceTimestampIntervalV1, CreateClusterReplicaV1,
19 CreateClusterReplicaV2, CreateClusterReplicaV3, CreateClusterReplicaV4, CreateIndexV1,
20 CreateMaterializedViewV1, CreateOrDropClusterReplicaReasonV1, CreateRoleV1, CreateSourceSinkV1,
21 CreateSourceSinkV2, CreateSourceSinkV3, CreateSourceSinkV4, DropClusterReplicaV1,
22 DropClusterReplicaV2, DropClusterReplicaV3, EventDetails, EventType, EventV1, FromPreviousIdV1,
23 FullNameV1, GrantRoleV1, GrantRoleV2, IdFullNameV1, IdNameV1, RefreshDecisionWithReasonV1,
24 RefreshDecisionWithReasonV2, RenameClusterReplicaV1, RenameClusterV1, RenameItemV1,
25 RenameSchemaV1, RevokeRoleV1, RevokeRoleV2, RotateKeysV1, SchedulingDecisionV1,
26 SchedulingDecisionsWithReasonsV1, SchedulingDecisionsWithReasonsV2, SchemaV1, SchemaV2, SetV1,
27 ToNewIdV1, UpdateItemV1, 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::AlterAddColumnV1> for AlterAddColumnV1 {
1192 fn into_proto(&self) -> crate::objects::audit_log_event_v1::AlterAddColumnV1 {
1193 crate::objects::audit_log_event_v1::AlterAddColumnV1 {
1194 id: self.id.to_string(),
1195 column: self.column.clone(),
1196 column_type: self.column_type.clone(),
1197 nullable: self.nullable,
1198 }
1199 }
1200
1201 fn from_proto(
1202 proto: crate::objects::audit_log_event_v1::AlterAddColumnV1,
1203 ) -> Result<Self, TryFromProtoError> {
1204 Ok(AlterAddColumnV1 {
1205 id: proto.id,
1206 column: proto.column,
1207 column_type: proto.column_type,
1208 nullable: proto.nullable,
1209 })
1210 }
1211}
1212
1213impl RustType<crate::objects::audit_log_event_v1::AlterSourceTimestampIntervalV1>
1214 for AlterSourceTimestampIntervalV1
1215{
1216 fn into_proto(&self) -> crate::objects::audit_log_event_v1::AlterSourceTimestampIntervalV1 {
1217 crate::objects::audit_log_event_v1::AlterSourceTimestampIntervalV1 {
1218 id: self.id.to_string(),
1219 old_interval: self.old_interval.clone(),
1220 new_interval: self.new_interval.clone(),
1221 }
1222 }
1223
1224 fn from_proto(
1225 proto: crate::objects::audit_log_event_v1::AlterSourceTimestampIntervalV1,
1226 ) -> Result<Self, TryFromProtoError> {
1227 Ok(AlterSourceTimestampIntervalV1 {
1228 id: proto.id,
1229 old_interval: proto.old_interval,
1230 new_interval: proto.new_interval,
1231 })
1232 }
1233}
1234
1235impl RustType<crate::objects::audit_log_event_v1::ToNewIdV1> for ToNewIdV1 {
1236 fn into_proto(&self) -> crate::objects::audit_log_event_v1::ToNewIdV1 {
1237 crate::objects::audit_log_event_v1::ToNewIdV1 {
1238 id: self.id.to_string(),
1239 new_id: self.new_id.to_string(),
1240 }
1241 }
1242
1243 fn from_proto(
1244 proto: crate::objects::audit_log_event_v1::ToNewIdV1,
1245 ) -> Result<Self, TryFromProtoError> {
1246 Ok(ToNewIdV1 {
1247 id: proto.id,
1248 new_id: proto.new_id,
1249 })
1250 }
1251}
1252
1253impl RustType<crate::objects::audit_log_event_v1::FromPreviousIdV1> for FromPreviousIdV1 {
1254 fn into_proto(&self) -> crate::objects::audit_log_event_v1::FromPreviousIdV1 {
1255 crate::objects::audit_log_event_v1::FromPreviousIdV1 {
1256 id: self.id.to_string(),
1257 previous_id: self.previous_id.to_string(),
1258 }
1259 }
1260
1261 fn from_proto(
1262 proto: crate::objects::audit_log_event_v1::FromPreviousIdV1,
1263 ) -> Result<Self, TryFromProtoError> {
1264 Ok(FromPreviousIdV1 {
1265 id: proto.id,
1266 previous_id: proto.previous_id,
1267 })
1268 }
1269}
1270
1271impl RustType<crate::objects::audit_log_event_v1::SetV1> for SetV1 {
1272 fn into_proto(&self) -> crate::objects::audit_log_event_v1::SetV1 {
1273 crate::objects::audit_log_event_v1::SetV1 {
1274 name: self.name.clone(),
1275 value: self.value.clone(),
1276 }
1277 }
1278
1279 fn from_proto(
1280 proto: crate::objects::audit_log_event_v1::SetV1,
1281 ) -> Result<Self, TryFromProtoError> {
1282 Ok(SetV1 {
1283 name: proto.name,
1284 value: proto.value,
1285 })
1286 }
1287}
1288
1289impl RustType<crate::objects::audit_log_event_v1::RotateKeysV1> for RotateKeysV1 {
1290 fn into_proto(&self) -> crate::objects::audit_log_event_v1::RotateKeysV1 {
1291 crate::objects::audit_log_event_v1::RotateKeysV1 {
1292 id: self.id.clone(),
1293 name: self.name.clone(),
1294 }
1295 }
1296
1297 fn from_proto(
1298 proto: crate::objects::audit_log_event_v1::RotateKeysV1,
1299 ) -> Result<Self, TryFromProtoError> {
1300 Ok(RotateKeysV1 {
1301 id: proto.id,
1302 name: proto.name,
1303 })
1304 }
1305}
1306
1307impl RustType<crate::objects::audit_log_event_v1::CreateRoleV1> for CreateRoleV1 {
1308 fn into_proto(&self) -> crate::objects::audit_log_event_v1::CreateRoleV1 {
1309 crate::objects::audit_log_event_v1::CreateRoleV1 {
1310 id: self.id.clone(),
1311 name: self.name.clone(),
1312 auto_provision_source: self.auto_provision_source.clone(),
1313 }
1314 }
1315
1316 fn from_proto(
1317 proto: crate::objects::audit_log_event_v1::CreateRoleV1,
1318 ) -> Result<Self, TryFromProtoError> {
1319 Ok(CreateRoleV1 {
1320 id: proto.id,
1321 name: proto.name,
1322 auto_provision_source: proto.auto_provision_source,
1323 })
1324 }
1325}
1326
1327impl RustType<crate::objects::audit_log_event_v1::Details> for EventDetails {
1328 fn into_proto(&self) -> crate::objects::audit_log_event_v1::Details {
1329 use crate::objects::audit_log_event_v1::Details::*;
1330
1331 match self {
1332 EventDetails::CreateClusterReplicaV1(details) => {
1333 CreateClusterReplicaV1(details.into_proto())
1334 }
1335 EventDetails::CreateClusterReplicaV2(details) => {
1336 CreateClusterReplicaV2(details.into_proto())
1337 }
1338 EventDetails::CreateClusterReplicaV3(details) => {
1339 CreateClusterReplicaV3(details.into_proto())
1340 }
1341 EventDetails::CreateClusterReplicaV4(details) => {
1342 CreateClusterReplicaV4(details.into_proto())
1343 }
1344 EventDetails::DropClusterReplicaV1(details) => {
1345 DropClusterReplicaV1(details.into_proto())
1346 }
1347 EventDetails::DropClusterReplicaV2(details) => {
1348 DropClusterReplicaV2(details.into_proto())
1349 }
1350 EventDetails::DropClusterReplicaV3(details) => {
1351 DropClusterReplicaV3(details.into_proto())
1352 }
1353 EventDetails::CreateSourceSinkV1(details) => CreateSourceSinkV1(details.into_proto()),
1354 EventDetails::CreateSourceSinkV2(details) => CreateSourceSinkV2(details.into_proto()),
1355 EventDetails::CreateSourceSinkV3(details) => CreateSourceSinkV3(details.into_proto()),
1356 EventDetails::CreateSourceSinkV4(details) => CreateSourceSinkV4(details.into_proto()),
1357 EventDetails::CreateIndexV1(details) => CreateIndexV1(details.into_proto()),
1358 EventDetails::CreateMaterializedViewV1(details) => {
1359 CreateMaterializedViewV1(details.into_proto())
1360 }
1361 EventDetails::AlterApplyReplacementV1(details) => {
1362 AlterApplyReplacementV1(details.into_proto())
1363 }
1364 EventDetails::AlterSourceSinkV1(details) => AlterSourceSinkV1(details.into_proto()),
1365 EventDetails::AlterSetClusterV1(details) => AlterSetClusterV1(details.into_proto()),
1366 EventDetails::GrantRoleV1(details) => GrantRoleV1(details.into_proto()),
1367 EventDetails::GrantRoleV2(details) => GrantRoleV2(details.into_proto()),
1368 EventDetails::RevokeRoleV1(details) => RevokeRoleV1(details.into_proto()),
1369 EventDetails::RevokeRoleV2(details) => RevokeRoleV2(details.into_proto()),
1370 EventDetails::UpdatePrivilegeV1(details) => UpdatePrivilegeV1(details.into_proto()),
1371 EventDetails::AlterDefaultPrivilegeV1(details) => {
1372 AlterDefaultPrivilegeV1(details.into_proto())
1373 }
1374 EventDetails::UpdateOwnerV1(details) => UpdateOwnerV1(details.into_proto()),
1375 EventDetails::IdFullNameV1(details) => IdFullNameV1(details.into_proto()),
1376 EventDetails::RenameClusterV1(details) => RenameClusterV1(details.into_proto()),
1377 EventDetails::RenameClusterReplicaV1(details) => {
1378 RenameClusterReplicaV1(details.into_proto())
1379 }
1380 EventDetails::RenameItemV1(details) => RenameItemV1(details.into_proto()),
1381 EventDetails::IdNameV1(details) => IdNameV1(details.into_proto()),
1382 EventDetails::SchemaV1(details) => SchemaV1(details.into_proto()),
1383 EventDetails::SchemaV2(details) => SchemaV2(details.into_proto()),
1384 EventDetails::RenameSchemaV1(details) => RenameSchemaV1(details.into_proto()),
1385 EventDetails::UpdateItemV1(details) => UpdateItemV1(details.into_proto()),
1386 EventDetails::AlterRetainHistoryV1(details) => {
1387 AlterRetainHistoryV1(details.into_proto())
1388 }
1389 EventDetails::AlterAddColumnV1(details) => AlterAddColumnV1(details.into_proto()),
1390 EventDetails::AlterSourceTimestampIntervalV1(details) => {
1391 AlterSourceTimestampIntervalV1(details.into_proto())
1392 }
1393 EventDetails::ToNewIdV1(details) => ToNewIdV1(details.into_proto()),
1394 EventDetails::FromPreviousIdV1(details) => FromPreviousIdV1(details.into_proto()),
1395 EventDetails::SetV1(details) => SetV1(details.into_proto()),
1396 EventDetails::ResetAllV1 => ResetAllV1(Empty {}),
1397 EventDetails::RotateKeysV1(details) => RotateKeysV1(details.into_proto()),
1398 EventDetails::CreateRoleV1(details) => CreateRoleV1(details.into_proto()),
1399 }
1400 }
1401
1402 fn from_proto(
1403 proto: crate::objects::audit_log_event_v1::Details,
1404 ) -> Result<Self, TryFromProtoError> {
1405 use crate::objects::audit_log_event_v1::Details::*;
1406
1407 match proto {
1408 CreateClusterReplicaV1(details) => {
1409 Ok(EventDetails::CreateClusterReplicaV1(details.into_rust()?))
1410 }
1411 CreateClusterReplicaV2(details) => {
1412 Ok(EventDetails::CreateClusterReplicaV2(details.into_rust()?))
1413 }
1414 CreateClusterReplicaV3(details) => {
1415 Ok(EventDetails::CreateClusterReplicaV3(details.into_rust()?))
1416 }
1417 CreateClusterReplicaV4(details) => {
1418 Ok(EventDetails::CreateClusterReplicaV4(details.into_rust()?))
1419 }
1420 DropClusterReplicaV1(details) => {
1421 Ok(EventDetails::DropClusterReplicaV1(details.into_rust()?))
1422 }
1423 DropClusterReplicaV2(details) => {
1424 Ok(EventDetails::DropClusterReplicaV2(details.into_rust()?))
1425 }
1426 DropClusterReplicaV3(details) => {
1427 Ok(EventDetails::DropClusterReplicaV3(details.into_rust()?))
1428 }
1429 CreateSourceSinkV1(details) => {
1430 Ok(EventDetails::CreateSourceSinkV1(details.into_rust()?))
1431 }
1432 CreateSourceSinkV2(details) => {
1433 Ok(EventDetails::CreateSourceSinkV2(details.into_rust()?))
1434 }
1435 CreateSourceSinkV3(details) => {
1436 Ok(EventDetails::CreateSourceSinkV3(details.into_rust()?))
1437 }
1438 CreateSourceSinkV4(details) => {
1439 Ok(EventDetails::CreateSourceSinkV4(details.into_rust()?))
1440 }
1441 CreateIndexV1(details) => Ok(EventDetails::CreateIndexV1(details.into_rust()?)),
1442 CreateMaterializedViewV1(details) => {
1443 Ok(EventDetails::CreateMaterializedViewV1(details.into_rust()?))
1444 }
1445 AlterApplyReplacementV1(details) => {
1446 Ok(EventDetails::AlterApplyReplacementV1(details.into_rust()?))
1447 }
1448 AlterSourceSinkV1(details) => Ok(EventDetails::AlterSourceSinkV1(details.into_rust()?)),
1449 AlterSetClusterV1(details) => Ok(EventDetails::AlterSetClusterV1(details.into_rust()?)),
1450 GrantRoleV1(details) => Ok(EventDetails::GrantRoleV1(details.into_rust()?)),
1451 GrantRoleV2(details) => Ok(EventDetails::GrantRoleV2(details.into_rust()?)),
1452 RevokeRoleV1(details) => Ok(EventDetails::RevokeRoleV1(details.into_rust()?)),
1453 RevokeRoleV2(details) => Ok(EventDetails::RevokeRoleV2(details.into_rust()?)),
1454 UpdatePrivilegeV1(details) => Ok(EventDetails::UpdatePrivilegeV1(details.into_rust()?)),
1455 AlterDefaultPrivilegeV1(details) => {
1456 Ok(EventDetails::AlterDefaultPrivilegeV1(details.into_rust()?))
1457 }
1458 UpdateOwnerV1(details) => Ok(EventDetails::UpdateOwnerV1(details.into_rust()?)),
1459 IdFullNameV1(details) => Ok(EventDetails::IdFullNameV1(details.into_rust()?)),
1460 RenameClusterV1(details) => Ok(EventDetails::RenameClusterV1(details.into_rust()?)),
1461 RenameClusterReplicaV1(details) => {
1462 Ok(EventDetails::RenameClusterReplicaV1(details.into_rust()?))
1463 }
1464 RenameItemV1(details) => Ok(EventDetails::RenameItemV1(details.into_rust()?)),
1465 IdNameV1(details) => Ok(EventDetails::IdNameV1(details.into_rust()?)),
1466 SchemaV1(details) => Ok(EventDetails::SchemaV1(details.into_rust()?)),
1467 SchemaV2(details) => Ok(EventDetails::SchemaV2(details.into_rust()?)),
1468 RenameSchemaV1(details) => Ok(EventDetails::RenameSchemaV1(details.into_rust()?)),
1469 UpdateItemV1(details) => Ok(EventDetails::UpdateItemV1(details.into_rust()?)),
1470 AlterRetainHistoryV1(details) => {
1471 Ok(EventDetails::AlterRetainHistoryV1(details.into_rust()?))
1472 }
1473 ToNewIdV1(details) => Ok(EventDetails::ToNewIdV1(details.into_rust()?)),
1474 FromPreviousIdV1(details) => Ok(EventDetails::FromPreviousIdV1(details.into_rust()?)),
1475 SetV1(details) => Ok(EventDetails::SetV1(details.into_rust()?)),
1476 ResetAllV1(Empty {}) => Ok(EventDetails::ResetAllV1),
1477 RotateKeysV1(details) => Ok(EventDetails::RotateKeysV1(details.into_rust()?)),
1478 CreateRoleV1(details) => Ok(EventDetails::CreateRoleV1(details.into_rust()?)),
1479 AlterAddColumnV1(details) => Ok(EventDetails::AlterAddColumnV1(details.into_rust()?)),
1480 AlterSourceTimestampIntervalV1(details) => Ok(
1481 EventDetails::AlterSourceTimestampIntervalV1(details.into_rust()?),
1482 ),
1483 }
1484 }
1485}
1486
1487impl RustType<crate::objects::AuditLogEventV1> for EventV1 {
1488 fn into_proto(&self) -> crate::objects::AuditLogEventV1 {
1489 crate::objects::AuditLogEventV1 {
1490 id: self.id,
1491 event_type: self.event_type.into_proto(),
1492 object_type: self.object_type.into_proto(),
1493 user: self.user.as_ref().map(|u| crate::objects::StringWrapper {
1494 inner: u.to_string(),
1495 }),
1496 occurred_at: crate::objects::EpochMillis {
1497 millis: self.occurred_at,
1498 },
1499 details: self.details.into_proto(),
1500 }
1501 }
1502
1503 fn from_proto(proto: crate::objects::AuditLogEventV1) -> Result<Self, TryFromProtoError> {
1504 Ok(EventV1 {
1505 id: proto.id,
1506 event_type: proto.event_type.into_rust()?,
1507 object_type: proto.object_type.into_rust()?,
1508 details: proto.details.into_rust()?,
1509 user: proto.user.map(|u| u.inner),
1510 occurred_at: proto.occurred_at.into_rust()?,
1511 })
1512 }
1513}