/*
* Fastly API
*
* 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/)
*
*/
use reqwest;
use crate::apis::ResponseContent;
use super::{Error, configuration};
/// struct for passing parameters to the method [`api_security_bulk_add_tags_to_operations`]
#[derive(Clone, Debug, Default)]
pub struct ApiSecurityBulkAddTagsToOperationsParams {
/// The unique identifier of the service.
pub service_id: String,
pub operation_bulk_add_tags: Option<crate::models::OperationBulkAddTags>
}
/// struct for passing parameters to the method [`api_security_bulk_create_operations`]
#[derive(Clone, Debug, Default)]
pub struct ApiSecurityBulkCreateOperationsParams {
/// The unique identifier of the service.
pub service_id: String,
pub operation_bulk_create: Option<crate::models::OperationBulkCreate>
}
/// struct for passing parameters to the method [`api_security_bulk_delete_operations`]
#[derive(Clone, Debug, Default)]
pub struct ApiSecurityBulkDeleteOperationsParams {
/// The unique identifier of the service.
pub service_id: String,
pub operation_bulk_delete: Option<crate::models::OperationBulkDelete>
}
/// struct for passing parameters to the method [`api_security_create_operation`]
#[derive(Clone, Debug, Default)]
pub struct ApiSecurityCreateOperationParams {
/// The unique identifier of the service.
pub service_id: String,
pub operation_create: Option<crate::models::OperationCreate>
}
/// struct for passing parameters to the method [`api_security_create_operation_tag`]
#[derive(Clone, Debug, Default)]
pub struct ApiSecurityCreateOperationTagParams {
/// The unique identifier of the service.
pub service_id: String,
pub tag_create: Option<crate::models::TagCreate>
}
/// struct for passing parameters to the method [`api_security_delete_operation`]
#[derive(Clone, Debug, Default)]
pub struct ApiSecurityDeleteOperationParams {
/// The unique identifier of the service.
pub service_id: String,
/// The unique identifier of the operation.
pub operation_id: String
}
/// struct for passing parameters to the method [`api_security_delete_operation_tag`]
#[derive(Clone, Debug, Default)]
pub struct ApiSecurityDeleteOperationTagParams {
/// The unique identifier of the service.
pub service_id: String,
/// The unique identifier of the operation tag.
pub tag_id: String
}
/// struct for passing parameters to the method [`api_security_get_operation`]
#[derive(Clone, Debug, Default)]
pub struct ApiSecurityGetOperationParams {
/// The unique identifier of the service.
pub service_id: String,
/// The unique identifier of the operation.
pub operation_id: String
}
/// struct for passing parameters to the method [`api_security_get_operation_tag`]
#[derive(Clone, Debug, Default)]
pub struct ApiSecurityGetOperationTagParams {
/// The unique identifier of the service.
pub service_id: String,
/// The unique identifier of the operation tag.
pub tag_id: String
}
/// struct for passing parameters to the method [`api_security_list_discovered_operations`]
#[derive(Clone, Debug, Default)]
pub struct ApiSecurityListDiscoveredOperationsParams {
/// The unique identifier of the service.
pub service_id: String,
/// Filter operations by HTTP method.
pub method: Option<Vec<String>>,
/// Filter operations by fully-qualified domain name (exact match).
pub domain: Option<Vec<String>>,
/// Filter operations by path (exact match).
pub path: Option<String>,
/// The maximum number of operations to return per page.
pub limit: Option<i32>,
/// The page number to return.
pub page: Option<i32>
}
/// struct for passing parameters to the method [`api_security_list_operation_tags`]
#[derive(Clone, Debug, Default)]
pub struct ApiSecurityListOperationTagsParams {
/// The unique identifier of the service.
pub service_id: String,
/// The maximum number of operations to return per page.
pub limit: Option<i32>,
/// The page number to return.
pub page: Option<i32>
}
/// struct for passing parameters to the method [`api_security_list_operations`]
#[derive(Clone, Debug, Default)]
pub struct ApiSecurityListOperationsParams {
/// The unique identifier of the service.
pub service_id: String,
/// Filter operations by operation tag ID. Only operations associated with this operation tag will be returned.
pub tag_id: Option<String>,
/// Filter operations by status. Defaults to SAVED if omitted.
pub status: Option<String>,
/// Filter operations by HTTP method.
pub method: Option<Vec<String>>,
/// Filter operations by fully-qualified domain name (exact match).
pub domain: Option<Vec<String>>,
/// Filter operations by path (exact match).
pub path: Option<String>,
/// The maximum number of operations to return per page.
pub limit: Option<i32>,
/// The page number to return.
pub page: Option<i32>
}
/// struct for passing parameters to the method [`api_security_update_operation`]
#[derive(Clone, Debug, Default)]
pub struct ApiSecurityUpdateOperationParams {
/// The unique identifier of the service.
pub service_id: String,
/// The unique identifier of the operation.
pub operation_id: String,
pub operation_update: Option<crate::models::OperationUpdate>
}
/// struct for passing parameters to the method [`api_security_update_operation_tag`]
#[derive(Clone, Debug, Default)]
pub struct ApiSecurityUpdateOperationTagParams {
/// The unique identifier of the service.
pub service_id: String,
/// The unique identifier of the operation tag.
pub tag_id: String,
pub body: Option<crate::models::TagBase>
}
/// struct for typed errors of method [`api_security_bulk_add_tags_to_operations`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ApiSecurityBulkAddTagsToOperationsError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status429(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`api_security_bulk_create_operations`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ApiSecurityBulkCreateOperationsError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status429(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`api_security_bulk_delete_operations`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ApiSecurityBulkDeleteOperationsError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status429(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`api_security_create_operation`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ApiSecurityCreateOperationError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status429(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`api_security_create_operation_tag`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ApiSecurityCreateOperationTagError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status429(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`api_security_delete_operation`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ApiSecurityDeleteOperationError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status429(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`api_security_delete_operation_tag`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ApiSecurityDeleteOperationTagError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status429(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`api_security_get_operation`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ApiSecurityGetOperationError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status429(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`api_security_get_operation_tag`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ApiSecurityGetOperationTagError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status429(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`api_security_list_discovered_operations`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ApiSecurityListDiscoveredOperationsError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status429(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`api_security_list_operation_tags`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ApiSecurityListOperationTagsError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status429(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`api_security_list_operations`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ApiSecurityListOperationsError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status429(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`api_security_update_operation`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ApiSecurityUpdateOperationError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status429(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`api_security_update_operation_tag`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ApiSecurityUpdateOperationTagError {
Status400(serde_json::Value),
Status401(serde_json::Value),
Status403(serde_json::Value),
Status404(serde_json::Value),
Status429(serde_json::Value),
UnknownValue(serde_json::Value),
}
/// Add tags to multiple operations in a single request.
pub async fn api_security_bulk_add_tags_to_operations(configuration: &mut configuration::Configuration, params: ApiSecurityBulkAddTagsToOperationsParams) -> Result<crate::models::InlineResponse2071, Error<ApiSecurityBulkAddTagsToOperationsError>> {
let local_var_configuration = configuration;
// unbox the parameters
let service_id = params.service_id;
let operation_bulk_add_tags = params.operation_bulk_add_tags;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api-security/v1/services/{service_id}/operations-bulk-tags", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&operation_bulk_add_tags);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
if "POST" != "GET" && "POST" != "HEAD" {
let headers = local_var_resp.headers();
local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => configuration::DEFAULT_RATELIMIT,
};
local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => 0,
};
}
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ApiSecurityBulkAddTagsToOperationsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Create multiple operations associated with a specific service in a single request.
pub async fn api_security_bulk_create_operations(configuration: &mut configuration::Configuration, params: ApiSecurityBulkCreateOperationsParams) -> Result<crate::models::InlineResponse207, Error<ApiSecurityBulkCreateOperationsError>> {
let local_var_configuration = configuration;
// unbox the parameters
let service_id = params.service_id;
let operation_bulk_create = params.operation_bulk_create;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api-security/v1/services/{service_id}/operations-bulk", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&operation_bulk_create);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
if "POST" != "GET" && "POST" != "HEAD" {
let headers = local_var_resp.headers();
local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => configuration::DEFAULT_RATELIMIT,
};
local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => 0,
};
}
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ApiSecurityBulkCreateOperationsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Delete multiple operations in a single request.
pub async fn api_security_bulk_delete_operations(configuration: &mut configuration::Configuration, params: ApiSecurityBulkDeleteOperationsParams) -> Result<crate::models::InlineResponse2071, Error<ApiSecurityBulkDeleteOperationsError>> {
let local_var_configuration = configuration;
// unbox the parameters
let service_id = params.service_id;
let operation_bulk_delete = params.operation_bulk_delete;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/api-security/v1/services/{service_id}/operations-bulk", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&operation_bulk_delete);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
if "DELETE" != "GET" && "DELETE" != "HEAD" {
let headers = local_var_resp.headers();
local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => configuration::DEFAULT_RATELIMIT,
};
local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => 0,
};
}
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ApiSecurityBulkDeleteOperationsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Create a new operation associated with a specific service.
pub async fn api_security_create_operation(configuration: &mut configuration::Configuration, params: ApiSecurityCreateOperationParams) -> Result<crate::models::OperationGet, Error<ApiSecurityCreateOperationError>> {
let local_var_configuration = configuration;
// unbox the parameters
let service_id = params.service_id;
let operation_create = params.operation_create;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&operation_create);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
if "POST" != "GET" && "POST" != "HEAD" {
let headers = local_var_resp.headers();
local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => configuration::DEFAULT_RATELIMIT,
};
local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => 0,
};
}
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ApiSecurityCreateOperationError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Create a new operation tag associated with a specific service.
pub async fn api_security_create_operation_tag(configuration: &mut configuration::Configuration, params: ApiSecurityCreateOperationTagParams) -> Result<crate::models::TagGet, Error<ApiSecurityCreateOperationTagError>> {
let local_var_configuration = configuration;
// unbox the parameters
let service_id = params.service_id;
let tag_create = params.tag_create;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&tag_create);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
if "POST" != "GET" && "POST" != "HEAD" {
let headers = local_var_resp.headers();
local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => configuration::DEFAULT_RATELIMIT,
};
local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => 0,
};
}
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ApiSecurityCreateOperationTagError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Delete an existing operation associated with a specific service.
pub async fn api_security_delete_operation(configuration: &mut configuration::Configuration, params: ApiSecurityDeleteOperationParams) -> Result<(), Error<ApiSecurityDeleteOperationError>> {
let local_var_configuration = configuration;
// unbox the parameters
let service_id = params.service_id;
let operation_id = params.operation_id;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
if "DELETE" != "GET" && "DELETE" != "HEAD" {
let headers = local_var_resp.headers();
local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => configuration::DEFAULT_RATELIMIT,
};
local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => 0,
};
}
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<ApiSecurityDeleteOperationError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Delete an existing operation tag.
pub async fn api_security_delete_operation_tag(configuration: &mut configuration::Configuration, params: ApiSecurityDeleteOperationTagParams) -> Result<(), Error<ApiSecurityDeleteOperationTagError>> {
let local_var_configuration = configuration;
// unbox the parameters
let service_id = params.service_id;
let tag_id = params.tag_id;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
if "DELETE" != "GET" && "DELETE" != "HEAD" {
let headers = local_var_resp.headers();
local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => configuration::DEFAULT_RATELIMIT,
};
local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => 0,
};
}
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<ApiSecurityDeleteOperationTagError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Get a specific operation associated with a service.
pub async fn api_security_get_operation(configuration: &mut configuration::Configuration, params: ApiSecurityGetOperationParams) -> Result<crate::models::OperationGet, Error<ApiSecurityGetOperationError>> {
let local_var_configuration = configuration;
// unbox the parameters
let service_id = params.service_id;
let operation_id = params.operation_id;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
if "GET" != "GET" && "GET" != "HEAD" {
let headers = local_var_resp.headers();
local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => configuration::DEFAULT_RATELIMIT,
};
local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => 0,
};
}
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ApiSecurityGetOperationError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Get a specific operation tag by its unique identifier.
pub async fn api_security_get_operation_tag(configuration: &mut configuration::Configuration, params: ApiSecurityGetOperationTagParams) -> Result<crate::models::TagGet, Error<ApiSecurityGetOperationTagError>> {
let local_var_configuration = configuration;
// unbox the parameters
let service_id = params.service_id;
let tag_id = params.tag_id;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
if "GET" != "GET" && "GET" != "HEAD" {
let headers = local_var_resp.headers();
local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => configuration::DEFAULT_RATELIMIT,
};
local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => 0,
};
}
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ApiSecurityGetOperationTagError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// List all discovered operations associated with a specific service. Optionally filter operations by status.
pub async fn api_security_list_discovered_operations(configuration: &mut configuration::Configuration, params: ApiSecurityListDiscoveredOperationsParams) -> Result<crate::models::InlineResponse2001, Error<ApiSecurityListDiscoveredOperationsError>> {
let local_var_configuration = configuration;
// unbox the parameters
let service_id = params.service_id;
let method = params.method;
let domain = params.domain;
let path = params.path;
let limit = params.limit;
let page = params.page;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = method {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("method".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => local_var_req_builder.query(&[("method", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref local_var_str) = domain {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("domain".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => local_var_req_builder.query(&[("domain", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref local_var_str) = path {
local_var_req_builder = local_var_req_builder.query(&[("path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = limit {
local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
if "GET" != "GET" && "GET" != "HEAD" {
let headers = local_var_resp.headers();
local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => configuration::DEFAULT_RATELIMIT,
};
local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => 0,
};
}
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ApiSecurityListDiscoveredOperationsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// List all operation tags associated with a specific service.
pub async fn api_security_list_operation_tags(configuration: &mut configuration::Configuration, params: ApiSecurityListOperationTagsParams) -> Result<crate::models::InlineResponse2003, Error<ApiSecurityListOperationTagsError>> {
let local_var_configuration = configuration;
// unbox the parameters
let service_id = params.service_id;
let limit = params.limit;
let page = params.page;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = limit {
local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
if "GET" != "GET" && "GET" != "HEAD" {
let headers = local_var_resp.headers();
local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => configuration::DEFAULT_RATELIMIT,
};
local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => 0,
};
}
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ApiSecurityListOperationTagsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// List all operations associated with a specific service. Optionally filter operations by tag ID.
pub async fn api_security_list_operations(configuration: &mut configuration::Configuration, params: ApiSecurityListOperationsParams) -> Result<crate::models::InlineResponse2002, Error<ApiSecurityListOperationsError>> {
let local_var_configuration = configuration;
// unbox the parameters
let service_id = params.service_id;
let tag_id = params.tag_id;
let status = params.status;
let method = params.method;
let domain = params.domain;
let path = params.path;
let limit = params.limit;
let page = params.page;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = tag_id {
local_var_req_builder = local_var_req_builder.query(&[("tag_id", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = status {
local_var_req_builder = local_var_req_builder.query(&[("status", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = method {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("method".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => local_var_req_builder.query(&[("method", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref local_var_str) = domain {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("domain".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => local_var_req_builder.query(&[("domain", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref local_var_str) = path {
local_var_req_builder = local_var_req_builder.query(&[("path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = limit {
local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = page {
local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
if "GET" != "GET" && "GET" != "HEAD" {
let headers = local_var_resp.headers();
local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => configuration::DEFAULT_RATELIMIT,
};
local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => 0,
};
}
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ApiSecurityListOperationsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Partially update an existing operation associated with a specific service.
pub async fn api_security_update_operation(configuration: &mut configuration::Configuration, params: ApiSecurityUpdateOperationParams) -> Result<crate::models::OperationGet, Error<ApiSecurityUpdateOperationError>> {
let local_var_configuration = configuration;
// unbox the parameters
let service_id = params.service_id;
let operation_id = params.operation_id;
let operation_update = params.operation_update;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&operation_update);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
if "PATCH" != "GET" && "PATCH" != "HEAD" {
let headers = local_var_resp.headers();
local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => configuration::DEFAULT_RATELIMIT,
};
local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => 0,
};
}
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ApiSecurityUpdateOperationError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Partially update an existing operation tag.
pub async fn api_security_update_operation_tag(configuration: &mut configuration::Configuration, params: ApiSecurityUpdateOperationTagParams) -> Result<crate::models::TagGet, Error<ApiSecurityUpdateOperationTagError>> {
let local_var_configuration = configuration;
// unbox the parameters
let service_id = params.service_id;
let tag_id = params.tag_id;
let body = params.body;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_apikey) = local_var_configuration.api_key {
let local_var_key = local_var_apikey.key.clone();
let local_var_value = match local_var_apikey.prefix {
Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
None => local_var_key,
};
local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
};
local_var_req_builder = local_var_req_builder.json(&body);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
if "PATCH" != "GET" && "PATCH" != "HEAD" {
let headers = local_var_resp.headers();
local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => configuration::DEFAULT_RATELIMIT,
};
local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
Some(v) => v.to_str().unwrap().parse().unwrap(),
None => 0,
};
}
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ApiSecurityUpdateOperationTagError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}