Add ImageById to provide details on an image id
diff --git a/images.go b/images.go
index 38c73e1..61a3369 100644
--- a/images.go
+++ b/images.go
@@ -21,6 +21,22 @@
return is, err
}
+func (gsp *genericServersProvider) ImageById(id string) (*Image, error) {
+ var is *Image
+
+ err := gsp.context.WithReauth(gsp.access, func() error {
+ url := gsp.endpoint + "/images/" + id
+ return perigee.Get(url, perigee.Options{
+ CustomClient: gsp.context.httpClient,
+ Results: &struct{ Image **Image }{&is},
+ MoreHeaders: map[string]string{
+ "X-Auth-Token": gsp.access.AuthToken(),
+ },
+ })
+ })
+ return is, err
+}
+
// ImageLink provides a reference to a image by either ID or by direct URL.
// Some services use just the ID, others use just the URL.
// This structure provides a common means of expressing both in a single field.
diff --git a/interfaces.go b/interfaces.go
index 8d5887c..6786d39 100644
--- a/interfaces.go
+++ b/interfaces.go
@@ -145,6 +145,9 @@
// returns full details for each image, if available.
ListImages() ([]Image, error)
+ // ImageById yields details about a specific image.
+ ImageById(id string) (*Image, error)
+
// Flavors
// ListFlavors yields the list of available system flavors. This function