regions

package
v0.0.0-...-8e7030c Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package regions manages and retrieves Regions in the OpenStack Identity Service.

Example to List Regions

listOpts := regions.ListOpts{
	ParentRegionID: "RegionOne",
}

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

allRegions, err := regions.ExtractRegions(allPages)
if err != nil {
	panic(err)
}

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

Example to Create a Region

createOpts := regions.CreateOpts{
	ID:             "TestRegion",
	Description: "Region for testing"
	Extra: map[string]interface{}{
		"email": "testregionsupport@example.com",
	}
}

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

Example to Update a Region

regionID := "TestRegion"

// There is currently a bug in Keystone where updating the optional Extras
// attributes set in regions.Create is not supported, see:
// https://bugs.launchpad.net/keystone/+bug/1729933
updateOpts := regions.UpdateOpts{
	Description: "Updated Description for region",
}

region, err := regions.Update(identityClient, regionID, updateOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a Region

regionID := "TestRegion"
err := regions.Delete(identityClient, regionID).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

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

Types

type CreateOpts

type CreateOpts struct {
	// ID is the ID of the new region.
	ID string `json:"id,omitempty"`

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

	// ParentRegionID is the ID of the parent the region to add this region under.
	ParentRegionID string `json:"parent_region_id,omitempty"`

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

CreateOpts provides options used to create a region.

func (CreateOpts) ToRegionCreateMap

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

ToRegionCreateMap formats a CreateOpts into a create request.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToRegionCreateMap() (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 Region.

func Create

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

Create creates a new Region.

func (CreateResult) Extract

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

Extract interprets any region results as a Region.

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, regionID string) (r DeleteResult)

Delete deletes a region.

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 Region.

func Get

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

Get retrieves details on a single region, by ID.

func (GetResult) Extract

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

Extract interprets any region results as a Region.

type ListOpts

type ListOpts struct {
	// ParentRegionID filters the response by a parent region ID.
	ParentRegionID string `q:"parent_region_id"`
}

ListOpts provides options to filter the List results.

func (ListOpts) ToRegionListQuery

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

ToRegionListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

ListOptsBuilder allows extensions to add additional parameters to the List request

type Region

type Region struct {
	// Description describes the region purpose.
	Description string `json:"description"`

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

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

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

	// ParentRegionID is the ID of the parent region.
	ParentRegionID string `json:"parent_region_id"`
}

Region helps manage related users.

func ExtractRegions

func ExtractRegions(r pagination.Page) ([]Region, error)

ExtractRegions returns a slice of Regions contained in a single page of results.

func (*Region) UnmarshalJSON

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

type RegionPage

type RegionPage struct {
	pagination.LinkedPageBase
}

RegionPage is a single page of Region results.

func (RegionPage) IsEmpty

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

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

func (RegionPage) NextPageURL

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

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

type UpdateOpts

type UpdateOpts struct {
	// Description is a description of the region.
	Description string `json:"description,omitempty"`

	// ParentRegionID is the ID of the parent region.
	ParentRegionID string `json:"parent_region_id,omitempty"`
}

UpdateOpts provides options for updating a region.

func (UpdateOpts) ToRegionUpdateMap

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

ToRegionUpdateMap formats a UpdateOpts into an update request.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToRegionUpdateMap() (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 Region.

func Update

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

Update updates an existing Region.

func (UpdateResult) Extract

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

Extract interprets any region results as a Region.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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