Update vendor dir and Godeps.json with new Godep
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
// Package roles provides functionality to interact with and control roles on
|
||||
// the API.
|
||||
//
|
||||
// A role represents a personality that a user can assume when performing a
|
||||
// specific set of operations. If a role includes a set of rights and
|
||||
// privileges, a user assuming that role inherits those rights and privileges.
|
||||
//
|
||||
// When a token is generated, the list of roles that user can assume is returned
|
||||
// back to them. Services that are being called by that user determine how they
|
||||
// interpret the set of roles a user has and to which operations or resources
|
||||
// each role grants access.
|
||||
//
|
||||
// It is up to individual services such as Compute or Image to assign meaning
|
||||
// to these roles. As far as the Identity service is concerned, a role is an
|
||||
// arbitrary name assigned by the user.
|
||||
package roles
|
@@ -1,48 +0,0 @@
|
||||
package roles
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
th "github.com/rackspace/gophercloud/testhelper"
|
||||
fake "github.com/rackspace/gophercloud/testhelper/client"
|
||||
)
|
||||
|
||||
func MockListRoleResponse(t *testing.T) {
|
||||
th.Mux.HandleFunc("/OS-KSADM/roles", func(w http.ResponseWriter, r *http.Request) {
|
||||
th.TestMethod(t, r, "GET")
|
||||
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
|
||||
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
fmt.Fprintf(w, `
|
||||
{
|
||||
"roles": [
|
||||
{
|
||||
"id": "123",
|
||||
"name": "compute:admin",
|
||||
"description": "Nova Administrator"
|
||||
}
|
||||
]
|
||||
}
|
||||
`)
|
||||
})
|
||||
}
|
||||
|
||||
func MockAddUserRoleResponse(t *testing.T) {
|
||||
th.Mux.HandleFunc("/tenants/{tenant_id}/users/{user_id}/roles/OS-KSADM/{role_id}", func(w http.ResponseWriter, r *http.Request) {
|
||||
th.TestMethod(t, r, "PUT")
|
||||
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
})
|
||||
}
|
||||
|
||||
func MockDeleteUserRoleResponse(t *testing.T) {
|
||||
th.Mux.HandleFunc("/tenants/{tenant_id}/users/{user_id}/roles/OS-KSADM/{role_id}", func(w http.ResponseWriter, r *http.Request) {
|
||||
th.TestMethod(t, r, "DELETE")
|
||||
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
})
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
package roles
|
||||
|
||||
import (
|
||||
"github.com/rackspace/gophercloud"
|
||||
"github.com/rackspace/gophercloud/pagination"
|
||||
)
|
||||
|
||||
// List is the operation responsible for listing all available global roles
|
||||
// that a user can adopt.
|
||||
func List(client *gophercloud.ServiceClient) pagination.Pager {
|
||||
createPage := func(r pagination.PageResult) pagination.Page {
|
||||
return RolePage{pagination.SinglePageBase(r)}
|
||||
}
|
||||
return pagination.NewPager(client, rootURL(client), createPage)
|
||||
}
|
||||
|
||||
// AddUserRole is the operation responsible for assigning a particular role to
|
||||
// a user. This is confined to the scope of the user's tenant - so the tenant
|
||||
// ID is a required argument.
|
||||
func AddUserRole(client *gophercloud.ServiceClient, tenantID, userID, roleID string) UserRoleResult {
|
||||
var result UserRoleResult
|
||||
_, result.Err = client.Put(userRoleURL(client, tenantID, userID, roleID), nil, nil, nil)
|
||||
return result
|
||||
}
|
||||
|
||||
// DeleteUserRole is the operation responsible for deleting a particular role
|
||||
// from a user. This is confined to the scope of the user's tenant - so the
|
||||
// tenant ID is a required argument.
|
||||
func DeleteUserRole(client *gophercloud.ServiceClient, tenantID, userID, roleID string) UserRoleResult {
|
||||
var result UserRoleResult
|
||||
_, result.Err = client.Delete(userRoleURL(client, tenantID, userID, roleID), nil)
|
||||
return result
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
package roles
|
||||
|
||||
import (
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/rackspace/gophercloud"
|
||||
"github.com/rackspace/gophercloud/pagination"
|
||||
)
|
||||
|
||||
// Role represents an API role resource.
|
||||
type Role struct {
|
||||
// The unique ID for the role.
|
||||
ID string
|
||||
|
||||
// The human-readable name of the role.
|
||||
Name string
|
||||
|
||||
// The description of the role.
|
||||
Description string
|
||||
|
||||
// The associated service for this role.
|
||||
ServiceID string
|
||||
}
|
||||
|
||||
// RolePage is a single page of a user Role collection.
|
||||
type RolePage struct {
|
||||
pagination.SinglePageBase
|
||||
}
|
||||
|
||||
// IsEmpty determines whether or not a page of Tenants contains any results.
|
||||
func (page RolePage) IsEmpty() (bool, error) {
|
||||
users, err := ExtractRoles(page)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return len(users) == 0, nil
|
||||
}
|
||||
|
||||
// ExtractRoles returns a slice of roles contained in a single page of results.
|
||||
func ExtractRoles(page pagination.Page) ([]Role, error) {
|
||||
casted := page.(RolePage).Body
|
||||
var response struct {
|
||||
Roles []Role `mapstructure:"roles"`
|
||||
}
|
||||
|
||||
err := mapstructure.Decode(casted, &response)
|
||||
return response.Roles, err
|
||||
}
|
||||
|
||||
// UserRoleResult represents the result of either an AddUserRole or
|
||||
// a DeleteUserRole operation.
|
||||
type UserRoleResult struct {
|
||||
gophercloud.ErrResult
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
package roles
|
||||
|
||||
import "github.com/rackspace/gophercloud"
|
||||
|
||||
const (
|
||||
ExtPath = "OS-KSADM"
|
||||
RolePath = "roles"
|
||||
UserPath = "users"
|
||||
)
|
||||
|
||||
func resourceURL(c *gophercloud.ServiceClient, id string) string {
|
||||
return c.ServiceURL(ExtPath, RolePath, id)
|
||||
}
|
||||
|
||||
func rootURL(c *gophercloud.ServiceClient) string {
|
||||
return c.ServiceURL(ExtPath, RolePath)
|
||||
}
|
||||
|
||||
func userRoleURL(c *gophercloud.ServiceClient, tenantID, userID, roleID string) string {
|
||||
return c.ServiceURL("tenants", tenantID, UserPath, userID, RolePath, ExtPath, roleID)
|
||||
}
|
52
vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/delegate.go
generated
vendored
52
vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/delegate.go
generated
vendored
@@ -1,52 +0,0 @@
|
||||
package extensions
|
||||
|
||||
import (
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/rackspace/gophercloud"
|
||||
common "github.com/rackspace/gophercloud/openstack/common/extensions"
|
||||
"github.com/rackspace/gophercloud/pagination"
|
||||
)
|
||||
|
||||
// ExtensionPage is a single page of Extension results.
|
||||
type ExtensionPage struct {
|
||||
common.ExtensionPage
|
||||
}
|
||||
|
||||
// IsEmpty returns true if the current page contains at least one Extension.
|
||||
func (page ExtensionPage) IsEmpty() (bool, error) {
|
||||
is, err := ExtractExtensions(page)
|
||||
if err != nil {
|
||||
return true, err
|
||||
}
|
||||
return len(is) == 0, nil
|
||||
}
|
||||
|
||||
// ExtractExtensions accepts a Page struct, specifically an ExtensionPage struct, and extracts the
|
||||
// elements into a slice of Extension structs.
|
||||
func ExtractExtensions(page pagination.Page) ([]common.Extension, error) {
|
||||
// Identity v2 adds an intermediate "values" object.
|
||||
|
||||
var resp struct {
|
||||
Extensions struct {
|
||||
Values []common.Extension `mapstructure:"values"`
|
||||
} `mapstructure:"extensions"`
|
||||
}
|
||||
|
||||
err := mapstructure.Decode(page.(ExtensionPage).Body, &resp)
|
||||
return resp.Extensions.Values, err
|
||||
}
|
||||
|
||||
// Get retrieves information for a specific extension using its alias.
|
||||
func Get(c *gophercloud.ServiceClient, alias string) common.GetResult {
|
||||
return common.Get(c, alias)
|
||||
}
|
||||
|
||||
// List returns a Pager which allows you to iterate over the full collection of extensions.
|
||||
// It does not accept query parameters.
|
||||
func List(c *gophercloud.ServiceClient) pagination.Pager {
|
||||
return common.List(c).WithPageCreator(func(r pagination.PageResult) pagination.Page {
|
||||
return ExtensionPage{
|
||||
ExtensionPage: common.ExtensionPage{SinglePageBase: pagination.SinglePageBase(r)},
|
||||
}
|
||||
})
|
||||
}
|
3
vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/doc.go
generated
vendored
3
vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/doc.go
generated
vendored
@@ -1,3 +0,0 @@
|
||||
// Package extensions provides information and interaction with the
|
||||
// different extensions available for the OpenStack Identity service.
|
||||
package extensions
|
60
vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/fixtures.go
generated
vendored
60
vendor/github.com/rackspace/gophercloud/openstack/identity/v2/extensions/fixtures.go
generated
vendored
@@ -1,60 +0,0 @@
|
||||
// +build fixtures
|
||||
|
||||
package extensions
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
th "github.com/rackspace/gophercloud/testhelper"
|
||||
"github.com/rackspace/gophercloud/testhelper/client"
|
||||
)
|
||||
|
||||
// ListOutput provides a single Extension result. It differs from the delegated implementation
|
||||
// by the introduction of an intermediate "values" member.
|
||||
const ListOutput = `
|
||||
{
|
||||
"extensions": {
|
||||
"values": [
|
||||
{
|
||||
"updated": "2013-01-20T00:00:00-00:00",
|
||||
"name": "Neutron Service Type Management",
|
||||
"links": [],
|
||||
"namespace": "http://docs.openstack.org/ext/neutron/service-type/api/v1.0",
|
||||
"alias": "service-type",
|
||||
"description": "API for retrieving service providers for Neutron advanced services"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
// HandleListExtensionsSuccessfully creates an HTTP handler that returns ListOutput for a List
|
||||
// call.
|
||||
func HandleListExtensionsSuccessfully(t *testing.T) {
|
||||
th.Mux.HandleFunc("/extensions", func(w http.ResponseWriter, r *http.Request) {
|
||||
th.TestMethod(t, r, "GET")
|
||||
th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
|
||||
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
|
||||
fmt.Fprintf(w, `
|
||||
{
|
||||
"extensions": {
|
||||
"values": [
|
||||
{
|
||||
"updated": "2013-01-20T00:00:00-00:00",
|
||||
"name": "Neutron Service Type Management",
|
||||
"links": [],
|
||||
"namespace": "http://docs.openstack.org/ext/neutron/service-type/api/v1.0",
|
||||
"alias": "service-type",
|
||||
"description": "API for retrieving service providers for Neutron advanced services"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
`)
|
||||
})
|
||||
|
||||
}
|
1
vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/doc.go
generated
vendored
1
vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/doc.go
generated
vendored
@@ -1 +0,0 @@
|
||||
package users
|
163
vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/fixtures.go
generated
vendored
163
vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/fixtures.go
generated
vendored
@@ -1,163 +0,0 @@
|
||||
package users
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
th "github.com/rackspace/gophercloud/testhelper"
|
||||
fake "github.com/rackspace/gophercloud/testhelper/client"
|
||||
)
|
||||
|
||||
func MockListUserResponse(t *testing.T) {
|
||||
th.Mux.HandleFunc("/users", func(w http.ResponseWriter, r *http.Request) {
|
||||
th.TestMethod(t, r, "GET")
|
||||
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
|
||||
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
fmt.Fprintf(w, `
|
||||
{
|
||||
"users":[
|
||||
{
|
||||
"id": "u1000",
|
||||
"name": "John Smith",
|
||||
"username": "jqsmith",
|
||||
"email": "john.smith@example.org",
|
||||
"enabled": true,
|
||||
"tenant_id": "12345"
|
||||
},
|
||||
{
|
||||
"id": "u1001",
|
||||
"name": "Jane Smith",
|
||||
"username": "jqsmith",
|
||||
"email": "jane.smith@example.org",
|
||||
"enabled": true,
|
||||
"tenant_id": "12345"
|
||||
}
|
||||
]
|
||||
}
|
||||
`)
|
||||
})
|
||||
}
|
||||
|
||||
func mockCreateUserResponse(t *testing.T) {
|
||||
th.Mux.HandleFunc("/users", func(w http.ResponseWriter, r *http.Request) {
|
||||
th.TestMethod(t, r, "POST")
|
||||
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
|
||||
|
||||
th.TestJSONRequest(t, r, `
|
||||
{
|
||||
"user": {
|
||||
"name": "new_user",
|
||||
"tenant_id": "12345",
|
||||
"enabled": false,
|
||||
"email": "new_user@foo.com"
|
||||
}
|
||||
}
|
||||
`)
|
||||
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
fmt.Fprintf(w, `
|
||||
{
|
||||
"user": {
|
||||
"name": "new_user",
|
||||
"tenant_id": "12345",
|
||||
"enabled": false,
|
||||
"email": "new_user@foo.com",
|
||||
"id": "c39e3de9be2d4c779f1dfd6abacc176d"
|
||||
}
|
||||
}
|
||||
`)
|
||||
})
|
||||
}
|
||||
|
||||
func mockGetUserResponse(t *testing.T) {
|
||||
th.Mux.HandleFunc("/users/new_user", func(w http.ResponseWriter, r *http.Request) {
|
||||
th.TestMethod(t, r, "GET")
|
||||
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
|
||||
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
fmt.Fprintf(w, `
|
||||
{
|
||||
"user": {
|
||||
"name": "new_user",
|
||||
"tenant_id": "12345",
|
||||
"enabled": false,
|
||||
"email": "new_user@foo.com",
|
||||
"id": "c39e3de9be2d4c779f1dfd6abacc176d"
|
||||
}
|
||||
}
|
||||
`)
|
||||
})
|
||||
}
|
||||
|
||||
func mockUpdateUserResponse(t *testing.T) {
|
||||
th.Mux.HandleFunc("/users/c39e3de9be2d4c779f1dfd6abacc176d", func(w http.ResponseWriter, r *http.Request) {
|
||||
th.TestMethod(t, r, "PUT")
|
||||
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
|
||||
|
||||
th.TestJSONRequest(t, r, `
|
||||
{
|
||||
"user": {
|
||||
"name": "new_name",
|
||||
"enabled": true,
|
||||
"email": "new_email@foo.com"
|
||||
}
|
||||
}
|
||||
`)
|
||||
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
fmt.Fprintf(w, `
|
||||
{
|
||||
"user": {
|
||||
"name": "new_name",
|
||||
"tenant_id": "12345",
|
||||
"enabled": true,
|
||||
"email": "new_email@foo.com",
|
||||
"id": "c39e3de9be2d4c779f1dfd6abacc176d"
|
||||
}
|
||||
}
|
||||
`)
|
||||
})
|
||||
}
|
||||
|
||||
func mockDeleteUserResponse(t *testing.T) {
|
||||
th.Mux.HandleFunc("/users/c39e3de9be2d4c779f1dfd6abacc176d", func(w http.ResponseWriter, r *http.Request) {
|
||||
th.TestMethod(t, r, "DELETE")
|
||||
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
})
|
||||
}
|
||||
|
||||
func mockListRolesResponse(t *testing.T) {
|
||||
th.Mux.HandleFunc("/tenants/1d8b6120dcc640fda4fc9194ffc80273/users/c39e3de9be2d4c779f1dfd6abacc176d/roles", func(w http.ResponseWriter, r *http.Request) {
|
||||
th.TestMethod(t, r, "GET")
|
||||
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
|
||||
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
fmt.Fprintf(w, `
|
||||
{
|
||||
"roles": [
|
||||
{
|
||||
"id": "9fe2ff9ee4384b1894a90878d3e92bab",
|
||||
"name": "foo_role"
|
||||
},
|
||||
{
|
||||
"id": "1ea3d56793574b668e85960fbf651e13",
|
||||
"name": "admin"
|
||||
}
|
||||
]
|
||||
}
|
||||
`)
|
||||
})
|
||||
}
|
161
vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/requests.go
generated
vendored
161
vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/requests.go
generated
vendored
@@ -1,161 +0,0 @@
|
||||
package users
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/rackspace/gophercloud"
|
||||
"github.com/rackspace/gophercloud/pagination"
|
||||
)
|
||||
|
||||
func List(client *gophercloud.ServiceClient) pagination.Pager {
|
||||
createPage := func(r pagination.PageResult) pagination.Page {
|
||||
return UserPage{pagination.SinglePageBase(r)}
|
||||
}
|
||||
|
||||
return pagination.NewPager(client, rootURL(client), createPage)
|
||||
}
|
||||
|
||||
// EnabledState represents whether the user is enabled or not.
|
||||
type EnabledState *bool
|
||||
|
||||
// Useful variables to use when creating or updating users.
|
||||
var (
|
||||
iTrue = true
|
||||
iFalse = false
|
||||
|
||||
Enabled EnabledState = &iTrue
|
||||
Disabled EnabledState = &iFalse
|
||||
)
|
||||
|
||||
// CommonOpts are the parameters that are shared between CreateOpts and
|
||||
// UpdateOpts
|
||||
type CommonOpts struct {
|
||||
// Either a name or username is required. When provided, the value must be
|
||||
// unique or a 409 conflict error will be returned. If you provide a name but
|
||||
// omit a username, the latter will be set to the former; and vice versa.
|
||||
Name, Username string
|
||||
|
||||
// The ID of the tenant to which you want to assign this user.
|
||||
TenantID string
|
||||
|
||||
// Indicates whether this user is enabled or not.
|
||||
Enabled EnabledState
|
||||
|
||||
// The email address of this user.
|
||||
Email string
|
||||
}
|
||||
|
||||
// CreateOpts represents the options needed when creating new users.
|
||||
type CreateOpts CommonOpts
|
||||
|
||||
// CreateOptsBuilder describes struct types that can be accepted by the Create call.
|
||||
type CreateOptsBuilder interface {
|
||||
ToUserCreateMap() (map[string]interface{}, error)
|
||||
}
|
||||
|
||||
// ToUserCreateMap assembles a request body based on the contents of a CreateOpts.
|
||||
func (opts CreateOpts) ToUserCreateMap() (map[string]interface{}, error) {
|
||||
m := make(map[string]interface{})
|
||||
|
||||
if opts.Name == "" && opts.Username == "" {
|
||||
return m, errors.New("Either a Name or Username must be provided")
|
||||
}
|
||||
|
||||
if opts.Name != "" {
|
||||
m["name"] = opts.Name
|
||||
}
|
||||
if opts.Username != "" {
|
||||
m["username"] = opts.Username
|
||||
}
|
||||
if opts.Enabled != nil {
|
||||
m["enabled"] = &opts.Enabled
|
||||
}
|
||||
if opts.Email != "" {
|
||||
m["email"] = opts.Email
|
||||
}
|
||||
if opts.TenantID != "" {
|
||||
m["tenant_id"] = opts.TenantID
|
||||
}
|
||||
|
||||
return map[string]interface{}{"user": m}, nil
|
||||
}
|
||||
|
||||
// Create is the operation responsible for creating new users.
|
||||
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult {
|
||||
var res CreateResult
|
||||
|
||||
reqBody, err := opts.ToUserCreateMap()
|
||||
if err != nil {
|
||||
res.Err = err
|
||||
return res
|
||||
}
|
||||
|
||||
_, res.Err = client.Post(rootURL(client), reqBody, &res.Body, &gophercloud.RequestOpts{
|
||||
OkCodes: []int{200, 201},
|
||||
})
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
// Get requests details on a single user, either by ID.
|
||||
func Get(client *gophercloud.ServiceClient, id string) GetResult {
|
||||
var result GetResult
|
||||
_, result.Err = client.Get(ResourceURL(client, id), &result.Body, nil)
|
||||
return result
|
||||
}
|
||||
|
||||
// UpdateOptsBuilder allows extensions to add additional attributes to the Update request.
|
||||
type UpdateOptsBuilder interface {
|
||||
ToUserUpdateMap() map[string]interface{}
|
||||
}
|
||||
|
||||
// UpdateOpts specifies the base attributes that may be updated on an existing server.
|
||||
type UpdateOpts CommonOpts
|
||||
|
||||
// ToUserUpdateMap formats an UpdateOpts structure into a request body.
|
||||
func (opts UpdateOpts) ToUserUpdateMap() map[string]interface{} {
|
||||
m := make(map[string]interface{})
|
||||
|
||||
if opts.Name != "" {
|
||||
m["name"] = opts.Name
|
||||
}
|
||||
if opts.Username != "" {
|
||||
m["username"] = opts.Username
|
||||
}
|
||||
if opts.Enabled != nil {
|
||||
m["enabled"] = &opts.Enabled
|
||||
}
|
||||
if opts.Email != "" {
|
||||
m["email"] = opts.Email
|
||||
}
|
||||
if opts.TenantID != "" {
|
||||
m["tenant_id"] = opts.TenantID
|
||||
}
|
||||
|
||||
return map[string]interface{}{"user": m}
|
||||
}
|
||||
|
||||
// Update is the operation responsible for updating exist users by their UUID.
|
||||
func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) UpdateResult {
|
||||
var result UpdateResult
|
||||
reqBody := opts.ToUserUpdateMap()
|
||||
_, result.Err = client.Put(ResourceURL(client, id), reqBody, &result.Body, &gophercloud.RequestOpts{
|
||||
OkCodes: []int{200},
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
// Delete is the operation responsible for permanently deleting an API user.
|
||||
func Delete(client *gophercloud.ServiceClient, id string) DeleteResult {
|
||||
var result DeleteResult
|
||||
_, result.Err = client.Delete(ResourceURL(client, id), nil)
|
||||
return result
|
||||
}
|
||||
|
||||
func ListRoles(client *gophercloud.ServiceClient, tenantID, userID string) pagination.Pager {
|
||||
createPage := func(r pagination.PageResult) pagination.Page {
|
||||
return RolePage{pagination.SinglePageBase(r)}
|
||||
}
|
||||
|
||||
return pagination.NewPager(client, listRolesURL(client, tenantID, userID), createPage)
|
||||
}
|
128
vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/results.go
generated
vendored
128
vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/results.go
generated
vendored
@@ -1,128 +0,0 @@
|
||||
package users
|
||||
|
||||
import (
|
||||
"github.com/mitchellh/mapstructure"
|
||||
|
||||
"github.com/rackspace/gophercloud"
|
||||
"github.com/rackspace/gophercloud/pagination"
|
||||
)
|
||||
|
||||
// User represents a user resource that exists on the API.
|
||||
type User struct {
|
||||
// The UUID for this user.
|
||||
ID string
|
||||
|
||||
// The human name for this user.
|
||||
Name string
|
||||
|
||||
// The username for this user.
|
||||
Username string
|
||||
|
||||
// Indicates whether the user is enabled (true) or disabled (false).
|
||||
Enabled bool
|
||||
|
||||
// The email address for this user.
|
||||
Email string
|
||||
|
||||
// The ID of the tenant to which this user belongs.
|
||||
TenantID string `mapstructure:"tenant_id"`
|
||||
}
|
||||
|
||||
// Role assigns specific responsibilities to users, allowing them to accomplish
|
||||
// certain API operations whilst scoped to a service.
|
||||
type Role struct {
|
||||
// UUID of the role
|
||||
ID string
|
||||
|
||||
// Name of the role
|
||||
Name string
|
||||
}
|
||||
|
||||
// UserPage is a single page of a User collection.
|
||||
type UserPage struct {
|
||||
pagination.SinglePageBase
|
||||
}
|
||||
|
||||
// RolePage is a single page of a user Role collection.
|
||||
type RolePage struct {
|
||||
pagination.SinglePageBase
|
||||
}
|
||||
|
||||
// IsEmpty determines whether or not a page of Tenants contains any results.
|
||||
func (page UserPage) IsEmpty() (bool, error) {
|
||||
users, err := ExtractUsers(page)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return len(users) == 0, nil
|
||||
}
|
||||
|
||||
// ExtractUsers returns a slice of Tenants contained in a single page of results.
|
||||
func ExtractUsers(page pagination.Page) ([]User, error) {
|
||||
casted := page.(UserPage).Body
|
||||
var response struct {
|
||||
Users []User `mapstructure:"users"`
|
||||
}
|
||||
|
||||
err := mapstructure.Decode(casted, &response)
|
||||
return response.Users, err
|
||||
}
|
||||
|
||||
// IsEmpty determines whether or not a page of Tenants contains any results.
|
||||
func (page RolePage) IsEmpty() (bool, error) {
|
||||
users, err := ExtractRoles(page)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return len(users) == 0, nil
|
||||
}
|
||||
|
||||
// ExtractRoles returns a slice of Roles contained in a single page of results.
|
||||
func ExtractRoles(page pagination.Page) ([]Role, error) {
|
||||
casted := page.(RolePage).Body
|
||||
var response struct {
|
||||
Roles []Role `mapstructure:"roles"`
|
||||
}
|
||||
|
||||
err := mapstructure.Decode(casted, &response)
|
||||
return response.Roles, err
|
||||
}
|
||||
|
||||
type commonResult struct {
|
||||
gophercloud.Result
|
||||
}
|
||||
|
||||
// Extract interprets any commonResult as a User, if possible.
|
||||
func (r commonResult) Extract() (*User, error) {
|
||||
if r.Err != nil {
|
||||
return nil, r.Err
|
||||
}
|
||||
|
||||
var response struct {
|
||||
User User `mapstructure:"user"`
|
||||
}
|
||||
|
||||
err := mapstructure.Decode(r.Body, &response)
|
||||
|
||||
return &response.User, err
|
||||
}
|
||||
|
||||
// CreateResult represents the result of a Create operation
|
||||
type CreateResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// GetResult represents the result of a Get operation
|
||||
type GetResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// UpdateResult represents the result of an Update operation
|
||||
type UpdateResult struct {
|
||||
commonResult
|
||||
}
|
||||
|
||||
// DeleteResult represents the result of a Delete operation
|
||||
type DeleteResult struct {
|
||||
commonResult
|
||||
}
|
21
vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/urls.go
generated
vendored
21
vendor/github.com/rackspace/gophercloud/openstack/identity/v2/users/urls.go
generated
vendored
@@ -1,21 +0,0 @@
|
||||
package users
|
||||
|
||||
import "github.com/rackspace/gophercloud"
|
||||
|
||||
const (
|
||||
tenantPath = "tenants"
|
||||
userPath = "users"
|
||||
rolePath = "roles"
|
||||
)
|
||||
|
||||
func ResourceURL(c *gophercloud.ServiceClient, id string) string {
|
||||
return c.ServiceURL(userPath, id)
|
||||
}
|
||||
|
||||
func rootURL(c *gophercloud.ServiceClient) string {
|
||||
return c.ServiceURL(userPath)
|
||||
}
|
||||
|
||||
func listRolesURL(c *gophercloud.ServiceClient, tenantID, userID string) string {
|
||||
return c.ServiceURL(tenantPath, tenantID, userPath, userID, rolePath)
|
||||
}
|
Reference in New Issue
Block a user