1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// This file is @generated by prost-build.
/// How a Grant was created.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum GrantSource {
Unspecified = 0,
/// Derived from a Trial row.
TrialProduct = 1,
TrialSubscription = 2,
TrialPlan = 3,
TrialEnterprise = 4,
/// Promo-code redemption.
Promo = 5,
/// Recurring quota credit (e.g. monthly free errors).
Recurring = 6,
/// One-off admin/support gift.
Gift = 7,
}
impl GrantSource {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "GRANT_SOURCE_UNSPECIFIED",
Self::TrialProduct => "GRANT_SOURCE_TRIAL_PRODUCT",
Self::TrialSubscription => "GRANT_SOURCE_TRIAL_SUBSCRIPTION",
Self::TrialPlan => "GRANT_SOURCE_TRIAL_PLAN",
Self::TrialEnterprise => "GRANT_SOURCE_TRIAL_ENTERPRISE",
Self::Promo => "GRANT_SOURCE_PROMO",
Self::Recurring => "GRANT_SOURCE_RECURRING",
Self::Gift => "GRANT_SOURCE_GIFT",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"GRANT_SOURCE_UNSPECIFIED" => Some(Self::Unspecified),
"GRANT_SOURCE_TRIAL_PRODUCT" => Some(Self::TrialProduct),
"GRANT_SOURCE_TRIAL_SUBSCRIPTION" => Some(Self::TrialSubscription),
"GRANT_SOURCE_TRIAL_PLAN" => Some(Self::TrialPlan),
"GRANT_SOURCE_TRIAL_ENTERPRISE" => Some(Self::TrialEnterprise),
"GRANT_SOURCE_PROMO" => Some(Self::Promo),
"GRANT_SOURCE_RECURRING" => Some(Self::Recurring),
"GRANT_SOURCE_GIFT" => Some(Self::Gift),
_ => None,
}
}
}
/// A non-billable quota allowance for an organization within a time window.
///
/// Grants can be offset by counter-grants: separate Grant rows with a negative
/// amount. The effective amount is the original amount plus the sum of all
/// counter-grant amounts, netted server-side and returned via
/// GetEffectiveGrants.
///
/// UNITS grants have exactly one entry in line_item_uids. CENTS grants may
/// have several.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Grant {
#[prost(uint64, tag = "1")]
pub id: u64,
#[prost(uint64, tag = "2")]
pub organization_id: u64,
#[prost(enumeration = "GrantType", tag = "3")]
pub r#type: i32,
/// The line items this grant applies to.
#[prost(string, repeated, tag = "4")]
pub line_item_uids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// The original amount. May be negative for counter-grants.
#[prost(int64, tag = "5")]
pub amount: i64,
#[prost(message, optional, tag = "6")]
pub start_date: ::core::option::Option<super::super::super::Date>,
#[prost(message, optional, tag = "7")]
pub end_date: ::core::option::Option<super::super::super::Date>,
#[prost(enumeration = "GrantStatus", tag = "8")]
pub status: i32,
#[prost(enumeration = "GrantSource", tag = "9")]
pub source: i32,
}
/// Denomination of a Grant.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum GrantType {
Unspecified = 0,
/// A quantity of units for specific line items.
Units = 1,
/// A monetary allowance measured in cents.
Cents = 2,
}
impl GrantType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "GRANT_TYPE_UNSPECIFIED",
Self::Units => "GRANT_TYPE_UNITS",
Self::Cents => "GRANT_TYPE_CENTS",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"GRANT_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
"GRANT_TYPE_UNITS" => Some(Self::Units),
"GRANT_TYPE_CENTS" => Some(Self::Cents),
_ => None,
}
}
}
/// Lifecycle state of a Grant.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum GrantStatus {
Unspecified = 0,
/// Consumable now; within \[start_date, end_date\].
Active = 1,
/// Manually deactivated (admin revoke, customer opt-out, etc.).
Inactive = 2,
/// Past end_date.
Expired = 3,
}
impl GrantStatus {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "GRANT_STATUS_UNSPECIFIED",
Self::Active => "GRANT_STATUS_ACTIVE",
Self::Inactive => "GRANT_STATUS_INACTIVE",
Self::Expired => "GRANT_STATUS_EXPIRED",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"GRANT_STATUS_UNSPECIFIED" => Some(Self::Unspecified),
"GRANT_STATUS_ACTIVE" => Some(Self::Active),
"GRANT_STATUS_INACTIVE" => Some(Self::Inactive),
"GRANT_STATUS_EXPIRED" => Some(Self::Expired),
_ => None,
}
}
}
/// A grant with counter-grant chains collapsed into a single effective amount.
/// Returned in drain priority order (end_date ASC, effective_amount ASC, grant_id ASC).
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct EffectiveGrant {
#[prost(uint64, tag = "1")]
pub grant_id: u64,
#[prost(enumeration = "GrantType", tag = "2")]
pub r#type: i32,
#[prost(string, repeated, tag = "3")]
pub line_item_uids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Usable amount after counter-grant collapse; always > 0.
#[prost(int64, tag = "4")]
pub effective_amount: i64,
/// The grant's own active window, inclusive on both ends. These are the
/// grant's stored dates, not clipped to the query window: the grant applies
/// only to usage on days within \[start_date, end_date\], so a grant ending
/// mid-window stops covering usage after end_date.
#[prost(message, optional, tag = "5")]
pub start_date: ::core::option::Option<super::super::super::Date>,
#[prost(message, optional, tag = "6")]
pub end_date: ::core::option::Option<super::super::super::Date>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetEffectiveGrantsRequest {
#[prost(uint64, tag = "1")]
pub organization_id: u64,
/// When set, returns only grants whose line_item_uids contain this value.
#[prost(string, optional, tag = "2")]
pub line_item_uid: ::core::option::Option<::prost::alloc::string::String>,
/// start_date / end_date define the query window. A grant is returned if its
/// own \[start_date, end_date\] overlaps this window (grant.start_date \<=
/// end_date AND grant.end_date >= start_date), inclusive on both ends. A grant
/// that begins before the window or ends inside it is therefore included.
/// Returned grants apply only to usage on the days each grant is itself active
/// — a grant ending mid-window does not cover usage after its end_date.
#[prost(message, optional, tag = "3")]
pub start_date: ::core::option::Option<super::super::super::Date>,
#[prost(message, optional, tag = "4")]
pub end_date: ::core::option::Option<super::super::super::Date>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetEffectiveGrantsResponse {
/// Grants with counter-chains collapsed, sorted by drain priority.
#[prost(message, repeated, tag = "1")]
pub effective_grants: ::prost::alloc::vec::Vec<EffectiveGrant>,
}