Documentation ¶
Index ¶
- Variables
- type ResourceURN
- func (*ResourceURN) Descriptor() ([]byte, []int)deprecated
- func (x *ResourceURN) GetCanonical() string
- func (x *ResourceURN) GetCollection() string
- func (x *ResourceURN) GetIdentifier() string
- func (x *ResourceURN) GetNamespace() string
- func (x *ResourceURN) GetResource() string
- func (*ResourceURN) ProtoMessage()
- func (x *ResourceURN) ProtoReflect() protoreflect.Message
- func (x *ResourceURN) Reset()
- func (x *ResourceURN) String() string
- func (r *ResourceURN) Validate(validateFuncs ...ValidateFunc) error
- type URN
- type ValidateFunc
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMissingCanonical signals that the canonical representation of the ResourceURN is missing ErrMissingCanonical = errors.New("urn: the URN is missing the canonical representation") // ErrInvalidCanonical signals that the canonical representation is invalid ErrInvalidCanonical = errors.New("urn: the canonical representation is invalid") // ErrMissingNamespace signals that the namespace of the ResourceURN is missing ErrMissingNamespace = errors.New("urn: the URN is missing a namespace") // ErrMissingCollection signals that the collection of the ResourceURN is missing ErrMissingCollection = errors.New("urn: the URN is missing a collection") // ErrMissingIdentifier signals that the identifier of the ResourceURN is missing ErrMissingIdentifier = errors.New("urn: the URN is missing a identifier") // ErrMissingResource signals that the resource of the ResourceURN is missing ErrMissingResource = errors.New("urn: the URN is missing a identifier") )
var ( // ErrorInvalid is returned when parsing an URN with an // invalid format. ErrorInvalid = errors.New("invalid URN format") )
var File_urn_urn_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type ResourceURN ¶
type ResourceURN struct { // canonical means the full representation of the URN Canonical string `protobuf:"bytes,1,opt,name=canonical,proto3" json:"canonical,omitempty"` // namespace is the name prefix to space various URN types Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"` // collection is the service space, which reflects a resource Collection string `protobuf:"bytes,3,opt,name=collection,proto3" json:"collection,omitempty"` // identifier is the identifier of the resource within a collection Identifier string `protobuf:"bytes,4,opt,name=identifier,proto3" json:"identifier,omitempty"` // resource can be an associated resource of the URN Resource string `protobuf:"bytes,5,opt,name=resource,proto3" json:"resource,omitempty"` // contains filtered or unexported fields }
A ResourceURN represents a unique identifier of a resource in a service.
func (*ResourceURN) Descriptor
deprecated
func (*ResourceURN) Descriptor() ([]byte, []int)
Deprecated: Use ResourceURN.ProtoReflect.Descriptor instead.
func (*ResourceURN) GetCanonical ¶
func (x *ResourceURN) GetCanonical() string
func (*ResourceURN) GetCollection ¶
func (x *ResourceURN) GetCollection() string
func (*ResourceURN) GetIdentifier ¶
func (x *ResourceURN) GetIdentifier() string
func (*ResourceURN) GetNamespace ¶
func (x *ResourceURN) GetNamespace() string
func (*ResourceURN) GetResource ¶
func (x *ResourceURN) GetResource() string
func (*ResourceURN) ProtoMessage ¶
func (*ResourceURN) ProtoMessage()
func (*ResourceURN) ProtoReflect ¶
func (x *ResourceURN) ProtoReflect() protoreflect.Message
func (*ResourceURN) Reset ¶
func (x *ResourceURN) Reset()
func (*ResourceURN) String ¶
func (x *ResourceURN) String() string
func (*ResourceURN) Validate ¶
func (r *ResourceURN) Validate(validateFuncs ...ValidateFunc) error
Validate returns a non-nil error in case the given URN is not fully valid. Meaning it does not transport all information in the message. This can be the case in transitioning to use the URN.proto and not yet fully publish everything.
urn := req.GetUrn() if err := urn.Validate(); err != nil{ return err }
type URN ¶
type URN struct {
// contains filtered or unexported fields
}
URN represents a unique, uniform identifier for a resource
func FromProto ¶
func FromProto(r *ResourceURN, validateFunc ...ValidateFunc) (*URN, error)
FromProto returns the URN representation from a proto.ResourceURN representation.
func New ¶
func New(namespace, collection, identifier, resource string, validateFunc ...ValidateFunc) (*URN, error)
New takes a Collection, an identifier, a resource and an optional list of options, and returns a URN. It may return a non-nil error if namespace, coll or identifier contain invalid values (e.g. an empty namespace, an unknown collection, etc).
func Parse ¶
func Parse(s string, validateFunc ...ValidateFunc) (*URN, error)
Parse takes a string and parses it to a URN.
func (*URN) Collection ¶
Collection returns the collection segment of the URN.
func (*URN) Identifier ¶
Identifier returns the identifier segment of the URN.
func (*URN) ProtoMessage ¶
func (u *URN) ProtoMessage() *ResourceURN
ProtoMessage returns the proto.ResourceURN representation of the URN.
type ValidateFunc ¶
ValidateFunc is a function to validate a URN.
func ValidateNamespace ¶
func ValidateNamespace() ValidateFunc
ValidateNamespace is a function to validate that the namespace is not empty.