Add support for Listing Servers.
Up to now, all you could do is authenticate with Gophercloud. Now, you
can list your servers too!
This is a pretty straight-ahead port of logic from Gorax to Gophercloud.
After you gain access to the ComputeApi, you simply invoke
ListServers(). This returns a slice of Server structures, one each for
the servers your account has access to. See the 02-list-servers.go
acceptance test.
Note that no unit-level tests exist for this functionality. Writing a
unit test for this code would only serve to test the compiler's ability
to emit bug-free machine code. (Observe ListServers() has no control
flow points, and all its dependencies already have their own unit
tests.)
Being that this is a straight-ahead port from Gorax, some things remain
to be done:
1) Provide an API for accessing Rackspace-specific fields. (#34)
2) Assuming (1) is successful, remove Rack-specific fields from Server
and other structures of interest. (#34)
3) Rename ComputeApi to something more descriptive -- like ServerApi().
(#33)
4) Implement token re-authentication logic. (#12)
diff --git a/authenticate.go b/authenticate.go
index d460673..8b87e44 100644
--- a/authenticate.go
+++ b/authenticate.go
@@ -134,3 +134,8 @@
urls := []string{ep.PublicURL, ep.InternalURL}
return urls[ac.UrlChoice]
}
+
+// See AccessProvider interface definition for details.
+func (a *Access) AuthToken() string {
+ return a.Token.Id
+}