Freddy 60f6ec0c2f Store check type in catalog (#6561) 1 month ago
..
watch 92fd596d32 api/watch: try to avoid more flakes in this package (#6538) 1 month ago
README.md 827fbac3ab Copy-and-paste Go client example (#4448) 1 year ago
acl.go 4a5ebb57b0 Add support for the Namespace HTTP API in the API Client (#6581) 1 month ago
acl_test.go d219e31db8 Update retries that weren't using retry.R (#6146) 4 months ago
agent.go 60f6ec0c2f Store check type in catalog (#6561) 1 month ago
agent_test.go 60f6ec0c2f Store check type in catalog (#6561) 1 month ago
api.go 5e26971864 Prune Unhealthy Agents (#6571) 1 month ago
api_test.go 2274f64cab Add Namespace as an api query/write option (#6551) 1 month ago
catalog.go 65be58703c connect: remove managed proxies (#6220) 3 months ago
catalog_test.go 65be58703c connect: remove managed proxies (#6220) 3 months ago
config_entry.go fdd10dd8b8 Expose HTTP-based paths through Connect proxy (#6446) 1 month ago
config_entry_discoverychain.go fd1c62ee8b connect: ensure time.Duration fields retain their human readable forms in the API (#6348) 3 months ago
config_entry_discoverychain_test.go 85cf2706e6 connect: change router syntax for matching query parameters to resemble the syntax for matching paths and headers for consistency. (#6163) 3 months ago
config_entry_test.go fdd10dd8b8 Expose HTTP-based paths through Connect proxy (#6446) 1 month ago
connect.go 9638466b88 api: fix up some comments and rename IssuedCert to LeafCert 1 year ago
connect_ca.go ef9f27cbc8 connect: tame thundering herd of CSRs on CA rotation (#5228) 10 months ago
connect_ca_test.go f45e495e38 Merge pull request #5376 from hashicorp/fix-tests 7 months ago
connect_intention.go 8d953f5840 Implement Mesh Gateways 4 months ago
connect_intention_test.go 8d953f5840 Implement Mesh Gateways 4 months ago
coordinate.go 2392545adc Merge branch 'coordinate-node-endpoint' of github.com:hashicorp/consul into esm-changes 2 years ago
coordinate_test.go f45e495e38 Merge pull request #5376 from hashicorp/fix-tests 7 months ago
debug.go 8c684db488 New command: consul debug (#4754) 1 year ago
debug_test.go 4243c3ae42 Move internal/ to sdk/ (#5568) 7 months ago
discovery_chain.go fd1c62ee8b connect: ensure time.Duration fields retain their human readable forms in the API (#6348) 3 months ago
discovery_chain_test.go 561b2fe606 connect: generate the full SNI names for discovery targets in the compiler rather than in the xds package (#6340) 3 months ago
event.go 5555e0eb9b api: initial import from armon/consul-api 4 years ago
event_test.go 4243c3ae42 Move internal/ to sdk/ (#5568) 7 months ago
go.mod ea6231ce35 api: bump to sdk v0.2.0 2 months ago
go.sum ea6231ce35 api: bump to sdk v0.2.0 2 months ago
health.go 60f6ec0c2f Store check type in catalog (#6561) 1 month ago
health_test.go 60f6ec0c2f Store check type in catalog (#6561) 1 month ago
kv.go 67bac7a815 api: add support for new txn operations 11 months ago
kv_test.go 7252679232 add serf check to TestAPI_ClientPutGetDelete, TestAPI_ClientWatchGet 9 months ago
lock.go 9043966efd Fix lock and semaphore timeouts 1 year ago
lock_test.go fa20c7db97 Merge Consul OSS branch 'master' at commit 95dbb7f2f1b9fc3528a16335201e2324f1b388bd 4 months ago
namespace.go 4a5ebb57b0 Add support for the Namespace HTTP API in the API Client (#6581) 1 month ago
namespace_test.go 4a5ebb57b0 Add support for the Namespace HTTP API in the API Client (#6581) 1 month ago
operator.go 08f81ebddb Moves operator sub-functions into their own files. 2 years ago
operator_area.go 4c5758d891 Remove operator_area note from godoc overview (#4603) 1 year ago
operator_autopilot.go dcb392df46 Simplify string(buf.Bytes()) to buf.String() (#3590) 2 years ago
operator_autopilot_test.go d219e31db8 Update retries that weren't using retry.R (#6146) 4 months ago
operator_keyring.go 174099593a agent: display messages from serf in cli (#5236) 10 months ago
operator_keyring_test.go 4243c3ae42 Move internal/ to sdk/ (#5568) 7 months ago
operator_license.go 69c7d64701 Add missing LicenseReset API function (#6311) 3 months ago
operator_raft.go 3c4a108769 Move Raft protocol version for list peers end point to server side, fix unit tests. This fixes #3449 2 years ago
operator_raft_test.go 7bbfef7000 api: refactor: unify naming of API tests 2 years ago
operator_segment.go 20296d4a89 Change segment list endpoint in docs/client api 2 years ago
prepared_query.go acfd87c673 Improve Connect with Prepared Queries (#5291) 9 months ago
prepared_query_test.go 4243c3ae42 Move internal/ to sdk/ (#5568) 7 months ago
raw.go 5f627fca1b api: Refactoring into shared write logic 4 years ago
semaphore.go 9043966efd Fix lock and semaphore timeouts 1 year ago
semaphore_test.go d93c82e966 add serf check to TestAPI_SemaphoreConflict 9 months ago
session.go 8d0a048408 Expands and rework context support in the API client. (#3273) 2 years ago
session_test.go 524192c919 Improve resilience of api pkg tests (#4676) 1 year ago
snapshot.go c01a3871c9 Adds support for snapshots and restores. (#2396) 3 years ago
snapshot_test.go f98512f1a3 add serf check to TestAPI_Snapshot 9 months ago
status.go 5555e0eb9b api: initial import from armon/consul-api 4 years ago
status_test.go f4dc8b42e0 [Travis][UnstableTests] Fixed unstable tests in travis (#5013) 11 months ago
txn.go 21380021af txn: update existing txn api docs with new operations 10 months ago
txn_test.go 60f6ec0c2f Store check type in catalog (#6561) 1 month ago

README.md

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:

package main

import "github.com/hashicorp/consul/api"
import "fmt"

func main() {
	// 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: "REDIS_MAXCLIENTS", Value: []byte("1000")}
	_, err = kv.Put(p, nil)
	if err != nil {
		panic(err)
	}

	// Lookup the pair
	pair, _, err := kv.Get("REDIS_MAXCLIENTS", nil)
	if err != nil {
		panic(err)
	}
	fmt.Printf("KV: %v %s\n", pair.Key, pair.Value)
}

To run this example, start a Consul server:

consul agent -dev

Copy the code above into a file such as main.go.

Install and run. You'll see a key (REDIS_MAXCLIENTS) and value (1000) printed.

$ go get
$ go run main.go
KV: REDIS_MAXCLIENTS 1000

After running the code, you can also view the values in the Consul UI on your local machine at http://localhost:8500/ui/dc1/kv