resources

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: BSD-2-Clause Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ResourcePath       = "ResourcePath"
	ResourceEntityPath = "ResourceEntityPath"

	WithContext = "WithContext"
	FindBy      = "FindBy"

	RestLiClient        = "Client"
	ClientReceiver      = "c"
	ClientType          = "client"
	ClientInterfaceType = "Client"

	ResourceInterfaceType = "Resource"

	CreatedEntity            = "CreatedEntity"
	CreatedAndReturnedEntity = "CreatedAndReturnedEntity"
	Elements                 = "Elements"
	BatchEntities            = "BatchEntities"
	BatchResponse            = "BatchResponse"
)

Variables

View Source
var (
	RestLiClientQual          = Code(Qual(utils.RestLiPackage, RestLiClient))
	RestLiClientReceiver      = Code(Id(ClientReceiver).Dot(RestLiClient))
	Context                   = Code(Qual("context", "Context"))
	RequestContext            = Code(Op("*").Qual(utils.RestLiPackage, "RequestContext"))
	RequestContextParam       = Code(Add(Ctx).Add(RequestContext))
	ElementsWithMetadata      = Code(Qual(utils.RestLiDataPackage, "ElementsWithMetadata"))
	BatchEntityUpdateResponse = Code(Op("*").Qual(utils.RestLiDataPackage, "BatchEntityUpdateResponse"))
	EmptyRecord               = Code(Qual(utils.RestLiDataPackage, "EmptyRecord"))

	Rp           = Code(Id("rp"))
	Ctx          = Code(Id("ctx"))
	Entity       = Code(Id("entity"))
	Entities     = Code(Id("entities"))
	Results      = Code(Id("results"))
	Keys         = Code(Id("keys"))
	QueryParams  = Code(Id("queryParams"))
	ActionParams = Code(Id("actionParams"))

	NoExcludedFields        = Code(Qual(utils.RestLiCodecPackage, "NoExcludedFields"))
	ReadOnlyFields          = Code(Id("ReadOnlyFields"))
	CreateAndReadOnlyFields = Code(Id("CreateAndReadOnlyFields"))
)
View Source
var CollectionMetadata = &types.Record{
	NamedType: types.NamedType{Identifier: utils.Identifier{
		Namespace: utils.RestLiDataPackage,
		Name:      "CollectionMedata",
	}},
	Fields: []types.Field{
		{
			Type: types.RestliType{Primitive: &types.Int32Primitive},
			Name: "start",
			Doc:  "The start index of this collection",
		},
		{
			Type: types.RestliType{Primitive: &types.Int32Primitive},
			Name: "count",
			Doc:  "The number of elements in this collection segment",
		},
		{
			Type:         types.RestliType{Primitive: &types.Int32Primitive},
			Name:         "total",
			Doc:          "The total number of elements in the entire collection (not just this segment)",
			DefaultValue: restli.StringPointer("0"),
		},
		{
			Type: types.RestliType{Array: &types.RestliType{Reference: &Link.Identifier}},
			Name: "links",
		},
	},
}

CollectionMetadata is manually parsed from https://github.com/linkedin/rest.li/blob/master/restli-common/src/main/pegasus/com/linkedin/restli/common/CollectionMetadata.pdl

View Source
var ErrorResponse = &types.Record{
	NamedType: types.NamedType{Identifier: utils.Identifier{
		Namespace: utils.RestLiDataPackage,
		Name:      "ErrorResponse",
	}},
	Fields: []types.Field{
		{
			Type:       types.RestliType{Primitive: &types.Int32Primitive},
			Name:       "status",
			Doc:        "The HTTP status code.",
			IsOptional: true,
		},
		{
			Type:       types.RestliType{Primitive: &types.StringPrimitive},
			Name:       "message",
			Doc:        "A human-readable explanation of the error.",
			IsOptional: true,
		},
		{
			Type:       types.RestliType{Primitive: &types.StringPrimitive},
			Name:       "exceptionClass",
			Doc:        "The FQCN of the exception thrown by the server.",
			IsOptional: true,
		},
		{
			Type:       types.RestliType{Primitive: &types.StringPrimitive},
			Name:       "stackTrace",
			Doc:        "The full stack trace of the exception thrown by the server.",
			IsOptional: true,
		},
	},
}

ErrorResponse is manually parsed from https://github.com/linkedin/rest.li/blob/master/restli-common/src/main/pegasus/com/linkedin/restli/common/ErrorResponse.pdl

View Source
var Link = &types.Record{
	NamedType: types.NamedType{Identifier: utils.Identifier{
		Namespace: utils.RestLiDataPackage,
		Name:      "Link",
	}},
	Fields: []types.Field{
		{
			Type: types.RestliType{Primitive: &types.StringPrimitive},
			Name: "rel",
			Doc:  "The link relation e.g. 'self' or 'next'",
		},
		{
			Type: types.RestliType{Primitive: &types.StringPrimitive},
			Name: "href",
			Doc:  "The link URI",
		},
		{
			Type: types.RestliType{Primitive: &types.StringPrimitive},
			Name: "type",
			Doc:  "The type (media type) of the resource",
		},
	},
}

Link is manually parsed from https://github.com/linkedin/rest.li/blob/master/restli-common/src/main/pegasus/com/linkedin/restli/common/Link.pdl

View Source
var PagingContext = &types.Record{
	NamedType: types.NamedType{Identifier: utils.PagingContextIdentifier},
	Fields: []types.Field{
		{
			Type:         types.RestliType{Primitive: &types.Int32Primitive},
			Name:         "start",
			IsOptional:   true,
			IncludedFrom: &utils.PagingContextIdentifier,
		},
		{
			Type:         types.RestliType{Primitive: &types.Int32Primitive},
			Name:         "count",
			IsOptional:   true,
			IncludedFrom: &utils.PagingContextIdentifier,
		},
	},
}

Functions

This section is empty.

Types

type Action

type Action struct {
	// contains filtered or unexported fields
}

func (*Action) FuncName

func (a *Action) FuncName() string

func (*Action) FuncParamNames

func (a *Action) FuncParamNames() []Code

func (*Action) FuncParamTypes

func (a *Action) FuncParamTypes() []Code

func (*Action) GenerateCode

func (a *Action) GenerateCode() *utils.CodeFile

func (*Action) GetMethod

func (m *Action) GetMethod() *Method

func (*Action) GetPathKeys added in v1.0.3

func (m *Action) GetPathKeys() (keys []*PathKey)

func (*Action) NonErrorFuncReturnParam added in v1.0.0

func (a *Action) NonErrorFuncReturnParam() Code

func (*Action) RegisterMethod added in v1.0.3

func (a *Action) RegisterMethod(server, resource, segments Code) Code

type Finder

type Finder struct {
	// contains filtered or unexported fields
}

func (*Finder) FuncName

func (f *Finder) FuncName() string

func (*Finder) FuncParamNames

func (f *Finder) FuncParamNames() []Code

func (*Finder) FuncParamTypes

func (f *Finder) FuncParamTypes() []Code

func (*Finder) GenerateCode

func (f *Finder) GenerateCode() *utils.CodeFile

func (*Finder) GetMethod

func (m *Finder) GetMethod() *Method

func (*Finder) GetPathKeys added in v1.0.3

func (m *Finder) GetPathKeys() (keys []*PathKey)

func (*Finder) NonErrorFuncReturnParam added in v1.0.0

func (f *Finder) NonErrorFuncReturnParam() Code

func (*Finder) RegisterMethod added in v1.0.3

func (f *Finder) RegisterMethod(server, resource, segments Code) Code

type Method

type Method struct {
	MethodType   MethodType        `json:"methodType"`
	Name         string            `json:"name"`
	Doc          string            `json:"doc"`
	OnEntity     bool              `json:"onEntity"`
	Params       []types.Field     `json:"params"`
	Return       *types.RestliType `json:"return"`
	Metadata     *types.RestliType `json:"metadata"`
	ReturnEntity bool              `json:"returnEntity"`
}

type MethodImplementation

type MethodImplementation interface {
	GetMethod() *Method
	GetPathKeys() []*PathKey
	FuncName() string
	FuncParamNames() []Code
	FuncParamTypes() []Code
	NonErrorFuncReturnParam() Code
	GenerateCode() *utils.CodeFile
	RegisterMethod(server, resource, segments Code) Code
}

type MethodType

type MethodType string
const (
	REST_METHOD MethodType = "REST_METHOD"
	ACTION      MethodType = "ACTION"
	FINDER      MethodType = "FINDER"
)

type PathKey

type PathKey struct {
	Name string           `json:"name"`
	Type types.RestliType `json:"type"`
}

func (*PathKey) GoType added in v1.0.3

func (pk *PathKey) GoType() *Statement

func (*PathKey) UnmarshalJSON added in v1.0.3

func (pk *PathKey) UnmarshalJSON(data []byte) error

type Resource

type Resource struct {
	Namespace            string                 `json:"namespace"`
	Doc                  string                 `json:"doc"`
	SourceFile           string                 `json:"sourceFile"`
	ResourcePathSegments []ResourcePathSegment  `json:"resourcePathSegments"`
	ResourceSchema       *types.RestliType      `json:"resourceSchema"`
	Methods              []MethodImplementation `json:"-"`
	ReadOnlyFields       []string               `json:"readOnlyFields"`
	CreateOnlyFields     []string               `json:"createOnlyFields"`
}

func (*Resource) GenerateCode

func (r *Resource) GenerateCode() []*utils.CodeFile

func (*Resource) LastSegment added in v1.0.3

func (r *Resource) LastSegment() ResourcePathSegment

func (*Resource) LocalType added in v1.0.3

func (r *Resource) LocalType(name string) *Statement

func (*Resource) NewCodeFile

func (r *Resource) NewCodeFile(filename string) *utils.CodeFile

func (*Resource) PackagePath

func (r *Resource) PackagePath() string

func (*Resource) ParentSegments added in v1.0.3

func (r *Resource) ParentSegments() []ResourcePathSegment

func (*Resource) UnmarshalJSON

func (r *Resource) UnmarshalJSON(data []byte) (err error)

type ResourcePathSegment added in v1.0.3

type ResourcePathSegment struct {
	ResourceName string   `json:"resourceName"`
	PathKey      *PathKey `json:"pathKey"`
}

type RestMethod

type RestMethod struct {
	// contains filtered or unexported fields
}

func (*RestMethod) EntityKeyType added in v1.0.3

func (r *RestMethod) EntityKeyType() *Statement

func (*RestMethod) EntityType added in v1.0.3

func (r *RestMethod) EntityType() *Statement

func (*RestMethod) FuncName

func (r *RestMethod) FuncName() string

func (*RestMethod) FuncParamNames

func (r *RestMethod) FuncParamNames() (params []Code)

func (*RestMethod) FuncParamTypes

func (r *RestMethod) FuncParamTypes() (params []Code)

func (*RestMethod) GenericParams added in v1.0.3

func (r *RestMethod) GenericParams() Code

func (*RestMethod) GetMethod

func (m *RestMethod) GetMethod() *Method

func (*RestMethod) GetPathKeys added in v1.0.3

func (m *RestMethod) GetPathKeys() (keys []*PathKey)

func (*RestMethod) NonErrorFuncReturnParam added in v1.0.0

func (r *RestMethod) NonErrorFuncReturnParam() Code

func (*RestMethod) PartialEntityUpdateType added in v1.0.3

func (r *RestMethod) PartialEntityUpdateType() *Statement

func (*RestMethod) RegisterMethod added in v1.0.3

func (r *RestMethod) RegisterMethod(server, resource, segments Code) Code

Jump to

Keyboard shortcuts

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