explorer

package
v0.0.0-...-430b99a Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package explorer contains the types and methods for relating OpenAPI operations to a set of Terraform Provider resource/data source actions (CRUD)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttributeOptions

type AttributeOptions struct {
	Aliases   map[string]string
	Overrides map[string]Override
}

type DataSource

type DataSource struct {
	ReadOp           *high.Operation
	CommonParameters []*high.Parameter
	SchemaOptions    SchemaOptions
}

DataSource contains a Read operation and schema options for configuration.

func (*DataSource) ReadOpParameters

func (e *DataSource) ReadOpParameters() []*high.Parameter

type Explorer

type Explorer interface {
	FindProvider() (Provider, error)
	FindResources() (map[string]Resource, error)
	FindDataSources() (map[string]DataSource, error)
}

Explorer implements methods that relate OpenAPI operations to a set of Terraform Provider resource/data source actions (CRUD)

func NewConfigExplorer

func NewConfigExplorer(spec high.Document, cfg config.Config) Explorer

A ConfigExplorer will use an additional config file to identify resource and data source operations in a provided OpenAPIv3 spec. This additional config file will provide information such as:

  • Create/Read/Update/Delete endpoints/URLs (schema will be automatically grabbed via request/response body and parameters in mapper)
  • Resource + Data Source names

func NewGuesstimatorExplorer

func NewGuesstimatorExplorer(spec high.Document) Explorer

As the name suggests, the Guesstimator evaluates an OpenAPIv3 spec and will return Resources, DataSources, and their respective names, based on RESTful conventions.

FindResources will group API paths together into collection operations and identity operations, then use the HTTP method to determine how to map to a terraform resource. A valid Resource will have a POST collection operation, GET identity operation, and a DELETE identity operation. The name of the Resource is a combination of the preceding paths, excluding any path parameters. An example of a valid Resource would be:

  • POST /org/{org_id}/users = Create operation for `org_users` resource
  • GET /org/{org_id}/users/{id} = Read operation for `org_users` resource
  • PUT /org/{org_id}/users/{id} = Update operation for `org_users` resource
  • DELETE /org/{org_id}/users/{id} = Delete operation for `org_users` resource

FindDataSources will group API paths together into collection operations and identity operations, then use the HTTP method to determine how to map to a terraform data source. A valid DataSource has a GET identity operation or a GET collection operation. The name of the DataSource is a combination of the preceding paths, excluding any path parameters, with an added suffix of "_collection" for the collection operation of a DataSource. An example of two valid DataSources would be:

  • GET /org/{org_id}/users = Read operation for `org_users_collection` data source
  • GET /org/{org_id}/users/{id} = Read operation for `org_users` data source

type Override

type Override struct {
	Description string
}

type Provider

type Provider struct {
	Name        string
	SchemaProxy *base.SchemaProxy
	Ignores     []string
}

Provider contains a name and a schema.

type Resource

type Resource struct {
	CreateOp         *high.Operation
	ReadOp           *high.Operation
	UpdateOp         *high.Operation
	DeleteOp         *high.Operation
	CommonParameters []*high.Parameter
	SchemaOptions    SchemaOptions
}

Resource contains CRUD operations and schema options for configuration.

func (*Resource) ReadOpParameters

func (e *Resource) ReadOpParameters() []*high.Parameter

type SchemaOptions

type SchemaOptions struct {
	Ignores          []string
	AttributeOptions AttributeOptions
}

Jump to

Keyboard shortcuts

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