consul_api

Struct Client

Source
pub struct Client { /* private fields */ }
Expand description

The Consul API client.

Implementations§

Source§

impl Client

Source

pub fn new() -> Self

Creates a new client with the default configuration.

Source

pub async fn agent_checks( &self, q: &FilterRequestQuery, ) -> Result<HashMap<String, HealthCheck>>

List Checks This endpoint returns all checks that are registered with the local agent. These checks were either provided through configuration files or added dynamically using the HTTP API.

Source

pub async fn agent_check_register(&self, b: &CheckDefinition) -> Result<bool>

Register Check This endpoint adds a new check to the local agent. Checks may be of script, HTTP, TCP, UDP, or TTL type. The agent is responsible for managing the status of the check and keeping the Catalog in sync.

Source

pub async fn agent_check_deregister( &self, q: &DeregisterCheckRequestQuery, ) -> Result<bool>

Deregister Check This endpoint remove a check from the local agent. The agent will take care of deregistering the check from the catalog. If the check with the provided ID does not exist, no action is taken.

Source

pub async fn agent_check_pass( &self, q: &AgentTTLCheckRequestQuery, ) -> Result<bool>

TTL Check Pass This endpoint is used with a TTL type check to set the status of the check to passing and to reset the TTL clock.

Source

pub async fn agent_check_warn( &self, q: &AgentTTLCheckRequestQuery, ) -> Result<()>

TTL Check Warn This endpoint is used with a TTL type check to set the status of the check to warning and to reset the TTL clock.

Source

pub async fn agent_check_fail( &self, q: &AgentTTLCheckRequestQuery, ) -> Result<bool>

TTL Check Fail This endpoint is used with a TTL type check to set the status of the check to critical and to reset the TTL clock.

Source

pub async fn agent_check_update( &self, q: &AgentTTLCheckUpdateRequestQuery, b: &AgentTTLCheckUpdateRequestBody, ) -> Result<bool>

TTL Check Update This endpoint is used with a TTL type check to set the status of the check and to reset the TTL clock.

Source

pub async fn agent_services( &self, q: &FilterRequestQuery, ) -> Result<HashMap<String, AgentService>>

List Services This endpoint returns all the services that are registered with the local agent. These services were either provided through configuration files or added dynamically using the HTTP API.

Source

pub async fn agent_service_configuration( &self, q: &ServiceConfigurationRequestQuery, ) -> Result<AgentService>

Source

pub async fn agent_get_service_health_by_name( &self, q: &LocalServiceHealthByNameRequestQuery, ) -> Result<Vec<AgentServiceChecksInfo>>

Get local service health Retrieve an aggregated state of service(s) on the local agent by name.

This endpoints support JSON format and text/plain formats, JSON being the default. In order to get the text format, you can append ?format=text to the URL or use Mime Content negotiation by specifying a HTTP Header Accept starting with text/plain.

Source

pub async fn agent_get_service_health_by_id( &self, q: &LocalServiceHealthByIDRequestQuery, ) -> Result<AgentServiceChecksInfo>

Get local service health by ID Retrieve the health state of a specific service on the local agent by ID.

Source

pub async fn agent_register_service( &self, q: &RegisterServiceRequestQuery, b: &ServiceDefinition, ) -> Result<()>

Register Service This endpoint adds a new service, with optional health checks, to the local agent.

The agent is responsible for managing the status of its local services, and for sending updates about its local services to the servers to keep the global catalog in sync.

Source

pub async fn agent_deregister_service( &self, q: &DeregisterServiceRequestQuery, ) -> Result<()>

Deregister Service This endpoint removes a service from the local agent. If the service does not exist, no action is taken.

The agent will take care of deregistering the service with the catalog. If there is an associated check, that is also deregistered.

Source

pub async fn agent_enable_maintenance_mode( &self, q: &EnableMaintenanceModeRequestQuery, ) -> Result<bool>

Enable Maintenance Mode

This endpoint places a given service into “maintenance mode”. During maintenance mode, the service will be marked as unavailable and will not be present in DNS or API queries. This API call is idempotent. Maintenance mode is persistent and will be automatically restored on agent restart.

Source

pub async fn agent_connect_authorize( &self, q: &ConnectAuthorizeRequestQuery, b: &ConnectAuthorizeRequest, ) -> Result<ConnectAuthorizeRequestReply>

Source

pub async fn kv_read_key( &self, q: &KVReadKeyRequestQuery, ) -> Result<Option<Vec<u8>>>

Read Key This endpoint returns the specified key. If no key exists at the given path, a 404 is returned instead of a 200 response.

Source

pub async fn kv_create_or_update_key( &self, q: &KVCreateOrUpdateKeyRequestQuery, b: Vec<u8>, ) -> Result<bool>

Create/Update Key This endpoint updates the value of the specified key. If no key exists at the given path, the key will be created.

Source

pub async fn kv_delete_key(&self, q: &KVDeleteKeyRequestQuery) -> Result<bool>

Delete Key This endpoint deletes a single key or all keys sharing a prefix.

Auto Trait Implementations§

§

impl Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T