()
| 32 | |
| 33 | impl AuthSource { |
| 34 | pub fn from_env() -> Result<Self, ApiError> { |
| 35 | let api_key = read_env_non_empty("ANTHROPIC_API_KEY")?; |
| 36 | let auth_token = read_env_non_empty("ANTHROPIC_AUTH_TOKEN")?; |
| 37 | match (api_key, auth_token) { |
| 38 | (Some(api_key), Some(bearer_token)) => Ok(Self::ApiKeyAndBearer { |
| 39 | api_key, |
| 40 | bearer_token, |
| 41 | }), |
| 42 | (Some(api_key), None) => Ok(Self::ApiKey(api_key)), |
| 43 | (None, Some(bearer_token)) => Ok(Self::BearerToken(bearer_token)), |
| 44 | (None, None) => Err(ApiError::MissingApiKey), |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | #[must_use] |
| 49 | pub fn api_key(&self) -> Option<&str> { |
nothing calls this directly
no test coverage detected