1use serde::Serialize;
2
3use crate::{CONNECTOR, ConnectorConfig, ConnectorError, PROVIDER};
4
5const CAPABILITIES: &[&str] = &[
6 "issue-observe",
7 "pull-request-observe",
8 "release-observe",
9 "repository-metadata-observe",
10 "workflow-run-observe",
11 "workflow-artifact-observe",
12 "workflow-artifact-download",
13 "private-repository-create",
14 "repository-snapshot-push",
15 "repository-delete",
16 "issue-create",
17 "pull-request-create",
18 "workflow-dispatch",
19];
20
21#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
22pub struct DoctorReport {
23 pub schema: &'static str,
24 pub connector: &'static str,
25 pub status: &'static str,
26 pub network_client_linked: bool,
27 pub secret_resolution_enabled: bool,
28 pub execution_enabled: bool,
29 pub embedded_authorization_policy: bool,
30 pub caller_authorization_required: bool,
31 pub codex_credential_reuse: bool,
32}
33
34#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
35pub struct CapabilityReport {
36 pub schema: &'static str,
37 pub connector: &'static str,
38 pub provider: &'static str,
39 pub planning_only: bool,
40 pub capabilities: Vec<&'static str>,
41}
42
43#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
44pub struct ValidationReport {
45 pub schema: &'static str,
46 pub connector: &'static str,
47 pub config_id: String,
48 pub valid: bool,
49}
50
51#[must_use]
52pub const fn doctor() -> DoctorReport {
53 DoctorReport {
54 schema: "zixcel://doctor/v1",
55 connector: CONNECTOR,
56 status: "healthy",
57 network_client_linked: false,
58 secret_resolution_enabled: false,
59 execution_enabled: true,
60 embedded_authorization_policy: false,
61 caller_authorization_required: true,
62 codex_credential_reuse: false,
63 }
64}
65
66#[must_use]
67pub fn capabilities() -> CapabilityReport {
68 CapabilityReport {
69 schema: "zixcel://capabilities/v1",
70 connector: CONNECTOR,
71 provider: PROVIDER,
72 planning_only: false,
73 capabilities: CAPABILITIES.to_vec(),
74 }
75}
76
77pub fn validation_report(config: &ConnectorConfig) -> Result<ValidationReport, ConnectorError> {
78 config.validate()?;
79 Ok(ValidationReport {
80 schema: "zixcel://validation-result/v1",
81 connector: CONNECTOR,
82 config_id: config.config_id.clone(),
83 valid: true,
84 })
85}