pub struct ApiClient { /* private fields */ }Expand description
HTTP API client for Conductor server.
Thread-safe and cloneable. Multiple clones share the same connection pool and authentication state.
§Authentication
The client automatically handles authentication when credentials are configured:
- Fetches tokens from
/tokenendpoint using key/secret - Proactively refreshes tokens before TTL expiration (default: 45 min)
- Automatically retries requests on 401 after refreshing token
- Gracefully handles OSS Conductor (no auth endpoint returns 404)
§Environment Variables
Configure via environment variables or .env file:
CONDUCTOR_SERVER_URL: Server API URL (default: http://localhost:8080/api)CONDUCTOR_AUTH_KEY: Authentication key ID (Orkes Conductor)CONDUCTOR_AUTH_SECRET: Authentication secret (Orkes Conductor)CONDUCTOR_AUTH_TOKEN_TTL_MINS: Token TTL in minutes (default: 45)CONDUCTOR_DEBUG: Enable debug logging (true/false)CONDUCTOR_TIMEOUT_SECS: Request timeout in seconds (default: 30)
Implementations§
Source§impl ApiClient
impl ApiClient
Sourcepub fn new(config: Configuration) -> Result<Self>
pub fn new(config: Configuration) -> Result<Self>
Create a new API client.
The client will automatically handle authentication if credentials are
configured via CONDUCTOR_AUTH_KEY and CONDUCTOR_AUTH_SECRET environment
variables, or via Configuration::with_auth().
§Errors
Returns crate::error::ConductorError::Http if the underlying reqwest client fails to build
(e.g. TLS backend initialization failure) – this doesn’t make any network request.
Sourcepub fn set_http_observer(&mut self, observer: Arc<dyn HttpMetricsObserver>)
pub fn set_http_observer(&mut self, observer: Arc<dyn HttpMetricsObserver>)
Install an HTTP metrics observer on an existing client.
All subsequent clones share the same observer via Arc.
Sourcepub async fn get<T>(&self, path: impl Into<ApiPath<'_>>) -> Result<T>where
T: DeserializeOwned,
pub async fn get<T>(&self, path: impl Into<ApiPath<'_>>) -> Result<T>where
T: DeserializeOwned,
GET request.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.
Sourcepub async fn get_text(&self, path: impl Into<ApiPath<'_>>) -> Result<String>
pub async fn get_text(&self, path: impl Into<ApiPath<'_>>) -> Result<String>
GET request returning raw text (for endpoints that respond with
text/plain rather than JSON, e.g. secret values)
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, or an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status.
Sourcepub async fn get_with_params<T>(
&self,
path: impl Into<ApiPath<'_>>,
params: &[(&str, &str)],
) -> Result<T>where
T: DeserializeOwned,
pub async fn get_with_params<T>(
&self,
path: impl Into<ApiPath<'_>>,
params: &[(&str, &str)],
) -> Result<T>where
T: DeserializeOwned,
GET request with query parameters.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.
Sourcepub async fn get_stream(&self, path: impl Into<ApiPath<'_>>) -> Result<Response>
pub async fn get_stream(&self, path: impl Into<ApiPath<'_>>) -> Result<Response>
GET request that returns the raw, unbuffered Response instead of deserializing it.
For endpoints whose body is consumed incrementally (e.g. Server-Sent Events) rather than
parsed as a single JSON document. Applies the same auth-header/refresh handling as
get, but does not retry on 401 — a streaming caller has already begun
reading the body by the time a status past the headers would be observed, so there is no
safe point to re-issue the request transparently.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, or an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status.
Sourcepub async fn post<B, T>(
&self,
path: impl Into<ApiPath<'_>>,
body: &B,
) -> Result<T>
pub async fn post<B, T>( &self, path: impl Into<ApiPath<'_>>, body: &B, ) -> Result<T>
POST request.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.
Sourcepub async fn post_text<B>(
&self,
path: impl Into<ApiPath<'_>>,
body: &B,
) -> Result<String>where
B: Serialize,
pub async fn post_text<B>(
&self,
path: impl Into<ApiPath<'_>>,
body: &B,
) -> Result<String>where
B: Serialize,
POST request returning raw text.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.
Sourcepub async fn put<B, T>(
&self,
path: impl Into<ApiPath<'_>>,
body: &B,
) -> Result<T>
pub async fn put<B, T>( &self, path: impl Into<ApiPath<'_>>, body: &B, ) -> Result<T>
PUT request.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.
Sourcepub async fn delete<T>(&self, path: impl Into<ApiPath<'_>>) -> Result<T>where
T: DeserializeOwned,
pub async fn delete<T>(&self, path: impl Into<ApiPath<'_>>) -> Result<T>where
T: DeserializeOwned,
DELETE request.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, or an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status.
Sourcepub async fn delete_no_content(
&self,
path: impl Into<ApiPath<'_>>,
) -> Result<()>
pub async fn delete_no_content( &self, path: impl Into<ApiPath<'_>>, ) -> Result<()>
DELETE request with no response body.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, or an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status.
Sourcepub async fn delete_with_body<B>(
&self,
path: impl Into<ApiPath<'_>>,
body: &B,
) -> Result<()>
pub async fn delete_with_body<B>( &self, path: impl Into<ApiPath<'_>>, body: &B, ) -> Result<()>
DELETE request with body.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.
Sourcepub async fn delete_with_params(
&self,
path: impl Into<ApiPath<'_>>,
params: &[(&str, &str)],
) -> Result<()>
pub async fn delete_with_params( &self, path: impl Into<ApiPath<'_>>, params: &[(&str, &str)], ) -> Result<()>
DELETE request with query parameters.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.
Sourcepub async fn post_no_response<B>(
&self,
path: impl Into<ApiPath<'_>>,
body: &B,
) -> Result<()>
pub async fn post_no_response<B>( &self, path: impl Into<ApiPath<'_>>, body: &B, ) -> Result<()>
POST request with no response.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, or an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status.
Sourcepub async fn post_no_body<T>(&self, path: impl Into<ApiPath<'_>>) -> Result<T>where
T: DeserializeOwned,
pub async fn post_no_body<T>(&self, path: impl Into<ApiPath<'_>>) -> Result<T>where
T: DeserializeOwned,
POST request with no body.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.
Sourcepub async fn post_no_body_no_response(
&self,
path: impl Into<ApiPath<'_>>,
) -> Result<()>
pub async fn post_no_body_no_response( &self, path: impl Into<ApiPath<'_>>, ) -> Result<()>
POST request with no body and no response.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, or an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status.
Sourcepub async fn put_no_response<B>(
&self,
path: impl Into<ApiPath<'_>>,
body: &B,
) -> Result<()>
pub async fn put_no_response<B>( &self, path: impl Into<ApiPath<'_>>, body: &B, ) -> Result<()>
PUT request with no response.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, or an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status.
Sourcepub async fn put_no_body(&self, path: impl Into<ApiPath<'_>>) -> Result<()>
pub async fn put_no_body(&self, path: impl Into<ApiPath<'_>>) -> Result<()>
PUT request with no request body and no response body
For endpoints mapped as a bare @PutMapping with no @RequestBody –
e.g. /scheduler/schedules/{name}/pause. Sends no payload and no
Content-Type at all, rather than a JSON null.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, or an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status.
Sourcepub async fn put_raw(
&self,
path: impl Into<ApiPath<'_>>,
body: &str,
) -> Result<()>
pub async fn put_raw( &self, path: impl Into<ApiPath<'_>>, body: &str, ) -> Result<()>
PUT request with raw text body.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, or an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status.
Sourcepub async fn post_with_params<B, T>(
&self,
path: impl Into<ApiPath<'_>>,
body: &B,
params: &[(&str, &str)],
) -> Result<T>
pub async fn post_with_params<B, T>( &self, path: impl Into<ApiPath<'_>>, body: &B, params: &[(&str, &str)], ) -> Result<T>
POST request with JSON body and query parameters.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.
Sourcepub async fn post_raw_with_params(
&self,
path: impl Into<ApiPath<'_>>,
body: &str,
params: &[(&str, &str)],
) -> Result<()>
pub async fn post_raw_with_params( &self, path: impl Into<ApiPath<'_>>, body: &str, params: &[(&str, &str)], ) -> Result<()>
POST request with raw text body and query parameters.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.
Sourcepub async fn put_raw_with_params(
&self,
path: impl Into<ApiPath<'_>>,
body: &str,
params: &[(&str, &str)],
) -> Result<()>
pub async fn put_raw_with_params( &self, path: impl Into<ApiPath<'_>>, body: &str, params: &[(&str, &str)], ) -> Result<()>
PUT request with raw text body and query parameters.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, or an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status.
Sourcepub async fn get_no_response(&self, path: impl Into<ApiPath<'_>>) -> Result<()>
pub async fn get_no_response(&self, path: impl Into<ApiPath<'_>>) -> Result<()>
GET request with no response.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, or an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status.
Sourcepub async fn force_refresh_token(&self) -> Result<()>
pub async fn force_refresh_token(&self) -> Result<()>
Force refresh the authentication token.
Called when a request fails with 401, indicating the token may have been invalidated server-side before TTL expiration.
§Errors
Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.
Sourcepub async fn is_oss(&self) -> bool
pub async fn is_oss(&self) -> bool
Check whether the server is OSS Conductor (vs Orkes Enterprise).
Probes POST /token with dummy credentials on first call and caches
the result. OSS Conductor returns 404 (the endpoint does not exist);
Enterprise returns a non-404 status (e.g. 401/403 for invalid creds).
This mirrors the detection strategy used by the JavaScript SDK.
Sourcepub async fn get_config(&self) -> Configuration
pub async fn get_config(&self) -> Configuration
Get configuration (for reading settings).