foundation_deployment_cloudflare 0.1.3

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

#![cfg(feature = "cloudflare_resources")]
#![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
// =============================================================================

/// `AlexandriaApiResponseCommon` type.
///
/// Same shape as `super::shared::ErrorsMessagesSuccessObject`.
pub type AlexandriaApiResponseCommon = super::shared::ErrorsMessagesSuccessObject;

/// `AlexandriaCategories` type.
pub type AlexandriaCategories = Vec<AlexandriaCategory>;

/// `AlexandriaCategory` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct AlexandriaCategory {
    /// `created_at` property.
    pub created_at: String,
    /// `description` property.
    pub description: String,
    /// `id` property.
    pub id: String,
    /// `name` property.
    pub name: String,
}

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

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

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

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

/// `AlexandriaGetCategoriesResponse` type.
///
/// Same shape as `super::shared::ApiEnvelope<Option<Vec<AlexandriaCategory>>>`.
pub type AlexandriaGetCategoriesResponse =
    super::shared::ApiEnvelope<Option<Vec<AlexandriaCategory>>>;

/// `AlexandriaGetCategoryResponse` type.
///
/// Same shape as `super::shared::ApiEnvelope<Option<AlexandriaCategory>>`.
pub type AlexandriaGetCategoryResponse = super::shared::ApiEnvelope<Option<AlexandriaCategory>>;

/// `AlexandriaMessages` type.
pub type AlexandriaMessages = Vec<std::collections::HashMap<String, serde_json::Value>>;

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

/// Arguments for [`getCategories_request`].
///
/// Same shape as `super::shared::AccountIdArgs`.
pub type GetCategoriesArgs = super::shared::AccountIdArgs;

/// Arguments for [`getCategoryById_request`].
///
/// Same shape as `super::shared::AccountIdIdArgs`.
pub type GetCategoryByIdArgs = super::shared::AccountIdIdArgs;

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

// -----------------------------------------------------------------------------
// GET /accounts/{accountId}/resource-library/categories
// -----------------------------------------------------------------------------

/// GET /accounts/{accountId}/resource-library/categories.
///
/// 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 = get_categories_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn get_categories_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &GetCategoriesArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<AlexandriaGetCategoriesResponse>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!("/accounts/{}/resource-library/categories", args.account_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()))?;

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

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

// -----------------------------------------------------------------------------
// GET /accounts/{accountId}/resource-library/categories/{id}
// -----------------------------------------------------------------------------

/// GET /accounts/{accountId}/resource-library/categories/{id}.
///
/// 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 = get_category_by_id_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn get_category_by_id_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &GetCategoryByIdArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<AlexandriaGetCategoryResponse>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!(
        "/accounts/{}/resource-library/categories/{}",
        args.account_id, args.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()))?;

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

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