fastly_api/apis/
tls_subscriptions_api.rs

1/*
2 * Fastly API
3 *
4 * Via the Fastly API you can perform any of the operations that are possible within the management console,  including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The API is organized into collections of endpoints that allow manipulation of objects related to Fastly services and accounts. For the most accurate and up-to-date API reference content, visit our [Developer Hub](https://www.fastly.com/documentation/reference/api/) 
5 *
6 */
7
8
9use reqwest;
10
11use crate::apis::ResponseContent;
12use super::{Error, configuration};
13
14/// struct for passing parameters to the method [`create_globalsign_email_challenge`]
15#[derive(Clone, Debug, Default)]
16pub struct CreateGlobalsignEmailChallengeParams {
17    /// Alphanumeric string identifying a TLS subscription.
18    pub tls_subscription_id: String,
19    /// Alphanumeric string identifying a TLS subscription.
20    pub tls_authorization_id: String,
21    pub request_body: Option<::std::collections::HashMap<String, serde_json::Value>>
22}
23
24/// struct for passing parameters to the method [`create_tls_sub`]
25#[derive(Clone, Debug, Default)]
26pub struct CreateTlsSubParams {
27    /// A flag that allows you to edit and delete a subscription with active domains. Valid to use on PATCH and DELETE actions. As a warning, removing an active domain from a subscription or forcing the deletion of a subscription may result in breaking TLS termination to that domain. 
28    pub force: Option<bool>,
29    pub tls_subscription: Option<crate::models::TlsSubscription>
30}
31
32/// struct for passing parameters to the method [`delete_globalsign_email_challenge`]
33#[derive(Clone, Debug, Default)]
34pub struct DeleteGlobalsignEmailChallengeParams {
35    /// Alphanumeric string identifying a TLS subscription.
36    pub tls_subscription_id: String,
37    /// Alphanumeric string identifying a TLS subscription.
38    pub tls_authorization_id: String,
39    /// Alphanumeric string identifying a GlobalSign email challenge.
40    pub globalsign_email_challenge_id: String
41}
42
43/// struct for passing parameters to the method [`delete_tls_sub`]
44#[derive(Clone, Debug, Default)]
45pub struct DeleteTlsSubParams {
46    /// Alphanumeric string identifying a TLS subscription.
47    pub tls_subscription_id: String
48}
49
50/// struct for passing parameters to the method [`get_tls_sub`]
51#[derive(Clone, Debug, Default)]
52pub struct GetTlsSubParams {
53    /// Alphanumeric string identifying a TLS subscription.
54    pub tls_subscription_id: String,
55    /// Include related objects. Optional, comma-separated values. Permitted values: `tls_authorizations`, `tls_authorizations.globalsign_email_challenge`, `tls_authorizations.self_managed_http_challenge`, and `tls_certificates`. 
56    pub include: Option<String>
57}
58
59/// struct for passing parameters to the method [`list_tls_subs`]
60#[derive(Clone, Debug, Default)]
61pub struct ListTlsSubsParams {
62    /// Limit the returned subscriptions by state. Valid values are `pending`, `processing`, `issued`, `renewing`, and `failed`. Accepts parameters: `not` (e.g., `filter[state][not]=renewing`). 
63    pub filter_state: Option<String>,
64    /// Limit the returned subscriptions to those that include the specific domain.
65    pub filter_tls_domains_id: Option<String>,
66    /// Limit the returned subscriptions to those that have currently active orders. Permitted values: `true`. 
67    pub filter_has_active_order: Option<bool>,
68    /// Limit the returned subscriptions to a specific certification authority. Values may include `certainly`, `lets-encrypt`, or `globalsign`. 
69    pub filter_certificate_authority: Option<String>,
70    /// The order in which to list the results.
71    pub sort: Option<String>,
72    /// Include related objects. Optional, comma-separated values. Permitted values: `tls_authorizations`, `tls_authorizations.globalsign_email_challenge`, `tls_authorizations.self_managed_http_challenge`, and `tls_certificates`. 
73    pub include: Option<String>,
74    /// Current page.
75    pub page_number: Option<i32>,
76    /// Number of records per page.
77    pub page_size: Option<i32>
78}
79
80/// struct for passing parameters to the method [`patch_tls_sub`]
81#[derive(Clone, Debug, Default)]
82pub struct PatchTlsSubParams {
83    /// Alphanumeric string identifying a TLS subscription.
84    pub tls_subscription_id: String,
85    /// A flag that allows you to edit and delete a subscription with active domains. Valid to use on PATCH and DELETE actions. As a warning, removing an active domain from a subscription or forcing the deletion of a subscription may result in breaking TLS termination to that domain. 
86    pub force: Option<bool>,
87    pub tls_subscription: Option<crate::models::TlsSubscription>
88}
89
90
91/// struct for typed errors of method [`create_globalsign_email_challenge`]
92#[derive(Debug, Clone, Serialize, Deserialize)]
93#[serde(untagged)]
94pub enum CreateGlobalsignEmailChallengeError {
95    UnknownValue(serde_json::Value),
96}
97
98/// struct for typed errors of method [`create_tls_sub`]
99#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum CreateTlsSubError {
102    UnknownValue(serde_json::Value),
103}
104
105/// struct for typed errors of method [`delete_globalsign_email_challenge`]
106#[derive(Debug, Clone, Serialize, Deserialize)]
107#[serde(untagged)]
108pub enum DeleteGlobalsignEmailChallengeError {
109    UnknownValue(serde_json::Value),
110}
111
112/// struct for typed errors of method [`delete_tls_sub`]
113#[derive(Debug, Clone, Serialize, Deserialize)]
114#[serde(untagged)]
115pub enum DeleteTlsSubError {
116    UnknownValue(serde_json::Value),
117}
118
119/// struct for typed errors of method [`get_tls_sub`]
120#[derive(Debug, Clone, Serialize, Deserialize)]
121#[serde(untagged)]
122pub enum GetTlsSubError {
123    UnknownValue(serde_json::Value),
124}
125
126/// struct for typed errors of method [`list_tls_subs`]
127#[derive(Debug, Clone, Serialize, Deserialize)]
128#[serde(untagged)]
129pub enum ListTlsSubsError {
130    UnknownValue(serde_json::Value),
131}
132
133/// struct for typed errors of method [`patch_tls_sub`]
134#[derive(Debug, Clone, Serialize, Deserialize)]
135#[serde(untagged)]
136pub enum PatchTlsSubError {
137    UnknownValue(serde_json::Value),
138}
139
140
141/// Creates an email challenge for a domain on a GlobalSign subscription. An email challenge will generate an email that can be used to validate domain ownership. If this challenge is created, then the domain can only be validated using email for the given subscription. 
142pub async fn create_globalsign_email_challenge(configuration: &mut configuration::Configuration, params: CreateGlobalsignEmailChallengeParams) -> Result<serde_json::Value, Error<CreateGlobalsignEmailChallengeError>> {
143    let local_var_configuration = configuration;
144
145    // unbox the parameters
146    let tls_subscription_id = params.tls_subscription_id;
147    let tls_authorization_id = params.tls_authorization_id;
148    let request_body = params.request_body;
149
150
151    let local_var_client = &local_var_configuration.client;
152
153    let local_var_uri_str = format!("{}/tls/subscriptions/{tls_subscription_id}/authorizations/{tls_authorization_id}/globalsign_email_challenges", local_var_configuration.base_path, tls_subscription_id=crate::apis::urlencode(tls_subscription_id), tls_authorization_id=crate::apis::urlencode(tls_authorization_id));
154    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
155
156    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
157        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
158    }
159    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
160        let local_var_key = local_var_apikey.key.clone();
161        let local_var_value = match local_var_apikey.prefix {
162            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
163            None => local_var_key,
164        };
165        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
166    };
167    local_var_req_builder = local_var_req_builder.json(&request_body);
168
169    let local_var_req = local_var_req_builder.build()?;
170    let local_var_resp = local_var_client.execute(local_var_req).await?;
171
172    if "POST" != "GET" && "POST" != "HEAD" {
173      let headers = local_var_resp.headers();
174      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
175          Some(v) => v.to_str().unwrap().parse().unwrap(),
176          None => configuration::DEFAULT_RATELIMIT,
177      };
178      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
179          Some(v) => v.to_str().unwrap().parse().unwrap(),
180          None => 0,
181      };
182    }
183
184    let local_var_status = local_var_resp.status();
185    let local_var_content = local_var_resp.text().await?;
186
187    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
188        serde_json::from_str(&local_var_content).map_err(Error::from)
189    } else {
190        let local_var_entity: Option<CreateGlobalsignEmailChallengeError> = serde_json::from_str(&local_var_content).ok();
191        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
192        Err(Error::ResponseError(local_var_error))
193    }
194}
195
196/// Create a new TLS subscription. This response includes a list of possible challenges to verify domain ownership.
197pub async fn create_tls_sub(configuration: &mut configuration::Configuration, params: CreateTlsSubParams) -> Result<crate::models::TlsSubscriptionResponse, Error<CreateTlsSubError>> {
198    let local_var_configuration = configuration;
199
200    // unbox the parameters
201    let force = params.force;
202    let tls_subscription = params.tls_subscription;
203
204
205    let local_var_client = &local_var_configuration.client;
206
207    let local_var_uri_str = format!("{}/tls/subscriptions", local_var_configuration.base_path);
208    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
209
210    if let Some(ref local_var_str) = force {
211        local_var_req_builder = local_var_req_builder.query(&[("force", &local_var_str.to_string())]);
212    }
213    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
214        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
215    }
216    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
217        let local_var_key = local_var_apikey.key.clone();
218        let local_var_value = match local_var_apikey.prefix {
219            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
220            None => local_var_key,
221        };
222        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
223    };
224    local_var_req_builder = local_var_req_builder.json(&tls_subscription);
225
226    let local_var_req = local_var_req_builder.build()?;
227    let local_var_resp = local_var_client.execute(local_var_req).await?;
228
229    if "POST" != "GET" && "POST" != "HEAD" {
230      let headers = local_var_resp.headers();
231      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
232          Some(v) => v.to_str().unwrap().parse().unwrap(),
233          None => configuration::DEFAULT_RATELIMIT,
234      };
235      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
236          Some(v) => v.to_str().unwrap().parse().unwrap(),
237          None => 0,
238      };
239    }
240
241    let local_var_status = local_var_resp.status();
242    let local_var_content = local_var_resp.text().await?;
243
244    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
245        serde_json::from_str(&local_var_content).map_err(Error::from)
246    } else {
247        let local_var_entity: Option<CreateTlsSubError> = serde_json::from_str(&local_var_content).ok();
248        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
249        Err(Error::ResponseError(local_var_error))
250    }
251}
252
253/// Deletes a GlobalSign email challenge. After a GlobalSign email challenge is deleted, the domain can use HTTP and DNS validation methods again.
254pub async fn delete_globalsign_email_challenge(configuration: &mut configuration::Configuration, params: DeleteGlobalsignEmailChallengeParams) -> Result<(), Error<DeleteGlobalsignEmailChallengeError>> {
255    let local_var_configuration = configuration;
256
257    // unbox the parameters
258    let tls_subscription_id = params.tls_subscription_id;
259    let tls_authorization_id = params.tls_authorization_id;
260    let globalsign_email_challenge_id = params.globalsign_email_challenge_id;
261
262
263    let local_var_client = &local_var_configuration.client;
264
265    let local_var_uri_str = format!("{}/tls/subscriptions/{tls_subscription_id}/authorizations/{tls_authorization_id}/globalsign_email_challenges/{globalsign_email_challenge_id}", local_var_configuration.base_path, tls_subscription_id=crate::apis::urlencode(tls_subscription_id), tls_authorization_id=crate::apis::urlencode(tls_authorization_id), globalsign_email_challenge_id=crate::apis::urlencode(globalsign_email_challenge_id));
266    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
267
268    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
269        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
270    }
271    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
272        let local_var_key = local_var_apikey.key.clone();
273        let local_var_value = match local_var_apikey.prefix {
274            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
275            None => local_var_key,
276        };
277        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
278    };
279
280    let local_var_req = local_var_req_builder.build()?;
281    let local_var_resp = local_var_client.execute(local_var_req).await?;
282
283    if "DELETE" != "GET" && "DELETE" != "HEAD" {
284      let headers = local_var_resp.headers();
285      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
286          Some(v) => v.to_str().unwrap().parse().unwrap(),
287          None => configuration::DEFAULT_RATELIMIT,
288      };
289      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
290          Some(v) => v.to_str().unwrap().parse().unwrap(),
291          None => 0,
292      };
293    }
294
295    let local_var_status = local_var_resp.status();
296    let local_var_content = local_var_resp.text().await?;
297
298    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
299        Ok(())
300    } else {
301        let local_var_entity: Option<DeleteGlobalsignEmailChallengeError> = serde_json::from_str(&local_var_content).ok();
302        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
303        Err(Error::ResponseError(local_var_error))
304    }
305}
306
307/// Destroy a TLS subscription. A subscription cannot be destroyed if there are domains in the TLS enabled state.
308pub async fn delete_tls_sub(configuration: &mut configuration::Configuration, params: DeleteTlsSubParams) -> Result<(), Error<DeleteTlsSubError>> {
309    let local_var_configuration = configuration;
310
311    // unbox the parameters
312    let tls_subscription_id = params.tls_subscription_id;
313
314
315    let local_var_client = &local_var_configuration.client;
316
317    let local_var_uri_str = format!("{}/tls/subscriptions/{tls_subscription_id}", local_var_configuration.base_path, tls_subscription_id=crate::apis::urlencode(tls_subscription_id));
318    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
319
320    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
321        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
322    }
323    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
324        let local_var_key = local_var_apikey.key.clone();
325        let local_var_value = match local_var_apikey.prefix {
326            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
327            None => local_var_key,
328        };
329        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
330    };
331
332    let local_var_req = local_var_req_builder.build()?;
333    let local_var_resp = local_var_client.execute(local_var_req).await?;
334
335    if "DELETE" != "GET" && "DELETE" != "HEAD" {
336      let headers = local_var_resp.headers();
337      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
338          Some(v) => v.to_str().unwrap().parse().unwrap(),
339          None => configuration::DEFAULT_RATELIMIT,
340      };
341      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
342          Some(v) => v.to_str().unwrap().parse().unwrap(),
343          None => 0,
344      };
345    }
346
347    let local_var_status = local_var_resp.status();
348    let local_var_content = local_var_resp.text().await?;
349
350    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
351        Ok(())
352    } else {
353        let local_var_entity: Option<DeleteTlsSubError> = serde_json::from_str(&local_var_content).ok();
354        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
355        Err(Error::ResponseError(local_var_error))
356    }
357}
358
359/// Show a TLS subscription.
360pub async fn get_tls_sub(configuration: &mut configuration::Configuration, params: GetTlsSubParams) -> Result<crate::models::TlsSubscriptionResponse, Error<GetTlsSubError>> {
361    let local_var_configuration = configuration;
362
363    // unbox the parameters
364    let tls_subscription_id = params.tls_subscription_id;
365    let include = params.include;
366
367
368    let local_var_client = &local_var_configuration.client;
369
370    let local_var_uri_str = format!("{}/tls/subscriptions/{tls_subscription_id}", local_var_configuration.base_path, tls_subscription_id=crate::apis::urlencode(tls_subscription_id));
371    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
372
373    if let Some(ref local_var_str) = include {
374        local_var_req_builder = local_var_req_builder.query(&[("include", &local_var_str.to_string())]);
375    }
376    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
377        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
378    }
379    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
380        let local_var_key = local_var_apikey.key.clone();
381        let local_var_value = match local_var_apikey.prefix {
382            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
383            None => local_var_key,
384        };
385        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
386    };
387
388    let local_var_req = local_var_req_builder.build()?;
389    let local_var_resp = local_var_client.execute(local_var_req).await?;
390
391    if "GET" != "GET" && "GET" != "HEAD" {
392      let headers = local_var_resp.headers();
393      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
394          Some(v) => v.to_str().unwrap().parse().unwrap(),
395          None => configuration::DEFAULT_RATELIMIT,
396      };
397      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
398          Some(v) => v.to_str().unwrap().parse().unwrap(),
399          None => 0,
400      };
401    }
402
403    let local_var_status = local_var_resp.status();
404    let local_var_content = local_var_resp.text().await?;
405
406    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
407        serde_json::from_str(&local_var_content).map_err(Error::from)
408    } else {
409        let local_var_entity: Option<GetTlsSubError> = serde_json::from_str(&local_var_content).ok();
410        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
411        Err(Error::ResponseError(local_var_error))
412    }
413}
414
415/// List all TLS subscriptions.
416pub async fn list_tls_subs(configuration: &mut configuration::Configuration, params: ListTlsSubsParams) -> Result<crate::models::TlsSubscriptionsResponse, Error<ListTlsSubsError>> {
417    let local_var_configuration = configuration;
418
419    // unbox the parameters
420    let filter_state = params.filter_state;
421    let filter_tls_domains_id = params.filter_tls_domains_id;
422    let filter_has_active_order = params.filter_has_active_order;
423    let filter_certificate_authority = params.filter_certificate_authority;
424    let sort = params.sort;
425    let include = params.include;
426    let page_number = params.page_number;
427    let page_size = params.page_size;
428
429
430    let local_var_client = &local_var_configuration.client;
431
432    let local_var_uri_str = format!("{}/tls/subscriptions", local_var_configuration.base_path);
433    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
434
435    if let Some(ref local_var_str) = filter_state {
436        local_var_req_builder = local_var_req_builder.query(&[("filter[state]", &local_var_str.to_string())]);
437    }
438    if let Some(ref local_var_str) = filter_tls_domains_id {
439        local_var_req_builder = local_var_req_builder.query(&[("filter[tls_domains.id]", &local_var_str.to_string())]);
440    }
441    if let Some(ref local_var_str) = filter_has_active_order {
442        local_var_req_builder = local_var_req_builder.query(&[("filter[has_active_order]", &local_var_str.to_string())]);
443    }
444    if let Some(ref local_var_str) = filter_certificate_authority {
445        local_var_req_builder = local_var_req_builder.query(&[("filter[certificate_authority]", &local_var_str.to_string())]);
446    }
447    if let Some(ref local_var_str) = sort {
448        local_var_req_builder = local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
449    }
450    if let Some(ref local_var_str) = include {
451        local_var_req_builder = local_var_req_builder.query(&[("include", &local_var_str.to_string())]);
452    }
453    if let Some(ref local_var_str) = page_number {
454        local_var_req_builder = local_var_req_builder.query(&[("page[number]", &local_var_str.to_string())]);
455    }
456    if let Some(ref local_var_str) = page_size {
457        local_var_req_builder = local_var_req_builder.query(&[("page[size]", &local_var_str.to_string())]);
458    }
459    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
460        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
461    }
462    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
463        let local_var_key = local_var_apikey.key.clone();
464        let local_var_value = match local_var_apikey.prefix {
465            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
466            None => local_var_key,
467        };
468        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
469    };
470
471    let local_var_req = local_var_req_builder.build()?;
472    let local_var_resp = local_var_client.execute(local_var_req).await?;
473
474    if "GET" != "GET" && "GET" != "HEAD" {
475      let headers = local_var_resp.headers();
476      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
477          Some(v) => v.to_str().unwrap().parse().unwrap(),
478          None => configuration::DEFAULT_RATELIMIT,
479      };
480      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
481          Some(v) => v.to_str().unwrap().parse().unwrap(),
482          None => 0,
483      };
484    }
485
486    let local_var_status = local_var_resp.status();
487    let local_var_content = local_var_resp.text().await?;
488
489    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
490        serde_json::from_str(&local_var_content).map_err(Error::from)
491    } else {
492        let local_var_entity: Option<ListTlsSubsError> = serde_json::from_str(&local_var_content).ok();
493        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
494        Err(Error::ResponseError(local_var_error))
495    }
496}
497
498/// Change the TLS domains or common name associated with this subscription, update the TLS configuration for this set of domains, or retry a subscription with state `failed` by setting the state to `retry`.
499pub async fn patch_tls_sub(configuration: &mut configuration::Configuration, params: PatchTlsSubParams) -> Result<crate::models::TlsSubscriptionResponse, Error<PatchTlsSubError>> {
500    let local_var_configuration = configuration;
501
502    // unbox the parameters
503    let tls_subscription_id = params.tls_subscription_id;
504    let force = params.force;
505    let tls_subscription = params.tls_subscription;
506
507
508    let local_var_client = &local_var_configuration.client;
509
510    let local_var_uri_str = format!("{}/tls/subscriptions/{tls_subscription_id}", local_var_configuration.base_path, tls_subscription_id=crate::apis::urlencode(tls_subscription_id));
511    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
512
513    if let Some(ref local_var_str) = force {
514        local_var_req_builder = local_var_req_builder.query(&[("force", &local_var_str.to_string())]);
515    }
516    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
517        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
518    }
519    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
520        let local_var_key = local_var_apikey.key.clone();
521        let local_var_value = match local_var_apikey.prefix {
522            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
523            None => local_var_key,
524        };
525        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
526    };
527    local_var_req_builder = local_var_req_builder.json(&tls_subscription);
528
529    let local_var_req = local_var_req_builder.build()?;
530    let local_var_resp = local_var_client.execute(local_var_req).await?;
531
532    if "PATCH" != "GET" && "PATCH" != "HEAD" {
533      let headers = local_var_resp.headers();
534      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
535          Some(v) => v.to_str().unwrap().parse().unwrap(),
536          None => configuration::DEFAULT_RATELIMIT,
537      };
538      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
539          Some(v) => v.to_str().unwrap().parse().unwrap(),
540          None => 0,
541      };
542    }
543
544    let local_var_status = local_var_resp.status();
545    let local_var_content = local_var_resp.text().await?;
546
547    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
548        serde_json::from_str(&local_var_content).map_err(Error::from)
549    } else {
550        let local_var_entity: Option<PatchTlsSubError> = serde_json::from_str(&local_var_content).ok();
551        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
552        Err(Error::ResponseError(local_var_error))
553    }
554}
555