api

package
v0.0.0-...-22855a0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const (
	AEP_OPERATION_REF = "https://aep.dev/json-schema/type/operation.json"
)

Variables

This section is empty.

Functions

func AddImplicitFieldsAndValidate

func AddImplicitFieldsAndValidate(api *API) error

addImplicitFieldsAndValidate adds implicit fields to the API object, such as the "path" variable in the resource.

func CollectionName

func CollectionName(r *Resource) string

return the collection name of the resource, but deduplicate the name of the previous parent e.g: - book-editions becomes editions under the parent resource book.

func ConvertToOpenAPI

func ConvertToOpenAPI(api *API) (*openapi.OpenAPI, error)

func OperationSchema

func OperationSchema() openapi.Schema

Types

type API

type API struct {
	ServerURL string `json:"server_url"`
	Name      string
	Contact   *Contact
	Schemas   map[string]*openapi.Schema
	// A list of the resources that are exposed by the API.
	//
	// The key "operation" carries a special meaning, and must
	// map to an aep.dev/151 Operation resource.
	Resources map[string]*Resource
}

func ExampleAPI

func ExampleAPI() *API

func GetAPI

func GetAPI(api *openapi.OpenAPI, serverURL, pathPrefix string) (*API, error)

func LoadAPIFromJson

func LoadAPIFromJson(data []byte) (*API, error)

func (*API) ConvertToOpenAPIBytes

func (api *API) ConvertToOpenAPIBytes() ([]byte, error)

func (*API) GetResource

func (s *API) GetResource(resource string) (*Resource, error)

type ApplyMethod

type ApplyMethod struct {
	IsLongRunning bool `json:"is_long_running"`
}

type Contact

type Contact struct {
	Name  string
	Email string
	URL   string
}

type CreateMethod

type CreateMethod struct {
	SupportsUserSettableCreate bool `json:"supports_user_settable_create"`
	IsLongRunning              bool `json:"is_long_running"`
}

type CustomMethod

type CustomMethod struct {
	Name          string
	Method        string
	Request       *openapi.Schema
	Response      *openapi.Schema
	IsLongRunning bool `json:"is_long_running"`
}

type DeleteMethod

type DeleteMethod struct {
	IsLongRunning bool `json:"is_long_running"`
}

type GetMethod

type GetMethod struct {
}

type ListMethod

type ListMethod struct {
	HasUnreachableResources bool `json:"has_unreachable_resources"`
	SupportsFilter          bool `json:"supports_filter"`
	SupportsSkip            bool `json:"supports_skip"`
}

type Methods

type Methods struct {
	Get    *GetMethod    `json:"get,omitempty"`
	List   *ListMethod   `json:"list,omitempty"`
	Apply  *ApplyMethod  `json:"apply,omitempty"`
	Create *CreateMethod `json:"create,omitempty"`
	Update *UpdateMethod `json:"update,omitempty"`
	Delete *DeleteMethod `json:"delete,omitempty"`
}

type PathWithParams

type PathWithParams struct {
	Pattern string
	Params  []openapi.Parameter
}

PathWithParams passes an http path with the OpenAPI parameters it contains. helpful to bundle them both when iterating.

type PatternInfo

type PatternInfo struct {
	// if true, the pattern represents an individual resource,
	// otherwise it represents a path to a collection of resources
	IsResourcePattern bool
	CustomMethodName  string
}

type Resource

type Resource struct {
	// the resource singular name is the name of the resource
	// in the API. It is used to generate the pattern for the resource.
	// e.g: book-edition -> book-editions
	//
	// The singular name is also used to generate the schema name.
	// e.g: book-edition -> BookEdition
	//
	// the resource singular **must** be in kebab-case.
	Singular string   `json:"singular"`
	Plural   string   `json:"plural"`
	Parents  []string `json:"parents,omitempty"`

	// Children is populated on load
	Children []*Resource `json:"-"`

	// the API reference is used to retrieve things like the parent resources.
	API           *API            `json:"-"`
	Schema        *openapi.Schema `json:"schema,omitempty"`
	Methods       Methods         `json:"methods,omitempty"`
	CustomMethods []*CustomMethod `json:"custom_methods,omitempty"`
	// contains filtered or unexported fields
}

func OperationResource

func OperationResource(m Methods, cm []*CustomMethod) *Resource

Return a longrunningoperation resource

func OperationResourceWithDefaults

func OperationResourceWithDefaults() *Resource

func (*Resource) GetPattern

func (r *Resource) GetPattern() string

func (*Resource) ParentResources

func (r *Resource) ParentResources() []*Resource

return the parent resources of the resource.

This function should only be called until after the API has been validated.

func (*Resource) PatternElems

func (r *Resource) PatternElems() []string

GeneratePatternStrings generates the pattern strings for a resource TODO(yft): support multiple parents

type UpdateMethod

type UpdateMethod struct {
	IsLongRunning bool `json:"is_long_running"`
}

Jump to

Keyboard shortcuts

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