pkg

package
v0.0.0-...-3c2683d Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToPascalCase

func ToPascalCase(s string) string

ToPascalCase converts a string to PascalCase.

func ToSdkName

func ToSdkName(s string) string

ToSdkName converts a property or attribute name to the lowerCamelCase convention that is used in Pulumi schema's properties.

Types

type CRUDOperationsMap

type CRUDOperationsMap struct {
	// C represents the POST (create) endpoint.
	C *string `json:"c,omitempty"`
	// R represents the GET (read) endpoint.
	R *string `json:"r,omitempty"`
	// U represents the PATCH endpoint.
	U *string `json:"u,omitempty"`
	// D represents the DELETE endpoint.
	D *string `json:"d,omitempty"`

	// P represents the PUT (overwrite/update) endpoint.
	P *string `json:"p,omitempty"`
}

CRUDOperationsMap identifies the endpoints to perform create, read, update and delete (CRUD) operations.

type OpenAPIContext

type OpenAPIContext struct {
	// Doc is the parsed, validated OpenAPI spec.
	Doc openapi3.T
	// Pkg is the Pulumi schema spec.
	Pkg *pschema.PackageSpec
	// ExcludedPaths is a slice of API endpoint paths
	// that should be skipped.
	ExcludedPaths []string
	// UseParentResourceAsModule indicates whether an endpoint
	// operation's parent resource should be used as the module
	// for a resource rather than using the root path of the
	// endpoint.
	// For example, when extracting a resource for the endpoint
	// `/rootResource/v1/subResource`, with this set to `true`,
	// the `subResource` will be under the module `subResource`
	// instead of `rootResource` module. This is useful to avoid
	// conflicts arising from properties named similarly in different
	// resource that are actually different despite their names.
	//
	// Another example is `rootResource/v1/subResource/{id}/secondResource`.
	// The resource called `secondResource` will be in a module called
	// `subResource` instead of a module called `rootResource`.
	UseParentResourceAsModule bool

	// OperationIdsHaveTypeSpecNamespace indicates if the API operation IDs
	// are separated by the CADL namespace they were defined in.
	OperationIdsHaveTypeSpecNamespace bool

	// TypeSpecNamespaceSeparator is the separator used in the operationId value.
	TypeSpecNamespaceSeparator string
	// contains filtered or unexported fields
}

OpenAPIContext represents an OpenAPI spec from which a Pulumi package spec can be extracted.

func (*OpenAPIContext) GatherResourcesFromAPI

func (o *OpenAPIContext) GatherResourcesFromAPI(csharpNamespaces map[string]string) (*ProviderMetadata, openapi3.T, error)

GatherResourcesFromAPI gathers resources from API endpoints. The goal is to extract resources and map their corresponding CRUD operations.

  • The "create" operation (denoted by a Post request) determines the schema for the resource.
  • The "read" operation (denoted by a Get request) determines the schema for "invokes" or "resource get's".
  • The "update" operation (denoted by a Patch request) determines the schema for resource updates. The Patch request schema is used to determine which properties can be patched when changes are detected in Diff() vs. which ones will force a resource replacement.

type ProviderMetadata

type ProviderMetadata struct {
	// ResourceToOperationMap identifies the endpoint that will
	// handle the CRUD for a given Pulumi resource type token.
	ResourceCRUDMap map[string]*CRUDOperationsMap `json:"crudMap"`

	// AutoNameMap is a map of resource type token and the name
	// property that can be auto-named by the provider.
	AutoNameMap map[string]string `json:"autoNameMap"`

	// SDKToAPINameMap is a map of a property's name in the Pulumi
	// schema to its actual API name. Can be nil.
	SDKToAPINameMap map[string]string `json:"sdkToApiNameMap"`
	// APIToSDKNameMap is the inverse of SDKToAPINameMap.
	APIToSDKNameMap map[string]string `json:"apiToSdkNameMap"`

	// PathParamNameMap is a map of a path param's original name to
	// its Pulumi schema name. Can be nil.
	PathParamNameMap map[string]string `json:"pathParamNameMap"`
}

ProviderMetadata represents metadata used by a provider.

Jump to

Keyboard shortcuts

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