ids

package
v1.18.7 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

README

ids

Nominal UUID types for the resource identifiers the region API owns.

Purpose

Provides distinct named types over uuid.UUID for every resource category the region service addresses through its public API:

Type Identifies
RegionID regions
IdentityID cloud identities
NetworkID networks
SecurityGroupID security groups
LoadBalancerID load balancers
ServerID servers
SSHCertificateAuthorityID SSH certificate authorities
FileStorageID file storage
ImageID images
FlavorID flavors

Each type is a distinct named type — not an alias — so the compiler prevents a NetworkID from being passed where a ServerID is expected, and so on across all types.

Each type implements encoding.TextUnmarshaler by delegating to uuid.UUID, so the oapi-codegen parameter binder validates UUID format at path-parameter binding time before any handler is reached. Non-UUID path values produce a 400 at the routing layer rather than propagating into business logic.

Scope

These types live at the API layer only. The region service mints UUIDs for its own CRD-backed resources (Region, Identity, Network, SecurityGroup, LoadBalancer, Server, SSHCertificateAuthority, FileStorage) and addresses provider-owned Image/Flavor resources by their provider-assigned UUIDs. The typed identifiers exist on the generated OpenAPI surface (path parameters and request/response body fields); handlers convert to plain strings at the boundary when crossing into Kubernetes object names, labels, provider calls, or CRD specs, all of which remain string-typed.

Identifiers owned by other services — organizationId, projectId, userId — use the identity service's pkg/ids types, not these. Provider-internal identifiers exposed only through hidden APIs (vlanId, subnetId, routerId, serverGroupId) remain plain strings.

Conversion

Inward (string → typed ID): Use Parse* for untrusted input (Kubernetes labels, request body fields read back from storage). Use MustParse* only where the value is guaranteed valid by a prior validation step — in practice a path parameter, which the oapi-codegen binder has already validated via UnmarshalText before the handler runs (so re-parsing it cannot panic), or a test fixture using a known-good literal.

Outward (typed ID → string): Call .String() to produce the canonical hyphenated UUID string for Kubernetes object names, label values, provider API calls, or log messages.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileStorageID

type FileStorageID uuid.UUID

FileStorageID is a UUID-backed identifier for file storage. It is a distinct named type so the compiler prevents accidental interchange with any other ID type. UnmarshalText delegates to uuid.UUID, so the oapi-codegen runtime rejects non-UUID path parameter values before any handler is reached.

func MustParseFileStorageID

func MustParseFileStorageID(s string) FileStorageID

MustParseFileStorageID parses s as a UUID into a FileStorageID. Panics if s is not a valid UUID; use only where s is guaranteed valid (e.g. previously validated API path parameters).

func ParseFileStorageID

func ParseFileStorageID(s string) (FileStorageID, error)

ParseFileStorageID parses s as a UUID into a FileStorageID, returning an error if s is not a valid UUID.

func (FileStorageID) MarshalText

func (v FileStorageID) MarshalText() ([]byte, error)

func (FileStorageID) String

func (v FileStorageID) String() string

func (*FileStorageID) UnmarshalText

func (v *FileStorageID) UnmarshalText(b []byte) error

type FlavorID

type FlavorID uuid.UUID

FlavorID is a UUID-backed identifier for flavors. The platform addresses flavors by their provider-assigned UUID; it is a distinct named type so the compiler prevents accidental interchange with any other ID type. UnmarshalText delegates to uuid.UUID, so the oapi-codegen runtime rejects non-UUID path parameter values before any handler is reached.

func MustParseFlavorID

func MustParseFlavorID(s string) FlavorID

MustParseFlavorID parses s as a UUID into a FlavorID. Panics if s is not a valid UUID; use only where s is guaranteed valid (e.g. previously validated API path parameters).

func ParseFlavorID

func ParseFlavorID(s string) (FlavorID, error)

ParseFlavorID parses s as a UUID into a FlavorID, returning an error if s is not a valid UUID.

func (FlavorID) MarshalText

func (v FlavorID) MarshalText() ([]byte, error)

func (FlavorID) String

func (v FlavorID) String() string

func (*FlavorID) UnmarshalText

func (v *FlavorID) UnmarshalText(b []byte) error

type IdentityID

type IdentityID uuid.UUID

IdentityID is a UUID-backed identifier for cloud identities. It is a distinct named type so the compiler prevents accidental interchange with any other ID type. UnmarshalText delegates to uuid.UUID, so the oapi-codegen runtime rejects non-UUID path parameter values before any handler is reached.

func MustParseIdentityID

func MustParseIdentityID(s string) IdentityID

MustParseIdentityID parses s as a UUID into an IdentityID. Panics if s is not a valid UUID; use only where s is guaranteed valid (e.g. previously validated API path parameters).

func ParseIdentityID

func ParseIdentityID(s string) (IdentityID, error)

ParseIdentityID parses s as a UUID into an IdentityID, returning an error if s is not a valid UUID.

func (IdentityID) MarshalText

func (v IdentityID) MarshalText() ([]byte, error)

func (IdentityID) String

func (v IdentityID) String() string

func (*IdentityID) UnmarshalText

func (v *IdentityID) UnmarshalText(b []byte) error

type ImageID

type ImageID uuid.UUID

ImageID is a UUID-backed identifier for images. The platform addresses images by their provider-assigned UUID; it is a distinct named type so the compiler prevents accidental interchange with any other ID type. UnmarshalText delegates to uuid.UUID, so the oapi-codegen runtime rejects non-UUID path parameter values before any handler is reached.

func MustParseImageID

func MustParseImageID(s string) ImageID

MustParseImageID parses s as a UUID into an ImageID. Panics if s is not a valid UUID; use only where s is guaranteed valid (e.g. previously validated API path parameters).

func ParseImageID

func ParseImageID(s string) (ImageID, error)

ParseImageID parses s as a UUID into an ImageID, returning an error if s is not a valid UUID.

func (ImageID) MarshalText

func (v ImageID) MarshalText() ([]byte, error)

func (ImageID) String

func (v ImageID) String() string

func (*ImageID) UnmarshalText

func (v *ImageID) UnmarshalText(b []byte) error

type LoadBalancerID

type LoadBalancerID uuid.UUID

LoadBalancerID is a UUID-backed identifier for load balancers. It is a distinct named type so the compiler prevents accidental interchange with any other ID type. UnmarshalText delegates to uuid.UUID, so the oapi-codegen runtime rejects non-UUID path parameter values before any handler is reached.

func MustParseLoadBalancerID

func MustParseLoadBalancerID(s string) LoadBalancerID

MustParseLoadBalancerID parses s as a UUID into a LoadBalancerID. Panics if s is not a valid UUID; use only where s is guaranteed valid (e.g. previously validated API path parameters).

func ParseLoadBalancerID

func ParseLoadBalancerID(s string) (LoadBalancerID, error)

ParseLoadBalancerID parses s as a UUID into a LoadBalancerID, returning an error if s is not a valid UUID.

func (LoadBalancerID) MarshalText

func (v LoadBalancerID) MarshalText() ([]byte, error)

func (LoadBalancerID) String

func (v LoadBalancerID) String() string

func (*LoadBalancerID) UnmarshalText

func (v *LoadBalancerID) UnmarshalText(b []byte) error

type NetworkID

type NetworkID uuid.UUID

NetworkID is a UUID-backed identifier for networks. It is a distinct named type so the compiler prevents accidental interchange with any other ID type. UnmarshalText delegates to uuid.UUID, so the oapi-codegen runtime rejects non-UUID path parameter values before any handler is reached.

func MustParseNetworkID

func MustParseNetworkID(s string) NetworkID

MustParseNetworkID parses s as a UUID into a NetworkID. Panics if s is not a valid UUID; use only where s is guaranteed valid (e.g. previously validated API path parameters).

func ParseNetworkID

func ParseNetworkID(s string) (NetworkID, error)

ParseNetworkID parses s as a UUID into a NetworkID, returning an error if s is not a valid UUID.

func (NetworkID) MarshalText

func (v NetworkID) MarshalText() ([]byte, error)

func (NetworkID) String

func (v NetworkID) String() string

func (*NetworkID) UnmarshalText

func (v *NetworkID) UnmarshalText(b []byte) error

type RegionID

type RegionID uuid.UUID

RegionID is a UUID-backed identifier for regions. It is a distinct named type so the compiler prevents accidental interchange with any other ID type. UnmarshalText delegates to uuid.UUID, so the oapi-codegen runtime rejects non-UUID path parameter values before any handler is reached.

func MustParseRegionID

func MustParseRegionID(s string) RegionID

MustParseRegionID parses s as a UUID into a RegionID. Panics if s is not a valid UUID; use only where s is guaranteed valid (e.g. previously validated API path parameters).

func ParseRegionID

func ParseRegionID(s string) (RegionID, error)

ParseRegionID parses s as a UUID into a RegionID, returning an error if s is not a valid UUID.

func (RegionID) MarshalText

func (v RegionID) MarshalText() ([]byte, error)

func (RegionID) String

func (v RegionID) String() string

func (*RegionID) UnmarshalText

func (v *RegionID) UnmarshalText(b []byte) error

type SSHCertificateAuthorityID

type SSHCertificateAuthorityID uuid.UUID

SSHCertificateAuthorityID is a UUID-backed identifier for SSH certificate authorities. It is a distinct named type so the compiler prevents accidental interchange with any other ID type. UnmarshalText delegates to uuid.UUID, so the oapi-codegen runtime rejects non-UUID path parameter values before any handler is reached.

func MustParseSSHCertificateAuthorityID

func MustParseSSHCertificateAuthorityID(s string) SSHCertificateAuthorityID

MustParseSSHCertificateAuthorityID parses s as a UUID into an SSHCertificateAuthorityID. Panics if s is not a valid UUID; use only where s is guaranteed valid (e.g. previously validated API path parameters).

func ParseSSHCertificateAuthorityID

func ParseSSHCertificateAuthorityID(s string) (SSHCertificateAuthorityID, error)

ParseSSHCertificateAuthorityID parses s as a UUID into an SSHCertificateAuthorityID, returning an error if s is not a valid UUID.

func (SSHCertificateAuthorityID) MarshalText

func (v SSHCertificateAuthorityID) MarshalText() ([]byte, error)

func (SSHCertificateAuthorityID) String

func (v SSHCertificateAuthorityID) String() string

func (*SSHCertificateAuthorityID) UnmarshalText

func (v *SSHCertificateAuthorityID) UnmarshalText(b []byte) error

type SecurityGroupID

type SecurityGroupID uuid.UUID

SecurityGroupID is a UUID-backed identifier for security groups. It is a distinct named type so the compiler prevents accidental interchange with any other ID type. UnmarshalText delegates to uuid.UUID, so the oapi-codegen runtime rejects non-UUID path parameter values before any handler is reached.

func MustParseSecurityGroupID

func MustParseSecurityGroupID(s string) SecurityGroupID

MustParseSecurityGroupID parses s as a UUID into a SecurityGroupID. Panics if s is not a valid UUID; use only where s is guaranteed valid (e.g. previously validated API path parameters).

func ParseSecurityGroupID

func ParseSecurityGroupID(s string) (SecurityGroupID, error)

ParseSecurityGroupID parses s as a UUID into a SecurityGroupID, returning an error if s is not a valid UUID.

func (SecurityGroupID) MarshalText

func (v SecurityGroupID) MarshalText() ([]byte, error)

func (SecurityGroupID) String

func (v SecurityGroupID) String() string

func (*SecurityGroupID) UnmarshalText

func (v *SecurityGroupID) UnmarshalText(b []byte) error

type ServerID

type ServerID uuid.UUID

ServerID is a UUID-backed identifier for servers. It is a distinct named type so the compiler prevents accidental interchange with any other ID type. UnmarshalText delegates to uuid.UUID, so the oapi-codegen runtime rejects non-UUID path parameter values before any handler is reached.

func MustParseServerID

func MustParseServerID(s string) ServerID

MustParseServerID parses s as a UUID into a ServerID. Panics if s is not a valid UUID; use only where s is guaranteed valid (e.g. previously validated API path parameters).

func ParseServerID

func ParseServerID(s string) (ServerID, error)

ParseServerID parses s as a UUID into a ServerID, returning an error if s is not a valid UUID.

func (ServerID) MarshalText

func (v ServerID) MarshalText() ([]byte, error)

func (ServerID) String

func (v ServerID) String() string

func (*ServerID) UnmarshalText

func (v *ServerID) UnmarshalText(b []byte) error

Jump to

Keyboard shortcuts

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