foundation_deployment_cloudflare 0.1.3

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

#![cfg(feature = "cloudflare_profile")]
#![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};

// Import shared types used by this module
use super::shared::OrganizationsApiProfile;

use super::shared::ApiResponse;

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

/// `AccountsGetAccountProfileResponse` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct AccountsGetAccountProfileResponse {
    /// `errors` property.
    pub errors: Vec<serde_json::Value>,
    /// `messages` property.
    pub messages: Vec<OrganizationsApiV4Message>,
    /// `result` property.
    pub result: OrganizationsApiProfile,
    /// `success` property.
    pub success: bool,
}

/// `OrganizationsApiV4Message` type.
///
/// Same shape as `super::shared::CodeMessageObject2`.
pub type OrganizationsApiV4Message = super::shared::CodeMessageObject2;

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

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

/// Arguments for [`Accounts_modifyAccountProfile_request`].
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct AccountsModifyAccountProfileArgs {
    /// Path parameter: `account_id`.
    pub account_id: String,
    /// Request body.
    pub body: OrganizationsApiProfile,
}

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

// -----------------------------------------------------------------------------
// GET /accounts/{account_id}/profile
// -----------------------------------------------------------------------------

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

// -----------------------------------------------------------------------------
// PUT /accounts/{account_id}/profile
// -----------------------------------------------------------------------------

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

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

    builder = builder
        .body_json(&args.body)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

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

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