pipeline

package
v0.0.0-...-bd59a41 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OutputSupportedServices

func OutputSupportedServices(input RunInput) error

func Run

func Run(input RunInput) error

Types

type DataType

type DataType uint8
const (
	DataTypeUnknown DataType = iota
	DataTypeModel
	DataTypeArray
	DataTypeString
	DataTypeInteger64
	DataTypeIntegerUnsigned64
	DataTypeInteger32
	DataTypeIntegerUnsigned32
	DataTypeInteger16
	DataTypeIntegerUnsigned16
	DataTypeInteger8
	DataTypeIntegerUnsigned8
	DataTypeFloat32
	DataTypeFloat64
	DataTypeBool
	DataTypeBase64
	DataTypeDate
	DataTypeDateTime
	DataTypeDuration
	DataTypeTime
	DataTypeUuid
	DataTypeBinary
)

func (DataType) CSType

func (ft DataType) CSType() *string

CSType returns a string containing the C# type name for the DataType. We intentionally consolidate some of these (ints and floats all the same size) to ease downstream implementation.

type Model

type Model struct {
	Fields map[string]*ModelField
	Common bool
	Prefix string
}

func (*Model) IsValid

func (m *Model) IsValid() bool

type ModelField

type ModelField struct {
	Title        string
	Type         *DataType
	Description  string
	Default      interface{}
	Enum         []string
	ItemType     *DataType
	ConstantName *string
	ModelName    *string
	JsonField    string
}

func (ModelField) CSType

func (f ModelField) CSType(models Models) *string

CSType returns a string containing the C# type name for the ModelField, either describing it as a literal type, a specific model type, or a collection of either.

type Models

type Models map[string]*Model

func (Models) Found

func (m Models) Found(modelName string) bool

Found returns true when the provided modelName was found in the Models map

func (Models) Merge

func (m Models) Merge(m2 Models)

func (Models) MergeDependants

func (m Models) MergeDependants(allModels Models, modelName string) error

MergeDependants inspects the named model in m, then traverses allModels and appends any dependant models to m, recursively

type Operation

type Operation struct {
	Name         string
	Type         OperationType
	Method       string
	ResourceId   *ResourceId
	UriSuffix    *string
	RequestModel *string
	RequestType  *DataType
	Responses    Responses
	Tags         []string
}

type OperationType

type OperationType uint8
const (
	OperationTypeUnknown OperationType = iota
	OperationTypeList
	OperationTypeRead
	OperationTypeCreate
	OperationTypeCreateUpdate
	OperationTypeUpdate
	OperationTypeDelete
)

func NewOperationType

func NewOperationType(method string) OperationType

type Resource

type Resource struct {
	Name       string
	Category   string
	Version    string
	Service    string
	Paths      []ResourceId
	Operations []Operation
}

type ResourceId

type ResourceId struct {
	Name     string
	Service  string
	Version  string
	Segments []ResourceIdSegment
}

func NewResourceId

func NewResourceId(path string, tags []string) (id ResourceId)

func (ResourceId) FindResourceIdName

func (r ResourceId) FindResourceIdName() (*string, bool)

FindResourceIdName returns a short name for the ResourceId. This currently has the same behavior as FindResourceName but may be changed in future if the ResourceId needs to be distinctly named.

func (ResourceId) FindResourceName

func (r ResourceId) FindResourceName() (*string, bool)

FindResourceName returns a short resource name based on the last significant segments of the ResourceId. Singularization follows the same rules as FullyQualifiedResourceName. e.g. if r represents `/applications/{applicationId}/synchronization/jobs/{synchronizationJobId}/schema`, the (shortened) returned name will be `SynchronizationJob`.

func (ResourceId) FullyQualifiedResourceName

func (r ResourceId) FullyQualifiedResourceName(suffixQualification *string) (*string, bool)

FullyQualifiedResourceName returns a human-readable name for the ResourceId, using all segments, each segment singularized except when the following segment is a plural function, or the first known verb is encountered. e.g. if r represents `/applications/{applicationId}/synchronization/jobs/{synchronizationJobId}/schema`, the returned name will be `ApplicationSynchronizationJob`

func (ResourceId) HasUserValue

func (r ResourceId) HasUserValue() bool

func (ResourceId) ID

func (r ResourceId) ID() string

func (ResourceId) IsMatchOrAncestor

func (r ResourceId) IsMatchOrAncestor(r2 ResourceId) (ResourceId, bool)

IsMatchOrAncestor compares the provided ResourceId (r2) against the current ResourceId and returns true if the two resource IDs match, or if this ResourceId is an ancestor of the provided ResourceId.

func (ResourceId) LastLabel

func (r ResourceId) LastLabel() *ResourceIdSegment

LastLabel returns the last label segment from the ResourceId

func (ResourceId) LastLabelBeforeSegment

func (r ResourceId) LastLabelBeforeSegment(i int) *ResourceIdSegment

LastLabelBeforeSegment returns the last label segment from the ResourceId that precedes the provided segment index

func (ResourceId) LastSegmentOfTypeBeforeSegment

func (r ResourceId) LastSegmentOfTypeBeforeSegment(types []ResourceIdSegmentType, i int) *ResourceIdSegment

LastSegmentOfTypeBeforeSegment returns the last segment of the specified type from the ResourceId that precedes the provided segment index

func (ResourceId) TruncateToLastSegmentOfTypeBeforeSegment

func (r ResourceId) TruncateToLastSegmentOfTypeBeforeSegment(types []ResourceIdSegmentType, i int) *ResourceId

TruncateToLastSegmentOfTypeBeforeSegment returns a new ResourceId, truncating this ResourceId to the last segment of the specified type from the ResourceId that precedes the provided segment index

type ResourceIdMatch

type ResourceIdMatch struct {
	Id        *ResourceId
	Remainder *ResourceId
}

type ResourceIdSegment

type ResourceIdSegment struct {
	Type  ResourceIdSegmentType
	Value string
	Field *string
}

type ResourceIdSegmentType

type ResourceIdSegmentType uint
const (
	SegmentLabel ResourceIdSegmentType = iota
	SegmentUserValue
	SegmentODataReference
	SegmentAction
	SegmentCast
	SegmentFunction
)

type ResourceIds

type ResourceIds []*ResourceId

func (ResourceIds) MatchIdOrAncestor

func (ri ResourceIds) MatchIdOrAncestor(resourceId ResourceId) (*ResourceIdMatch, bool)

MatchIdOrAncestor returns a ResourceIdMatch containing a matching/ancestor ResourceId and/or a remaininder value, or nil if no match/ancestor was found. A match is a ResourceId that represents the same path, and an ancestor is any ResourceId that represents a shorter matching path. Where multiple ancestors are found, the most granular (i.e. the longest) ancestor is returned.

Example 1: If resourceId represents `/users/{userId}` The returned ResourceIdMatch is likely to represent `/users/{userId}` (a match) with no remainder.

Example 2: If resourceId represents `/applications/{applicationId}/owners` The returned ResourceIdMatch is likely to represent `/applications/{applicationId}` with a remainder of `/owners`

type Resources

type Resources map[string]*Resource

func (Resources) ServiceHasValidResources

func (r Resources) ServiceHasValidResources(serviceName string) bool

ServiceHasValidResources returns true when resources are found for the provided serviceName that have usable operations defined (specifically any operations that do not require a response model, or that have a response model for any response)

type Response

type Response struct {
	Status      int
	ContentType *string
	ModelName   *string
	Type        *DataType
}

type Responses

type Responses []Response

func (Responses) FindModelName

func (rs Responses) FindModelName() *string

type RunInput

type RunInput struct {
	ProviderPrefix string

	Logger hclog.Logger

	CommonTypesDirectoryName string
	ConfigFilePath           string
	MetadataDirectory        string
	OpenApiFilePattern       string
	OutputDirectory          string
	Services                 []string
	SupportedVersions        []string
}

type ServiceTags

type ServiceTags map[string][]string

type Tree

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

Jump to

Keyboard shortcuts

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