Documentation
¶
Overview ¶
Package holds higher-level abstractions on top of OpenAPI that are used to generate code via text/template for Databricks SDK in different languages.
Index ¶
- Variables
- type Batch
- type Binding
- type Entity
- func (e *Entity) CamelName() string
- func (e *Entity) Enum() (enum []EnumEntry)
- func (e *Entity) Field(name string) *Field
- func (e *Entity) Fields() (fields []Field)
- func (e *Entity) FullName() string
- func (e *Entity) HasIdentifierField() bool
- func (e *Entity) HasNameField() bool
- func (e *Entity) IdentifierField() *Field
- func (e *Entity) IsExternal() bool
- func (e *Entity) IsNumber() bool
- func (e *Entity) IsObject() bool
- func (e *Entity) PascalName() string
- type EnumEntry
- type Field
- type Method
- type Named
- func (n *Named) CamelName() string
- func (n *Named) Comment(prefix string, maxLen int) string
- func (n *Named) ConstantName() string
- func (n *Named) FirstSentence() string
- func (n *Named) HasComment() bool
- func (n *Named) IsNameReserved() bool
- func (n *Named) KebabName() string
- func (n *Named) PascalName() string
- func (n *Named) Singular() *Named
- func (n *Named) SnakeName() string
- func (n *Named) TitleName() string
- type NamedIdMap
- type Package
- func (pkg *Package) EmptyTypes() (types []*Named)
- func (pkg *Package) FullName() string
- func (pkg *Package) HasPagination() bool
- func (pkg *Package) HasPathParams() bool
- func (pkg *Package) HasWaits() bool
- func (pkg *Package) ImportedEntities() (res []*Entity)
- func (pkg *Package) ImportedPackages() (res []string)
- func (pkg *Package) Load(spec *openapi.Specification, tag *openapi.Tag) error
- func (pkg *Package) Services() (types []*Service)
- func (pkg *Package) Types() (types []*Entity)
- type Pagination
- type PathPart
- type Service
- type Shortcut
- type Wait
- func (w *Wait) Binding() (binding []Binding)
- func (w *Wait) ComplexMessagePath() bool
- func (w *Wait) Failure() (match []EnumEntry)
- func (w *Wait) ForceBindRequest() bool
- func (w *Wait) MessagePath() (path []*Field)
- func (w *Wait) MessagePathHead() *Field
- func (w *Wait) Poll() *Method
- func (w *Wait) StatusPath() (path []*Field)
- func (w *Wait) Success() (match []EnumEntry)
- func (w *Wait) Timeout() int
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
func NewFromFile ¶
NewFromFile loads OpenAPI specification from file
type Binding ¶
type Binding struct {
// Polling method request field
PollField *Field
// Wrapped method either response or request body field
Bind *Field
// Is wrapped method response used?
IsResponseBind bool
}
Binding connects fields in generated code across multiple requests
type Entity ¶
type Entity struct {
Named
Package *Package
ArrayValue *Entity
MapValue *Entity
IsInt bool
IsInt64 bool
IsFloat64 bool
IsBool bool
IsString bool
IsEmpty bool
// this field does not have a concrete type
IsAny bool
// this field holds the identifier of the entity
IsIdentifier bool
// this field holds a name of the entity
IsName bool
// this field is computed on the platform side
IsComputed bool
// if entity has required fields, this is the order of them
RequiredOrder []string
// contains filtered or unexported fields
}
Entity represents a Type
func (*Entity) CamelName ¶
CamelName overrides parent implementation by appending List suffix for unnamed list types
func (*Entity) HasIdentifierField ¶
Does this type have x-databricks-id field?
func (*Entity) HasNameField ¶
Does this type have x-databricks-name field?
func (*Entity) IdentifierField ¶
Return field with x-databricks-id
func (*Entity) IsExternal ¶
IsExternal returns true if entity is declared in external package and has to be imported from it
func (*Entity) IsObject ¶
IsObject returns true if entity is not a Mpa and has more than zero fields
func (*Entity) PascalName ¶
PascalName overrides parent implementation by appending List suffix for unnamed list types
type Field ¶
type Field struct {
Named
Required bool
Entity *Entity
Of *Entity
IsJson bool
IsPath bool
IsQuery bool
Schema *openapi.Schema
}
Field of a Type (Entity)
func (*Field) IsOptionalObject ¶
type Method ¶
type Method struct {
Named
Service *Service
// HTTP method name
Verb string
// Full API Path, including /api/2.x prefix
Path string
// Slice of path params, e.g. permissions/{type}/{id}
PathParts []PathPart
// Request type representation
Request *Entity
// Response type representation
Response *Entity
EmptyResponseName Named
// contains filtered or unexported fields
}
Method represents service RPC
func (*Method) CanHaveResponseBody ¶
func (*Method) GetByName ¶
GetByName returns entity from the same service with x-databricks-crud:read
func (*Method) NamedIdMap ¶
func (m *Method) NamedIdMap() *NamedIdMap
NamedIdMap returns name-to-id mapping retrieval definition for all entities of a type
func (*Method) Pagination ¶
func (m *Method) Pagination() *Pagination
Pagination returns definition for possibly multi-request result iterator
type Named ¶
Named holds common methods for identifying and describing things
func (*Named) Comment ¶
Comment formats description into language-specific comment multi-line strings
func (*Named) ConstantName ¶
ConstantName creates NAMES_LIKE_THIS
func (*Named) FirstSentence ¶ added in v0.1.1
func (*Named) HasComment ¶
func (*Named) IsNameReserved ¶
type NamedIdMap ¶
type NamedIdMap struct {
Named
Id *Field
NamePath []*Field
Entity *Entity
// if List method returns []Item directly
// without generated iteration wrapper
Direct bool
}
NamedIdMap depends on Pagination and is generated, when paginated item entity has Identifier and Name fields. End-users usually use this method for drop-downs or any other selectors.
type Package ¶
type Package struct {
Named
Components *openapi.Components
// contains filtered or unexported fields
}
Package represents a service package, which contains entities and interfaces that are relevant to a single service
func (*Package) EmptyTypes ¶
EmptyTypes returns sorted list of types without fields
func (*Package) HasPagination ¶
HasPagination returns try if any service within this package has result iteration
func (*Package) HasPathParams ¶
HasPathParams returns true if any service has methods that rely on path params
func (*Package) HasWaits ¶
HasWaits returns true if any service has methods with long-running operations
func (*Package) ImportedEntities ¶
func (*Package) ImportedPackages ¶
type Pagination ¶
type Pagination struct {
Offset *Field
Limit *Field
Results *Field
Entity *Entity
Token *Binding
Increment int
}
Pagination holds definition of result iteration type per specific RPC. Databricks as of now has a couple different types of pagination:
- next_token/next_page_token + repeated field
- offset/limit with zero-based offsets + repeated field
- page/limit with 1-based pages + repeated field
- repeated inline field
- repeated field
func (*Pagination) MultiRequest ¶
func (p *Pagination) MultiRequest() bool
func (*Pagination) NeedsOffsetDedupe ¶
func (p *Pagination) NeedsOffsetDedupe() bool
type Service ¶
type Service struct {
Named
IsRpcStyle bool
IsAccounts bool
Package *Package
ByPathParamsMethods []*Shortcut
// contains filtered or unexported fields
}
Service represents specific Databricks API
func (*Service) HasPagination ¶
HasPagination returns true if any method has result iteration
func (*Service) MatchesPackageName ¶
MatchesPackageName if package name and service name are the same, e.g. `clusters` package & `Clusters` service
type Shortcut ¶
Shortcut holds definition of "shortcut" methods, that are generated for methods with request entities only with required fields.
type Wait ¶
type Wait struct {
// represents a method that triggers the start of the long-running operation
Method *Method
}
Wait represents a long-running operation, that requires multiple RPC calls
func (*Wait) ComplexMessagePath ¶
func (*Wait) ForceBindRequest ¶
ForceBindRequest is a workaround for Jobs#RepairRun, that does not send run_id in response
func (*Wait) MessagePath ¶
MessagePath holds the path to the field of polled entity, that can tell about current inner status of the long-running operation
func (*Wait) MessagePathHead ¶
func (*Wait) Poll ¶
Poll returns method definition for checking the state of the long running operation
func (*Wait) StatusPath ¶
StatusPath holds the path to the field of polled entity, that holds current state of the long-running operation