diff --git a/snapshots.go b/snapshots.go index 181188d..17e62cb 100644 --- a/snapshots.go +++ b/snapshots.go @@ -37,6 +37,7 @@ type Snapshot struct { MinDiskSize int `json:"min_disk_size,omitempty"` SizeGigaBytes float64 `json:"size_gigabytes,omitempty"` Created string `json:"created_at,omitempty"` + Tags []string `json:"tags,omitempty"` } type snapshotRoot struct { diff --git a/snapshots_test.go b/snapshots_test.go index 728be7d..a9f9450 100644 --- a/snapshots_test.go +++ b/snapshots_test.go @@ -176,10 +176,11 @@ func TestSnapshot_String(t *testing.T) { MinDiskSize: 20, SizeGigaBytes: 4.84, Created: "2013-11-27T09:24:55Z", + Tags: []string{"one", "two"}, } stringified := snapshot.String() - expected := `godo.Snapshot{ID:"1", Name:"Snapsh176ot", ResourceID:"0", ResourceType:"droplet", Regions:["one"], MinDiskSize:20, SizeGigaBytes:4.84, Created:"2013-11-27T09:24:55Z"}` + expected := `godo.Snapshot{ID:"1", Name:"Snapsh176ot", ResourceID:"0", ResourceType:"droplet", Regions:["one"], MinDiskSize:20, SizeGigaBytes:4.84, Created:"2013-11-27T09:24:55Z", Tags:["one" "two"]}` if expected != stringified { t.Errorf("Snapshot.String returned %+v, expected %+v", stringified, expected) } diff --git a/storage.go b/storage.go index 88fd8a4..a4e13f8 100644 --- a/storage.go +++ b/storage.go @@ -175,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. diff --git a/storage_test.go b/storage_test.go index 8f753f4..e2be581 100644 --- a/storage_test.go +++ b/storage_test.go @@ -631,6 +631,7 @@ func TestStorageSnapshots_Create(t *testing.T) { VolumeID: "98d414c6-295e-4e3a-ac58-eb9456c1e1d1", Name: "my snapshot", Description: "my description", + Tags: []string{"one", "two"}, } want := &Snapshot{ @@ -639,6 +640,7 @@ func TestStorageSnapshots_Create(t *testing.T) { Name: "my snapshot", SizeGigaBytes: 100, Created: "2002-10-02T15:00:00.05Z", + Tags: []string{"one", "two"}, } jBlob := `{ "snapshot":{ @@ -647,7 +649,8 @@ func TestStorageSnapshots_Create(t *testing.T) { "name": "my snapshot", "description": "my description", "size_gigabytes": 100, - "created_at": "2002-10-02T15:00:00.05Z" + "created_at": "2002-10-02T15:00:00.05Z", + "tags": ["one", "two"] }, "links": { "pages": { diff --git a/tags.go b/tags.go index 295a2e9..0a74b12 100644 --- a/tags.go +++ b/tags.go @@ -33,14 +33,16 @@ var _ TagsService = &TagsServiceOp{} type ResourceType string const ( - //DropletResourceType holds the string representing our ResourceType of Droplet. + // DropletResourceType holds the string representing our ResourceType of Droplet. DropletResourceType ResourceType = "droplet" - //ImageResourceType holds the string representing our ResourceType of Image. + // ImageResourceType holds the string representing our ResourceType of Image. ImageResourceType ResourceType = "image" - //VolumeResourceType holds the string representing our ResourceType of Volume. + // VolumeResourceType holds the string representing our ResourceType of Volume. VolumeResourceType ResourceType = "volume" - //LoadBalancerResourceType holds the string representing our ResourceType of LoadBalancer. + // LoadBalancerResourceType holds the string representing our ResourceType of LoadBalancer. LoadBalancerResourceType ResourceType = "load_balancer" + // VolumeSnapshotResourceType holds the string representing our ResourceType for storage Snapshots. + VolumeSnapshotResourceType ResourceType = "volumesnapshot" ) // Resource represent a single resource for associating/disassociating with tags