Skip to main content

fastly_api/apis/
apisecurity_operations_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 [`api_security_create_operation`]
15#[derive(Clone, Debug, Default)]
16pub struct ApiSecurityCreateOperationParams {
17    /// The unique identifier of the service.
18    pub service_id: String,
19    pub operation_create: Option<crate::models::OperationCreate>
20}
21
22/// struct for passing parameters to the method [`api_security_create_operation_tag`]
23#[derive(Clone, Debug, Default)]
24pub struct ApiSecurityCreateOperationTagParams {
25    /// The unique identifier of the service.
26    pub service_id: String,
27    pub tag_create: Option<crate::models::TagCreate>
28}
29
30/// struct for passing parameters to the method [`api_security_delete_operation`]
31#[derive(Clone, Debug, Default)]
32pub struct ApiSecurityDeleteOperationParams {
33    /// The unique identifier of the service.
34    pub service_id: String,
35    /// The unique identifier of the operation.
36    pub operation_id: String
37}
38
39/// struct for passing parameters to the method [`api_security_delete_operation_tag`]
40#[derive(Clone, Debug, Default)]
41pub struct ApiSecurityDeleteOperationTagParams {
42    /// The unique identifier of the service.
43    pub service_id: String,
44    /// The unique identifier of the operation tag.
45    pub tag_id: String
46}
47
48/// struct for passing parameters to the method [`api_security_get_operation`]
49#[derive(Clone, Debug, Default)]
50pub struct ApiSecurityGetOperationParams {
51    /// The unique identifier of the service.
52    pub service_id: String,
53    /// The unique identifier of the operation.
54    pub operation_id: String
55}
56
57/// struct for passing parameters to the method [`api_security_get_operation_tag`]
58#[derive(Clone, Debug, Default)]
59pub struct ApiSecurityGetOperationTagParams {
60    /// The unique identifier of the service.
61    pub service_id: String,
62    /// The unique identifier of the operation tag.
63    pub tag_id: String
64}
65
66/// struct for passing parameters to the method [`api_security_list_discovered_operations`]
67#[derive(Clone, Debug, Default)]
68pub struct ApiSecurityListDiscoveredOperationsParams {
69    /// The unique identifier of the service.
70    pub service_id: String,
71    /// Filter operations by status. Only operations with this status will be returned.
72    pub status: Option<String>,
73    /// The maximum number of operations to return per page.
74    pub limit: Option<i32>,
75    /// The page number to return.
76    pub page: Option<i32>
77}
78
79/// struct for passing parameters to the method [`api_security_list_operation_tags`]
80#[derive(Clone, Debug, Default)]
81pub struct ApiSecurityListOperationTagsParams {
82    /// The unique identifier of the service.
83    pub service_id: String
84}
85
86/// struct for passing parameters to the method [`api_security_list_operations`]
87#[derive(Clone, Debug, Default)]
88pub struct ApiSecurityListOperationsParams {
89    /// The unique identifier of the service.
90    pub service_id: String,
91    /// Filter operations by operation tag ID. Only operations associated with this operation tag will be returned.
92    pub tag_id: Option<String>,
93    /// The maximum number of operations to return per page.
94    pub limit: Option<i32>,
95    /// The page number to return.
96    pub page: Option<i32>
97}
98
99/// struct for passing parameters to the method [`api_security_update_operation`]
100#[derive(Clone, Debug, Default)]
101pub struct ApiSecurityUpdateOperationParams {
102    /// The unique identifier of the service.
103    pub service_id: String,
104    /// The unique identifier of the operation.
105    pub operation_id: String,
106    pub operation_update: Option<crate::models::OperationUpdate>
107}
108
109/// struct for passing parameters to the method [`api_security_update_operation_tag`]
110#[derive(Clone, Debug, Default)]
111pub struct ApiSecurityUpdateOperationTagParams {
112    /// The unique identifier of the service.
113    pub service_id: String,
114    /// The unique identifier of the operation tag.
115    pub tag_id: String,
116    pub body: Option<crate::models::TagBase>
117}
118
119
120/// struct for typed errors of method [`api_security_create_operation`]
121#[derive(Debug, Clone, Serialize, Deserialize)]
122#[serde(untagged)]
123pub enum ApiSecurityCreateOperationError {
124    Status400(serde_json::Value),
125    Status401(serde_json::Value),
126    Status403(serde_json::Value),
127    Status404(serde_json::Value),
128    Status429(serde_json::Value),
129    UnknownValue(serde_json::Value),
130}
131
132/// struct for typed errors of method [`api_security_create_operation_tag`]
133#[derive(Debug, Clone, Serialize, Deserialize)]
134#[serde(untagged)]
135pub enum ApiSecurityCreateOperationTagError {
136    Status400(serde_json::Value),
137    Status401(serde_json::Value),
138    Status403(serde_json::Value),
139    Status429(serde_json::Value),
140    UnknownValue(serde_json::Value),
141}
142
143/// struct for typed errors of method [`api_security_delete_operation`]
144#[derive(Debug, Clone, Serialize, Deserialize)]
145#[serde(untagged)]
146pub enum ApiSecurityDeleteOperationError {
147    Status400(serde_json::Value),
148    Status401(serde_json::Value),
149    Status403(serde_json::Value),
150    Status404(serde_json::Value),
151    Status429(serde_json::Value),
152    UnknownValue(serde_json::Value),
153}
154
155/// struct for typed errors of method [`api_security_delete_operation_tag`]
156#[derive(Debug, Clone, Serialize, Deserialize)]
157#[serde(untagged)]
158pub enum ApiSecurityDeleteOperationTagError {
159    Status400(serde_json::Value),
160    Status401(serde_json::Value),
161    Status403(serde_json::Value),
162    Status404(serde_json::Value),
163    Status429(serde_json::Value),
164    UnknownValue(serde_json::Value),
165}
166
167/// struct for typed errors of method [`api_security_get_operation`]
168#[derive(Debug, Clone, Serialize, Deserialize)]
169#[serde(untagged)]
170pub enum ApiSecurityGetOperationError {
171    Status400(serde_json::Value),
172    Status401(serde_json::Value),
173    Status403(serde_json::Value),
174    Status404(serde_json::Value),
175    Status429(serde_json::Value),
176    UnknownValue(serde_json::Value),
177}
178
179/// struct for typed errors of method [`api_security_get_operation_tag`]
180#[derive(Debug, Clone, Serialize, Deserialize)]
181#[serde(untagged)]
182pub enum ApiSecurityGetOperationTagError {
183    Status400(serde_json::Value),
184    Status401(serde_json::Value),
185    Status403(serde_json::Value),
186    Status404(serde_json::Value),
187    Status429(serde_json::Value),
188    UnknownValue(serde_json::Value),
189}
190
191/// struct for typed errors of method [`api_security_list_discovered_operations`]
192#[derive(Debug, Clone, Serialize, Deserialize)]
193#[serde(untagged)]
194pub enum ApiSecurityListDiscoveredOperationsError {
195    Status400(serde_json::Value),
196    Status401(serde_json::Value),
197    Status403(serde_json::Value),
198    Status404(serde_json::Value),
199    Status429(serde_json::Value),
200    UnknownValue(serde_json::Value),
201}
202
203/// struct for typed errors of method [`api_security_list_operation_tags`]
204#[derive(Debug, Clone, Serialize, Deserialize)]
205#[serde(untagged)]
206pub enum ApiSecurityListOperationTagsError {
207    Status400(serde_json::Value),
208    Status401(serde_json::Value),
209    Status403(serde_json::Value),
210    Status429(serde_json::Value),
211    UnknownValue(serde_json::Value),
212}
213
214/// struct for typed errors of method [`api_security_list_operations`]
215#[derive(Debug, Clone, Serialize, Deserialize)]
216#[serde(untagged)]
217pub enum ApiSecurityListOperationsError {
218    Status400(serde_json::Value),
219    Status401(serde_json::Value),
220    Status403(serde_json::Value),
221    Status404(serde_json::Value),
222    Status429(serde_json::Value),
223    UnknownValue(serde_json::Value),
224}
225
226/// struct for typed errors of method [`api_security_update_operation`]
227#[derive(Debug, Clone, Serialize, Deserialize)]
228#[serde(untagged)]
229pub enum ApiSecurityUpdateOperationError {
230    Status400(serde_json::Value),
231    Status401(serde_json::Value),
232    Status403(serde_json::Value),
233    Status404(serde_json::Value),
234    Status429(serde_json::Value),
235    UnknownValue(serde_json::Value),
236}
237
238/// struct for typed errors of method [`api_security_update_operation_tag`]
239#[derive(Debug, Clone, Serialize, Deserialize)]
240#[serde(untagged)]
241pub enum ApiSecurityUpdateOperationTagError {
242    Status400(serde_json::Value),
243    Status401(serde_json::Value),
244    Status403(serde_json::Value),
245    Status404(serde_json::Value),
246    Status429(serde_json::Value),
247    UnknownValue(serde_json::Value),
248}
249
250
251/// Create a new operation associated with a specific service.
252pub async fn api_security_create_operation(configuration: &mut configuration::Configuration, params: ApiSecurityCreateOperationParams) -> Result<crate::models::OperationGet, Error<ApiSecurityCreateOperationError>> {
253    let local_var_configuration = configuration;
254
255    // unbox the parameters
256    let service_id = params.service_id;
257    let operation_create = params.operation_create;
258
259
260    let local_var_client = &local_var_configuration.client;
261
262    let local_var_uri_str = format!("{}/api-security/v1/services/{service_id}/operations", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id));
263    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
264
265    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
266        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
267    }
268    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
269        let local_var_key = local_var_apikey.key.clone();
270        let local_var_value = match local_var_apikey.prefix {
271            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
272            None => local_var_key,
273        };
274        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
275    };
276    local_var_req_builder = local_var_req_builder.json(&operation_create);
277
278    let local_var_req = local_var_req_builder.build()?;
279    let local_var_resp = local_var_client.execute(local_var_req).await?;
280
281    if "POST" != "GET" && "POST" != "HEAD" {
282      let headers = local_var_resp.headers();
283      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
284          Some(v) => v.to_str().unwrap().parse().unwrap(),
285          None => configuration::DEFAULT_RATELIMIT,
286      };
287      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
288          Some(v) => v.to_str().unwrap().parse().unwrap(),
289          None => 0,
290      };
291    }
292
293    let local_var_status = local_var_resp.status();
294    let local_var_content = local_var_resp.text().await?;
295
296    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
297        serde_json::from_str(&local_var_content).map_err(Error::from)
298    } else {
299        let local_var_entity: Option<ApiSecurityCreateOperationError> = serde_json::from_str(&local_var_content).ok();
300        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
301        Err(Error::ResponseError(local_var_error))
302    }
303}
304
305/// Create a new operation tag associated with a specific service.
306pub async fn api_security_create_operation_tag(configuration: &mut configuration::Configuration, params: ApiSecurityCreateOperationTagParams) -> Result<crate::models::TagGet, Error<ApiSecurityCreateOperationTagError>> {
307    let local_var_configuration = configuration;
308
309    // unbox the parameters
310    let service_id = params.service_id;
311    let tag_create = params.tag_create;
312
313
314    let local_var_client = &local_var_configuration.client;
315
316    let local_var_uri_str = format!("{}/api-security/v1/services/{service_id}/tags", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id));
317    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
318
319    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
320        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
321    }
322    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
323        let local_var_key = local_var_apikey.key.clone();
324        let local_var_value = match local_var_apikey.prefix {
325            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
326            None => local_var_key,
327        };
328        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
329    };
330    local_var_req_builder = local_var_req_builder.json(&tag_create);
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 "POST" != "GET" && "POST" != "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        serde_json::from_str(&local_var_content).map_err(Error::from)
352    } else {
353        let local_var_entity: Option<ApiSecurityCreateOperationTagError> = 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/// Delete an existing operation associated with a specific service.
360pub async fn api_security_delete_operation(configuration: &mut configuration::Configuration, params: ApiSecurityDeleteOperationParams) -> Result<(), Error<ApiSecurityDeleteOperationError>> {
361    let local_var_configuration = configuration;
362
363    // unbox the parameters
364    let service_id = params.service_id;
365    let operation_id = params.operation_id;
366
367
368    let local_var_client = &local_var_configuration.client;
369
370    let local_var_uri_str = format!("{}/api-security/v1/services/{service_id}/operations/{operation_id}", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), operation_id=crate::apis::urlencode(operation_id));
371    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
372
373    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
374        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
375    }
376    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
377        let local_var_key = local_var_apikey.key.clone();
378        let local_var_value = match local_var_apikey.prefix {
379            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
380            None => local_var_key,
381        };
382        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
383    };
384
385    let local_var_req = local_var_req_builder.build()?;
386    let local_var_resp = local_var_client.execute(local_var_req).await?;
387
388    if "DELETE" != "GET" && "DELETE" != "HEAD" {
389      let headers = local_var_resp.headers();
390      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
391          Some(v) => v.to_str().unwrap().parse().unwrap(),
392          None => configuration::DEFAULT_RATELIMIT,
393      };
394      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
395          Some(v) => v.to_str().unwrap().parse().unwrap(),
396          None => 0,
397      };
398    }
399
400    let local_var_status = local_var_resp.status();
401    let local_var_content = local_var_resp.text().await?;
402
403    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
404        Ok(())
405    } else {
406        let local_var_entity: Option<ApiSecurityDeleteOperationError> = serde_json::from_str(&local_var_content).ok();
407        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
408        Err(Error::ResponseError(local_var_error))
409    }
410}
411
412/// Delete an existing operation tag.
413pub async fn api_security_delete_operation_tag(configuration: &mut configuration::Configuration, params: ApiSecurityDeleteOperationTagParams) -> Result<(), Error<ApiSecurityDeleteOperationTagError>> {
414    let local_var_configuration = configuration;
415
416    // unbox the parameters
417    let service_id = params.service_id;
418    let tag_id = params.tag_id;
419
420
421    let local_var_client = &local_var_configuration.client;
422
423    let local_var_uri_str = format!("{}/api-security/v1/services/{service_id}/tags/{tag_id}", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), tag_id=crate::apis::urlencode(tag_id));
424    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
425
426    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
427        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
428    }
429    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
430        let local_var_key = local_var_apikey.key.clone();
431        let local_var_value = match local_var_apikey.prefix {
432            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
433            None => local_var_key,
434        };
435        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
436    };
437
438    let local_var_req = local_var_req_builder.build()?;
439    let local_var_resp = local_var_client.execute(local_var_req).await?;
440
441    if "DELETE" != "GET" && "DELETE" != "HEAD" {
442      let headers = local_var_resp.headers();
443      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
444          Some(v) => v.to_str().unwrap().parse().unwrap(),
445          None => configuration::DEFAULT_RATELIMIT,
446      };
447      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
448          Some(v) => v.to_str().unwrap().parse().unwrap(),
449          None => 0,
450      };
451    }
452
453    let local_var_status = local_var_resp.status();
454    let local_var_content = local_var_resp.text().await?;
455
456    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
457        Ok(())
458    } else {
459        let local_var_entity: Option<ApiSecurityDeleteOperationTagError> = serde_json::from_str(&local_var_content).ok();
460        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
461        Err(Error::ResponseError(local_var_error))
462    }
463}
464
465/// Get a specific operation associated with a service.
466pub async fn api_security_get_operation(configuration: &mut configuration::Configuration, params: ApiSecurityGetOperationParams) -> Result<crate::models::OperationGet, Error<ApiSecurityGetOperationError>> {
467    let local_var_configuration = configuration;
468
469    // unbox the parameters
470    let service_id = params.service_id;
471    let operation_id = params.operation_id;
472
473
474    let local_var_client = &local_var_configuration.client;
475
476    let local_var_uri_str = format!("{}/api-security/v1/services/{service_id}/operations/{operation_id}", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), operation_id=crate::apis::urlencode(operation_id));
477    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
478
479    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
480        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
481    }
482    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
483        let local_var_key = local_var_apikey.key.clone();
484        let local_var_value = match local_var_apikey.prefix {
485            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
486            None => local_var_key,
487        };
488        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
489    };
490
491    let local_var_req = local_var_req_builder.build()?;
492    let local_var_resp = local_var_client.execute(local_var_req).await?;
493
494    if "GET" != "GET" && "GET" != "HEAD" {
495      let headers = local_var_resp.headers();
496      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
497          Some(v) => v.to_str().unwrap().parse().unwrap(),
498          None => configuration::DEFAULT_RATELIMIT,
499      };
500      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
501          Some(v) => v.to_str().unwrap().parse().unwrap(),
502          None => 0,
503      };
504    }
505
506    let local_var_status = local_var_resp.status();
507    let local_var_content = local_var_resp.text().await?;
508
509    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
510        serde_json::from_str(&local_var_content).map_err(Error::from)
511    } else {
512        let local_var_entity: Option<ApiSecurityGetOperationError> = serde_json::from_str(&local_var_content).ok();
513        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
514        Err(Error::ResponseError(local_var_error))
515    }
516}
517
518/// Get a specific operation tag by its unique identifier.
519pub async fn api_security_get_operation_tag(configuration: &mut configuration::Configuration, params: ApiSecurityGetOperationTagParams) -> Result<crate::models::TagGet, Error<ApiSecurityGetOperationTagError>> {
520    let local_var_configuration = configuration;
521
522    // unbox the parameters
523    let service_id = params.service_id;
524    let tag_id = params.tag_id;
525
526
527    let local_var_client = &local_var_configuration.client;
528
529    let local_var_uri_str = format!("{}/api-security/v1/services/{service_id}/tags/{tag_id}", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), tag_id=crate::apis::urlencode(tag_id));
530    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
531
532    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
533        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
534    }
535    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
536        let local_var_key = local_var_apikey.key.clone();
537        let local_var_value = match local_var_apikey.prefix {
538            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
539            None => local_var_key,
540        };
541        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
542    };
543
544    let local_var_req = local_var_req_builder.build()?;
545    let local_var_resp = local_var_client.execute(local_var_req).await?;
546
547    if "GET" != "GET" && "GET" != "HEAD" {
548      let headers = local_var_resp.headers();
549      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
550          Some(v) => v.to_str().unwrap().parse().unwrap(),
551          None => configuration::DEFAULT_RATELIMIT,
552      };
553      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
554          Some(v) => v.to_str().unwrap().parse().unwrap(),
555          None => 0,
556      };
557    }
558
559    let local_var_status = local_var_resp.status();
560    let local_var_content = local_var_resp.text().await?;
561
562    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
563        serde_json::from_str(&local_var_content).map_err(Error::from)
564    } else {
565        let local_var_entity: Option<ApiSecurityGetOperationTagError> = serde_json::from_str(&local_var_content).ok();
566        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
567        Err(Error::ResponseError(local_var_error))
568    }
569}
570
571/// List all discovered operations associated with a specific service. Optionally filter operations by status.
572pub async fn api_security_list_discovered_operations(configuration: &mut configuration::Configuration, params: ApiSecurityListDiscoveredOperationsParams) -> Result<crate::models::InlineResponse2001, Error<ApiSecurityListDiscoveredOperationsError>> {
573    let local_var_configuration = configuration;
574
575    // unbox the parameters
576    let service_id = params.service_id;
577    let status = params.status;
578    let limit = params.limit;
579    let page = params.page;
580
581
582    let local_var_client = &local_var_configuration.client;
583
584    let local_var_uri_str = format!("{}/api-security/v1/services/{service_id}/discovered-operations", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id));
585    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
586
587    if let Some(ref local_var_str) = status {
588        local_var_req_builder = local_var_req_builder.query(&[("status", &local_var_str.to_string())]);
589    }
590    if let Some(ref local_var_str) = limit {
591        local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
592    }
593    if let Some(ref local_var_str) = page {
594        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
595    }
596    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
597        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
598    }
599    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
600        let local_var_key = local_var_apikey.key.clone();
601        let local_var_value = match local_var_apikey.prefix {
602            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
603            None => local_var_key,
604        };
605        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
606    };
607
608    let local_var_req = local_var_req_builder.build()?;
609    let local_var_resp = local_var_client.execute(local_var_req).await?;
610
611    if "GET" != "GET" && "GET" != "HEAD" {
612      let headers = local_var_resp.headers();
613      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
614          Some(v) => v.to_str().unwrap().parse().unwrap(),
615          None => configuration::DEFAULT_RATELIMIT,
616      };
617      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
618          Some(v) => v.to_str().unwrap().parse().unwrap(),
619          None => 0,
620      };
621    }
622
623    let local_var_status = local_var_resp.status();
624    let local_var_content = local_var_resp.text().await?;
625
626    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
627        serde_json::from_str(&local_var_content).map_err(Error::from)
628    } else {
629        let local_var_entity: Option<ApiSecurityListDiscoveredOperationsError> = serde_json::from_str(&local_var_content).ok();
630        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
631        Err(Error::ResponseError(local_var_error))
632    }
633}
634
635/// List all operation tags associated with a specific service.
636pub async fn api_security_list_operation_tags(configuration: &mut configuration::Configuration, params: ApiSecurityListOperationTagsParams) -> Result<crate::models::InlineResponse2003, Error<ApiSecurityListOperationTagsError>> {
637    let local_var_configuration = configuration;
638
639    // unbox the parameters
640    let service_id = params.service_id;
641
642
643    let local_var_client = &local_var_configuration.client;
644
645    let local_var_uri_str = format!("{}/api-security/v1/services/{service_id}/tags", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id));
646    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
647
648    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
649        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
650    }
651    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
652        let local_var_key = local_var_apikey.key.clone();
653        let local_var_value = match local_var_apikey.prefix {
654            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
655            None => local_var_key,
656        };
657        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
658    };
659
660    let local_var_req = local_var_req_builder.build()?;
661    let local_var_resp = local_var_client.execute(local_var_req).await?;
662
663    if "GET" != "GET" && "GET" != "HEAD" {
664      let headers = local_var_resp.headers();
665      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
666          Some(v) => v.to_str().unwrap().parse().unwrap(),
667          None => configuration::DEFAULT_RATELIMIT,
668      };
669      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
670          Some(v) => v.to_str().unwrap().parse().unwrap(),
671          None => 0,
672      };
673    }
674
675    let local_var_status = local_var_resp.status();
676    let local_var_content = local_var_resp.text().await?;
677
678    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
679        serde_json::from_str(&local_var_content).map_err(Error::from)
680    } else {
681        let local_var_entity: Option<ApiSecurityListOperationTagsError> = serde_json::from_str(&local_var_content).ok();
682        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
683        Err(Error::ResponseError(local_var_error))
684    }
685}
686
687/// List all operations associated with a specific service. Optionally filter operations by tag ID.
688pub async fn api_security_list_operations(configuration: &mut configuration::Configuration, params: ApiSecurityListOperationsParams) -> Result<crate::models::InlineResponse2002, Error<ApiSecurityListOperationsError>> {
689    let local_var_configuration = configuration;
690
691    // unbox the parameters
692    let service_id = params.service_id;
693    let tag_id = params.tag_id;
694    let limit = params.limit;
695    let page = params.page;
696
697
698    let local_var_client = &local_var_configuration.client;
699
700    let local_var_uri_str = format!("{}/api-security/v1/services/{service_id}/operations", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id));
701    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
702
703    if let Some(ref local_var_str) = tag_id {
704        local_var_req_builder = local_var_req_builder.query(&[("tag_id", &local_var_str.to_string())]);
705    }
706    if let Some(ref local_var_str) = limit {
707        local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
708    }
709    if let Some(ref local_var_str) = page {
710        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
711    }
712    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
713        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
714    }
715    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
716        let local_var_key = local_var_apikey.key.clone();
717        let local_var_value = match local_var_apikey.prefix {
718            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
719            None => local_var_key,
720        };
721        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
722    };
723
724    let local_var_req = local_var_req_builder.build()?;
725    let local_var_resp = local_var_client.execute(local_var_req).await?;
726
727    if "GET" != "GET" && "GET" != "HEAD" {
728      let headers = local_var_resp.headers();
729      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
730          Some(v) => v.to_str().unwrap().parse().unwrap(),
731          None => configuration::DEFAULT_RATELIMIT,
732      };
733      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
734          Some(v) => v.to_str().unwrap().parse().unwrap(),
735          None => 0,
736      };
737    }
738
739    let local_var_status = local_var_resp.status();
740    let local_var_content = local_var_resp.text().await?;
741
742    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
743        serde_json::from_str(&local_var_content).map_err(Error::from)
744    } else {
745        let local_var_entity: Option<ApiSecurityListOperationsError> = serde_json::from_str(&local_var_content).ok();
746        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
747        Err(Error::ResponseError(local_var_error))
748    }
749}
750
751/// Partially update an existing operation associated with a specific service.
752pub async fn api_security_update_operation(configuration: &mut configuration::Configuration, params: ApiSecurityUpdateOperationParams) -> Result<crate::models::OperationGet, Error<ApiSecurityUpdateOperationError>> {
753    let local_var_configuration = configuration;
754
755    // unbox the parameters
756    let service_id = params.service_id;
757    let operation_id = params.operation_id;
758    let operation_update = params.operation_update;
759
760
761    let local_var_client = &local_var_configuration.client;
762
763    let local_var_uri_str = format!("{}/api-security/v1/services/{service_id}/operations/{operation_id}", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), operation_id=crate::apis::urlencode(operation_id));
764    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
765
766    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
767        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
768    }
769    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
770        let local_var_key = local_var_apikey.key.clone();
771        let local_var_value = match local_var_apikey.prefix {
772            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
773            None => local_var_key,
774        };
775        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
776    };
777    local_var_req_builder = local_var_req_builder.json(&operation_update);
778
779    let local_var_req = local_var_req_builder.build()?;
780    let local_var_resp = local_var_client.execute(local_var_req).await?;
781
782    if "PATCH" != "GET" && "PATCH" != "HEAD" {
783      let headers = local_var_resp.headers();
784      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
785          Some(v) => v.to_str().unwrap().parse().unwrap(),
786          None => configuration::DEFAULT_RATELIMIT,
787      };
788      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
789          Some(v) => v.to_str().unwrap().parse().unwrap(),
790          None => 0,
791      };
792    }
793
794    let local_var_status = local_var_resp.status();
795    let local_var_content = local_var_resp.text().await?;
796
797    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
798        serde_json::from_str(&local_var_content).map_err(Error::from)
799    } else {
800        let local_var_entity: Option<ApiSecurityUpdateOperationError> = serde_json::from_str(&local_var_content).ok();
801        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
802        Err(Error::ResponseError(local_var_error))
803    }
804}
805
806/// Partially update an existing operation tag.
807pub async fn api_security_update_operation_tag(configuration: &mut configuration::Configuration, params: ApiSecurityUpdateOperationTagParams) -> Result<crate::models::TagGet, Error<ApiSecurityUpdateOperationTagError>> {
808    let local_var_configuration = configuration;
809
810    // unbox the parameters
811    let service_id = params.service_id;
812    let tag_id = params.tag_id;
813    let body = params.body;
814
815
816    let local_var_client = &local_var_configuration.client;
817
818    let local_var_uri_str = format!("{}/api-security/v1/services/{service_id}/tags/{tag_id}", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), tag_id=crate::apis::urlencode(tag_id));
819    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
820
821    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
822        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
823    }
824    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
825        let local_var_key = local_var_apikey.key.clone();
826        let local_var_value = match local_var_apikey.prefix {
827            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
828            None => local_var_key,
829        };
830        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
831    };
832    local_var_req_builder = local_var_req_builder.json(&body);
833
834    let local_var_req = local_var_req_builder.build()?;
835    let local_var_resp = local_var_client.execute(local_var_req).await?;
836
837    if "PATCH" != "GET" && "PATCH" != "HEAD" {
838      let headers = local_var_resp.headers();
839      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
840          Some(v) => v.to_str().unwrap().parse().unwrap(),
841          None => configuration::DEFAULT_RATELIMIT,
842      };
843      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
844          Some(v) => v.to_str().unwrap().parse().unwrap(),
845          None => 0,
846      };
847    }
848
849    let local_var_status = local_var_resp.status();
850    let local_var_content = local_var_resp.text().await?;
851
852    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
853        serde_json::from_str(&local_var_content).map_err(Error::from)
854    } else {
855        let local_var_entity: Option<ApiSecurityUpdateOperationTagError> = serde_json::from_str(&local_var_content).ok();
856        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
857        Err(Error::ResponseError(local_var_error))
858    }
859}
860