vendor: Updating github.com/gophercloud/gophercloud
This commit is contained in:
parent
74189c5211
commit
4209720b7f
70
vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/swauth/requests.go
generated
vendored
Normal file
70
vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/swauth/requests.go
generated
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
package swauth
|
||||
|
||||
import "github.com/gophercloud/gophercloud"
|
||||
|
||||
// AuthOptsBuilder describes struct types that can be accepted by the Auth call.
|
||||
// The AuthOpts struct in this package does.
|
||||
type AuthOptsBuilder interface {
|
||||
ToAuthOptsMap() (map[string]string, error)
|
||||
}
|
||||
|
||||
// AuthOpts specifies an authentication request.
|
||||
type AuthOpts struct {
|
||||
// User is an Swauth-based username in username:tenant format.
|
||||
User string `h:"X-Auth-User" required:"true"`
|
||||
// Key is a secret/password to authenticate the User with.
|
||||
Key string `h:"X-Auth-Key" required:"true"`
|
||||
}
|
||||
|
||||
// ToAuthOptsMap formats an AuthOpts structure into a request body.
|
||||
func (opts AuthOpts) ToAuthOptsMap() (map[string]string, error) {
|
||||
return gophercloud.BuildHeaders(opts)
|
||||
}
|
||||
|
||||
// Auth performs an authentication request for a Swauth-based user.
|
||||
func Auth(c *gophercloud.ProviderClient, opts AuthOptsBuilder) (r GetAuthResult) {
|
||||
h := make(map[string]string)
|
||||
|
||||
if opts != nil {
|
||||
headers, err := opts.ToAuthOptsMap()
|
||||
if err != nil {
|
||||
r.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
for k, v := range headers {
|
||||
h[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
resp, err := c.Request("GET", getURL(c), &gophercloud.RequestOpts{
|
||||
MoreHeaders: h,
|
||||
OkCodes: []int{200},
|
||||
})
|
||||
|
||||
if resp != nil {
|
||||
r.Header = resp.Header
|
||||
}
|
||||
|
||||
r.Err = err
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// NewObjectStorageV1 creates a Swauth-authenticated *gophercloud.ServiceClient
|
||||
// client that can issue ObjectStorage-based API calls.
|
||||
func NewObjectStorageV1(pc *gophercloud.ProviderClient, authOpts AuthOpts) (*gophercloud.ServiceClient, error) {
|
||||
auth, err := Auth(pc, authOpts).Extract()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
swiftClient := &gophercloud.ServiceClient{
|
||||
ProviderClient: pc,
|
||||
Endpoint: gophercloud.NormalizeURL(auth.StorageURL),
|
||||
}
|
||||
|
||||
swiftClient.TokenID = auth.Token
|
||||
|
||||
return swiftClient, nil
|
||||
}
|
27
vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/swauth/results.go
generated
vendored
Normal file
27
vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/swauth/results.go
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
package swauth
|
||||
|
||||
import (
|
||||
"github.com/gophercloud/gophercloud"
|
||||
)
|
||||
|
||||
// GetAuthResult temporarily contains the response from a Swauth
|
||||
// authentication call.
|
||||
type GetAuthResult struct {
|
||||
gophercloud.HeaderResult
|
||||
}
|
||||
|
||||
// AuthResult contains the authentication information from a Swauth
|
||||
// authentication request.
|
||||
type AuthResult struct {
|
||||
Token string `json:"X-Auth-Token"`
|
||||
StorageURL string `json:"X-Storage-Url"`
|
||||
CDNURL string `json:"X-CDN-Management-Url"`
|
||||
}
|
||||
|
||||
// Extract is a method that attempts to interpret any Swauth authentication
|
||||
// response as a AuthResult struct.
|
||||
func (r GetAuthResult) Extract() (*AuthResult, error) {
|
||||
var s *AuthResult
|
||||
err := r.ExtractInto(&s)
|
||||
return s, err
|
||||
}
|
7
vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/swauth/urls.go
generated
vendored
Normal file
7
vendor/github.com/gophercloud/gophercloud/openstack/objectstorage/v1/swauth/urls.go
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
package swauth
|
||||
|
||||
import "github.com/gophercloud/gophercloud"
|
||||
|
||||
func getURL(c *gophercloud.ProviderClient) string {
|
||||
return c.IdentityBase + "auth/v1.0"
|
||||
}
|
|
@ -1377,6 +1377,12 @@
|
|||
"revision": "45720eeefeeeba03b2d7da500297ec68eeee51af",
|
||||
"revisionTime": "2016-10-31T15:28:56Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "roxPPVwS2CjJhf0CApHNQxAX7EA=",
|
||||
"path": "github.com/gophercloud/gophercloud/openstack/objectstorage/v1/swauth",
|
||||
"revision": "d5eda9707e146108e4d424062b602fd97a71c2e6",
|
||||
"revisionTime": "2016-11-14T18:28:31Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "TDOZnaS0TO0NirpxV1QwPerAQTY=",
|
||||
"path": "github.com/gophercloud/gophercloud/openstack/utils",
|
||||
|
|
Loading…
Reference in New Issue