Adding BlockStorage Snapshots v2 API

Change-Id: If240939038c1aaf45ac8e7c6b0d2914805031f12
diff --git a/openstack/blockstorage/v2/snapshots/requests.go b/openstack/blockstorage/v2/snapshots/requests.go
new file mode 100644
index 0000000..5dca94c
--- /dev/null
+++ b/openstack/blockstorage/v2/snapshots/requests.go
@@ -0,0 +1,39 @@
+package snapshots
+
+import (
+	gophercloud "gerrit.mcp.mirantis.net/debian/gophercloud.git"
+	"gerrit.mcp.mirantis.net/debian/gophercloud.git/pagination"
+)
+
+// ListOptsBuilder allows extensions to add additional parameters to the List
+// request.
+type ListOptsBuilder interface {
+	ToVolumeListQuery() (string, error)
+}
+
+type ListOpts struct {
+	// admin-only option. Set it to true to see all tenant volumes.
+	AllTenants bool `q:"all_tenants"`
+}
+
+// ToVolumeListQuery formats a ListOpts into a query string.
+func (opts ListOpts) ToVolumeListQuery() (string, error) {
+	q, err := gophercloud.BuildQueryString(opts)
+	return q.String(), err
+}
+
+// List returns Volumes optionally limited by the conditions provided in ListOpts.
+func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager {
+	url := listURL(client)
+	if opts != nil {
+		query, err := opts.ToVolumeListQuery()
+		if err != nil {
+			return pagination.Pager{Err: err}
+		}
+		url += query
+	}
+
+	return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
+		return SnapshotPage{pagination.SinglePageBase(r)}
+	})
+}
diff --git a/openstack/blockstorage/v2/snapshots/results.go b/openstack/blockstorage/v2/snapshots/results.go
new file mode 100644
index 0000000..23f5538
--- /dev/null
+++ b/openstack/blockstorage/v2/snapshots/results.go
@@ -0,0 +1,54 @@
+package snapshots
+
+import (
+	"encoding/json"
+	"time"
+
+	"gerrit.mcp.mirantis.net/debian/gophercloud.git"
+	"gerrit.mcp.mirantis.net/debian/gophercloud.git/pagination"
+)
+
+type Snapshot struct {
+	// Unique identifier for the snapshot.
+	ID string `json:"id"`
+	// Current status of the snapshot.
+	Status string `json:"status"`
+	// Size of the snapshot in GB.
+	Size int `json:"size"`
+	// The date when this snapshot was created.
+	CreatedAt time.Time `json:"-"`
+	// Human-readable display name for the snapshot.
+	Name string `json:"name"`
+}
+
+func (r *Snapshot) UnmarshalJSON(b []byte) error {
+	type tmp Snapshot
+	var s struct {
+		tmp
+		CreatedAt gophercloud.JSONRFC3339MilliNoZ `json:"created_at"`
+	}
+	err := json.Unmarshal(b, &s)
+	if err != nil {
+		return err
+	}
+	*r = Snapshot(s.tmp)
+
+	r.CreatedAt = time.Time(s.CreatedAt)
+
+	return err
+}
+
+type SnapshotPage struct {
+	pagination.SinglePageBase
+}
+
+// ExtractVolumes extracts and returns Volumes. It is used while iterating over a volumes.List call.
+func ExtractSnapshots(r pagination.Page) ([]Snapshot, error) {
+	var s []Snapshot
+	err := ExtractSnapshotInto(r, &s)
+	return s, err
+}
+
+func ExtractSnapshotInto(r pagination.Page, v interface{}) error {
+	return r.(SnapshotPage).Result.ExtractIntoSlicePtr(v, "snapshots")
+}
diff --git a/openstack/blockstorage/v2/snapshots/urls.go b/openstack/blockstorage/v2/snapshots/urls.go
new file mode 100644
index 0000000..01237ef
--- /dev/null
+++ b/openstack/blockstorage/v2/snapshots/urls.go
@@ -0,0 +1,7 @@
+package snapshots
+
+import gophercloud "gerrit.mcp.mirantis.net/debian/gophercloud.git"
+
+func listURL(c *gophercloud.ServiceClient) string {
+	return c.ServiceURL("snapshots")
+}