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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
//! `EntitlementResource` and the licence-scoped [`LicenseEntitlement`].
//!
//! Fields: `name`, `code`, `kind`, `metadata`, `created`, `updated`.
//!
//! `code` is the stable, developer-facing identifier — `name` is just a
//! display label. [`crate::Client::has_entitlement`] matches on
//! `code`, never `name`. Despite the URL nesting under
//! `/licenses/{id}/entitlements`, these are full `Entitlement` resources,
//! not lightweight junction/relationship records.
//!
//! `kind` ([`EntitlementKind`]) is a required, always-present field: `Flag`
//! is a boolean grant (the only kind that existed before entitlement
//! metering), `Meter` is a named, per-license counter with an independent
//! cap. It is meaningful on every scope an entitlement is read from, so it
//! lives on the shared [`EntitlementAttributes`], not only on the
//! licence-scoped shape below.
//!
//! The licence-scoped **list** route (and the metering actions —
//! [`crate::Client::increment_entitlement_usage`],
//! [`crate::Client::decrement_entitlement_usage`],
//! [`crate::Client::reset_entitlement_usage`] — which return the same shape)
//! carry attributes the others do not: `inherited`, true when the licence
//! holds the entitlement through its policy rather than by a direct
//! attachment; `max_value`, the effective cap for a `kind: "meter"`
//! entitlement (nullable — `None` means unlimited, meaningless for a
//! `flag`); and `current_value`, the running count (`0` if never
//! incremented, which also means "only inherited, never directly attached"
//! — see [`LicenseEntitlementAttributes::current_value`]). `inherited`
//! decides what a caller can do with the row — an inherited entitlement
//! cannot be detached (`403 POLICY_ENTITLEMENT`), re-attaching it fails
//! (`422 ENTITLEMENT_ALREADY_INHERITED`), and, because the item route
//! resolves direct attachments only, `GET .../entitlements/{id}` on it
//! **404s**. Read it via [`crate::Client::list_license_entitlements`], which
//! returns [`LicenseEntitlement`]; [`EntitlementResource`] itself is shared
//! with the account-, policy- and release-scoped routes, where the server
//! emits none of `inherited`/`max_value`/`current_value`.
/// The `entitlements` JSON:API resource: `{ id, type, attributes }`. Field
/// set matches the Tamga API's actual full `EntitlementResource` serializer —
/// confirmed the license-scoped list/get endpoints return this, not the
/// lightweight `LicenseEntitlementResource` junction resource (which only
/// carries `created`/`updated` timestamps).
/// Attributes of an [`EntitlementResource`].
/// Whether an [`EntitlementResource`] is a boolean grant or a named,
/// per-license counter with an independent cap.
///
/// Always present on the wire — never optional or defaulted, unlike most of
/// this crate's forward-compatible fields. Deserializes any unrecognized
/// wire value into `Unknown(String)` rather than failing, the same
/// hand-written approach (not `#[serde(other)]`, which only fits unit
/// variants and would drop the string) as
/// [`crate::models::validation::ValidationCode`] — so a future server-side
/// kind cannot hard-break deserialization of every entitlement response.
/// One row of `GET /licenses/{id}/entitlements` — an
/// [`EntitlementResource`] plus the licence-scoped `inherited` flag the
/// shared resource type has no field for.
///
/// Returned by [`crate::Client::list_license_entitlements`]. The plain
/// [`crate::Client::list_entitlements`] parses the same response into bare
/// [`EntitlementResource`]s and drops the flag; use this variant whenever
/// the caller intends to act on a row (detach it, re-attach it, or fetch it
/// by id), because all three of those behave differently for an inherited
/// entitlement.
/// Attributes of a [`LicenseEntitlement`] — [`EntitlementAttributes`] plus
/// `inherited`, `max_value` and `current_value`.