resource

package
v0.94.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MPL-2.0 Imports: 6 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Resource

type Resource struct {
	// ID uniquely identifies a resource within an HCP project
	ID string
	// Type is the name of the kind of resource identified
	Type string
	// Organization is the UUID of the HCP organization the resource belongs to
	Organization string
	// Project is the UUID of the HCP project the resource belongs to
	Project string
}

Resource is a representation of a HCP resource identifier

func FromLink(l *models.HashicorpCloudLocationLink) (r Resource, err error)

FromLink converts a models.HashicorpCloudLocationLink to a Resource.

func FromString

func FromString(str string) (r Resource, err error)

FromString parses the string encoding of a resource identifier.

func Must

func Must(r Resource, err error) Resource

Must is a helper function that wraps a call to a function returning (Resource, error) such as FromLink or FromString and panics if the error is non-nil. It is intended for use in variable initializations such as

var packageResource = resource.Must(resource.FromString("..."))

Link returns a *models.HashicorpCloudLocationLink initialized with values from the Resource

func (Resource) Location

Location returns a *models.HashicorpCloudLocationLocation initialized with the Resource's organization and project IDs.

func (*Resource) MarshalJSON

func (r *Resource) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*Resource) MarshalText

func (r *Resource) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface. The encoding is the same as returned by String.

func (Resource) String

func (r Resource) String() string

String encodes the resource identifier in the following canonical format:

"organization/<Organization UUID>/project/<Project UUID>/<Type>/<ID>"

Example:

"organization/ccbdd191-5dc3-4a73-9e05-6ac30ca67992/project/36019e0d-ed59-4df6-9990-05bb7fc793b6/hashicorp.consul.linked-cluster/prod-on-prem"

func (*Resource) UnmarshalJSON

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

UnmarshalJSON implements the json.Unmarshaler interface

func (*Resource) UnmarshalText

func (r *Resource) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface and parses an encoded Resource.

Jump to

Keyboard shortcuts

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