# README
Consul API client
This package provides the api
package which attempts to
provide programmatic access to the full Consul API.
Currently, all of the Consul APIs included in version 0.6.0 are supported.
Documentation
The full documentation is available on Godoc
Usage
Below is an example of using the Consul client:
// Get a new client
client, err := api.NewClient(api.DefaultConfig())
if err != nil {
panic(err)
}
// Get a handle to the KV API
kv := client.KV()
// PUT a new KV pair
p := &api.KVPair{Key: "foo", Value: []byte("test")}
_, err = kv.Put(p, nil)
if err != nil {
panic(err)
}
// Lookup the pair
pair, _, err := kv.Get("foo", nil)
if err != nil {
panic(err)
}
fmt.Printf("KV: %v", pair)
# Functions
DefaultConfig returns a default configuration for the client.
DefaultNonPooledConfig returns a default configuration for the client which does not pool connections.
IsRetryableError returns true for 500 errors from the Consul servers, and network connection errors.
NewClient returns a new client.
NewHttpClient returns an http client configured with the given Transport and TLS config.
No description provided by the author
ParseConsulCAConfig takes a raw config map and returns a parsed ConsulCAProviderConfig.
TLSConfig is used to generate a TLSClientConfig that's useful for talking to Consul using TLS.
# Constants
ACLClientType is the client type token.
ACLManagementType is the management type token.
AllSegments is used to select for all segments in MembersOpts.
DefaultLockRetryTime is how long we wait after a failed lock acquisition before attempting to do the lock again.
DefaultLockSessionName is the Session Name we assign if none is provided.
DefaultLockSessionTTL is the default session TTL if no Session is provided when creating a new Lock.
DefaultLockWaitTime is how long we block for at a time to check if lock acquisition is possible.
DefaultMonitorRetryTime is how long we wait after a failed monitor check of a lock (500 response code).
DefaultSemaphoreKey is the key used within the prefix to use for coordination between all the contenders.
DefaultSemaphoreSessionName is the Session Name we assign if none is provided.
DefaultSemaphoreSessionTTL is the default session TTL if no Session is provided when creating a new Semaphore.
DefaultSemaphoreWaitTime is how long we block for at a time to check if semaphore acquisition is possible.
HealthAny is special, and is used as a wild card, not as a specific state.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
HTTPAddrEnvName defines an environment variable name which sets the HTTP address if there is no -http-addr specified.
HTTPAuthEnvName defines an environment variable name which sets the HTTP authentication header.
HTTPCAFile defines an environment variable name which sets the CA file to use for talking to Consul over TLS.
HTTPCAPath defines an environment variable name which sets the path to a directory of CA certs to use for talking to Consul over TLS.
HTTPClientCert defines an environment variable name which sets the client cert file to use for talking to Consul over TLS.
HTTPClientKey defines an environment variable name which sets the client key file to use for talking to Consul over TLS.
HTTPSSLEnvName defines an environment variable name which sets whether or not to use HTTPS.
HTTPSSLVerifyEnvName defines an environment variable name which sets whether or not to disable certificate checking.
HTTPTLSServerName defines an environment variable name which sets the server name to use as the SNI host when connecting via TLS.
HTTPTokenEnvName defines an environment variable name which sets the HTTP token.
No description provided by the author
No description provided by the author
IntentionDefaultNamespace is the default namespace value.
No description provided by the author
No description provided by the author
IntentionSourceConsul is a service within the Consul catalog.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
LockFlagValue is a magic flag we set to indicate a key is being used for a lock.
NodeMaint is the special key set by a node in maintenance mode.
ProxyExecModeDaemon indicates that the proxy command should be long-running and should be started and supervised by the agent until it's target service is deregistered.
ProxyExecModeScript indicates that the proxy command should be invoke to completion on each change to the configuration of lifecycle event.
SemaphoreFlagValue is a magic flag we set to indicate a key is being used for a semaphore.
ServiceKindConnectProxy is a proxy for the Connect feature.
ServiceKindTypical is a typical, classic Consul service.
ServiceMaintPrefix is the prefix for a service in maintenance mode.
SessionBehaviorDelete is new in Consul 0.5 and changes the behavior to delete all associated locks on session invalidation.
SessionBehaviorRelease is the default behavior and causes all associated locks to be released on session invalidation.
# Variables
ErrLockConflict is returned if the flags on a key used for a lock do not match expectation.
ErrLockHeld is returned if we attempt to double lock.
ErrLockInUse is returned if we attempt to destroy a lock that is in use.
ErrLockNotHeld is returned if we attempt to unlock a lock that we do not hold.
ErrSemaphoreConflict is returned if the flags on a key used for a semaphore do not match expectation.
ErrSemaphoreHeld is returned if we attempt to double lock.
ErrSemaphoreInUse is returned if we attempt to destroy a semaphore that is in use.
ErrSemaphoreNotHeld is returned if we attempt to unlock a semaphore that we do not hold.
No description provided by the author
# Structs
ACL can be used to query the ACL endpoints.
ACLEntry is used to represent an ACL entry.
ACLReplicationStatus is used to represent the status of ACL replication.
Agent can be used to query the Agent endpoints.
AgentAuthorize is the response structure for Connect authorization.
AgentAuthorizeParams are the request parameters for authorizing a request.
AgentCheck represents a check known to the agent.
AgentCheckRegistration is used to register a new check.
AgentMember represents a cluster member known to the agent.
AgentService represents a service known to the agent.
AgentServiceCheck is used to define a node or service level check.
AgentServiceConnect represents the Connect configuration of a service.
AgentServiceConnectProxy represents the Connect Proxy configuration of a service.
AgentServiceRegistration is used to register a new service.
AgentToken is used when updating ACL tokens for an agent.
Area defines a network area.
AreaJoinResponse is returned when a join occurs and gives the result for each address.
AutopilotConfiguration is used for querying/setting the Autopilot configuration.
CAConfig is the structure for the Connect CA configuration.
CARoot represents a root CA certificate that is trusted.
CARootList is the structure for the results of listing roots.
Catalog can be used to query the Catalog endpoints.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Client provides a client to the Consul API.
Config is used to configure the creation of a client.
Connect can be used to work with endpoints related to Connect, the feature for securely connecting services within Consul.
ConnectProxyConfig is the response structure for agent-local proxy configuration.
ConsulCAProviderConfig is the config for the built-in Consul CA provider.
Coordinate can be used to query the coordinate endpoints.
CoordinateDatacenterMap has the coordinates for servers in a given datacenter and area.
CoordinateEntry represents a node and its associated network coordinate.
Event can be used to query the Event endpoints.
GaugeValue stores one value that is updated as time goes on, such as the amount of memory allocated.
Health can be used to query the Health endpoints.
HealthCheck is used to represent a single check.
HealthCheckDefinition is used to store the details about a health check's execution.
HttpBasicAuth is used to authenticate http client with HTTP Basic Authentication.
Intention defines an intention for the Connect Service Graph.
IntentionCheck are the arguments for the intention check API.
IntentionMatch are the arguments for the intention match API.
KeyringResponse is returned when listing the gossip encryption keys.
KV is used to manipulate the K/V API.
KVPair is used to represent a single K/V entry.
KVTxnOp defines a single operation inside a transaction.
KVTxnResponse has the outcome of a transaction.
LeafCert is a certificate that has been issued by a Connect CA.
Lock is used to implement client-side leader election.
LockOptions is used to parameterize the Lock behavior.
MembersOpts is used for querying member information.
Metrics info is used to store different types of metric values from the agent.
No description provided by the author
Operator can be used to perform low-level operator tasks for Consul.
OperatorHealthReply is a representation of the overall health of the cluster.
PointValue holds a series of points for a metric.
PreparedQuery can be used to query the prepared query endpoints.
PreparedQueryDefinition defines a complete prepared query.
PreparedQueryExecuteResponse has the results of executing a query.
QueryDatacenterOptions sets options about how we fail over if there are no healthy nodes in the local datacenter.
QueryDNSOptions controls settings when query results are served over DNS.
QueryMeta is used to return meta data about a query.
QueryOptions are used to parameterize a query.
QueryTemplate carries the arguments for creating a templated query.
RaftConfiguration is returned when querying for the current Raft configuration.
RaftServer has information about a server in the Raft configuration.
Raw can be used to do raw queries against custom endpoints.
SampledValue stores info about a metric that is incremented over time, such as the number of requests to an HTTP endpoint.
Semaphore is used to implement a distributed semaphore using the Consul KV primitives.
SemaphoreOptions is used to parameterize the Semaphore.
SerfMember is a generic structure for reporting information about members in a Serf cluster.
ServerHealth is the health (from the leader's point of view) of a server.
ServiceEntry is used for the health service endpoint.
ServiceQuery is used to query for a set of healthy nodes offering a specific service.
Session can be used to query the Session endpoints.
SessionEntry represents a session in consul.
Snapshot can be used to query the /v1/snapshot endpoint to take snapshots of Consul's internal state and restore snapshots for disaster recovery.
Status can be used to query the Status endpoints.
TLSConfig is used to generate a TLSClientConfig that's useful for talking to Consul using TLS.
TxnError is used to return information about an operation in a transaction.
TxnOp is the internal format we send to Consul.
TxnResponse is the internal format we receive from Consul.
TxnResult is the internal format we receive from Consul.
UserEvent represents an event that was fired by the user.
WriteMeta is used to return meta data about a write.
WriteOptions are used to parameterize a write.
# Type aliases
No description provided by the author
HealthChecks is a collection of HealthCheck structs.
IntentionAction is the action that the intention represents.
IntentionMatchType is the target for a match request.
IntentionSourceType is the type of the source within an intention.
KVOp constants give possible operations available in a KVTxn.
KVPairs is a list of KVPair objects.
KVTxnOps defines a set of operations to be performed inside a single transaction.
ProxyExecMode is the execution mode for a managed Connect proxy.
ReadableDuration is a duration type that is serialized to JSON in human readable format.
ServiceKind is the kind of service being registered.
TxnErrors is a list of TxnError objects.
TxnOps is a list of transaction operations.
TxnResults is a list of TxnResult objects.