Identity v3 Projects List (#163)
* Identity v3 Projects List
* Rename ToListQuery to ToProjectListQuery
diff --git a/acceptance/openstack/identity/v3/identity.go b/acceptance/openstack/identity/v3/identity.go
index 268fd79..2969bc9 100644
--- a/acceptance/openstack/identity/v3/identity.go
+++ b/acceptance/openstack/identity/v3/identity.go
@@ -4,6 +4,7 @@
"testing"
"github.com/gophercloud/gophercloud/openstack/identity/v3/endpoints"
+ "github.com/gophercloud/gophercloud/openstack/identity/v3/projects"
"github.com/gophercloud/gophercloud/openstack/identity/v3/services"
"github.com/gophercloud/gophercloud/openstack/identity/v3/tokens"
)
@@ -18,6 +19,17 @@
t.Logf("URL: %s", endpoint.URL)
}
+// PrintProject will print a project and all of its attributes.
+func PrintProject(t *testing.T, project *projects.Project) {
+ t.Logf("ID: %s", project.ID)
+ t.Logf("IsDomain: %t", project.IsDomain)
+ t.Logf("Description: %s", project.Description)
+ t.Logf("DomainID: %s", project.DomainID)
+ t.Logf("Enabled: %t", project.Enabled)
+ t.Logf("Name: %s", project.Name)
+ t.Logf("ParentID: %s", project.ParentID)
+}
+
// PrintService will print a service and all of its attributes.
func PrintService(t *testing.T, service *services.Service) {
t.Logf("ID: %s", service.ID)
diff --git a/acceptance/openstack/identity/v3/projects_test.go b/acceptance/openstack/identity/v3/projects_test.go
new file mode 100644
index 0000000..c78cbfe
--- /dev/null
+++ b/acceptance/openstack/identity/v3/projects_test.go
@@ -0,0 +1,36 @@
+// +build acceptance
+
+package v3
+
+import (
+ "testing"
+
+ "github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/openstack/identity/v3/projects"
+)
+
+func TestProjectsList(t *testing.T) {
+ client, err := clients.NewIdentityV3Client()
+ if err != nil {
+ t.Fatalf("Unable to obtain an identity client: %v")
+ }
+
+ var iTrue bool = true
+ listOpts := projects.ListOpts{
+ Enabled: &iTrue,
+ }
+
+ allPages, err := projects.List(client, listOpts).AllPages()
+ if err != nil {
+ t.Fatalf("Unable to list projects: %v", err)
+ }
+
+ allProjects, err := projects.ExtractProjects(allPages)
+ if err != nil {
+ t.Fatalf("Unable to extract projects: %v", err)
+ }
+
+ for _, project := range allProjects {
+ PrintProject(t, &project)
+ }
+}