class Etcd::Api

Defined in:

etcd/api.cr

Constant Summary

DEFAULT_HOST = "localhost"
DEFAULT_PORT = 2379
DEFAULT_VERSION = "v3"

Constructors

Instance Method Summary

Constructor Detail

def self.new(url : URI, api_version : String = DEFAULT_VERSION) #

[View source]
def self.new(host : String = "localhost", port : Int32 | Nil = nil, api_version : String | Nil = nil) #

[View source]

Instance Method Detail

def api_version : String #

API version


[View source]
def api_version=(api_version : String) #

API version


[View source]
def connection : HTTP::Client #

:no_doc: Underlying HTTP connection - exposed for access from test framework only.


[View source]
def delete(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType | Nil = nil) #

Executes a DELETE request on the etcd client connection.

The response status will be automatically checked and a Etcd::ApiError raised if unsuccessful.


[View source]
def delete(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType = nil, &) #

Executes a DELETE request and yields a HTTP::Client::Response.

When working with endpoint that provide stream responses these may be accessed as available by calling #body_io on the yielded response object.

The response status will be automatically checked and a etcd::ApiError raised if unsuccessful.


[View source]
def delete(path, headers : HTTP::Headers, body = nil) #

Executes a DELETE request on the etcd client connection with a JSON body formed from the passed NamedTuple... or a Hash.


[View source]
def delete(path, body = nil) #

Executes a DELETE request on the etcd client connection with a JSON body formed from the passed NamedTuple... or a Hash.


[View source]
def delete(path, headers : HTTP::Headers, body : NamedTuple | Hash, &) #

Executes a DELETE request on the etcd client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def delete(path, body : NamedTuple | Hash, &) #

Executes a DELETE request on the etcd client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def get(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType | Nil = nil) #

Executes a GET request on the etcd client connection.

The response status will be automatically checked and a Etcd::ApiError raised if unsuccessful.


[View source]
def get(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType = nil, &) #

Executes a GET request and yields a HTTP::Client::Response.

When working with endpoint that provide stream responses these may be accessed as available by calling #body_io on the yielded response object.

The response status will be automatically checked and a etcd::ApiError raised if unsuccessful.


[View source]
def get(path, headers : HTTP::Headers, body = nil) #

Executes a GET request on the etcd client connection with a JSON body formed from the passed NamedTuple... or a Hash.


[View source]
def get(path, body = nil) #

Executes a GET request on the etcd client connection with a JSON body formed from the passed NamedTuple... or a Hash.


[View source]
def get(path, headers : HTTP::Headers, body : NamedTuple | Hash, &) #

Executes a GET request on the etcd client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def get(path, body : NamedTuple | Hash, &) #

Executes a GET request on the etcd client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def host : String #

[View source]
def port : Int32 #

[View source]
def post(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType | Nil = nil) #

Executes a POST request on the etcd client connection.

The response status will be automatically checked and a Etcd::ApiError raised if unsuccessful.


[View source]
def post(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType = nil, &) #

Executes a POST request and yields a HTTP::Client::Response.

When working with endpoint that provide stream responses these may be accessed as available by calling #body_io on the yielded response object.

The response status will be automatically checked and a etcd::ApiError raised if unsuccessful.


[View source]
def post(path, headers : HTTP::Headers, body = nil) #

Executes a POST request on the etcd client connection with a JSON body formed from the passed NamedTuple... or a Hash.


[View source]
def post(path, body = nil) #

Executes a POST request on the etcd client connection with a JSON body formed from the passed NamedTuple... or a Hash.


[View source]
def post(path, headers : HTTP::Headers, body : NamedTuple | Hash, &) #

Executes a POST request on the etcd client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def post(path, body : NamedTuple | Hash, &) #

Executes a POST request on the etcd client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def put(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType | Nil = nil) #

Executes a PUT request on the etcd client connection.

The response status will be automatically checked and a Etcd::ApiError raised if unsuccessful.


[View source]
def put(path, headers : HTTP::Headers | Nil = nil, body : HTTP::Client::BodyType = nil, &) #

Executes a PUT request and yields a HTTP::Client::Response.

When working with endpoint that provide stream responses these may be accessed as available by calling #body_io on the yielded response object.

The response status will be automatically checked and a etcd::ApiError raised if unsuccessful.


[View source]
def put(path, headers : HTTP::Headers, body = nil) #

Executes a PUT request on the etcd client connection with a JSON body formed from the passed NamedTuple... or a Hash.


[View source]
def put(path, body = nil) #

Executes a PUT request on the etcd client connection with a JSON body formed from the passed NamedTuple... or a Hash.


[View source]
def put(path, headers : HTTP::Headers, body : NamedTuple | Hash, &) #

Executes a PUT request on the etcd client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def put(path, body : NamedTuple | Hash, &) #

Executes a PUT request on the etcd client connection with a JSON body formed from the passed NamedTuple and yields streamed response entries to the block.


[View source]
def spawn_connection #

TODO Add connection pooling. Currently, there's contention on the http connection Better to lease connections from a pool, and use the sclient object This way, we can reuse the same infra around the connection


[View source]
def token : String | Nil #

[View source]
def url : URI | Nil #

[View source]