pub struct KibanaClient { /* private fields */ }Expand description
Kibana client for making API requests.
The client can operate in two modes:
- Root mode (
space: None): For global operations like managing spaces - Space mode (
space: Some(id)): For space-scoped operations
Use .space(id) to create a space-scoped client from a root client.
§Example
use kibana_sync::{Auth, KibanaClient};
use url::Url;
let url = Url::parse("http://localhost:5601")?;
let client = KibanaClient::builder(url)
.auth(Auth::None)
.spaces([("marketing".to_string(), "Marketing".to_string())])
.build()?;
// Root client for global operations (e.g., managing spaces)
let response = client.get("/api/spaces/space").await?;
// Space-scoped client for space-specific operations
let marketing = client.space("marketing")?;
let objects = marketing.get("/api/saved_objects/_find").await?;
// Get the current space ID
assert_eq!(marketing.space_id(), "marketing");Implementations§
Source§impl KibanaClient
impl KibanaClient
Sourcepub fn builder(url: Url) -> KibanaClientBuilder
pub fn builder(url: Url) -> KibanaClientBuilder
Start configuring a root Kibana client from explicit values.
Sourcepub fn new(url: Url, auth: Auth) -> Result<Self>
pub fn new(url: Url, auth: Auth) -> Result<Self>
Create a root client with default options and only the default space.
Sourcepub fn space(&self, id: &str) -> Result<KibanaClient>
pub fn space(&self, id: &str) -> Result<KibanaClient>
Create a space-scoped client for the given space ID.
Returns a new client that will automatically scope all API requests
to the specified space (prefixing paths with /s/{space}/).
§Arguments
id- Space ID to scope to
§Returns
A new KibanaClient scoped to the specified space
§Errors
Returns an error if the space ID is not in the loaded manifest
§Example
let marketing = client.space("marketing")?;
assert_eq!(marketing.space_id(), "marketing");Sourcepub async fn server_version_info(&self) -> Result<KibanaVersionInfo>
pub async fn server_version_info(&self) -> Result<KibanaVersionInfo>
Resolve and cache Kibana server version info from /api/status.
Sourcepub async fn server_version(&self) -> Result<KibanaVersion>
pub async fn server_version(&self) -> Result<KibanaVersion>
Resolve the normalized Kibana server version.
Sourcepub fn supports_capability(
version: &KibanaVersion,
capability: ApiCapability,
) -> bool
pub fn supports_capability( version: &KibanaVersion, capability: ApiCapability, ) -> bool
Check if a capability is supported on a specific Kibana version.
Sourcepub fn unsupported_capability_reason(
version: &KibanaVersion,
capability: ApiCapability,
) -> String
pub fn unsupported_capability_reason( version: &KibanaVersion, capability: ApiCapability, ) -> String
Build a user-facing unsupported message for a capability/version pair.
Sourcepub fn space_id(&self) -> &str
pub fn space_id(&self) -> &str
Get the current space ID.
Returns “default” for root mode or the default space.
Sourcepub fn space_name(&self, id: &str) -> Option<&str>
pub fn space_name(&self, id: &str) -> Option<&str>
Sourcepub async fn test_connection(&self) -> Result<Response>
pub async fn test_connection(&self) -> Result<Response>
Verify the connection and authentication to Kibana.
Makes a GET request to /api/status to verify connectivity.
Sourcepub async fn request(
&self,
method: Method,
headers: &HashMap<String, String>,
path: &str,
body: Option<&[u8]>,
) -> Result<Response>
pub async fn request( &self, method: Method, headers: &HashMap<String, String>, path: &str, body: Option<&[u8]>, ) -> Result<Response>
Send a request to a given path.
If this client is scoped to a space, the path will be prefixed with /s/{space}/.
For root mode, the path is used as-is.
§Arguments
method- HTTP methodheaders- Additional headerspath- API pathbody- Optional request body
Sourcepub async fn get_internal(&self, path: &str) -> Result<Response>
pub async fn get_internal(&self, path: &str) -> Result<Response>
Helper for GET requests for internal Kibana APIs. Adds X-Elastic-Internal-Origin header required by some APIs (e.g., workflows).
Sourcepub async fn head_internal(&self, path: &str) -> Result<Response>
pub async fn head_internal(&self, path: &str) -> Result<Response>
Helper for HEAD requests for internal Kibana APIs. Adds X-Elastic-Internal-Origin header required by some APIs.
Sourcepub async fn post_json(&self, path: &str, body: &[u8]) -> Result<Response>
pub async fn post_json(&self, path: &str, body: &[u8]) -> Result<Response>
Helper for POST requests with JSON body.
Sourcepub async fn post_json_value(
&self,
path: &str,
value: &Value,
) -> Result<Response>
pub async fn post_json_value( &self, path: &str, value: &Value, ) -> Result<Response>
Helper for POST requests with JSON value.
Sourcepub async fn post_json_value_internal(
&self,
path: &str,
value: &Value,
) -> Result<Response>
pub async fn post_json_value_internal( &self, path: &str, value: &Value, ) -> Result<Response>
Helper for POST requests with JSON value for internal Kibana APIs. Adds X-Elastic-Internal-Origin header required by some APIs (e.g., workflows).
Sourcepub async fn put_json_value(
&self,
path: &str,
value: &Value,
) -> Result<Response>
pub async fn put_json_value( &self, path: &str, value: &Value, ) -> Result<Response>
Helper for PUT requests with JSON value.
Trait Implementations§
Source§impl Clone for KibanaClient
impl Clone for KibanaClient
Source§fn clone(&self) -> KibanaClient
fn clone(&self) -> KibanaClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for KibanaClient
impl Debug for KibanaClient
Auto Trait Implementations§
impl !RefUnwindSafe for KibanaClient
impl !UnwindSafe for KibanaClient
impl Freeze for KibanaClient
impl Send for KibanaClient
impl Sync for KibanaClient
impl Unpin for KibanaClient
impl UnsafeUnpin for KibanaClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.