foundation_deployment_cloudflare 0.1.3

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

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

/// `AccountsBatchMoveAccountsRequest` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct AccountsBatchMoveAccountsRequest {
    /// `account_ids` property.
    pub account_ids: Vec<String>,
    /// `destination_organization_id` property.
    pub destination_organization_id: String,
}

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

/// `AccountsMoveAccountsRequest` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct AccountsMoveAccountsRequest {
    /// `destination_organization_id` property.
    pub destination_organization_id: String,
}

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

/// `OrganizationsApiBatchAccountMoveResponse` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct OrganizationsApiBatchAccountMoveResponse {
    /// `statuses` property.
    pub statuses: std::collections::HashMap<String, serde_json::Value>,
}

/// `OrganizationsApiMoveAccountResponse` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct OrganizationsApiMoveAccountResponse {
    /// `account_id` property.
    pub account_id: String,
    /// `destination_organization_id` property.
    pub destination_organization_id: String,
    /// `source_organization_id` property.
    pub source_organization_id: String,
}

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

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

/// Arguments for [`Accounts_batchMoveAccounts_request`].
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct AccountsBatchMoveAccountsArgs {
    /// Request body.
    pub body: AccountsBatchMoveAccountsRequest,
}

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

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

// -----------------------------------------------------------------------------
// POST /accounts/move
// -----------------------------------------------------------------------------

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

    let mut builder = PreparedRequestBuilder::post(&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_json(client.into(), builder.build()).await
}

// -----------------------------------------------------------------------------
// POST /accounts/{account_id}/move
// -----------------------------------------------------------------------------

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

    let mut builder = PreparedRequestBuilder::post(&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_json(client.into(), builder.build()).await
}