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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
// this file is @generated
#![allow(clippy::doc_markdown, clippy::default_trait_access)]
#[allow(unused_imports, clippy::wildcard_imports)]
use crate::{error::Result, models::*, Configuration};
/// Query and header parameters of [`Licenses::list`].
#[derive(Clone, Debug, Default)]
#[non_exhaustive]
pub struct LicensesListOptions {
/// Filter by customer ID or alias
pub customer_id: Option<String>,
/// The `subscription_id` query parameter.
pub subscription_id: Option<String>,
/// Include revoked licenses. Default: false.
pub include_revoked: Option<bool>,
}
impl LicensesListOptions {
/// Options with no parameter set.
#[must_use]
pub fn new() -> Self {
Self {
customer_id: None,
subscription_id: None,
include_revoked: None,
}
}
/// Sets the `customer_id` query parameter.
#[must_use]
pub fn customer_id(mut self, customer_id: impl Into<String>) -> Self {
self.customer_id = Some(customer_id.into());
self
}
/// Sets the `customer_id` query parameter, or unsets it with `None`.
#[must_use]
pub fn maybe_customer_id(mut self, customer_id: Option<String>) -> Self {
self.customer_id = customer_id;
self
}
/// Sets the `subscription_id` query parameter.
#[must_use]
pub fn subscription_id(mut self, subscription_id: impl Into<String>) -> Self {
self.subscription_id = Some(subscription_id.into());
self
}
/// Sets the `subscription_id` query parameter, or unsets it with `None`.
#[must_use]
pub fn maybe_subscription_id(mut self, subscription_id: Option<String>) -> Self {
self.subscription_id = subscription_id;
self
}
/// Sets the `include_revoked` query parameter.
#[must_use]
pub fn include_revoked(mut self, include_revoked: impl Into<bool>) -> Self {
self.include_revoked = Some(include_revoked.into());
self
}
/// Sets the `include_revoked` query parameter, or unsets it with `None`.
#[must_use]
pub fn maybe_include_revoked(mut self, include_revoked: Option<bool>) -> Self {
self.include_revoked = include_revoked;
self
}
}
/// The licenses API, from the client's
/// [`licenses`](crate::api::Meteroid::licenses).
#[derive(Clone)]
pub struct Licenses {
cfg: std::sync::Arc<Configuration>,
options: crate::api::RequestOptions,
}
impl std::fmt::Debug for Licenses {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Licenses")
.field("options", &self.options)
.finish_non_exhaustive()
}
}
impl Licenses {
pub(super) fn new(cfg: std::sync::Arc<Configuration>) -> Self {
Self {
cfg,
options: crate::api::RequestOptions::default(),
}
}
/// Applies `options` (headers, timeout, retries, idempotency key) to the calls made
/// through the returned value.
#[must_use]
pub fn with_options(mut self, options: crate::api::RequestOptions) -> Self {
self.options = options;
self
}
/// List licenses
///
/// `GET /api/v1/licenses`.
///
/// # Errors
///
/// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (401, 404, 429).
pub fn list(
&self,
options: impl Into<Option<LicensesListOptions>>,
) -> crate::api::Call<crate::models::LicenseListResponse> {
let LicensesListOptions {
customer_id,
subscription_id,
include_revoked,
} = options.into().unwrap_or_default();
crate::request::Request::new(http::Method::GET, "/api/v1/licenses")
.with_optional_query_param("customer_id", customer_id)
.with_optional_query_param("subscription_id", subscription_id)
.with_optional_query_param("include_revoked", include_revoked)
.with_options(&self.options)
.json(&self.cfg)
}
/// Issue a license
///
/// Issues a license to a customer, optionally tied to one of its subscriptions. Online, the
/// license is pending until their installation activates it with the returned one-time code.
/// Offline, it is returned signed at once, for an installation that can't reach the server.
///
/// `POST /api/v1/licenses`.
///
/// # Errors
///
/// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (400, 401, 403, 404, 409, 429).
pub fn create(
&self,
issue_license_request: crate::models::IssueLicenseRequest,
) -> crate::api::Call<crate::models::IssueLicenseResponse> {
crate::request::Request::new(http::Method::POST, "/api/v1/licenses")
.with_body_param(issue_license_request)
.with_options(&self.options)
.json(&self.cfg)
}
/// Get a license
///
/// `GET /api/v1/licenses/{license_id}`.
///
/// # Errors
///
/// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (401, 404, 429).
pub fn retrieve(
&self,
license_id: impl Into<crate::models::LicenseId>,
) -> crate::api::Call<crate::models::License> {
crate::request::Request::new(http::Method::GET, "/api/v1/licenses/{license_id}")
.with_path_param(
"license_id",
Into::<crate::models::LicenseId>::into(license_id),
)
.with_options(&self.options)
.json(&self.cfg)
}
/// Get a license's activation code
///
/// Available until the license is activated or revoked; for an ephemeral license, until revoked.
///
/// `GET /api/v1/licenses/{license_id}/activation-code`.
///
/// # Errors
///
/// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (401, 404, 429).
pub fn retrieve_activation_code(
&self,
license_id: impl Into<crate::models::LicenseId>,
) -> crate::api::Call<crate::models::LicenseActivationCode> {
crate::request::Request::new(
http::Method::GET,
"/api/v1/licenses/{license_id}/activation-code",
)
.with_path_param(
"license_id",
Into::<crate::models::LicenseId>::into(license_id),
)
.with_options(&self.options)
.json(&self.cfg)
}
/// Issue an offline license
///
/// Signs a long-lived license for an air-gapped installation from an existing license, e.g. to
/// renew an offline license before it expires. Given an instance id, binds the license to it.
///
/// `POST /api/v1/licenses/{license_id}/offline`.
///
/// # Errors
///
/// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (400, 401, 403, 404, 409, 429).
pub fn offline(
&self,
license_id: impl Into<crate::models::LicenseId>,
issue_offline_license_request: crate::models::IssueOfflineLicenseRequest,
) -> crate::api::Call<crate::models::OfflineLicense> {
crate::request::Request::new(http::Method::POST, "/api/v1/licenses/{license_id}/offline")
.with_path_param(
"license_id",
Into::<crate::models::LicenseId>::into(license_id),
)
.with_body_param(issue_offline_license_request)
.with_options(&self.options)
.json(&self.cfg)
}
/// Revoke a license
///
/// `POST /api/v1/licenses/{license_id}/revoke`.
///
/// # Errors
///
/// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (401, 404, 429).
pub fn revoke(
&self,
license_id: impl Into<crate::models::LicenseId>,
revoke_license_request: crate::models::RevokeLicenseRequest,
) -> crate::api::Call<crate::models::License> {
crate::request::Request::new(http::Method::POST, "/api/v1/licenses/{license_id}/revoke")
.with_path_param(
"license_id",
Into::<crate::models::LicenseId>::into(license_id),
)
.with_body_param(revoke_license_request)
.with_options(&self.options)
.json(&self.cfg)
}
/// Get the licensing signing keys
///
/// The keys licenses are signed with, and the public endpoints installations talk to.
///
/// `GET /api/v1/licensing/signing-keys`.
///
/// # Errors
///
/// An API error's body is [`RestErrorResponse`](crate::models::RestErrorResponse) (401, 403, 429).
pub fn list_licensing_signing_keys(
&self,
) -> crate::api::Call<crate::models::LicenseSigningKeysResponse> {
crate::request::Request::new(http::Method::GET, "/api/v1/licensing/signing-keys")
.with_options(&self.options)
.json(&self.cfg)
}
}