groups

package
v1.0.22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package groups manages and retrieves Groups in the OpenStack Identity Service.

Example to List Groups

listOpts := groups.ListOpts{
	DomainID: "default",
}

allPages, err := groups.List(identityClient, listOpts).AllPages()
if err != nil {
	panic(err)
}

allGroups, err := groups.ExtractGroups(allPages)
if err != nil {
	panic(err)
}

for _, group := range allGroups {
	fmt.Printf("%+v\n", group)
}

Example to Create a Group

createOpts := groups.CreateOpts{
	Name:             "groupname",
	DomainID:         "default",
	Extra: map[string]interface{}{
		"email": "groupname@example.com",
	}
}

group, err := groups.Create(identityClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to Update a Group

groupID := "0fe36e73809d46aeae6705c39077b1b3"

updateOpts := groups.UpdateOpts{
	Description: "Updated Description for group",
}

group, err := groups.Update(identityClient, groupID, updateOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a Group

groupID := "0fe36e73809d46aeae6705c39077b1b3"
err := groups.Delete(identityClient, groupID).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

List enumerates the Groups to which the current token has access.

Types

type CreateOpts

type CreateOpts struct {
	// Name is the name of the new group.
	Name string `json:"name" required:"true"`

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

	// DomainID is the ID of the domain the group belongs to.
	DomainID string `json:"domain_id,omitempty"`

	// Extra is free-form extra key/value pairs to describe the group.
	Extra map[string]interface{} `json:"-"`
}

CreateOpts provides options used to create a group.

func (CreateOpts) ToGroupCreateMap

func (opts CreateOpts) ToGroupCreateMap() (map[string]interface{}, error)

ToGroupCreateMap formats a CreateOpts into a create request.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToGroupCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder allows extensions to add additional parameters to the Create request.

type CreateResult

type CreateResult struct {
	// contains filtered or unexported fields
}

CreateResult is the response from a Create operation. Call its Extract method to interpret it as a Group.

func Create

func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)

Create creates a new Group.

func (CreateResult) Extract

func (r CreateResult) Extract() (*Group, error)

Extract interprets any group results as a Group.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult is the response from a Delete operation. Call its ExtractErr to determine if the request succeeded or failed.

func Delete

func Delete(client *gophercloud.ServiceClient, groupID string) (r DeleteResult)

Delete deletes a group.

type GetResult

type GetResult struct {
	// contains filtered or unexported fields
}

GetResult is the response from a Get operation. Call its Extract method to interpret it as a Group.

func Get

func Get(client *gophercloud.ServiceClient, id string) (r GetResult)

Get retrieves details on a single group, by ID.

func (GetResult) Extract

func (r GetResult) Extract() (*Group, error)

Extract interprets any group results as a Group.

type Group

type Group struct {
	// Description describes the group purpose.
	Description string `json:"description"`

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

	// ID is the unique ID of the group.
	ID string `json:"id"`

	// Extra is a collection of miscellaneous key/values.
	Extra map[string]interface{} `json:"-"`

	// Links contains referencing links to the group.
	Links map[string]interface{} `json:"links"`

	// Name is the name of the group.
	Name string `json:"name"`
}

Group helps manage related users.

func ExtractGroups

func ExtractGroups(r pagination.Page) ([]Group, error)

ExtractGroups returns a slice of Groups contained in a single page of results.

func (*Group) UnmarshalJSON

func (r *Group) UnmarshalJSON(b []byte) error

type GroupPage

type GroupPage struct {
	pagination.LinkedPageBase
}

GroupPage is a single page of Group results.

func (GroupPage) IsEmpty

func (r GroupPage) IsEmpty() (bool, error)

IsEmpty determines whether or not a page of Groups contains any results.

func (GroupPage) NextPageURL

func (r GroupPage) NextPageURL() (string, error)

NextPageURL extracts the "next" link from the links section of the result.

type ListOpts

type ListOpts struct {
	// DomainID filters the response by a domain ID.
	DomainID string `q:"domain_id"`

	// Name filters the response by group name.
	Name string `q:"name"`
}

ListOpts provides options to filter the List results.

func (ListOpts) ToGroupListQuery

func (opts ListOpts) ToGroupListQuery() (string, error)

ToGroupListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToGroupListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request

type UpdateOpts

type UpdateOpts struct {
	// Name is the name of the new group.
	Name string `json:"name,omitempty"`

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

	// DomainID is the ID of the domain the group belongs to.
	DomainID string `json:"domain_id,omitempty"`

	// Extra is free-form extra key/value pairs to describe the group.
	Extra map[string]interface{} `json:"-"`
}

UpdateOpts provides options for updating a group.

func (UpdateOpts) ToGroupUpdateMap

func (opts UpdateOpts) ToGroupUpdateMap() (map[string]interface{}, error)

ToGroupUpdateMap formats a UpdateOpts into an update request.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToGroupUpdateMap() (map[string]interface{}, error)
}

UpdateOptsBuilder allows extensions to add additional parameters to the Update request.

type UpdateResult

type UpdateResult struct {
	// contains filtered or unexported fields
}

UpdateResult is the response from an Update operation. Call its Extract method to interpret it as a Group.

func Update

func Update(client *gophercloud.ServiceClient, groupID string, opts UpdateOptsBuilder) (r UpdateResult)

Update updates an existing Group.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Group, error)

Extract interprets any group results as a Group.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL