Identity v3 Projects Get (#164)
* Identity v3 Projects Get
* Renaming ToGetQuery to ToProjectGetQuery
* Fixing acceptance test
diff --git a/openstack/identity/v3/projects/requests.go b/openstack/identity/v3/projects/requests.go
index 213db9c..73e4c4c 100644
--- a/openstack/identity/v3/projects/requests.go
+++ b/openstack/identity/v3/projects/requests.go
@@ -50,3 +50,36 @@
return ProjectPage{pagination.LinkedPageBase{PageResult: r}}
})
}
+
+// GetOptsBuilder allows extensions to add additional parameters to
+// the Get request.
+type GetOptsBuilder interface {
+ ToProjectGetQuery() (string, error)
+}
+
+// GetOpts allows you to modify the details included in the Get request.
+type GetOpts struct{}
+
+// ToProjectGetQuery formats a GetOpts into a query string.
+func (opts GetOpts) ToProjectGetQuery() (string, error) {
+ q, err := gophercloud.BuildQueryString(opts)
+ return q.String(), err
+}
+
+// Get retrieves details on a single project, by ID.
+func Get(client *gophercloud.ServiceClient, id string, opts GetOptsBuilder) (r GetResult) {
+ url := getURL(client, id)
+ if opts != nil {
+ query, err := opts.ToProjectGetQuery()
+ if err != nil {
+ r.Err = err
+ return
+ }
+ url += query
+ }
+
+ _, r.Err = client.Get(url, &r.Body, &gophercloud.RequestOpts{
+ OkCodes: []int{200},
+ })
+ return
+}