mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 09:25:46 +03:00
api: add snapshot restore
This commit is contained in:
@@ -945,6 +945,10 @@ func decodeBody(resp *http.Response, out interface{}) error {
|
||||
|
||||
// encodeBody is used to encode a request body
|
||||
func encodeBody(obj interface{}) (io.Reader, error) {
|
||||
if reader, ok := obj.(io.Reader); ok {
|
||||
return reader, nil
|
||||
}
|
||||
|
||||
buf := bytes.NewBuffer(nil)
|
||||
enc := json.NewEncoder(buf)
|
||||
if err := enc.Encode(obj); err != nil {
|
||||
|
||||
@@ -222,6 +222,17 @@ func (op *Operator) Snapshot(q *QueryOptions) (io.ReadCloser, error) {
|
||||
return cr, nil
|
||||
}
|
||||
|
||||
// SnapshotRestore is used to restore a running nomad cluster to an original
|
||||
// state.
|
||||
func (op *Operator) SnapshotRestore(in io.Reader, q *WriteOptions) (*WriteMeta, error) {
|
||||
wm, err := op.c.write("/v1/operator/snapshot", in, nil, q)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return wm, nil
|
||||
}
|
||||
|
||||
type License struct {
|
||||
// The unique identifier of the license
|
||||
LicenseID string
|
||||
|
||||
4
vendor/github.com/hashicorp/nomad/api/api.go
generated
vendored
4
vendor/github.com/hashicorp/nomad/api/api.go
generated
vendored
@@ -945,6 +945,10 @@ func decodeBody(resp *http.Response, out interface{}) error {
|
||||
|
||||
// encodeBody is used to encode a request body
|
||||
func encodeBody(obj interface{}) (io.Reader, error) {
|
||||
if reader, ok := obj.(io.Reader); ok {
|
||||
return reader, nil
|
||||
}
|
||||
|
||||
buf := bytes.NewBuffer(nil)
|
||||
enc := json.NewEncoder(buf)
|
||||
if err := enc.Encode(obj); err != nil {
|
||||
|
||||
11
vendor/github.com/hashicorp/nomad/api/operator.go
generated
vendored
11
vendor/github.com/hashicorp/nomad/api/operator.go
generated
vendored
@@ -222,6 +222,17 @@ func (op *Operator) Snapshot(q *QueryOptions) (io.ReadCloser, error) {
|
||||
return cr, nil
|
||||
}
|
||||
|
||||
// SnapshotRestore is used to restore a running nomad cluster to an original
|
||||
// state.
|
||||
func (op *Operator) SnapshotRestore(in io.Reader, q *WriteOptions) (*WriteMeta, error) {
|
||||
wm, err := op.c.write("/v1/operator/snapshot", in, nil, q)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return wm, nil
|
||||
}
|
||||
|
||||
type License struct {
|
||||
// The unique identifier of the license
|
||||
LicenseID string
|
||||
|
||||
Reference in New Issue
Block a user