entity

package
v0.0.0-...-22ca86b Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: AGPL-3.0, Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthGroupURL

func AuthGroupURL(groupName string) *api.URL

AuthGroupURL returns an *api.URL to a group.

func CertificateURL

func CertificateURL(fingerprint string) *api.URL

CertificateURL returns an *api.URL to a certificate.

func IdentityProviderGroupURL

func IdentityProviderGroupURL(identityProviderGroupName string) *api.URL

IdentityProviderGroupURL returns an *api.URL to an identity provider group.

func IdentityURL

func IdentityURL(authenticationMethod string, identifier string) *api.URL

IdentityURL returns an *api.URL to an identity.

func ImageAliasURL

func ImageAliasURL(projectName string, imageAliasName string) *api.URL

ImageAliasURL returns an *api.URL to an image alias.

func ImageURL

func ImageURL(projectName string, imageName string) *api.URL

ImageURL returns an *api.URL to an image.

func InstanceBackupURL

func InstanceBackupURL(projectName string, instanceName string, backupName string) *api.URL

InstanceBackupURL returns an *api.URL to an instance backup.

func InstanceSnapshotURL

func InstanceSnapshotURL(projectName string, instanceName string, snapshotName string) *api.URL

InstanceSnapshotURL returns an *api.URL to an instance snapshot.

func InstanceURL

func InstanceURL(projectName string, instanceName string) *api.URL

InstanceURL returns an *api.URL to an instance.

func NetworkACLURL

func NetworkACLURL(projectName string, networkACLName string) *api.URL

NetworkACLURL returns an *api.URL to a network ACL.

func NetworkURL

func NetworkURL(projectName string, networkName string) *api.URL

NetworkURL returns an *api.URL to a network.

func NetworkZoneURL

func NetworkZoneURL(projectName string, networkZoneName string) *api.URL

NetworkZoneURL returns an *api.URL to a network zone.

func PlacementGroupURL

func PlacementGroupURL(projectName string, placementGroupName string) *api.URL

PlacementGroupURL returns an *api.URL to a placement group.

func ProfileURL

func ProfileURL(projectName string, profileName string) *api.URL

ProfileURL returns an *api.URL to a profile.

func ProjectURL

func ProjectURL(projectName string) *api.URL

ProjectURL returns an *api.URL to a Project.

func ServerURL

func ServerURL() *api.URL

ServerURL returns an *api.URL to the server.

func StorageBucketURL

func StorageBucketURL(projectName string, location string, storagePoolName string, storageBucketName string) *api.URL

StorageBucketURL returns an *api.URL to a storage bucket.

func StoragePoolURL

func StoragePoolURL(storagePoolName string) *api.URL

StoragePoolURL returns an *api.URL to a storage pool.

func StorageVolumeBackupURL

func StorageVolumeBackupURL(projectName string, location string, poolName string, volumeTypeName string, volumeName, backupName string) *api.URL

StorageVolumeBackupURL returns an *api.URL to a storage volume backup.

func StorageVolumeSnapshotURL

func StorageVolumeSnapshotURL(projectName string, location string, poolName string, volumeTypeName string, volumeName, backupName string) *api.URL

StorageVolumeSnapshotURL returns an *api.URL to a storage volume snapshot.

func StorageVolumeURL

func StorageVolumeURL(projectName string, location string, storagePoolName string, storageVolumeType string, storageVolumeName string) *api.URL

StorageVolumeURL returns an *api.URL to a storage volume.

Types

type Reference

type Reference struct {
	EntityType  Type
	ProjectName string
	Location    string
	PathArgs    []string
	// contains filtered or unexported fields
}

Reference represents a canonical entity reference.

func NewReference

func NewReference(projectName string, entityType Type, location string, pathArgs ...string) (*Reference, error)

NewReference constructs a *Reference and validates it by attempting to build the canonical URL.

func ReferenceFromURL

func ReferenceFromURL(u url.URL) (*Reference, error)

ReferenceFromURL parses a url.URL into a *Reference.

func (Reference) GetPathArgs

func (r Reference) GetPathArgs(numParts int) []string

GetPathArgs returns the specified number of path parts, if available.

func (Reference) Name

func (r Reference) Name() string

Name returns the name of the entity, which is the last path argument.

func (Reference) URL

func (r Reference) URL() *api.URL

URL returns an *api.URL for this Reference.

type Type

type Type string

Type represents a resource type in LXD that is addressable via the API.

const (
	// TypeContainer represents container resources.
	TypeContainer Type = "container"

	// TypeImage represents image resources.
	TypeImage Type = "image"

	// TypeProfile represents profile resources.
	TypeProfile Type = "profile"

	// TypeProject represents project resources.
	TypeProject Type = "project"

	// TypeCertificate represents certificate resources.
	TypeCertificate Type = "certificate"

	// TypeInstance represents instance resources.
	TypeInstance Type = "instance"

	// TypeInstanceBackup represents instance backup resources.
	TypeInstanceBackup Type = "instance_backup"

	// TypeInstanceSnapshot represents instance snapshot resources.
	TypeInstanceSnapshot Type = "instance_snapshot"

	// TypeNetwork represents network resources.
	TypeNetwork Type = "network"

	// TypeNetworkACL represents network acl resources.
	TypeNetworkACL Type = "network_acl"

	// TypeClusterMember represents node resources.
	TypeClusterMember Type = "cluster_member"

	// TypeOperation represents operation resources.
	TypeOperation Type = "operation"

	// TypeStoragePool represents storage pool resources.
	TypeStoragePool Type = "storage_pool"

	// TypeStorageVolume represents storage volume resources.
	TypeStorageVolume Type = "storage_volume"

	// TypeStorageVolumeBackup represents storage volume backup resources.
	TypeStorageVolumeBackup Type = "storage_volume_backup"

	// TypeStorageVolumeSnapshot represents storage volume snapshot resources.
	TypeStorageVolumeSnapshot Type = "storage_volume_snapshot"

	// TypeWarning represents warning resources.
	TypeWarning Type = "warning"

	// TypeClusterGroup represents cluster group resources.
	TypeClusterGroup Type = "cluster_group"

	// TypeStorageBucket represents storage bucket resources.
	TypeStorageBucket Type = "storage_bucket"

	// TypeServer represents the top level /1.0 resource.
	TypeServer Type = "server"

	// TypeImageAlias represents image alias resources.
	TypeImageAlias Type = "image_alias"

	// TypeNetworkZone represents network zone resources.
	TypeNetworkZone Type = "network_zone"

	// TypeIdentity represents identity resources.
	TypeIdentity Type = "identity"

	// TypeAuthGroup represents authorization group resources.
	TypeAuthGroup Type = "group"

	// TypeIdentityProviderGroup represents identity provider group resources.
	TypeIdentityProviderGroup Type = "identity_provider_group"

	// TypePlacementGroup represents placement group resources.
	TypePlacementGroup Type = "placement_group"
)

func APIMetricsEntityTypes

func APIMetricsEntityTypes() []Type

APIMetricsEntityTypes returns the list of entity types relevant for the API metrics.

func ParseURL

func ParseURL(u url.URL) (entityType Type, projectName string, location string, pathArguments []string, err error)

ParseURL parses a raw URL string and returns the Type, project, location, and path arguments (mux vars).

Path arguments are returned in the order they are found in the URL. If there is no project query parameter and the Type requires a project, then api.ProjectDefaultName is returned as the project name. The returned location is the value of the "target" query parameter. All returned values are unescaped.

func ParseURLWithNamedArgs

func ParseURLWithNamedArgs(u url.URL) (entityType Type, projectName string, location string, args map[string]string, err error)

ParseURLWithNamedArgs parses a raw URL string and returns the Type and a map of named arguments, where each entry maps an argument name to its corresponding value parsed from the URL.

func (Type) RequiresProject

func (t Type) RequiresProject() (bool, error)

RequiresProject returns true if an entity of the Type can only exist within the context of a project. Operations and warnings may still be project specific but it is not an absolute requirement.

func (Type) String

func (t Type) String() string

String implements fmt.Stringer for Type.

func (Type) URL

func (t Type) URL(projectName string, location string, pathArguments ...string) (*api.URL, error)

URL returns a string URL for the Type.

If the Type is project specific and no project name is given, the project name will be set to api.ProjectDefaultName.

Warning: All arguments to this function will be URL encoded. They must not be URL encoded before calling this method.

func (Type) URLFromNamedArgs

func (t Type) URLFromNamedArgs(projectName string, location string, pathArguments map[string]string) (*api.URL, error)

URLFromNamedArgs returns a string URL for the Type.

If the Type is project specific and no project name is given, the project name will be set to api.ProjectDefaultName.

Warning: All arguments to this function will be URL encoded. They must not be URL encoded before calling this method.

func (Type) Validate

func (t Type) Validate() error

Validate returns an error if the Type is not in the list of allowed types. If the allowEmpty argument is set to true an empty string is allowed. This is to accommodate that warnings may not refer to a specific entity type.

Jump to

Keyboard shortcuts

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