Skip to content
This repository was archived by the owner on Oct 25, 2023. It is now read-only.

Commit 03fba9c

Browse files
committed
Merge branch 'feat/snapshots'
2 parents 5a8dcc3 + e9e1556 commit 03fba9c

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

endpoints.go

+24-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (client *Client) DeleteVolume(name string) (*Response, *ResponseStatus, err
5959
return client.FormattedRequest("/delete/volumes/\"%s\"", name)
6060
}
6161

62-
// DeleteHost : deletes a hotst by its ID or nickname
62+
// DeleteHost : deletes a host by its ID or nickname
6363
func (client *Client) DeleteHost(name string) (*Response, *ResponseStatus, error) {
6464
return client.FormattedRequest("/delete/host/\"%s\"", name)
6565
}
@@ -92,3 +92,26 @@ func (client *Client) ShowHostMaps(host string) ([]Volume, *ResponseStatus, erro
9292

9393
return mappings, status, err
9494
}
95+
96+
// ShowSnapshots : list snapshots
97+
func (client *Client) ShowSnapshots(names ...string) (*Response, *ResponseStatus, error) {
98+
if len(names) == 0 {
99+
return client.FormattedRequest("/show/snapshots")
100+
}
101+
return client.FormattedRequest("/show/snapshots/%q", strings.Join(names, ","))
102+
}
103+
104+
// CreateSnapshot : create a snapshot in a snap pool and the snap pool if it doesn't exsits
105+
func (client *Client) CreateSnapshot(name string, snapshotName string) (*Response, *ResponseStatus, error) {
106+
return client.FormattedRequest("/create/snapshots/volumes/%q/%q", name, snapshotName)
107+
}
108+
109+
// DeleteSnapshot : delete a snapshot
110+
func (client *Client) DeleteSnapshot(names ...string) (*Response, *ResponseStatus, error) {
111+
return client.FormattedRequest("/delete/snapshot/%q", strings.Join(names, ","))
112+
}
113+
114+
// CopyVolume : create an new volume by copying another one or a snapshot
115+
func (client *Client) CopyVolume(sourceName string, destinationName string, pool string) (*Response, *ResponseStatus, error) {
116+
return client.FormattedRequest("/copy/volume/destination-pool/%q/name/%q/%q", pool, destinationName, sourceName)
117+
}

response.go

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package dothill
22

33
import (
44
"encoding/xml"
5+
"fmt"
56
"strconv"
67
"strings"
78
"time"
@@ -91,6 +92,20 @@ func (res *Response) GetStatus() *ResponseStatus {
9192
}
9293
}
9394

95+
func (object *Object) GetProperties(names ...string) ([]*Property, error) {
96+
var properties []*Property
97+
98+
for _, name := range names {
99+
if property, ok := object.PropertiesMap[name]; ok {
100+
properties = append(properties, property)
101+
} else {
102+
return nil, fmt.Errorf("missing property %q", name)
103+
}
104+
}
105+
106+
return properties, nil
107+
}
108+
94109
func fillObjectMap(obj *Object) {
95110
obj.PropertiesMap = make(map[string]*Property)
96111

0 commit comments

Comments
 (0)