foundation_deployment_cloudflare 0.1.3

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

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

/// `OrganizationsApiBoolAllocation` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct OrganizationsApiBoolAllocation {
    /// `type` property.
    #[serde(rename = "type")]
    pub r#type: String,
    /// `value` property.
    pub value: bool,
}

/// `OrganizationsApiEntitlement` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct OrganizationsApiEntitlement {
    /// `allocation` property.
    pub allocation: serde_json::Value,
    /// `feature` property.
    pub feature: OrganizationsApiFeature,
}

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

/// `OrganizationsApiInnateEntitlements` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct OrganizationsApiInnateEntitlements {
    /// `allow_add_subdomain` property.
    pub allow_add_subdomain: OrganizationsApiBoolAllocation,
    /// `allow_auto_accept_invites` property.
    pub allow_auto_accept_invites: OrganizationsApiBoolAllocation,
    /// `cname_setup_allowed` property.
    pub cname_setup_allowed: OrganizationsApiBoolAllocation,
    /// `custom_entitlements` property.
    pub custom_entitlements: Option<Vec<OrganizationsApiEntitlement>>,
    /// `mhs_certificate_count` property.
    pub mhs_certificate_count: OrganizationsApiMaxCountAllocation,
    /// `partial_setup_allowed` property.
    pub partial_setup_allowed: OrganizationsApiBoolAllocation,
}

/// `OrganizationsApiMaxCountAllocation` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct OrganizationsApiMaxCountAllocation {
    /// `type` property.
    #[serde(rename = "type")]
    pub r#type: String,
    /// `value` property.
    pub value: i64,
}

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

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

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

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

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

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

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