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

Commit

Permalink
Merge branch 'feat/snapshots'
Browse files Browse the repository at this point in the history
  • Loading branch information
plaffitt committed Mar 31, 2021
2 parents 5a8dcc3 + e9e1556 commit 03fba9c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
25 changes: 24 additions & 1 deletion endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (client *Client) DeleteVolume(name string) (*Response, *ResponseStatus, err
return client.FormattedRequest("/delete/volumes/\"%s\"", name)
}

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

return mappings, status, err
}

// ShowSnapshots : list snapshots
func (client *Client) ShowSnapshots(names ...string) (*Response, *ResponseStatus, error) {
if len(names) == 0 {
return client.FormattedRequest("/show/snapshots")
}
return client.FormattedRequest("/show/snapshots/%q", strings.Join(names, ","))
}

// CreateSnapshot : create a snapshot in a snap pool and the snap pool if it doesn't exsits
func (client *Client) CreateSnapshot(name string, snapshotName string) (*Response, *ResponseStatus, error) {
return client.FormattedRequest("/create/snapshots/volumes/%q/%q", name, snapshotName)
}

// DeleteSnapshot : delete a snapshot
func (client *Client) DeleteSnapshot(names ...string) (*Response, *ResponseStatus, error) {
return client.FormattedRequest("/delete/snapshot/%q", strings.Join(names, ","))
}

// CopyVolume : create an new volume by copying another one or a snapshot
func (client *Client) CopyVolume(sourceName string, destinationName string, pool string) (*Response, *ResponseStatus, error) {
return client.FormattedRequest("/copy/volume/destination-pool/%q/name/%q/%q", pool, destinationName, sourceName)
}
15 changes: 15 additions & 0 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dothill

import (
"encoding/xml"
"fmt"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -91,6 +92,20 @@ func (res *Response) GetStatus() *ResponseStatus {
}
}

func (object *Object) GetProperties(names ...string) ([]*Property, error) {
var properties []*Property

for _, name := range names {
if property, ok := object.PropertiesMap[name]; ok {
properties = append(properties, property)
} else {
return nil, fmt.Errorf("missing property %q", name)
}
}

return properties, nil
}

func fillObjectMap(obj *Object) {
obj.PropertiesMap = make(map[string]*Property)

Expand Down

0 comments on commit 03fba9c

Please sign in to comment.