StorageOS update api library

This commit is contained in:
Sunny
2018-09-14 19:36:57 +05:30
parent 8b98e802ed
commit a4cc754fb4
33 changed files with 795 additions and 1695 deletions

View File

@@ -41,7 +41,7 @@ func (c *Client) PoolList(opts types.ListOptions) ([]*types.Pool, error) {
}
// PoolCreate creates a pool on the server and returns the new object.
func (c *Client) PoolCreate(opts types.PoolCreateOptions) (*types.Pool, error) {
func (c *Client) PoolCreate(opts types.PoolOptions) (*types.Pool, error) {
resp, err := c.do("POST", PoolAPIPrefix, doOptions{
data: opts,
context: opts.Context,
@@ -56,6 +56,27 @@ func (c *Client) PoolCreate(opts types.PoolCreateOptions) (*types.Pool, error) {
return &pool, nil
}
// PoolUpdate - update pool
func (c *Client) PoolUpdate(opts types.PoolOptions) (*types.Pool, error) {
ref := opts.Name
if IsUUID(opts.ID) {
ref = opts.ID
}
resp, err := c.do("PUT", PoolAPIPrefix+"/"+ref, doOptions{
data: opts,
context: opts.Context,
})
if err != nil {
return nil, err
}
var pool types.Pool
if err := json.NewDecoder(resp.Body).Decode(&pool); err != nil {
return nil, err
}
return &pool, nil
}
// Pool returns a pool by its reference.
func (c *Client) Pool(ref string) (*types.Pool, error) {
resp, err := c.do("GET", PoolAPIPrefix+"/"+ref, doOptions{})