stackresources

package
v0.0.0-...-5458e1c Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0, Apache-2.0 Imports: 4 Imported by: 2

Documentation

Overview

Package stackresources provides operations for working with stack resources. A resource is a template artifact that represents some component of your desired architecture (a Cloud Server, a group of scaled Cloud Servers, a load balancer, some configuration management system, and so forth).

Example of get resource information in stack

rsrc_result := stackresources.Get(client, stack.Name, stack.ID, rsrc.Name)
if rsrc_result.Err != nil {
    panic(rsrc_result.Err)
}
rsrc, err := rsrc_result.Extract()
if err != nil {
    panic(err)
}

Example for list stack resources

all_stack_rsrc_pages, err := stackresources.List(client, stack.Name, stack.ID, nil).AllPages()
if err != nil {
    panic(err)
}

all_stack_rsrcs, err := stackresources.ExtractResources(all_stack_rsrc_pages)
if err != nil {
    panic(err)
}

fmt.Println("Resource List:")
for _, rsrc := range all_stack_rsrcs {
    // Get information of a resource in stack
    rsrc_result := stackresources.Get(client, stack.Name, stack.ID, rsrc.Name)
    if rsrc_result.Err != nil {
        panic(rsrc_result.Err)
    }
    rsrc, err := rsrc_result.Extract()
    if err != nil {
        panic(err)
    }
    fmt.Println("Resource Name: ", rsrc.Name, ", Physical ID: ", rsrc.PhysicalID, ", Status: ", rsrc.Status)
}

Example for get resource type schema

schema_result := stackresources.Schema(client, "OS::Heat::Stack")
if schema_result.Err != nil {
    panic(schema_result.Err)
}
schema, err := schema_result.Extract()
if err != nil {
    panic(err)
}
fmt.Println("Schema for resource type OS::Heat::Stack")
fmt.Println(schema.SupportStatus)

Example for get resource type Template

tmp_result := stackresources.Template(client, "OS::Heat::Stack")
if tmp_result.Err != nil {
    panic(tmp_result.Err)
}
tmp, err := tmp_result.Extract()
if err != nil {
    panic(err)
}
fmt.Println("Template for resource type OS::Heat::Stack")
fmt.Println(string(tmp))

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List(client *gophercloud.ServiceClient, stackName, stackID string, opts ListOptsBuilder) pagination.Pager

List makes a request against the API to list resources for the given stack.

func ListTypes

func ListTypes(client *gophercloud.ServiceClient) pagination.Pager

ListTypes makes a request against the API to list resource types.

Types

type FindResult

type FindResult struct {
	gophercloud.Result
}

FindResult represents the result of a Find operation.

func Find

func Find(c *gophercloud.ServiceClient, stackName string) (r FindResult)

Find retrieves stack resources for the given stack name.

func (FindResult) Extract

func (r FindResult) Extract() ([]Resource, error)

Extract returns a slice of Resource objects and is called after a Find operation.

type GetResult

type GetResult struct {
	gophercloud.Result
}

GetResult represents the result of a Get operation.

func Get

func Get(c *gophercloud.ServiceClient, stackName, stackID, resourceName string) (r GetResult)

Get retreives data for the given stack resource.

func (GetResult) Extract

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

Extract returns a pointer to a Resource object and is called after a Get operation.

type ListOpts

type ListOpts struct {
	// Include resources from nest stacks up to Depth levels of recursion.
	Depth int `q:"nested_depth"`
}

ListOpts allows the filtering and sorting of paginated collections through the API. Marker and Limit are used for pagination.

func (ListOpts) ToStackResourceListQuery

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

ToStackResourceListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

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

type MarkUnhealthyOpts

type MarkUnhealthyOpts struct {
	// A boolean indicating whether the target resource should be marked as unhealthy.
	MarkUnhealthy bool `json:"mark_unhealthy"`
	// The reason for the current stack resource state.
	ResourceStatusReason string `json:"resource_status_reason,omitempty"`
}

MarkUnhealthyOpts contains the common options struct used in this package's MarkUnhealthy operations.

func (MarkUnhealthyOpts) ToMarkUnhealthyMap

func (opts MarkUnhealthyOpts) ToMarkUnhealthyMap() (map[string]interface{}, error)

ToMarkUnhealthyMap validates that a template was supplied and calls the ToMarkUnhealthyMap private function.

type MarkUnhealthyOptsBuilder

type MarkUnhealthyOptsBuilder interface {
	ToMarkUnhealthyMap() (map[string]interface{}, error)
}

MarkUnhealthyOptsBuilder is the interface options structs have to satisfy in order to be used in the MarkUnhealthy operation in this package

type MarkUnhealthyResult

type MarkUnhealthyResult struct {
	gophercloud.ErrResult
}

MarkUnhealthyResult represents the result of a mark unhealthy operation.

func MarkUnhealthy

func MarkUnhealthy(c *gophercloud.ServiceClient, stackName, stackID, resourceName string, opts MarkUnhealthyOptsBuilder) (r MarkUnhealthyResult)

MarkUnhealthy marks the specified resource in the stack as unhealthy.

type MetadataResult

type MetadataResult struct {
	gophercloud.Result
}

MetadataResult represents the result of a Metadata operation.

func Metadata

func Metadata(c *gophercloud.ServiceClient, stackName, stackID, resourceName string) (r MetadataResult)

Metadata retreives the metadata for the given stack resource.

func (MetadataResult) Extract

func (r MetadataResult) Extract() (map[string]string, error)

Extract returns a map object and is called after a Metadata operation.

type Resource

type Resource struct {
	Attributes     map[string]interface{} `json:"attributes"`
	CreationTime   time.Time              `json:"-"`
	Description    string                 `json:"description"`
	Links          []gophercloud.Link     `json:"links"`
	LogicalID      string                 `json:"logical_resource_id"`
	Name           string                 `json:"resource_name"`
	ParentResource string                 `json:"parent_resource"`
	PhysicalID     string                 `json:"physical_resource_id"`
	RequiredBy     []interface{}          `json:"required_by"`
	Status         string                 `json:"resource_status"`
	StatusReason   string                 `json:"resource_status_reason"`
	Type           string                 `json:"resource_type"`
	UpdatedTime    time.Time              `json:"-"`
}

Resource represents a stack resource.

func ExtractResources

func ExtractResources(r pagination.Page) ([]Resource, error)

ExtractResources interprets the results of a single page from a List() call, producing a slice of Resource entities.

func (*Resource) UnmarshalJSON

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

type ResourcePage

type ResourcePage struct {
	pagination.SinglePageBase
}

ResourcePage abstracts the raw results of making a List() request against the API. As OpenStack extensions may freely alter the response bodies of structures returned to the client, you may only safely access the data provided through the ExtractResources call.

func (ResourcePage) IsEmpty

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

IsEmpty returns true if a page contains no Server results.

type ResourceTypePage

type ResourceTypePage struct {
	pagination.SinglePageBase
}

ResourceTypePage abstracts the raw results of making a ListTypes() request against the API. As OpenStack extensions may freely alter the response bodies of structures returned to the client, you may only safely access the data provided through the ExtractResourceTypes call.

func (ResourceTypePage) IsEmpty

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

IsEmpty returns true if a ResourceTypePage contains no resource types.

type ResourceTypes

type ResourceTypes []string

ResourceTypes represents the type that holds the result of ExtractResourceTypes. We define methods on this type to sort it before output

func ExtractResourceTypes

func ExtractResourceTypes(r pagination.Page) (ResourceTypes, error)

ExtractResourceTypes extracts and returns resource types.

func (ResourceTypes) Len

func (r ResourceTypes) Len() int

func (ResourceTypes) Less

func (r ResourceTypes) Less(i, j int) bool

func (ResourceTypes) Swap

func (r ResourceTypes) Swap(i, j int)

type SchemaResult

type SchemaResult struct {
	gophercloud.Result
}

SchemaResult represents the result of a Schema operation.

func Schema

func Schema(c *gophercloud.ServiceClient, resourceType string) (r SchemaResult)

Schema retreives the schema for the given resource type.

func (SchemaResult) Extract

func (r SchemaResult) Extract() (*TypeSchema, error)

Extract returns a pointer to a TypeSchema object and is called after a Schema operation.

type TemplateResult

type TemplateResult struct {
	gophercloud.Result
}

TemplateResult represents the result of a Template operation.

func Template

func Template(c *gophercloud.ServiceClient, resourceType string) (r TemplateResult)

Template retreives the template representation for the given resource type.

func (TemplateResult) Extract

func (r TemplateResult) Extract() ([]byte, error)

Extract returns the template and is called after a Template operation.

type TypeSchema

type TypeSchema struct {
	Attributes    map[string]interface{} `json:"attributes"`
	Properties    map[string]interface{} `json:"properties"`
	ResourceType  string                 `json:"resource_type"`
	SupportStatus map[string]interface{} `json:"support_status"`
}

TypeSchema represents a stack resource schema.

Jump to

Keyboard shortcuts

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