Line data Source code
1 : use serde::{Deserialize, Serialize};
2 : use std::fmt::Display;
3 : use utils::id::{EndpointId, TenantId, TimelineId};
4 :
5 : /// Claims to add, remove, or retrieve endpoint data. Used by compute_ctl
6 0 : #[derive(Deserialize, Serialize, PartialEq)]
7 : pub struct EndpointStorageClaims {
8 : pub tenant_id: TenantId,
9 : pub timeline_id: TimelineId,
10 : pub endpoint_id: EndpointId,
11 : pub exp: u64,
12 : }
13 :
14 : /// Claims to remove tenant, timeline, or endpoint data. Used by control plane
15 0 : #[derive(Deserialize, Serialize, PartialEq)]
16 : pub struct DeletePrefixClaims {
17 : pub tenant_id: TenantId,
18 : /// None when tenant is deleted (endpoint_id is also None in this case)
19 : pub timeline_id: Option<TimelineId>,
20 : /// None when timeline is deleted
21 : pub endpoint_id: Option<EndpointId>,
22 : pub exp: u64,
23 : }
24 :
25 : impl Display for EndpointStorageClaims {
26 0 : fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27 0 : write!(
28 0 : f,
29 0 : "EndpointClaims(tenant_id={} timeline_id={} endpoint_id={} exp={})",
30 : self.tenant_id, self.timeline_id, self.endpoint_id, self.exp
31 : )
32 0 : }
33 : }
34 :
35 : impl Display for DeletePrefixClaims {
36 0 : fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
37 0 : write!(
38 0 : f,
39 0 : "DeletePrefixClaims(tenant_id={} timeline_id={} endpoint_id={}, exp={})",
40 : self.tenant_id,
41 0 : self.timeline_id
42 0 : .as_ref()
43 0 : .map(ToString::to_string)
44 0 : .unwrap_or("".to_string()),
45 0 : self.endpoint_id
46 0 : .as_ref()
47 0 : .map(ToString::to_string)
48 0 : .unwrap_or("".to_string()),
49 : self.exp
50 : )
51 0 : }
52 : }
|