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