//! # cnb — Rust client for the [CNB (Cloud Native Build)](https://cnb.cool) platform.
//!
//! An async, typed, production-grade SDK for the CNB public API, covering all
//! 241 operations across 28 tag groups (repositories, issues, pulls, git,
//! releases, builds, artifactories, workspaces, AI helpers, …).
//!
//! This crate is **not officially affiliated** with CNB.
//!
//! ## Quick start
//!
//! ```no_run
//! use cnb::ApiClient;
//!
//! # async fn run() -> Result<(), Box<dyn std::error::Error>> {
//! // Picks up `CNB_TOKEN` from the environment.
//! let client = ApiClient::new()?;
//!
//! # #[cfg(feature = "users")]
//! # {
//! let me = client.users().get_user_info().await?;
//! println!("{me:?}");
//! # }
//! # Ok(())
//! # }
//! ```
//!
//! Every resource method returns a [`Result<T>`](crate::Result) where `T` is a
//! typed DTO from the [`models`] module (or `serde_json::Value` for endpoints
//! where the upstream spec did not pin a schema).
//!
//! ## Features
//!
//! | Feature            | Default | Description                                        |
//! | ------------------ | :-----: | -------------------------------------------------- |
//! | `rustls-tls`       | ✓       | Use `rustls` as the TLS backend (no OpenSSL).      |
//! | `native-tls`       |         | Use the system TLS (OpenSSL / Secure Transport).   |
//! | `retry`            | ✓       | Automatic retries with exponential back-off.       |
//! | `tracing`          |         | Emit `tracing` spans for each API call.            |
//! | `stream`           |         | `Stream`-based pagination helpers.                 |
//! | `all-resources`    | ✓       | Enable every resource module. Disable to slim.     |
//! | _per-resource_     | ✓       | `activities`, `ai`, …, `workspace` — see `Cargo.toml`. |
//!
//! TLS backends are mutually exclusive. When disabling the default, pick one:
//!
//! ```toml
//! cnb = { version = "0.2", default-features = false, features = ["native-tls", "retry", "all-resources"] }
//! ```
//!
//! ## Error handling
//!
//! All errors are a [`ApiError`]. Non-2xx responses preserve the raw body plus
//! any parsed `code` / `message` / `request_id` fields:
//!
//! ```no_run
//! use cnb::{ApiClient, ApiError};
//!
//! # async fn run() -> Result<(), Box<dyn std::error::Error>> {
//! let client = ApiClient::new()?;
//! # #[cfg(feature = "repositories")]
//! # {
//! match client.repositories().get_by_id("owner/name".into()).await {
//!     Ok(repo) => println!("{repo:?}"),
//!     Err(ApiError::Http { status: 404, .. }) => println!("not found"),
//!     Err(ApiError::Http { status, body, .. }) => println!("HTTP {status}: {body}"),
//!     Err(e) => println!("transport error: {e}"),
//! }
//! # }
//! # Ok(())
//! # }
//! ```

#![cfg_attr(docsrs, feature(doc_cfg))]
#![deny(rust_2018_idioms)]
#![warn(missing_docs)]

// -----------------------------------------------------------------------------
// Hand-written core runtime.
// -----------------------------------------------------------------------------
mod client;
mod error;
pub mod http;
pub mod pagination;
mod retry;

pub use client::{ApiClient, ClientBuilder, CNB_API_ACCEPT, DEFAULT_BASE_URL, TOKEN_ENV_VAR};
pub use error::{ApiError, Result};
pub use retry::RetryConfig;

// -----------------------------------------------------------------------------
// Generated DTOs.
// -----------------------------------------------------------------------------
pub mod models;

// -----------------------------------------------------------------------------
// Generated resource modules, each gated behind a per-resource feature.
// -----------------------------------------------------------------------------
#[cfg(feature = "activities")]
#[cfg_attr(docsrs, doc(cfg(feature = "activities")))]
pub mod activities;
#[cfg(feature = "ai")]
#[cfg_attr(docsrs, doc(cfg(feature = "ai")))]
pub mod ai;
#[cfg(feature = "artifactory")]
#[cfg_attr(docsrs, doc(cfg(feature = "artifactory")))]
pub mod artifactory;
#[cfg(feature = "assets")]
#[cfg_attr(docsrs, doc(cfg(feature = "assets")))]
pub mod assets;
#[cfg(feature = "badge")]
#[cfg_attr(docsrs, doc(cfg(feature = "badge")))]
pub mod badge;
#[cfg(feature = "build")]
#[cfg_attr(docsrs, doc(cfg(feature = "build")))]
pub mod build;
#[cfg(feature = "charge")]
#[cfg_attr(docsrs, doc(cfg(feature = "charge")))]
pub mod charge;
#[cfg(feature = "event")]
#[cfg_attr(docsrs, doc(cfg(feature = "event")))]
pub mod event;
#[cfg(feature = "followers")]
#[cfg_attr(docsrs, doc(cfg(feature = "followers")))]
pub mod followers;
#[cfg(feature = "git")]
#[cfg_attr(docsrs, doc(cfg(feature = "git")))]
pub mod git;
#[cfg(feature = "git_settings")]
#[cfg_attr(docsrs, doc(cfg(feature = "git_settings")))]
pub mod git_settings;
#[cfg(feature = "issues")]
#[cfg_attr(docsrs, doc(cfg(feature = "issues")))]
pub mod issues;
#[cfg(feature = "knowledge_base")]
#[cfg_attr(docsrs, doc(cfg(feature = "knowledge_base")))]
pub mod knowledge_base;
#[cfg(feature = "members")]
#[cfg_attr(docsrs, doc(cfg(feature = "members")))]
pub mod members;
#[cfg(feature = "missions")]
#[cfg_attr(docsrs, doc(cfg(feature = "missions")))]
pub mod missions;
#[cfg(feature = "organizations")]
#[cfg_attr(docsrs, doc(cfg(feature = "organizations")))]
pub mod organizations;
#[cfg(feature = "pulls")]
#[cfg_attr(docsrs, doc(cfg(feature = "pulls")))]
pub mod pulls;
#[cfg(feature = "rank")]
#[cfg_attr(docsrs, doc(cfg(feature = "rank")))]
pub mod rank;
#[cfg(feature = "registries")]
#[cfg_attr(docsrs, doc(cfg(feature = "registries")))]
pub mod registries;
#[cfg(feature = "releases")]
#[cfg_attr(docsrs, doc(cfg(feature = "releases")))]
pub mod releases;
#[cfg(feature = "repo_code_issue")]
#[cfg_attr(docsrs, doc(cfg(feature = "repo_code_issue")))]
pub mod repo_code_issue;
#[cfg(feature = "repo_contributor")]
#[cfg_attr(docsrs, doc(cfg(feature = "repo_contributor")))]
pub mod repo_contributor;
#[cfg(feature = "repo_labels")]
#[cfg_attr(docsrs, doc(cfg(feature = "repo_labels")))]
pub mod repo_labels;
#[cfg(feature = "repositories")]
#[cfg_attr(docsrs, doc(cfg(feature = "repositories")))]
pub mod repositories;
#[cfg(feature = "search")]
#[cfg_attr(docsrs, doc(cfg(feature = "search")))]
pub mod search;
#[cfg(feature = "security")]
#[cfg_attr(docsrs, doc(cfg(feature = "security")))]
pub mod security;
#[cfg(feature = "starring")]
#[cfg_attr(docsrs, doc(cfg(feature = "starring")))]
pub mod starring;
#[cfg(feature = "users")]
#[cfg_attr(docsrs, doc(cfg(feature = "users")))]
pub mod users;
#[cfg(feature = "wiki")]
#[cfg_attr(docsrs, doc(cfg(feature = "wiki")))]
pub mod wiki;
#[cfg(feature = "workspace")]
#[cfg_attr(docsrs, doc(cfg(feature = "workspace")))]
pub mod workspace;
