foundation_deployment_cloudflare 0.1.3

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

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

/// `OrganizationsApiAccount` type.
///
/// Same shape as `super::shared::OrganizationsApiAccountShape`.
pub type OrganizationsApiAccount = super::shared::OrganizationsApiAccountShape;

/// `OrganizationsApiTenant` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct OrganizationsApiTenant {
    /// `cdate` property.
    pub cdate: String,
    /// `customer_id` property.
    pub customer_id: Option<String>,
    /// `edate` property.
    pub edate: String,
    /// `tenant_contacts` property.
    pub tenant_contacts: std::collections::HashMap<String, serde_json::Value>,
    /// `tenant_labels` property.
    pub tenant_labels: Vec<String>,
    /// `tenant_metadata` property.
    pub tenant_metadata: std::collections::HashMap<String, serde_json::Value>,
    /// `tenant_name` property.
    pub tenant_name: String,
    /// `tenant_network` property.
    pub tenant_network: serde_json::Value,
    /// `tenant_status` property.
    pub tenant_status: String,
    /// `tenant_tag` property.
    pub tenant_tag: String,
    /// `tenant_type` property.
    pub tenant_type: String,
    /// `tenant_units` property.
    pub tenant_units: Vec<OrganizationsApiTenantUnit>,
}

/// `OrganizationsApiTenantUnit` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct OrganizationsApiTenantUnit {
    /// `unit_memberships` property.
    pub unit_memberships: Vec<serde_json::Value>,
    /// `unit_metadata` property.
    pub unit_metadata: serde_json::Value,
    /// `unit_name` property.
    pub unit_name: String,
    /// `unit_status` property.
    pub unit_status: String,
    /// `unit_tag` property.
    pub unit_tag: String,
}

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

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

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

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

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

/// Arguments for [`Tenants_retrieveTenant_request`].
///
/// Same shape as `super::shared::TenantIdArgs`.
pub type TenantsRetrieveTenantArgs = super::shared::TenantIdArgs;

/// Arguments for [`Tenants_validAccountTypes_request`].
///
/// Same shape as `super::shared::TenantIdArgs`.
pub type TenantsValidAccountTypesArgs = super::shared::TenantIdArgs;

/// Arguments for [`Tenants_listAccounts_request`].
///
/// Same shape as `super::shared::TenantIdArgs`.
pub type TenantsListAccountsArgs = super::shared::TenantIdArgs;

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

// -----------------------------------------------------------------------------
// GET /tenants/{tenant_id}
// -----------------------------------------------------------------------------

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

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

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