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<Option<AgentService>>

Source

pub async fn agent_get_service_health_by_name<S: Into<String>>( &self, service_name: S, 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<S: Into<String>>( &self, service_id: S, q: &LocalServiceHealthByIDRequestQuery, ) -> Result<Option<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<bool>

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<S: Into<String>>( &self, service_id: S, q: &DeregisterServiceRequestQuery, ) -> Result<bool>

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 catalog_register_entity( &self, q: &CatalogRegisterEntityQuery, b: &RegisterRequest, ) -> Result<bool>

Catalog Register Entity This endpoint is a low-level mechanism for registering or updating entries in the catalog. It is usually preferable to instead use the agent endpoints for registration as they are simpler and perform anti-entropy.

Source

pub async fn catalog_deregister_entity( &self, q: &CatalogDeregisterEntityQuery, b: &DeregisterRequest, ) -> Result<bool>

Catalog Deregister Entity This endpoint is a low-level mechanism for directly removing entries from the Catalog. It is usually preferable to instead use the agent endpoints for deregistration as they are simpler and perform anti-entropy.

Source

pub async fn catalog_list_datacenters(&self) -> Result<Vec<String>>

Catalog List Datacenters This endpoint returns the list of all known datacenters. The datacenters will be sorted in ascending order based on the estimated median round trip time from the server to the servers in that datacenter.

Source

pub async fn catalog_list_nodes(&self) -> Result<Vec<Node>>

Catalog List Nodes This endpoint and returns the nodes registered in a given datacenter.

Source

pub async fn catalog_list_services( &self, q: &CatalogListServicesQuery, ) -> Result<HashMap<String, Vec<String>>>

Catalog List Services This endpoint returns the services registered in a given datacenter.

Source

pub async fn catalog_list_nodes_for_service<S: Into<String>>( &self, service_name: S, q: &CatalogListNodesForServiceQuery, ) -> Result<Vec<ServiceNode>>

Catalog List Nodes for Service This endpoint returns the nodes providing a service in a given datacenter.

Source

pub async fn catalog_list_nodes_for_mesh_capable_service<S: Into<String>>( &self, service: S, q: &CatalogListNodesForServiceQuery, ) -> Result<Vec<ServiceNode>>

List Nodes for Mesh-capable Service This endpoint returns the nodes providing a mesh-capable service in a given datacenter. This will include both proxies and native integrations. A service may register both mesh-capable and incapable services at the same time, so this endpoint may be used to filter only the mesh-capable endpoints.

Source

pub async fn catalog_node_services<S: Into<String>>( &self, node_name: S, q: &CatalogNodeServicesQuery, ) -> Result<Option<NodeServices>>

Retrieve Map of Services for a Node This endpoint returns the node’s registered services.

Source

pub async fn catalog_gateway_services<S: Into<String>>( &self, gateway: S, q: &CatalogGatewayServicesQuery, ) -> Result<Vec<GatewayService>>

List Services for Gateway This endpoint returns the services associated with an ingress gateway or terminating gateway.

Source

pub async fn event_fire<S: Into<String>>( &self, name: S, body: Option<Vec<u8>>, q: &EventFireQuery, ) -> Result<bool>

Fire Event This endpoint triggers a new user event.

Source

pub async fn event_list(&self, q: &EventListQuery) -> Result<Vec<UserEvent>>

List Events This endpoint returns the most recent events (up to 256) known by the agent. As a consequence of how the event command works, each agent may have a different view of the events. Events are broadcast using the gossip protocol, so they have no global ordering nor do they make a promise of delivery.

Source

pub async fn health_list_nodes<S: Into<String>>( &self, node: S, q: &HealthListNodesQuery, ) -> Result<Vec<HealthCheck>>

List Checks for Node This endpoint returns the checks specific to the node provided on the path.

Source

pub async fn health_list_services<S: Into<String>>( &self, service: S, q: &HealthListServicesQuery, ) -> Result<Vec<HealthCheck>>

List Checks for Service This endpoint returns the checks associated with the service provided on the path.

Source

pub async fn health_list_service_instances<S: Into<String>>( &self, service: S, q: &HealthListServiceInstancesQuery, ) -> Result<Vec<CheckServiceNode>>

List Service Instances for Service This endpoint returns the service instances providing the service indicated on the path. Users can also build in support for dynamic load balancing and other features by incorporating the use of health checks.

Source

pub async fn health_list_service_instances_for_mesh_capable<S: Into<String>>( &self, service: S, q: &HealthListServiceInstancesQuery, ) -> Result<Vec<CheckServiceNode>>

List Service Instances for Mesh-enabled Service

This endpoint returns the service instances providing a mesh-capable service in a given datacenter. This will include both proxies and native integrations. A service may register both mesh-capable and incapable services at the same time, so this endpoint may be used to filter only the mesh-capable endpoints.

Source

pub async fn health_list_service_instances_for_ingress_gateways<S: Into<String>>( &self, service: S, q: &HealthListServiceInstancesQuery, ) -> Result<Vec<CheckServiceNode>>

List Service Instances for Ingress Gateways Associated with a Service

This API is available in Consul versions 1.8.0 and later.

This endpoint returns the service instances providing an ingress gateway for a service in a given datacenter.

Source

pub async fn health_list_state( &self, state: Health, q: &HealthListStateQuery, ) -> Result<Vec<HealthCheck>>

List Checks in State

This endpoint returns the checks in the state provided on the path.

Source

pub async fn kv_read_key<S: Into<String>>( &self, key: S, q: &KVReadKeyQuery, ) -> 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<S: Into<String>>( &self, key: S, b: Vec<u8>, q: &KVCreateOrUpdateKeyQuery, ) -> 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<S: Into<String>>( &self, key: S, q: &KVDeleteKeyQuery, ) -> Result<bool>

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

Source

pub async fn status_leader(&self, q: &StatusQuery) -> Result<String>

Get Raft Leader

This endpoint returns the Raft leader for the datacenter in which the agent is running.

Source

pub async fn status_peers(&self, q: &StatusQuery) -> Result<Vec<String>>

List Raft Peers

This endpoint retrieves the Raft peers for the datacenter in which the agent is running. This list of peers is strongly consistent and can be useful in determining when a given server has successfully joined the cluster.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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,