fastly_api/apis/
legacy_waf_update_status_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 [`get_waf_update_status`]
15#[derive(Clone, Debug, Default)]
16pub struct GetWafUpdateStatusParams {
17    /// Alphanumeric string identifying the service.
18    pub service_id: String,
19    /// Alphanumeric string identifying a Firewall.
20    pub firewall_id: String,
21    /// Alphanumeric string identifying a WAF update status.
22    pub update_status_id: String
23}
24
25/// struct for passing parameters to the method [`list_waf_update_statuses`]
26#[derive(Clone, Debug, Default)]
27pub struct ListWafUpdateStatusesParams {
28    /// Alphanumeric string identifying the service.
29    pub service_id: String,
30    /// Alphanumeric string identifying a Firewall.
31    pub firewall_id: String,
32    /// Current page.
33    pub page_number: Option<i32>,
34    /// Number of records per page.
35    pub page_size: Option<i32>,
36    /// Include relationships. Optional, comma separated values. Permitted values: `waf`. 
37    pub include: Option<String>
38}
39
40
41/// struct for typed errors of method [`get_waf_update_status`]
42#[derive(Debug, Clone, Serialize, Deserialize)]
43#[serde(untagged)]
44pub enum GetWafUpdateStatusError {
45    UnknownValue(serde_json::Value),
46}
47
48/// struct for typed errors of method [`list_waf_update_statuses`]
49#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum ListWafUpdateStatusesError {
52    UnknownValue(serde_json::Value),
53}
54
55
56/// Get a specific update status object for a particular service and firewall object.
57pub async fn get_waf_update_status(configuration: &mut configuration::Configuration, params: GetWafUpdateStatusParams) -> Result<serde_json::Value, Error<GetWafUpdateStatusError>> {
58    let local_var_configuration = configuration;
59
60    // unbox the parameters
61    let service_id = params.service_id;
62    let firewall_id = params.firewall_id;
63    let update_status_id = params.update_status_id;
64
65
66    let local_var_client = &local_var_configuration.client;
67
68    let local_var_uri_str = format!("{}/service/{service_id}/wafs/{firewall_id}/update_statuses/{update_status_id}", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), firewall_id=crate::apis::urlencode(firewall_id), update_status_id=crate::apis::urlencode(update_status_id));
69    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
70
71    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
72        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
73    }
74    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
75        let local_var_key = local_var_apikey.key.clone();
76        let local_var_value = match local_var_apikey.prefix {
77            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
78            None => local_var_key,
79        };
80        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
81    };
82
83    let local_var_req = local_var_req_builder.build()?;
84    let local_var_resp = local_var_client.execute(local_var_req).await?;
85
86    if "GET" != "GET" && "GET" != "HEAD" {
87      let headers = local_var_resp.headers();
88      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
89          Some(v) => v.to_str().unwrap().parse().unwrap(),
90          None => configuration::DEFAULT_RATELIMIT,
91      };
92      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
93          Some(v) => v.to_str().unwrap().parse().unwrap(),
94          None => 0,
95      };
96    }
97
98    let local_var_status = local_var_resp.status();
99    let local_var_content = local_var_resp.text().await?;
100
101    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
102        serde_json::from_str(&local_var_content).map_err(Error::from)
103    } else {
104        let local_var_entity: Option<GetWafUpdateStatusError> = serde_json::from_str(&local_var_content).ok();
105        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
106        Err(Error::ResponseError(local_var_error))
107    }
108}
109
110/// List all update statuses for a particular service and firewall object.
111pub async fn list_waf_update_statuses(configuration: &mut configuration::Configuration, params: ListWafUpdateStatusesParams) -> Result<serde_json::Value, Error<ListWafUpdateStatusesError>> {
112    let local_var_configuration = configuration;
113
114    // unbox the parameters
115    let service_id = params.service_id;
116    let firewall_id = params.firewall_id;
117    let page_number = params.page_number;
118    let page_size = params.page_size;
119    let include = params.include;
120
121
122    let local_var_client = &local_var_configuration.client;
123
124    let local_var_uri_str = format!("{}/service/{service_id}/wafs/{firewall_id}/update_statuses", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), firewall_id=crate::apis::urlencode(firewall_id));
125    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
126
127    if let Some(ref local_var_str) = page_number {
128        local_var_req_builder = local_var_req_builder.query(&[("page[number]", &local_var_str.to_string())]);
129    }
130    if let Some(ref local_var_str) = page_size {
131        local_var_req_builder = local_var_req_builder.query(&[("page[size]", &local_var_str.to_string())]);
132    }
133    if let Some(ref local_var_str) = include {
134        local_var_req_builder = local_var_req_builder.query(&[("include", &local_var_str.to_string())]);
135    }
136    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
137        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
138    }
139    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
140        let local_var_key = local_var_apikey.key.clone();
141        let local_var_value = match local_var_apikey.prefix {
142            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
143            None => local_var_key,
144        };
145        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
146    };
147
148    let local_var_req = local_var_req_builder.build()?;
149    let local_var_resp = local_var_client.execute(local_var_req).await?;
150
151    if "GET" != "GET" && "GET" != "HEAD" {
152      let headers = local_var_resp.headers();
153      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
154          Some(v) => v.to_str().unwrap().parse().unwrap(),
155          None => configuration::DEFAULT_RATELIMIT,
156      };
157      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
158          Some(v) => v.to_str().unwrap().parse().unwrap(),
159          None => 0,
160      };
161    }
162
163    let local_var_status = local_var_resp.status();
164    let local_var_content = local_var_resp.text().await?;
165
166    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
167        serde_json::from_str(&local_var_content).map_err(Error::from)
168    } else {
169        let local_var_entity: Option<ListWafUpdateStatusesError> = serde_json::from_str(&local_var_content).ok();
170        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
171        Err(Error::ResponseError(local_var_error))
172    }
173}
174