clispec

package
v0.0.0-...-0a03860 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Name        string       `json:"name,omitempty"`
	Description string       `json:"description,omitempty"`
	APISummary  string       `json:"apiSummary,omitempty"`
	Path        string       `json:"path,omitempty"`
	Verb        string       `json:"verb,omitempty"`
	Parameters  []*Parameter `json:"parameters,omitempty"`
	RequestBody *RequestBody `json:"requestBody,omitempty"`
	Response    *Response    `json:"response,omitempty"`
}

Command represents a Chronosphere CLI command

func (*Command) SupportsDryRun

func (c *Command) SupportsDryRun() bool

SupportsDryRun determines in the endpoint has support for dry-run.

type Entity

type Entity struct {
	Name   string   `json:"name,omitempty"`
	Create *Command `json:"create,omitempty"`
	Get    *Command `json:"get,omitempty"`
	Update *Command `json:"update,omitempty"`
	Delete *Command `json:"delete,omitempty"`
	List   *Command `json:"list,omitempty"`
	Type   *Type    `json:"type,omitempty"`

	IsSingleton bool
}

Entity represents a Chronosphere entity exposed by the public API (e.g. a "monitor")

func (*Entity) IsNotSingleton

func (e *Entity) IsNotSingleton() bool

IsNotSingleton determines if the entity is not a singleton. Helper for templates.

func (*Entity) ScaffoldYAML

func (e *Entity) ScaffoldYAML() (string, error)

ScaffoldYAML returns a valid config/v1 object of the entity.

func (*Entity) SupportsForceDelete

func (e *Entity) SupportsForceDelete() bool

type Parameter

type Parameter struct {
	Name        string         `json:"name,omitempty"`
	Description string         `json:"description,omitempty"`
	Place       ParameterPlace `json:"place,omitempty"`
	GoType      string         `json:"goType,omitempty"`
	Required    bool           `json:"required,omitempty"`
}

Parameter represents a parameter to a Chronosphere API that must be provided by the user

func (*Parameter) FlagType

func (p *Parameter) FlagType() string

FlagType returns the function name we expect to use for the given parameter type.

func (*Parameter) SwaggerName

func (p *Parameter) SwaggerName() string

SwaggerName returns the name of the field in the Swagger generated List parameters.

type ParameterPlace

type ParameterPlace string

ParameterPlace is a string that represents the location of a parameter in a request

const (
	// PlacePath represents a parameter that is in the path of a request (e.g. /foo/{bar})
	PlacePath ParameterPlace = "path"
	// PlaceQuery represents a parameter that is in the query string of a request (e.g. ?foo=bar)
	PlaceQuery ParameterPlace = "query"
	// PlaceBody represents a parameter that is in the body of a request
	PlaceBody ParameterPlace = "body"
)

type RequestBody

type RequestBody struct {
	Required bool  `json:"required,omitempty"`
	Schema   *Type `json:"schema,omitempty"`
}

RequestBody represents the request body of a Chronosphere API request

type Response

type Response struct {
	IsArray bool  `json:"isArray,omitempty"`
	Schema  *Type `json:"schema,omitempty"`
}

Response represents the response from a Chronosphere API request

type Spec

type Spec struct {
	Name     string             `json:"name,omitempty"`
	BasePath string             `json:"basePath,omitempty"`
	Entities map[string]*Entity `json:"entities,omitempty"`
}

Spec is the top-level struct that represents the Chronosphere CLI spec

func Parse

func Parse(path string) (*Spec, error)

Parse will parse the swagger spec at the given path and return a *cli.Spec

type Type

type Type struct {
	APIVersion string                `json:"apiVersion,omitempty"`
	Kind       string                `json:"kind,omitempty"`
	Properties spec.SchemaProperties `json:"properties,omitempty"`
}

Type represents a type for the input/output files that chronoctl writes

Jump to

Keyboard shortcuts

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