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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
//! External service provider integrations for credential synchronization.
//!
//! This module contains provider implementations for various external services
//! like GitHub, following the Repository Pattern and Dependency Injection principles.
//! Providers handle secure credential synchronization, API interactions, and
//! service-specific configuration management.
//!
//! ## Supported Providers
//!
//! - [`github`] - GitHub API integration for repository and organization sync
//! - [`registry`] - Provider registry management and factory patterns
//!
//! ## Provider Architecture
//!
//! The provider system uses several design patterns:
//!
//! - **Factory Pattern**: [`ProviderFactory`] creates providers dynamically
//! - **Repository Pattern**: Providers implement [`SecretProvider`] trait
//! - **Dependency Injection**: Providers receive configuration via constructor
//!
//! ## Usage Examples
//!
//! ### Using the Provider Factory
//!
//! ```rust,no_run
//! use claude_code_toolkit::providers::ProviderFactory;
//! use std::collections::HashMap;
//!
//! #[tokio::main]
//! async fn main() -> claude_code_toolkit::Result<()> {
//! let factory = ProviderFactory::new();
//!
//! // List available providers
//! let providers = factory.available_providers();
//! println!("Available providers: {:?}", providers);
//!
//! // Create a GitHub provider
//! let mut config = HashMap::new();
//! config.insert("token".to_string(), "your-github-token".to_string());
//! config.insert("org".to_string(), "your-org".to_string());
//!
//! let provider = factory.create("github", &config)?;
//! // Use provider for operations...
//!
//! Ok(())
//! }
//! ```
//!
//! ### Direct Provider Usage
//!
//! ```rust,no_run
//! use claude_code_toolkit::providers::github::GitHubProvider;
//! use std::collections::HashMap;
//!
//! #[tokio::main]
//! async fn main() -> claude_code_toolkit::Result<()> {
//! let mut config = HashMap::new();
//! config.insert("token".to_string(), "your-token".to_string());
//!
//! let provider = GitHubProvider::new(config)?;
//!
//! // Use provider for operations...
//!
//! Ok(())
//! }
//! ```
//!
//! ## Configuration Requirements
//!
//! Each provider has specific configuration requirements:
//!
//! ### GitHub Provider
//! - **Required**: `token` (GitHub personal access token)
//! - **Optional**: `org` (default organization), `base_url` (GitHub Enterprise URL)
//!
//! ## Security Considerations
//!
//! - All API tokens are stored securely and never logged
//! - Network communications use HTTPS with certificate validation
//! - Sensitive configuration is validated before use
//! - Rate limiting and retry logic prevent API abuse
use crateResult;
use crateSecretProvider;
use HashMap;
/// Provider factory following Factory Pattern
/// Provider creator trait for Factory Pattern
/// Base provider implementation with common functionality