Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions openstack/identity/v3/catalog/requests.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package catalog

import (
"github.com/huaweicloud/golangsdk"
"github.com/huaweicloud/golangsdk/pagination"
)

// List enumerates the services available to a specific user.
func List(client *golangsdk.ServiceClient) pagination.Pager {
url := listURL(client)
return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page {
return CatalogPage{pagination.LinkedPageBase{PageResult: r}}
})
}
42 changes: 42 additions & 0 deletions openstack/identity/v3/catalog/results.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package catalog

import (
"github.com/huaweicloud/golangsdk/openstack/identity/v3/tokens"
"github.com/huaweicloud/golangsdk/pagination"
)

// CatalogPage is a single page of Service results.
type CatalogPage struct {
pagination.LinkedPageBase
}

// IsEmpty returns true if the CatalogPage contains no results.
func (p CatalogPage) IsEmpty() (bool, error) {
services, err := ExtractServiceCatalog(p)
return len(services) == 0, err
}

// NextPageURL extracts the "next" link from the links section of the result.
func (r CatalogPage) NextPageURL() (string, error) {
var s struct {
Links struct {
Next string `json:"next"`
Previous string `json:"previous"`
} `json:"links"`
}
err := r.ExtractInto(&s)
if err != nil {
return "", err
}
return s.Links.Next, err
}

// ExtractServiceCatalog extracts a slice of Catalog from a Collection acquired
// from List.
func ExtractServiceCatalog(r pagination.Page) ([]tokens.CatalogEntry, error) {
var s struct {
Entries []tokens.CatalogEntry `json:"catalog"`
}
err := (r.(CatalogPage)).ExtractInto(&s)
return s.Entries, err
}
7 changes: 7 additions & 0 deletions openstack/identity/v3/catalog/urls.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package catalog

import "github.com/huaweicloud/golangsdk"

func listURL(client *golangsdk.ServiceClient) string {
return client.ServiceURL("auth/catalog")
}
6 changes: 6 additions & 0 deletions openstack/identity/v3/users/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ type CreateOpts struct {

// Password is the password of the new user.
Password string `json:"password,omitempty"`

// Description is a description of the user.
Description string `json:"description,omitempty"`
}

// ToUserCreateMap formats a CreateOpts into a create request.
Expand Down Expand Up @@ -133,6 +136,9 @@ type UpdateOpts struct {

// Password is the password of the new user.
Password string `json:"password,omitempty"`

// Description is a description of the user.
Description string `json:"description,omitempty"`
}

// ToUserUpdateMap formats a UpdateOpts into an update request.
Expand Down
3 changes: 3 additions & 0 deletions openstack/identity/v3/users/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ type User struct {
// DefaultProjectID is the ID of the default project of the user.
DefaultProjectID string `json:"default_project_id"`

// Description is a description of the user.
Description string `json:"description"`

// DomainID is the domain ID the user belongs to.
DomainID string `json:"domain_id"`

Expand Down