-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.rs
More file actions
128 lines (122 loc) · 3.24 KB
/
Copy pathlib.rs
File metadata and controls
128 lines (122 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//! FOSSA API client library.
//!
//! A Rust library for interacting with the FOSSA REST API using a
//! trait-based architecture where each operation (Get, List, Update)
//! is defined as a trait that entity types implement.
//!
//! # Quick Start
//!
//! ```no_run
//! use fossapi::{FossaClient, Project, Dependency, Get, List};
//!
//! #[tokio::main]
//! async fn main() -> fossapi::Result<()> {
//! // Create client from environment variables
//! let client = FossaClient::from_env()?;
//!
//! // Get a project by locator
//! let project = Project::get(&client, "custom+my-org/my-project".to_string()).await?;
//! println!("Project: {}", project.title);
//!
//! // List all projects
//! let projects = Project::list_all(&client, &Default::default()).await?;
//! println!("Found {} projects", projects.len());
//!
//! // List dependencies for a revision
//! let deps = fossapi::get_dependencies(
//! &client,
//! "custom+my-org/my-project$main",
//! Default::default(),
//! ).await?;
//! println!("Found {} dependencies", deps.len());
//!
//! Ok(())
//! }
//! ```
//!
//! # Architecture
//!
//! The library is organized around three core traits:
//!
//! - [`Get`] - Fetch a single entity by ID
//! - [`List`] - Fetch paginated collections of entities
//! - [`Update`] - Modify an existing entity
//!
//! Each entity type (like [`Project`] or [`Dependency`]) implements
//! the traits that are supported by its API endpoints.
//!
//! # Configuration
//!
//! The client reads configuration from environment variables:
//!
//! - `FOSSA_API_KEY` (required) - Your FOSSA API key
//! - `FOSSA_API_URL` (optional) - Base URL (defaults to `https://app.fossa.com/api`)
pub mod cli;
mod client;
mod error;
pub mod mcp;
mod models;
pub mod output;
mod pagination;
mod traits;
#[cfg(feature = "test-server")]
pub mod mock_server;
// Re-export core types
pub use client::FossaClient;
pub use error::{FossaError, Result};
pub use pagination::{Page, PaginationParams};
// Re-export traits
pub use output::PrettyPrint;
pub use traits::{Get, List, Update};
// Re-export models
pub use models::{
// Project types
LatestRevision,
Project,
ProjectIssues,
ProjectListQuery,
ProjectUpdateParams,
// Revision types
Revision,
RevisionListQuery,
RevisionLoc,
RevisionQuery,
// Dependency types
Dependency,
DependencyIssue,
DependencyListQuery,
DependencyQuery,
IssueStatus,
IssueType,
LicenseInfo,
// Issue types
Issue,
IssueCategory,
IssueDepths,
IssueEpss,
IssueListQuery,
IssueProject,
IssueRemediation,
IssueSource,
IssueStatuses,
// Snippet types
CodeLine,
Snippet,
SnippetIssueCounts,
SnippetKind,
SnippetLicense,
SnippetListQuery,
SnippetLocation,
SnippetMatch,
SnippetMatchDetails,
SnippetPath,
SnippetQuery,
};
// Re-export convenience functions
pub use models::{get_dependencies, get_dependencies_page};
pub use models::{get_issues, get_issues_page, get_project_issues};
pub use models::{get_revision, get_revisions, get_revisions_page};
pub use models::{
get_snippet_details, get_snippet_locations, get_snippet_match, get_snippet_paths,
get_snippets, get_snippets_page,
};