resourceids

package
v0.67.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MPL-2.0 Imports: 5 Imported by: 10,761

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Id

type Id interface {
	// ID returns the fully formatted ID for this Resource ID
	ID() string

	// String returns a friendly description of the components of this Resource ID
	// which is suitable for use in error messages (for example 'MyThing %q / Resource Group %q')
	String() string
}

Id defines a type for a ResourceId of some kind

type NumberOfSegmentsDidntMatchError added in v0.56.0

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

func NewNumberOfSegmentsDidntMatchError added in v0.56.0

func NewNumberOfSegmentsDidntMatchError(id ResourceId, parseResult ParseResult) NumberOfSegmentsDidntMatchError

func (NumberOfSegmentsDidntMatchError) Error added in v0.56.0

Error returns a detailed error message highlighting the issues found when parsing this Resource ID Segment.

type ParseResult added in v0.17.0

type ParseResult struct {
	// Parsed is a map of segmentName : segmentValue
	Parsed map[string]string

	// RawInput is the raw value that's been parsed to obtain Parsed
	RawInput string
}

func (ParseResult) SegmentNamed added in v0.56.0

func (p ParseResult) SegmentNamed(key string, insensitively bool) (*string, bool)

SegmentNamed returns the specified Resource ID segment by its name, if it exists

type Parser added in v0.17.0

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

func NewParserFromResourceIdType added in v0.17.0

func NewParserFromResourceIdType(id ResourceId) Parser

NewParserFromResourceIdType takes a ResourceId interface and uses its (ordered) Segments to create a Parser which can be used to Parse Resource ID's.

func (Parser) Parse added in v0.17.0

func (p Parser) Parse(input string, insensitively bool) (*ParseResult, error)

Parse processes a Resource ID and parses it into a ParseResult containing a map of the Known Segments for this Resource ID which callers of this method can then process to form a Resource ID struct of those values doing any type conversions as necessary (for

example, type-casting/converting Constants).

`input`: the Resource ID to be parsed, which should match the segments for this Resource ID `insensitively`: should this Resource ID be parsed case-insensitively and fix up any Constant,

Resource Provider and Static Segments to the expected casing.

type ResourceID

type ResourceID struct {
	SubscriptionID    string
	ResourceGroup     string
	Provider          string
	SecondaryProvider string
	Path              map[string]string
}

ResourceID represents a parsed long-form Azure Resource Manager ID with the Subscription ID, Resource Group and the Provider as top- level fields, and other key-value pairs available via a map in the Path field.

func ParseAzureResourceID

func ParseAzureResourceID(id string) (*ResourceID, error)

ParseAzureResourceID converts a long-form Azure Resource Manager ID into a ResourceID.

func (*ResourceID) PopSegment

func (id *ResourceID) PopSegment(name string) (string, error)

PopSegment retrieves a segment from the Path and returns it if found it removes it from the Path then return the value if not found, this returns nil

func (*ResourceID) ValidateNoEmptySegments

func (id *ResourceID) ValidateNoEmptySegments(sourceId string) error

ValidateNoEmptySegments validates ...

type ResourceId added in v0.17.0

type ResourceId interface {

	// FromParseResult populates the Resource ID using the ParseResult provided in `input`
	FromParseResult(input ParseResult) error

	// ID returns the fully formatted ID for this Resource ID
	ID() string

	// String returns a friendly description of the components of this Resource ID
	// which is suitable for use in error messages (for example 'MyThing %q / Resource Group %q')
	String() string

	// Segments returns an ordered list of expected Segments that make up this Resource ID
	Segments() []Segment
}

type Segment added in v0.17.0

type Segment struct {
	// ExampleValue is an example of a value for this field, which is intended only to
	// be used as a placeholder.
	ExampleValue string

	// FixedValue is the Fixed/Static value for this segment - only present when `Type`
	// is `ResourceProviderSegmentType` or `StaticSegmentType`.
	FixedValue *string

	// Name is the camelCased name of this segment, which is normalized (and safe to use as a
	// parameter/a field if necessary).
	Name string

	// PossibleValues is a list of possible values for this segment - only present when
	// `Type` is `ConstantSegmentType`
	PossibleValues *[]string

	// Type specifies the Type of Segment that this is, for example a `StaticSegmentType`
	Type SegmentType
}

func ConstantSegment added in v0.17.0

func ConstantSegment(name string, possibleValues []string, exampleValue string) Segment

ConstantSegment is a helper which returns a Segment for a Constant

func ResourceGroupSegment added in v0.17.0

func ResourceGroupSegment(name, exampleValue string) Segment

ResourceGroupSegment is a helper which returns a Segment for a Resource Group

func ResourceProviderSegment added in v0.17.0

func ResourceProviderSegment(name, resourceProvider, exampleValue string) Segment

ResourceProviderSegment is a helper which returns a Segment for a Resource Provider

func ScopeSegment added in v0.17.0

func ScopeSegment(name, exampleValue string) Segment

ScopeSegment is a helper which returns a Segment for a Scope

func StaticSegment added in v0.17.0

func StaticSegment(name, staticValue, exampleValue string) Segment

StaticSegment is a helper which returns a Segment for a Static Value

func SubscriptionIdSegment added in v0.17.0

func SubscriptionIdSegment(name, exampleValue string) Segment

SubscriptionIdSegment is a helper which returns a Segment for a Subscription Id

func UserSpecifiedSegment added in v0.17.0

func UserSpecifiedSegment(name, exampleValue string) Segment

UserSpecifiedSegment is a helper which returns a Segment for a User Specified Segment

type SegmentNotSpecifiedError added in v0.56.0

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

func NewSegmentNotSpecifiedError added in v0.56.0

func NewSegmentNotSpecifiedError(id ResourceId, segmentName string, parseResult ParseResult) SegmentNotSpecifiedError

NewSegmentNotSpecifiedError returns a SegmentNotSpecifiedError for the provided Resource ID, segment and parseResult combination

func (SegmentNotSpecifiedError) Error added in v0.56.0

func (e SegmentNotSpecifiedError) Error() string

Error returns a detailed error message highlighting the issues found when parsing this Resource ID Segment.

type SegmentType added in v0.17.0

type SegmentType string
const (
	// ConstantSegmentType specifies that this Segment is a Constant
	ConstantSegmentType SegmentType = "Constant"

	// ResourceGroupSegmentType specifies that this Segment is a Resource Group name
	ResourceGroupSegmentType SegmentType = "ResourceGroup"

	// ResourceProviderSegmentType specifies that this Segment is a Resource Provider
	ResourceProviderSegmentType SegmentType = "ResourceProvider"

	// ScopeSegmentType specifies that this Segment is a Scope
	ScopeSegmentType SegmentType = "Scope"

	// StaticSegmentType specifies that this Segment is a Static/Fixed Value
	StaticSegmentType SegmentType = "Static"

	// SubscriptionIdSegmentType specifies that this Segment is a Subscription ID
	SubscriptionIdSegmentType SegmentType = "SubscriptionId"

	// UserSpecifiedSegmentType specifies that this Segment is User-Specifiable
	UserSpecifiedSegmentType SegmentType = "UserSpecified"
)

Jump to

Keyboard shortcuts

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