1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

DIGITAL OCEAN: Update github.com/digitalocean/godo (#513)

This commit is contained in:
Tom Limoncelli
2019-06-30 08:58:25 -04:00
committed by GitHub
parent 9ff8f6926f
commit d5ff6d6e5c
34 changed files with 2469 additions and 148 deletions

View File

@@ -1,12 +1,10 @@
package godo
import (
"context"
"fmt"
"time"
"net/http"
"github.com/digitalocean/godo/context"
"time"
)
const (
@@ -46,19 +44,26 @@ var _ StorageService = &StorageServiceOp{}
// Volume represents a Digital Ocean block store volume.
type Volume struct {
ID string `json:"id"`
Region *Region `json:"region"`
Name string `json:"name"`
SizeGigaBytes int64 `json:"size_gigabytes"`
Description string `json:"description"`
DropletIDs []int `json:"droplet_ids"`
CreatedAt time.Time `json:"created_at"`
ID string `json:"id"`
Region *Region `json:"region"`
Name string `json:"name"`
SizeGigaBytes int64 `json:"size_gigabytes"`
Description string `json:"description"`
DropletIDs []int `json:"droplet_ids"`
CreatedAt time.Time `json:"created_at"`
FilesystemType string `json:"filesystem_type"`
FilesystemLabel string `json:"filesystem_label"`
Tags []string `json:"tags"`
}
func (f Volume) String() string {
return Stringify(f)
}
func (f Volume) URN() string {
return ToURN("Volume", f.ID)
}
type storageVolumesRoot struct {
Volumes []Volume `json:"volumes"`
Links *Links `json:"links"`
@@ -72,11 +77,14 @@ type storageVolumeRoot struct {
// VolumeCreateRequest represents a request to create a block store
// volume.
type VolumeCreateRequest struct {
Region string `json:"region"`
Name string `json:"name"`
Description string `json:"description"`
SizeGigaBytes int64 `json:"size_gigabytes"`
SnapshotID string `json:"snapshot_id"`
Region string `json:"region"`
Name string `json:"name"`
Description string `json:"description"`
SizeGigaBytes int64 `json:"size_gigabytes"`
SnapshotID string `json:"snapshot_id"`
FilesystemType string `json:"filesystem_type"`
FilesystemLabel string `json:"filesystem_label"`
Tags []string `json:"tags"`
}
// ListVolumes lists all storage volumes.
@@ -85,6 +93,10 @@ func (svc *StorageServiceOp) ListVolumes(ctx context.Context, params *ListVolume
if params != nil {
if params.Region != "" && params.Name != "" {
path = fmt.Sprintf("%s?name=%s&region=%s", path, params.Name, params.Region)
} else if params.Region != "" {
path = fmt.Sprintf("%s?region=%s", path, params.Region)
} else if params.Name != "" {
path = fmt.Sprintf("%s?name=%s", path, params.Name)
}
if params.ListOptions != nil {
@@ -163,9 +175,10 @@ func (svc *StorageServiceOp) DeleteVolume(ctx context.Context, id string) (*Resp
// SnapshotCreateRequest represents a request to create a block store
// volume.
type SnapshotCreateRequest struct {
VolumeID string `json:"volume_id"`
Name string `json:"name"`
Description string `json:"description"`
VolumeID string `json:"volume_id"`
Name string `json:"name"`
Description string `json:"description"`
Tags []string `json:"tags"`
}
// ListSnapshots lists all snapshots related to a storage volume.