core

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiscoveryMimeType added in v0.2.0

func DiscoveryMimeType(compression string) string

DiscoveryMimeType returns a MIME type for a Discovery description of an API.

func ExportComplexityToSheet

func ExportComplexityToSheet(ctx context.Context, name string, inputs []*rpc.Artifact) (string, error)

func ExportIndexToSheet

func ExportIndexToSheet(ctx context.Context, name string, index *rpc.Index) (string, error)

func ExportInt64ToSheet

func ExportInt64ToSheet(ctx context.Context, name string, artifacts []*rpc.Artifact) (string, error)

func ExportVersionHistoryToSheet

func ExportVersionHistoryToSheet(ctx context.Context, name string, artifact *rpc.Artifact) (string, error)

func ExportVocabularyToSheet

func ExportVocabularyToSheet(ctx context.Context, name string, vocabulary *metrics.Vocabulary) (string, error)

func GUnzippedBytes

func GUnzippedBytes(input []byte) ([]byte, error)

GUnzippedBytes uncompresses a slice of bytes.

func GZippedBytes

func GZippedBytes(input []byte) ([]byte, error)

GZippedBytes compresses a slice of bytes.

func GetAPI

func GetAPI(ctx context.Context,
	client *gapic.RegistryClient,
	name names.Api,
	handler ApiHandler) error

func GetArtifact added in v0.2.0

func GetArtifact(ctx context.Context,
	client *gapic.RegistryClient,
	name names.Artifact,
	getContents bool,
	handler ArtifactHandler) error

func GetBytesForSpec

func GetBytesForSpec(ctx context.Context, client connection.Client, spec *rpc.ApiSpec) ([]byte, error)

func GetDeployment added in v0.4.2

func GetDeployment(ctx context.Context,
	client *gapic.RegistryClient,
	name names.Deployment,
	handler DeploymentHandler) error

func GetDeploymentRevision added in v0.4.5

func GetDeploymentRevision(ctx context.Context,
	client *gapic.RegistryClient,
	name names.DeploymentRevision,
	handler DeploymentHandler) error

func GetProject

func GetProject(ctx context.Context,
	client *gapic.AdminClient,
	name names.Project,
	handler ProjectHandler) error

func GetSpec

func GetSpec(ctx context.Context,
	client *gapic.RegistryClient,
	name names.Spec,
	getContents bool,
	handler SpecHandler) error

func GetSpecRevision added in v0.4.5

func GetSpecRevision(ctx context.Context,
	client *gapic.RegistryClient,
	name names.SpecRevision,
	getContents bool,
	handler SpecHandler) error

func GetVersion

func GetVersion(ctx context.Context,
	client *gapic.RegistryClient,
	name names.Version,
	handler VersionHandler) error

func IndexUnion

func IndexUnion(inputs []*rpc.Index) *rpc.Index

func IsDiscovery added in v0.2.0

func IsDiscovery(mimeType string) bool

IsDiscovery returns true if a MIME type represents a Google API Discovery document.

func IsGZipCompressed added in v0.2.0

func IsGZipCompressed(mimeType string) bool

IsGZipCompressed returns true if a MIME type represents a type compressed with GZip encoding.

func IsOpenAPIv2 added in v0.2.0

func IsOpenAPIv2(mimeType string) bool

IsOpenAPIv2 returns true if a MIME type represents an OpenAPI v2 spec.

func IsOpenAPIv3 added in v0.2.0

func IsOpenAPIv3(mimeType string) bool

IsOpenAPIv3 returns true if a MIME type represents an OpenAPI v3 spec.

func IsProto added in v0.2.0

func IsProto(mimeType string) bool

IsProto returns true if a MIME type represents a Protocol Buffers Language API description.

func IsZipArchive added in v0.2.0

func IsZipArchive(mimeType string) bool

IsZipArchive returns true if a MIME type represents a type stored as a multifile Zip archive.

func ListAPIs

func ListAPIs(ctx context.Context,
	client *gapic.RegistryClient,
	name names.Api,
	filter string,
	handler ApiHandler) error

func ListArtifacts added in v0.2.0

func ListArtifacts(ctx context.Context,
	client *gapic.RegistryClient,
	name names.Artifact,
	filter string,
	getContents bool,
	handler ArtifactHandler) error

func ListDeploymentRevisions added in v0.4.5

func ListDeploymentRevisions(ctx context.Context,
	client *gapic.RegistryClient,
	name names.Deployment,
	filterFlag string,
	handler DeploymentHandler) error

func ListDeployments added in v0.4.2

func ListDeployments(ctx context.Context,
	client *gapic.RegistryClient,
	name names.Deployment,
	filter string,
	handler DeploymentHandler) error

func ListProjects

func ListProjects(ctx context.Context,
	client *gapic.AdminClient,
	name names.Project,
	filter string,
	handler ProjectHandler) error

func ListSpecRevisions

func ListSpecRevisions(ctx context.Context,
	client *gapic.RegistryClient,
	name names.Spec,
	filterFlag string,
	handler SpecHandler) error

func ListSpecs

func ListSpecs(ctx context.Context,
	client *gapic.RegistryClient,
	name names.Spec,
	filter string,
	handler SpecHandler) error

func ListVersions

func ListVersions(ctx context.Context,
	client *gapic.RegistryClient,
	name names.Version,
	filter string,
	handler VersionHandler) error

func MessageTypeForMimeType added in v0.2.0

func MessageTypeForMimeType(protoType string) (string, error)

MessageTypeForMimeType returns the Protocol Buffer message type represented by a MIME type.

func MimeTypeForMessageType added in v0.2.0

func MimeTypeForMessageType(protoType string) string

MimeTypeForMessageType returns a MIME type that represents a Protocol Buffer message type.

func NewIndexFromZippedProtos

func NewIndexFromZippedProtos(b []byte) (*rpc.Index, error)

func NewLintFromOpenAPI added in v0.2.0

func NewLintFromOpenAPI(name string, spec []byte, linter string) (*rpc.Lint, error)

NewLintFromOpenAPI runs the API linter and returns the results.

func NewLintFromZippedProtos added in v0.2.0

func NewLintFromZippedProtos(name string, b []byte) (*rpc.Lint, error)

NewLintFromZippedProtos runs the API linter and returns the results.

func NewReferencesFromZippedProtos added in v0.2.1

func NewReferencesFromZippedProtos(b []byte) (*rpc.References, error)

NewReferencesFromZippedProtos computes references of a Protobuf spec.

func NewVocabularyFromZippedProtos

func NewVocabularyFromZippedProtos(b []byte) (*metrics.Vocabulary, error)

func OpenAPIMimeType added in v0.2.0

func OpenAPIMimeType(compression, version string) string

OpenAPIMimeType returns a MIME type for an OpenAPI description of an API.

func PrintAPI

func PrintAPI(api *rpc.Api) error

func PrintAPIDetail

func PrintAPIDetail(message *rpc.Api) error

func PrintArtifact added in v0.2.0

func PrintArtifact(artifact *rpc.Artifact) error

func PrintArtifactContents added in v0.2.0

func PrintArtifactContents(artifact *rpc.Artifact) error

func PrintArtifactDetail added in v0.2.0

func PrintArtifactDetail(artifact *rpc.Artifact) error

func PrintDeployment added in v0.4.2

func PrintDeployment(deployment *rpc.ApiDeployment) error

func PrintDeploymentDetail added in v0.4.2

func PrintDeploymentDetail(message *rpc.ApiDeployment) error

func PrintMessage

func PrintMessage(message proto.Message)

func PrintProject

func PrintProject(project *rpc.Project) error

func PrintProjectDetail

func PrintProjectDetail(message *rpc.Project) error

func PrintSpec

func PrintSpec(spec *rpc.ApiSpec) error

func PrintSpecContents

func PrintSpecContents(message *rpc.ApiSpec) error

func PrintSpecDetail

func PrintSpecDetail(message *rpc.ApiSpec) error

func PrintVersion

func PrintVersion(version *rpc.ApiVersion) error

func PrintVersionDetail

func PrintVersionDetail(message *rpc.ApiVersion) error

func ProtobufMimeType added in v0.2.1

func ProtobufMimeType(compression string) string

ProtobufMimeType returns a MIME type for a Protocol Buffers description of an API.

func SetArtifact added in v0.2.0

func SetArtifact(ctx context.Context,
	client *gapic.RegistryClient,
	artifact *rpc.Artifact) error

func SummarizeDiscoveryDocument

func SummarizeDiscoveryDocument(document *discovery.Document) *metrics.Complexity

func SummarizeOpenAPIv2Document

func SummarizeOpenAPIv2Document(document *openapi_v2.Document) *metrics.Complexity

func SummarizeOpenAPIv3Document

func SummarizeOpenAPIv3Document(document *openapi_v3.Document) *metrics.Complexity

func SummarizeZippedProtos added in v0.4.5

func SummarizeZippedProtos(b []byte) (*metrics.Complexity, error)

func UnzipArchiveToMap added in v0.4.5

func UnzipArchiveToMap(b []byte) (map[string][]byte, error)

UnzipArchiveToMap will decompress a zip archive to a map. May be memory intensive for large zip archives.

func UnzipArchiveToPath

func UnzipArchiveToPath(b []byte, dest string) ([]string, error)

UnzipArchiveToPath will decompress a zip archive, writing all files and folders within the zip archive (parameter 1) to an output directory (parameter 2). Based on an example published at https://golangcode.com/unzip-files-in-go/

func WorkerPool added in v0.3.1

func WorkerPool(ctx context.Context, n int) (chan<- Task, func())

This function creates a waitgroup and a taskQueue for the workerPool. It will create "n" workers which will listen for Tasks on the taskQueue. It returns the taskQueue and a wait func. The clients should add new tasks to this taskQueue and call the call the wait func when done. Do not separately close the taskQueue, make use of the wait func.

func WorkerPoolWithWarnings added in v0.4.5

func WorkerPoolWithWarnings(ctx context.Context, n int) (chan<- Task, func())

Similar to WorkerPool except it creates workers which log task errors as "Warnings"

func ZipArchiveOfPath

func ZipArchiveOfPath(path, prefix string, recursive bool) (buf bytes.Buffer, err error)

ZipArchiveOfPath reads the contents of a path into a zip archive. The specified prefix is stripped from file names in the archive. Based on an example published at https://golangcode.com/create-zip-files-in-go/

Types

type ApiHandler

type ApiHandler func(*rpc.Api) error

type ArtifactHandler added in v0.2.0

type ArtifactHandler func(*rpc.Artifact) error

type DeploymentHandler added in v0.4.2

type DeploymentHandler func(*rpc.ApiDeployment) error

type Details added in v0.2.0

type Details struct {
	Title    string
	Services []string
}

Details contains details about a spec.

func NewDetailsFromZippedProtos added in v0.2.0

func NewDetailsFromZippedProtos(ctx context.Context, b []byte) (*Details, error)

NewDetailsFromZippedProtos returns a Details structure describing a spec.

type Labeling added in v0.3.0

type Labeling struct {
	Overwrite bool
	Set       map[string]string
	Clear     []string
}

Labeling represents a user-specified change to a set of labels or annotations. Note that this same structure is used for both labels and annotations.

func (*Labeling) Apply added in v0.3.0

func (l *Labeling) Apply(m map[string]string) (map[string]string, error)

Apply applies a labeling to a map. It returns the modified map because it creates the map if nil is passed in.

type ProjectHandler

type ProjectHandler func(*rpc.Project) error

type ServiceConfig added in v0.4.5

type ServiceConfig struct {
	Type  string `yaml:"type"`
	Title string `yaml:"title"`
}

The API Service Configuration contains important API properties.

type SheetsClient

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

SheetsClient represents a client of the Sheets API.

func NewSheetsClient

func NewSheetsClient(ctx context.Context, id string) (*SheetsClient, error)

NewSheetsClient creates an authenticated client of the Sheets API.

func (*SheetsClient) CreateSheet

func (sc *SheetsClient) CreateSheet(title string, sheetTitles []string) (*sheets.Spreadsheet, error)

CreateSheet creates a new spreadsheet and configures the client to point to it.

func (*SheetsClient) Fetch

func (sc *SheetsClient) Fetch(ctx context.Context, cellRange string) (*sheets.ValueRange, error)

Fetch gets the contents of the configured sheet.

func (*SheetsClient) FormatHeaderRow

func (sc *SheetsClient) FormatHeaderRow(ctx context.Context, sheetId int64) (*sheets.BatchUpdateSpreadsheetResponse, error)

FormatHeaderRow freezes and bolds the top row of the configured sheet.

func (*SheetsClient) Update

func (sc *SheetsClient) Update(ctx context.Context, cellRange string, values [][]interface{}) (*sheets.UpdateValuesResponse, error)

Update updates a range of values in the configured sheet.

type SpecHandler

type SpecHandler func(*rpc.ApiSpec) error

type SpectralLintLocation added in v0.2.0

type SpectralLintLocation struct {
	Line      int32 `json:"line"`
	Character int32 `json:"character"`
}

type SpectralLintRange added in v0.2.0

type SpectralLintRange struct {
	Start SpectralLintLocation `json:"start"`
	End   SpectralLintLocation `json:"end"`
}

type SpectralLintResult added in v0.2.0

type SpectralLintResult struct {
	Code     string            `json:"code"`
	Path     []string          `json:"path"`
	Message  string            `json:"message"`
	Severity int32             `json:"severity"`
	Range    SpectralLintRange `json:"range"`
	Source   string            `json:"source"`
}

type Task

type Task interface {
	Run(ctx context.Context) error
	String() string
}

Task is a generic interface for a runnable operation

type VersionHandler

type VersionHandler func(*rpc.ApiVersion) error

type Vocabulary

type Vocabulary struct {
	Schemas    map[string]int
	Operations map[string]int
	Parameters map[string]int
	Properties map[string]int
}

Vocabulary represents the counts of various types of terms in an API.

Jump to

Keyboard shortcuts

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