...

Package aipreflect

import "go.einride.tech/aip/reflect/aipreflect"
Overview
Index

Overview ▾

Package aipreflect provides primitives to manipulate AIP annotations and descriptors.

func RangeParentResourcesInPackage

func RangeParentResourcesInPackage(
    registry *protoregistry.Files,
    packageName protoreflect.FullName,
    pattern string,
    fn func(parent *annotations.ResourceDescriptor) bool,
)

RangeParentResourcesInPackage iterates over all a resource's parent descriptors in a package while fn returns true. The provided registry is used for looking up files in the package. The iteration order is undefined.

func RangeResourceDescriptorsInFile

func RangeResourceDescriptorsInFile(
    file protoreflect.FileDescriptor,
    fn func(resource *annotations.ResourceDescriptor) bool,
)

RangeResourceDescriptorsInFile iterates over all resource descriptors in a file while fn returns true. The iteration order is undefined.

func RangeResourceDescriptorsInPackage

func RangeResourceDescriptorsInPackage(
    registry *protoregistry.Files,
    packageName protoreflect.FullName,
    fn func(resource *annotations.ResourceDescriptor) bool,
)

RangeResourceDescriptorsInPackage iterates over all resource descriptors in a package while fn returns true. The provided registry is used for looking up files in the package. The iteration order is undefined.

func ValidateResourceReferences

func ValidateResourceReferences(message proto.Message) error

ValidateResourceReferences validates the resource reference fields in a message.

type GrammaticalName

GrammaticalName is the grammatical name for the singular or plural form of resource type. Grammatical names must be URL-safe and use lowerCamelCase.

type GrammaticalName string // e.g. "userEvents"

func (GrammaticalName) UpperCamelCase

func (g GrammaticalName) UpperCamelCase() string

UpperCamelCase returns the UpperCamelCase version of the grammatical name, for use in e.g. method names.

func (GrammaticalName) Validate

func (g GrammaticalName) Validate() error

Validate checks that the grammatical name is non-empty, URL-safe, and uses lowerCamelCase.

type MethodType

MethodType is an AIP method type.

type MethodType int
const (
    // MethodTypeNone represents no method type.
    MethodTypeNone MethodType = iota

    // MethodTypeGet is the method type of the AIP standard Get method.
    // See: https://google.aip.dev/131 (Standard methods: Get).
    MethodTypeGet

    // MethodTypeList is the method type of the AIP standard List method.
    // See: https://google.aip.dev/132 (Standard methods: List).
    MethodTypeList

    // MethodTypeCreate is the method type of the AIP standard Create method.
    // See: https://google.aip.dev/133 (Standard methods: Create).
    MethodTypeCreate

    // MethodTypeUpdate is the method type of the AIP standard Update method.
    // See: https://google.aip.dev/133 (Standard methods: Update).
    MethodTypeUpdate

    // MethodTypeDelete is the method type of the AIP standard Delete method.
    // See: https://google.aip.dev/135 (Standard methods: Delete).
    MethodTypeDelete

    // MethodTypeUndelete is the method type of the AIP Undelete method for soft delete.
    // See: https://google.aip.dev/164 (Soft delete).
    MethodTypeUndelete

    // MethodTypeBatchGet is the method type of the AIP standard BatchGet method.
    // See: https://google.aip.dev/231 (Batch methods: Get).
    MethodTypeBatchGet

    // MethodTypeBatchCreate is the method type of the AIP standard BatchCreate method.
    // See: https://google.aip.dev/233 (Batch methods: Create).
    MethodTypeBatchCreate

    // MethodTypeBatchUpdate is the method type of the AIP standard BatchUpdate method.
    // See: https://google.aip.dev/234 (Batch methods: Update).
    MethodTypeBatchUpdate

    // MethodTypeBatchDelete is the method type of the AIP standard BatchDelete method.
    // See: https://google.aip.dev/235 (Batch methods: Delete).
    MethodTypeBatchDelete

    // MethodTypeSearch is the method type of the custom AIP method for searching a resource collection.
    // See: https://google.aip.dev/136 (Custom methods).
    MethodTypeSearch
)

func (MethodType) IsPlural

func (s MethodType) IsPlural() bool

IsPlural returns true if the method type relates to a plurality of resources.

func (MethodType) NamePrefix

func (s MethodType) NamePrefix() protoreflect.Name

NamePrefix returns the method type's method name prefix.

func (MethodType) String

func (i MethodType) String() string

type ResourceType

ResourceType represents a resource type name.

type ResourceType string // e.g. pubsub.googleapis.com/Topic.

func (ResourceType) ServiceName

func (n ResourceType) ServiceName() string

ServiceName returns the service name of the resource type name.

func (ResourceType) Type

func (n ResourceType) Type() string

Type returns the type of the resource type name.

func (ResourceType) Validate

func (n ResourceType) Validate() error

Validate checks that the resource type name is syntactically valid.