foundation_deployment_cloudflare 0.1.3

Cloudflare API v4 client — DNS records, zones, certificates
//! Auto-generated API module for cloudflare reports.
//!
//! Generated by `cargo run --bin ewe_platform gen_api`.
//! DO NOT EDIT MANUALLY.
//!
//! Feature flag: `cloudflare_reports `

#![cfg(feature = "cloudflare_reports")]
#![allow(clippy::too_many_arguments, clippy::type_complexity)]
#![allow(
    clippy::missing_errors_doc,
    clippy::doc_markdown,
    clippy::useless_format
)]
#![allow(unused_imports)]

use foundation_macros::JsonHash;
use foundation_netio::shared::client::http_client::HttpClient;
use foundation_netio::{DynNetClient, PreparedRequestBuilder};
use serde::{Deserialize, Serialize};

use super::shared::ApiResponse;

// =============================================================================
// TYPE DECLARATIONS
// =============================================================================

/// `AbuseReportsEmailListItem` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct AbuseReportsEmailListItem {
    /// `body` property.
    pub body: String,
    /// `id` property.
    pub id: String,
    /// `recipient` property.
    pub recipient: String,
    /// `sent_at` property.
    pub sent_at: String,
    /// `subject` property.
    pub subject: String,
}

/// `AbuseReportsMessage` type.
///
/// Same shape as `super::shared::MessageObject`.
pub type AbuseReportsMessage = super::shared::MessageObject;

/// `AbuseReportsMitigatedEntityType` type.
pub type AbuseReportsMitigatedEntityType = String;

/// `AbuseReportsMitigationListItem` type.
///
/// Same shape as `super::shared::AbuseReportsMitigationListItemShape`.
pub type AbuseReportsMitigationListItem = super::shared::AbuseReportsMitigationListItemShape;

/// `AbuseReportsMitigationStatus` type.
pub type AbuseReportsMitigationStatus = String;

/// `AbuseReportsMitigationType` type.
pub type AbuseReportsMitigationType = String;

/// `ListEmailsResponse` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct ListEmailsResponse {
    /// `errors` property.
    pub errors: Option<Vec<AbuseReportsMessage>>,
    /// `messages` property.
    pub messages: Option<Vec<AbuseReportsMessage>>,
    /// `result` property.
    pub result: Option<ListEmailsResponseResult>,
    /// `result_info` property.
    pub result_info: Option<ListEmailsResponseResultInfo>,
    /// `success` property.
    pub success: bool,
}

/// `ListEmailsResponseResult` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct ListEmailsResponseResult {
    /// `emails` property.
    pub emails: Vec<AbuseReportsEmailListItem>,
}

/// `ListEmailsResponseResultInfo` type.
///
/// Same shape as `super::shared::ListAbuseReportsResponseResultInfoShape`.
pub type ListEmailsResponseResultInfo = super::shared::ListAbuseReportsResponseResultInfoShape;

/// `ListMitigationsResponse` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct ListMitigationsResponse {
    /// `errors` property.
    pub errors: Option<Vec<AbuseReportsMessage>>,
    /// `messages` property.
    pub messages: Option<Vec<AbuseReportsMessage>>,
    /// `result` property.
    pub result: Option<ListMitigationsResponseResult>,
    /// `result_info` property.
    pub result_info: Option<ListMitigationsResponseResultInfo>,
    /// `success` property.
    pub success: bool,
}

/// `ListMitigationsResponseResult` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct ListMitigationsResponseResult {
    /// `mitigations` property.
    pub mitigations: Vec<AbuseReportsMitigationListItem>,
}

/// `ListMitigationsResponseResultInfo` type.
///
/// Same shape as `super::shared::ListAbuseReportsResponseResultInfoShape`.
pub type ListMitigationsResponseResultInfo = super::shared::ListAbuseReportsResponseResultInfoShape;

// =============================================================================
// ARGS TYPES (per-endpoint)
// =============================================================================

/// Arguments for [`ListEmails_request`].
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct ListEmailsArgs {
    /// Path parameter: `account_id`.
    pub account_id: String,
    /// Path parameter: `report_id`.
    pub report_id: String,
    /// Query parameter: `page`.
    pub page: Option<String>,
    /// Query parameter: `per_page`.
    pub per_page: Option<String>,
}

/// Arguments for [`ListMitigations_request`].
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct ListMitigationsArgs {
    /// Path parameter: `account_id`.
    pub account_id: String,
    /// Path parameter: `report_id`.
    pub report_id: String,
    /// Query parameter: `page`.
    pub page: Option<String>,
    /// Query parameter: `per_page`.
    pub per_page: Option<String>,
    /// Query parameter: `sort`.
    pub sort: Option<String>,
    /// Query parameter: `type`.
    pub r#type: Option<String>,
    /// Query parameter: `effective_before`.
    pub effective_before: Option<String>,
    /// Query parameter: `effective_after`.
    pub effective_after: Option<String>,
    /// Query parameter: `status`.
    pub status: Option<String>,
    /// Query parameter: `entity_type`.
    pub entity_type: Option<String>,
}

// =============================================================================
// CLIENT FUNCTIONS (per-endpoint)
// =============================================================================

// -----------------------------------------------------------------------------
// GET /accounts/{account_id}/abuse-reports/{report_id}/emails
// -----------------------------------------------------------------------------

/// GET /accounts/{account_id}/abuse-reports/{report_id}/emails.
///
/// Takes a client and args, builds the request, optionally applies
/// modifications, then sends it via `send_async().await`.
///
/// # Arguments
///
/// * `client` - HTTP client for making the request: a `DynNetClient`, or an `ApiClient` carrying the `BodyLimits` the response is read under
/// * `args` - Request arguments (path params, query params, body)
/// * `builder_mod` - Optional closure to modify the request builder (e.g., add headers)
///
/// # Example
///
/// ```ignore
/// let response = list_emails_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn list_emails_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &ListEmailsArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<ListEmailsResponse>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!(
        "/accounts/{}/abuse-reports/{}/emails",
        args.account_id, args.report_id,
    );
    let endpoint_url = format!("{}{}", base_url, path);

    let mut builder = PreparedRequestBuilder::get(&endpoint_url)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

    builder = builder.query("page", args.page.as_deref());
    builder = builder.query("per_page", args.per_page.as_deref());

    if let Some(f) = builder_mod {
        f(&mut builder);
    }

    super::shared::send_json(client.into(), builder.build()).await
}

// -----------------------------------------------------------------------------
// GET /accounts/{account_id}/abuse-reports/{report_id}/mitigations
// -----------------------------------------------------------------------------

/// GET /accounts/{account_id}/abuse-reports/{report_id}/mitigations.
///
/// Takes a client and args, builds the request, optionally applies
/// modifications, then sends it via `send_async().await`.
///
/// # Arguments
///
/// * `client` - HTTP client for making the request: a `DynNetClient`, or an `ApiClient` carrying the `BodyLimits` the response is read under
/// * `args` - Request arguments (path params, query params, body)
/// * `builder_mod` - Optional closure to modify the request builder (e.g., add headers)
///
/// # Example
///
/// ```ignore
/// let response = list_mitigations_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn list_mitigations_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &ListMitigationsArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<ListMitigationsResponse>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!(
        "/accounts/{}/abuse-reports/{}/mitigations",
        args.account_id, args.report_id,
    );
    let endpoint_url = format!("{}{}", base_url, path);

    let mut builder = PreparedRequestBuilder::get(&endpoint_url)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

    builder = builder.query("page", args.page.as_deref());
    builder = builder.query("per_page", args.per_page.as_deref());
    builder = builder.query("sort", args.sort.as_deref());
    builder = builder.query("type", args.r#type.as_deref());
    builder = builder.query("effective_before", args.effective_before.as_deref());
    builder = builder.query("effective_after", args.effective_after.as_deref());
    builder = builder.query("status", args.status.as_deref());
    builder = builder.query("entity_type", args.entity_type.as_deref());

    if let Some(f) = builder_mod {
        f(&mut builder);
    }

    super::shared::send_json(client.into(), builder.build()).await
}