Skip to content

Commit ee236ff

Browse files
feat: add connector methods and fix DynamicPolicy type (#30)
Add getConnector and getConnectorHealth methods for connector management. Also fix DynamicPolicy type to match API response format (type/conditions/actions/priority instead of category/tier/config). Changes: - Add getConnector(id) to retrieve connector details - Add getConnectorHealth(id) for health check - Add ConnectorHealthStatus type - Fix DynamicPolicy class to use type/conditions/actions/priority - Add DynamicPolicyAction class for action definitions - Update ListDynamicPoliciesOptions to filter by type
1 parent 765c351 commit ee236ff

6 files changed

Lines changed: 313 additions & 134 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- **Get Connector**: `getConnector(id)` to retrieve details for a specific connector
13+
- **Connector Health Check**: `getConnectorHealth(id)` to check health status of an installed connector
14+
- **ConnectorHealthStatus type**: New type for connector health responses
1215
- **Orchestrator Health Check**: `orchestratorHealthCheck()` to verify Orchestrator service health
1316
- **Uninstall Connector**: `uninstallConnector()` to remove installed MCP connectors
1417

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.getaxonflow</groupId>
88
<artifactId>axonflow-sdk</artifactId>
9-
<version>1.10.0</version>
9+
<version>1.11.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>AxonFlow Java SDK</name>

src/main/java/com/getaxonflow/sdk/AxonFlow.java

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,62 @@ public void uninstallConnector(String connectorName) {
615615
}, "uninstallConnector");
616616
}
617617

618+
/**
619+
* Gets details for a specific connector by ID.
620+
*
621+
* @param connectorId the connector ID
622+
* @return the connector info
623+
*/
624+
public ConnectorInfo getConnector(String connectorId) {
625+
Objects.requireNonNull(connectorId, "connectorId cannot be null");
626+
627+
return retryExecutor.execute(() -> {
628+
String path = "/api/v1/connectors/" + connectorId;
629+
Request httpRequest = buildOrchestratorRequest("GET", path, null);
630+
try (Response response = httpClient.newCall(httpRequest).execute()) {
631+
return parseResponse(response, ConnectorInfo.class);
632+
}
633+
}, "getConnector");
634+
}
635+
636+
/**
637+
* Asynchronously gets details for a specific connector by ID.
638+
*
639+
* @param connectorId the connector ID
640+
* @return a future containing the connector info
641+
*/
642+
public CompletableFuture<ConnectorInfo> getConnectorAsync(String connectorId) {
643+
return CompletableFuture.supplyAsync(() -> getConnector(connectorId), asyncExecutor);
644+
}
645+
646+
/**
647+
* Gets the health status of an installed connector.
648+
*
649+
* @param connectorId the connector ID
650+
* @return the health status
651+
*/
652+
public ConnectorHealthStatus getConnectorHealth(String connectorId) {
653+
Objects.requireNonNull(connectorId, "connectorId cannot be null");
654+
655+
return retryExecutor.execute(() -> {
656+
String path = "/api/v1/connectors/" + connectorId + "/health";
657+
Request httpRequest = buildOrchestratorRequest("GET", path, null);
658+
try (Response response = httpClient.newCall(httpRequest).execute()) {
659+
return parseResponse(response, ConnectorHealthStatus.class);
660+
}
661+
}, "getConnectorHealth");
662+
}
663+
664+
/**
665+
* Asynchronously gets the health status of an installed connector.
666+
*
667+
* @param connectorId the connector ID
668+
* @return a future containing the health status
669+
*/
670+
public CompletableFuture<ConnectorHealthStatus> getConnectorHealthAsync(String connectorId) {
671+
return CompletableFuture.supplyAsync(() -> getConnectorHealth(connectorId), asyncExecutor);
672+
}
673+
618674
/**
619675
* Queries an MCP connector.
620676
*
@@ -1330,11 +1386,8 @@ private String buildDynamicPolicyQueryString(String basePath, ListDynamicPolicie
13301386
StringBuilder path = new StringBuilder(basePath);
13311387
StringBuilder query = new StringBuilder();
13321388

1333-
if (options.getCategory() != null) {
1334-
appendQueryParam(query, "category", options.getCategory().getValue());
1335-
}
1336-
if (options.getTier() != null) {
1337-
appendQueryParam(query, "tier", options.getTier().getValue());
1389+
if (options.getType() != null) {
1390+
appendQueryParam(query, "type", options.getType());
13381391
}
13391392
if (options.getEnabled() != null) {
13401393
appendQueryParam(query, "enabled", options.getEnabled().toString());
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
* Copyright 2025 AxonFlow
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.getaxonflow.sdk.types;
17+
18+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
19+
import com.fasterxml.jackson.annotation.JsonProperty;
20+
21+
import java.util.Collections;
22+
import java.util.Map;
23+
import java.util.Objects;
24+
25+
/**
26+
* Health status of an installed MCP connector.
27+
*/
28+
@JsonIgnoreProperties(ignoreUnknown = true)
29+
public final class ConnectorHealthStatus {
30+
31+
@JsonProperty("healthy")
32+
private final Boolean healthy;
33+
34+
@JsonProperty("latency")
35+
private final Long latency;
36+
37+
@JsonProperty("details")
38+
private final Map<String, String> details;
39+
40+
@JsonProperty("timestamp")
41+
private final String timestamp;
42+
43+
@JsonProperty("error")
44+
private final String error;
45+
46+
public ConnectorHealthStatus(
47+
@JsonProperty("healthy") Boolean healthy,
48+
@JsonProperty("latency") Long latency,
49+
@JsonProperty("details") Map<String, String> details,
50+
@JsonProperty("timestamp") String timestamp,
51+
@JsonProperty("error") String error) {
52+
this.healthy = healthy != null ? healthy : false;
53+
this.latency = latency != null ? latency : 0L;
54+
this.details = details != null ? Collections.unmodifiableMap(details) : Collections.emptyMap();
55+
this.timestamp = timestamp != null ? timestamp : "";
56+
this.error = error;
57+
}
58+
59+
/**
60+
* Returns whether the connector is healthy.
61+
*
62+
* @return true if healthy
63+
*/
64+
public Boolean isHealthy() {
65+
return healthy;
66+
}
67+
68+
/**
69+
* Returns the connection latency in nanoseconds.
70+
*
71+
* @return latency in nanoseconds
72+
*/
73+
public Long getLatency() {
74+
return latency;
75+
}
76+
77+
/**
78+
* Returns additional health check details.
79+
*
80+
* @return immutable map of health details
81+
*/
82+
public Map<String, String> getDetails() {
83+
return details;
84+
}
85+
86+
/**
87+
* Returns the timestamp of the health check.
88+
*
89+
* @return ISO 8601 timestamp string
90+
*/
91+
public String getTimestamp() {
92+
return timestamp;
93+
}
94+
95+
/**
96+
* Returns the error message if unhealthy.
97+
*
98+
* @return error message or null if healthy
99+
*/
100+
public String getError() {
101+
return error;
102+
}
103+
104+
@Override
105+
public boolean equals(Object o) {
106+
if (this == o) return true;
107+
if (o == null || getClass() != o.getClass()) return false;
108+
ConnectorHealthStatus that = (ConnectorHealthStatus) o;
109+
return Objects.equals(healthy, that.healthy) &&
110+
Objects.equals(latency, that.latency) &&
111+
Objects.equals(timestamp, that.timestamp) &&
112+
Objects.equals(error, that.error);
113+
}
114+
115+
@Override
116+
public int hashCode() {
117+
return Objects.hash(healthy, latency, timestamp, error);
118+
}
119+
120+
@Override
121+
public String toString() {
122+
return "ConnectorHealthStatus{" +
123+
"healthy=" + healthy +
124+
", latency=" + latency +
125+
", timestamp='" + timestamp + '\'' +
126+
", error='" + error + '\'' +
127+
'}';
128+
}
129+
}

0 commit comments

Comments
 (0)