pub struct Client { /* private fields */ }Expand description
The Consul API client.
Implementations§
Source§impl Client
impl Client
Sourcepub async fn agent_checks(
&self,
q: &FilterRequestQuery,
) -> Result<HashMap<String, HealthCheck>>
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.
Sourcepub async fn agent_check_register(&self, b: &CheckDefinition) -> Result<bool>
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.
Sourcepub async fn agent_check_deregister(
&self,
q: &DeregisterCheckRequestQuery,
) -> Result<bool>
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.
Sourcepub async fn agent_check_pass(
&self,
q: &AgentTTLCheckRequestQuery,
) -> Result<bool>
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.
Sourcepub async fn agent_check_warn(
&self,
q: &AgentTTLCheckRequestQuery,
) -> Result<()>
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.
Sourcepub async fn agent_check_fail(
&self,
q: &AgentTTLCheckRequestQuery,
) -> Result<bool>
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.
Sourcepub async fn agent_check_update(
&self,
q: &AgentTTLCheckUpdateRequestQuery,
b: &AgentTTLCheckUpdateRequestBody,
) -> Result<bool>
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.
Sourcepub async fn agent_services(
&self,
q: &FilterRequestQuery,
) -> Result<HashMap<String, AgentService>>
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.
pub async fn agent_service_configuration( &self, q: &ServiceConfigurationRequestQuery, ) -> Result<AgentService>
Sourcepub async fn agent_get_service_health_by_name(
&self,
q: &LocalServiceHealthByNameRequestQuery,
) -> Result<Vec<AgentServiceChecksInfo>>
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.
Sourcepub async fn agent_get_service_health_by_id(
&self,
q: &LocalServiceHealthByIDRequestQuery,
) -> Result<AgentServiceChecksInfo>
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.
Sourcepub async fn agent_register_service(
&self,
q: &RegisterServiceRequestQuery,
b: &ServiceDefinition,
) -> Result<()>
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.
Sourcepub async fn agent_deregister_service(
&self,
q: &DeregisterServiceRequestQuery,
) -> Result<()>
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.
Sourcepub async fn agent_enable_maintenance_mode(
&self,
q: &EnableMaintenanceModeRequestQuery,
) -> Result<bool>
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.
Sourcepub async fn kv_read_key(
&self,
q: &KVReadKeyRequestQuery,
) -> Result<Option<Vec<u8>>>
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.
Sourcepub async fn kv_create_or_update_key(
&self,
q: &KVCreateOrUpdateKeyRequestQuery,
b: Vec<u8>,
) -> Result<bool>
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.
Sourcepub async fn kv_delete_key(&self, q: &KVDeleteKeyRequestQuery) -> Result<bool>
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.