add comments
diff --git a/openstack/identity/v2/client.go b/openstack/identity/v2/client.go
index c736833..d9a5b06 100644
--- a/openstack/identity/v2/client.go
+++ b/openstack/identity/v2/client.go
@@ -4,19 +4,43 @@
"os"
)
+// Client contains information that defines a generic Openstack Client.
type Client struct {
- Endpoint string
+ // Endpoint is the URL against which to authenticate.
+ Endpoint string
+ // Authority holds the results of authenticating against the Endpoint.
Authority AuthResults
- Options AuthOptions
+ // Options holds the authentication options. Useful for auto-reauthentication.
+ Options AuthOptions
}
+// ClientOpts contains options for creating a generic Openstack Client.
type ClientOpts struct {
- Type string
- Name string
- Region string
+ // Type is the service type for the client (e.g., "compute", "object-store").
+ // Type is a required field.
+ Type string
+ // Name is the service name for the client (e.g., "nova").
+ // Name is not a required field, but it is used if present. Services can have the
+ // same Type but different Name, which is one example of when both Type and Name are needed.
+ Name string
+ // Region is the region in which the service resides.
+ // Region is not a required field. If Region is not set, then the OS_REGION_NAME enviroment
+ // variable is used.
+ Region string
+ // URLType is they type of endpoint to be returned (e.g., "public", "private").
+ // URLType is not required, and defaults to "public".
URLType string
}
+// NewClient returns a generic Openstack Client of type identity.Client. This is a helper function
+// to create a client for the various Openstack services.
+// Example (error checking omitted for brevity):
+// ao, err := utils.AuthOptions()
+// c, err := ao.NewClient(identity.ClientOpts{
+// Type: "compute",
+// Name: "nova",
+// })
+// serversClient := servers.NewClient(c.Endpoint, c.Authority, c.Options)
func (ao AuthOptions) NewClient(opts ClientOpts) (Client, error) {
client := Client{
Options: ao,