Help us shape the future of Go! Take the 2026 Go Developer Survey

addressscopes

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package addressscopes provides the ability to retrieve and manage Address scopes through the Neutron API.

Example of Listing Address scopes

listOpts := addressscopes.ListOpts{
    IPVersion: 6,
}

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

allAddressScopes, err := addressscopes.ExtractAddressScopes(allPages)
if err != nil {
    panic(err)
}

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

Example to Get an Address scope

addressScopeID = "9cc35860-522a-4d35-974d-51d4b011801e"
addressScope, err := addressscopes.Get(networkClient, addressScopeID).Extract()
if err != nil {
    panic(err)
}

Example to Create a new Address scope

addressScopeOpts := addressscopes.CreateOpts{
    Name: "my_address_scope",
    IPVersion: 6,
}
addressScope, err := addressscopes.Create(networkClient, addressScopeOpts).Extract()
if err != nil {
    panic(err)
}

Example to Update an Address scope

addressScopeID = "9cc35860-522a-4d35-974d-51d4b011801e"
newName := "awesome_name"
updateOpts := addressscopes.UpdateOpts{
    Name: &newName,
}

addressScope, err := addressscopes.Update(networkClient, addressScopeID, updateOpts).Extract()
if err != nil {
    panic(err)
}

Example to Delete an Address scope

addressScopeID = "9cc35860-522a-4d35-974d-51d4b011801e"
err := addressscopes.Delete(networkClient, addressScopeID).ExtractErr()
if err != nil {
    panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

List returns a Pager which allows you to iterate over a collection of address-scopes. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.

Default policy settings return only the address-scopes owned by the project of the user submitting the request, unless the user has the administrative role.

Types

type AddressScope

type AddressScope struct {
	// ID is the id of the address-scope.
	ID string `json:"id"`

	// Name is the human-readable name of the address-scope.
	Name string `json:"name"`

	// TenantID is the id of the Identity project.
	TenantID string `json:"tenant_id"`

	// ProjectID is the id of the Identity project.
	ProjectID string `json:"project_id"`

	// IPVersion is the IP protocol version.
	IPVersion int `json:"ip_version"`

	// Shared indicates whether this address-scope is shared across all projects.
	Shared bool `json:"shared"`
}

AddressScope represents a Neutron address-scope.

func ExtractAddressScopes

func ExtractAddressScopes(r pagination.Page) ([]AddressScope, error)

ExtractAddressScopes interprets the results of a single page from a List() API call, producing a slice of AddressScopes structs.

type AddressScopePage

type AddressScopePage struct {
	pagination.LinkedPageBase
}

AddressScopePage stores a single page of AddressScopes from a List() API call.

func (AddressScopePage) IsEmpty

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

IsEmpty determines whether or not a AddressScopePage is empty.

func (AddressScopePage) NextPageURL

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

NextPageURL is invoked when a paginated collection of address-scope has reached the end of a page and the pager seeks to traverse over a new one. In order to do this, it needs to construct the next page's URL.

type CreateOpts

type CreateOpts struct {
	// Name is the human-readable name of the address-scope.
	Name string `json:"name"`

	// TenantID is the id of the Identity project.
	TenantID string `json:"tenant_id,omitempty"`

	// ProjectID is the id of the Identity project.
	ProjectID string `json:"project_id,omitempty"`

	// IPVersion is the IP protocol version.
	IPVersion int `json:"ip_version"`

	// Shared indicates whether this address-scope is shared across all projects.
	Shared bool `json:"shared,omitempty"`
}

CreateOpts specifies parameters of a new address-scope.

func (CreateOpts) ToAddressScopeCreateMap

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

ToAddressScopeCreateMap constructs a request body from CreateOpts.

type CreateOptsBuilder

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

CreateOptsBuilder allows to add additional parameters to the Create request.

type CreateResult

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

CreateResult represents the result of a create operation. Call its Extract method to interpret it as a SubnetPool.

func Create

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

Create requests the creation of a new address-scope on the server.

func (CreateResult) Extract

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

Extract is a function that accepts a result and extracts an address-scope resource.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult represents the result of a delete operation. Call its ExtractErr method to determine if the request succeeded or failed.

func Delete

func Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult)

Delete accepts a unique ID and deletes the address-scope associated with it.

type GetResult

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

GetResult represents the result of a get operation. Call its Extract method to interpret it as a SubnetPool.

func Get

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

Get retrieves a specific address-scope based on its ID.

func (GetResult) Extract

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

Extract is a function that accepts a result and extracts an address-scope resource.

type ListOpts

type ListOpts struct {
	ID          string `q:"id"`
	Name        string `q:"name"`
	TenantID    string `q:"tenant_id"`
	ProjectID   string `q:"project_id"`
	IPVersion   int    `q:"ip_version"`
	Shared      *bool  `q:"shared"`
	Description string `q:"description"`
	Limit       int    `q:"limit"`
	Marker      string `q:"marker"`
	SortKey     string `q:"sort_key"`
	SortDir     string `q:"sort_dir"`
}

ListOpts allows the filtering and sorting of paginated collections through the Neutron API. Filtering is achieved by passing in struct field values that map to the address-scope attributes you want to see returned. SortKey allows you to sort by a particular address-scope attribute. SortDir sets the direction, and is either `asc' or `desc'. Marker and Limit are used for the pagination.

func (ListOpts) ToAddressScopeListQuery

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

ToAddressScopeListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

ListOptsBuilder allows extensions to add additional parameters to the List request.

type UpdateOpts

type UpdateOpts struct {
	// Name is the human-readable name of the address-scope.
	Name *string `json:"name,omitempty"`

	// Shared indicates whether this address-scope is shared across all projects.
	Shared *bool `json:"shared,omitempty"`
}

UpdateOpts represents options used to update an address-scope.

func (UpdateOpts) ToAddressScopeUpdateMap

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

ToAddressScopeUpdateMap builds a request body from UpdateOpts.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToAddressScopeUpdateMap() (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 represents the result of an update operation. Call its Extract method to interpret it as an AddressScope.

func Update

func Update(c *gophercloud.ServiceClient, addressScopeID string, opts UpdateOptsBuilder) (r UpdateResult)

Update accepts a UpdateOpts struct and updates an existing address-scope using the values provided.

func (UpdateResult) Extract

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

Extract is a function that accepts a result and extracts an address-scope resource.

Directories

Path Synopsis
subnetpools unit tests
subnetpools unit tests

Jump to

Keyboard shortcuts

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