azidx

package
v0.0.0-...-6c70ea7 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 24 Imported by: 2

Documentation

Index

Constants

View Source
const (
	OperationKindGet     OperationKind = "GET"
	OperationKindPut                   = "PUT"
	OperationKindPost                  = "POST"
	OperationKindDelete                = "DELETE"
	OperationKindOptions               = "OPTIONS"
	OperationKindHead                  = "HEAD"
	OperationKindPatch                 = "PATCH"
)
View Source
const ResourceRP = "Microsoft.Resources"
View Source
const Wildcard = "*"

Variables

Functions

func BuildGithubLink(ref jsonreference.Ref, commit, specdir string) (string, error)

func PathItemOperation

func PathItemOperation(pathItem spec.PathItem, op OperationKind) *spec.Operation

func SetLogger

func SetLogger(l Logger)

func SpecListFromReadmeMD

func SpecListFromReadmeMD(b []byte) ([]string, error)

Types

type APIMethods

type APIMethods map[OperationKind]ResourceTypes

type APIVersions

type APIVersions map[string]APIMethods

type DedupMatcher

type DedupMatcher struct {
	Name        string
	RP          *regexp.Regexp
	Version     *regexp.Regexp
	RT          *regexp.Regexp
	ACT         *regexp.Regexp
	Method      *regexp.Regexp
	PathPattern *regexp.Regexp
}

func (DedupMatcher) Match

func (key DedupMatcher) Match(loc OpLocator, pathp string) bool

type DedupMatcherIn

type DedupMatcherIn struct {
	RP      string   `json:"rp,omitempty"`
	Version string   `json:"version,omitemptyn"`
	RT      string   `json:"rt,omitempty"`
	ACT     string   `json:"act,omitempty"`
	Method  string   `json:"method,omitempty"`
	Paths   []string `json:"paths,omitempty"`
}

type DedupOp

type DedupOp struct {
	Picker *DedupPicker
	Ignore bool
	Any    bool
}

type DedupPicker

type DedupPicker struct {
	SpecPath *regexp.Regexp
	Pointer  *regexp.Regexp
}

func (DedupPicker) Match

func (picker DedupPicker) Match(ref jsonreference.Ref) bool

type DedupPickerIn

type DedupPickerIn struct {
	SpecPath string `json:"spec_path,omitempty"`
	Pointer  string `json:"pointer,omitempty"`
}

type DedupRecord

type DedupRecord struct {
	Matcher DedupMatcherIn `json:"matcher"`
	Picker  *DedupPickerIn `json:"picker"`
	Ignore  *bool          `json:"ignore"`
	Any     *bool          `json:"any"`
}

type DeduplicateRecords

type DeduplicateRecords map[string]DedupRecord

func (DeduplicateRecords) ToDeduplicator

func (records DeduplicateRecords) ToDeduplicator() (Deduplicator, error)

type Deduplicator

type Deduplicator map[DedupMatcher]DedupOp

type FlattenOpIndex

type FlattenOpIndex map[OpLocator]OperationRefs

type Index

type Index struct {
	Commit            string `json:"commit,omitempty"`
	ResourceProviders `json:"resource_providers"`
}

func BuildIndex

func BuildIndex(specdir string, dedupFile string) (*Index, error)

BuildIndex builds the index file for the given specification directory. Since there are duplicated specification files in the directory, that defines the same API (same API path, version, operation), users can optionally specify a deduplication file. Otherwise, it will use a default dedup file instead.

func (Index) Lookup

func (idx Index) Lookup(method string, uRL url.URL) (*jsonreference.Ref, error)

type Logger

type Logger interface {
	Debug(msg string, args ...interface{})
	Info(msg string, args ...interface{})
	Warn(msg string, args ...interface{})
	Error(msg string, args ...interface{})
}

type MatchSegment

type MatchSegment struct {
	Value      string
	IsWildcard bool
	IsAny      bool
}

type Matcher

type Matcher struct {
	PrefixSep bool
	Separater string
	Segments  []MatchSegment
}

func (Matcher) Less

func (m Matcher) Less(om Matcher) bool

func (Matcher) Match

func (m Matcher) Match(input string) bool

type Matchers

type Matchers []Matcher

func (Matchers) Len

func (m Matchers) Len() int

func (Matchers) Less

func (m Matchers) Less(i int, j int) bool

func (Matchers) Swap

func (m Matchers) Swap(i int, j int)

type NullLogger

type NullLogger struct{}

func (*NullLogger) Debug

func (n *NullLogger) Debug(msg string, args ...interface{})

func (*NullLogger) Error

func (n *NullLogger) Error(msg string, args ...interface{})

func (*NullLogger) Info

func (n *NullLogger) Info(msg string, args ...interface{})

func (*NullLogger) Warn

func (n *NullLogger) Warn(msg string, args ...interface{})

type OpLocator

type OpLocator struct {
	// Upper cased RP name, e.g. MICROSOFT.COMPUTE. This might be "" for API path that has no explicit RP defined (e.g. /subscriptions/{subscriptionId})
	// This can be "*" to indicate it maps any RP
	RP string
	// API version, e.g. 2020-10-01-preview
	Version string
	// Upper cased resource type, e.g. /VIRTUALNETWORKS/SUBNETS
	// Each subtype can be "*" to indicate it maps any sub type.
	RT string
	// Upper cased potential action/collection type, e.g. LISTKEYS (action), SUBNETS
	// This can be "*" to indicate it maps any RP
	ACT string
	// HTTP operation kind, e.g. GET
	Method OperationKind
}

type OperationInfo

type OperationInfo struct {
	Actions       map[string]OperationRefs `json:"actions,omitempty"`
	OperationRefs OperationRefs            `json:"operation_refs,omitempty"`
}

type OperationKind

type OperationKind string

type OperationRefs

type OperationRefs map[PathPatternStr]jsonreference.Ref

OperationRefs represents a set of operation defintion (in form of JSON reference) that are mapped by the same operation locator. Since for a given operation locator, there might maps to multiple operation definition, only differing by the contained path pattern, there fore the actual operation ref is keyed by the containing path pattern. The value is a JSON reference to the operation, e.g. <dir>/foo.json#/paths/~1subscriptions~1{subscriptionId}~1providers~1{resourceProviderNamespace}~1register/post

func (OperationRefs) MarshalJSON

func (o OperationRefs) MarshalJSON() ([]byte, error)

func (*OperationRefs) UnmarshalJSON

func (o *OperationRefs) UnmarshalJSON(b []byte) error

type PathPattern

type PathPattern struct {
	Segments []PathSegment
}

func ParsePathPatternFromString

func ParsePathPatternFromString(path string) *PathPattern

func ParsePathPatternFromSwagger

func ParsePathPatternFromSwagger(specFile string, swagger *spec.Swagger, path string, operation OperationKind) ([]PathPattern, error)

func (PathPattern) String

func (p PathPattern) String() string

type PathPatternStr

type PathPatternStr string

PathPatternStr represents an API path pattern, with all the fixed segment upper cased, and all the parameterized segment as a literal "{}", or "{*}" (for x-ms-skip-url-encoding).

type PathSegment

type PathSegment struct {
	FixedName   string
	IsParameter bool
	IsMulti     bool // indicates the x-ms-skip-url-encoding = true
}

type ResourceProviders

type ResourceProviders map[string]APIVersions

type ResourceTypes

type ResourceTypes map[string]*OperationInfo

type TagInfo

type TagInfo struct {
	InputFile []string `yaml:"input-file"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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