backstage-client 0.1.4

A Rust client library for interacting with the Backstage Catalog API. Provides type-safe access to Backstage entities with async support, filtering, and comprehensive error handling.
Documentation
//! # Backstage Client Library
//!
//! A Rust client library for interacting with the Backstage Catalog API.
//! This library provides type-safe access to Backstage entities and supports
//! filtering, querying, and retrieving various entity types.
//!
//! ## Features
//!
//! - **Type-safe entities**: Strongly typed representations of all Backstage entity kinds
//! - **Async support**: Built on tokio and reqwest for modern async operations
//! - **Filtering**: Support for complex entity filtering using query parameters
//! - **Error handling**: Comprehensive error types with detailed error information
//! - **Authentication**: Bearer token authentication support
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use backstage_client::{BackstageClient, entities::Entity};
//! use std::collections::HashMap;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//!     let client = BackstageClient::new("https://backstage.example.com", "your-token")?;
//!
//!     // Fetch all entities
//!     let entities = client.fetch_entities::<Entity>(None).await?;
//!     println!("Found {} entities", entities.len());
//!
//!     // Fetch only components
//!     let mut filters = HashMap::new();
//!     filters.insert("kind".to_string(), "Component".to_string());
//!     let components = client.fetch_entities::<Entity>(Some(filters)).await?;
//!     println!("Found {} components", components.len());
//!
//!     Ok(())
//! }
//! ```
//!
//! ## Supported Entity Types
//!
//! - [`Component`](entities::Component) - Software components
//! - [`ApiEntity`](entities::ApiEntity) - API definitions
//! - [`ResourceEntity`](entities::ResourceEntity) - Infrastructure resources
//! - [`SystemEntity`](entities::SystemEntity) - System definitions
//! - [`GroupEntity`](entities::GroupEntity) - User groups
//! - [`UserEntity`](entities::UserEntity) - Individual users
//! - [`LocationEntity`](entities::LocationEntity) - Entity locations
//! - [`DomainEntity`](entities::DomainEntity) - Business domains
//! - [`TemplateEntity`](entities::TemplateEntity) - Software templates

pub mod client;
pub mod entities;
pub mod error;

// Re-export the main client and commonly used types
pub use client::BackstageClient;
pub use error::{ClientError, Result};

// Re-export all entity types for convenience
pub use entities::{
    ApiEntity, Component, DomainEntity, Entity, GroupEntity, LocationEntity, Metadata,
    ResourceEntity, SystemEntity, TemplateEntity, UserEntity,
};

// Re-export common types
pub use entities::common::{Relation, Target};

#[cfg(test)]
mod tests {
    use super::*;
    use std::collections::HashMap;

    #[test]
    fn test_library_exports() {
        // Test that we can create a client
        let client_result = BackstageClient::new("https://example.com", "token");
        assert!(client_result.is_ok());

        // Test that we can create filters
        let mut filters = HashMap::new();
        filters.insert("kind".to_string(), "Component".to_string());

        // Test that error types are accessible
        let _error: ClientError = ClientError::InvalidUrl("test".to_string());
    }
}