java

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: Apache-2.0 Imports: 27 Imported by: 10

Documentation

Overview

Copyright 2022, Pulumi Corporation. All rights reserved.

Default value and config value code-generation facilities for SDK generation are kept in this separate file as they are a bit intricate.

Index

Constants

View Source
const (
	// MissingKeyErrorOption is the renderer option to stop execution immediately with an error on missing key
	MissingKeyErrorOption = "missingkey=error"
)

Variables

View Source
var Importer schema.Language = importer(0)

Importer implements schema.Language for Java

Functions

func GeneratePackage

func GeneratePackage(tool string, pkg *schema.Package, extraFiles map[string][]byte) (map[string][]byte, error)

func GenerateProgram

func GenerateProgram(program *pcl.Program) (map[string][]byte, hcl.Diagnostics, error)

func GenerateProject

func GenerateProject(directory string, project workspace.Project, program *pcl.Program) error

func LanguageResources

func LanguageResources(tool string, pkg *schema.Package) (map[string]LanguageResource, error)

LanguageResources returns a map of resources that can be used by downstream codegen. The map key is the resource schema token.

func Template

func Template(name string, text string) *tmplt.Template

Types

type DocLanguageHelper

type DocLanguageHelper struct{}

DocLanguageHelper is the Java-specific implementation of the similarly named codegen interface.

func (DocLanguageHelper) GetDocLinkForFunctionInputOrOutputType

func (d DocLanguageHelper) GetDocLinkForFunctionInputOrOutputType(
	pkg *schema.Package, modName, typeName string, input bool,
) string

func (DocLanguageHelper) GetDocLinkForPulumiType

func (d DocLanguageHelper) GetDocLinkForPulumiType(pkg *schema.Package, typeName string) string

TODO revisit once javadocs are published.

Not every language currently supports this. For Python docsgen the implementation returns "" also.

For an example of a language that supports this, check out Go.

When visiting https://www.pulumi.com/registry/packages/aws/api-docs/s3/bucket/ search for `func NewBucket`.

Context, BucketArgs and ResourceOption get linked to Go API docs.

For Java we could link to JavaDoc when appropriate.

func (DocLanguageHelper) GetDocLinkForResourceInputOrOutputType

func (d DocLanguageHelper) GetDocLinkForResourceInputOrOutputType(
	pkg *schema.Package, modName, typeName string, input bool,
) string

func (DocLanguageHelper) GetDocLinkForResourceType

func (d DocLanguageHelper) GetDocLinkForResourceType(pkg *schema.Package, modName, typeName string) string

func (DocLanguageHelper) GetEnumName

func (d DocLanguageHelper) GetEnumName(e *schema.Enum, typeName string) (string, error)

func (DocLanguageHelper) GetFunctionName

func (d DocLanguageHelper) GetFunctionName(modName string, f *schema.Function) string

func (DocLanguageHelper) GetLanguageTypeString

func (d DocLanguageHelper) GetLanguageTypeString(
	pkg *schema.Package, moduleName string, t schema.Type, input bool,
) string

func (DocLanguageHelper) GetMethodName

func (d DocLanguageHelper) GetMethodName(m *schema.Method) string

func (DocLanguageHelper) GetMethodResultName

func (d DocLanguageHelper) GetMethodResultName(
	pkg *schema.Package, modName string, r *schema.Resource, m *schema.Method,
) string
func (d DocLanguageHelper) GetModuleDocLink(pkg *schema.Package, modName string) (string, string)

func (DocLanguageHelper) GetPropertyName

func (d DocLanguageHelper) GetPropertyName(p *schema.Property) (string, error)

func (DocLanguageHelper) GetResourceFunctionResultName

func (d DocLanguageHelper) GetResourceFunctionResultName(modName string, f *schema.Function) string

type LanguageResource

type LanguageResource struct {
	*schema.Resource

	Name    string // The resource name (e.g. Deployment)
	Package string // The package name (e.g. apps.v1)
}

LanguageResource is derived from the schema and can be used by downstream codegen.

type MethodCall

type MethodCall struct {
	This   string
	Method string
	Args   []string
}

func (MethodCall) String

func (m MethodCall) String() string

type PackageInfo

type PackageInfo struct {
	// Overrides how Schema packages names translate to Java
	// package names.
	//
	// Absent an entry in Packages, Java code generator tries to
	// do something reasonable and produce a Java looking name for
	// a given Schema package. If this undesirable, adding an
	// entry in Packages will specify the desired Java name
	// manually.
	//
	// For example, pulumi-kubernetes specifies Packages names for
	// versioned API packages like this:
	//
	//     packages:
	//       "admissionregistration.k8s.io/v1: "admissionregistration.v1"
	//
	Packages map[string]string `json:"packages,omitempty"`

	// The prefix of the Java package to generate.
	//
	// Defaults to "com.pulumi".
	//
	// The generated Java code will start with:
	//
	//     package ${BasePackage}.${pkg.Name};
	//
	// Note that pkg.Name is coming from the Schema.
	//
	// For example, if the package is named "azuread" then the
	// generated code will be placed under:
	//
	//     package com.pulumi.azuread
	//
	// And if BasePackage is set to "com.myorg" then the generated
	// code will instead be placed under:
	//
	//     package com.myorg.azuread
	//
	BasePackage string `json:"basePackage"`

	// If set to "gradle" enables a generation of a basic set of
	// Gradle build files.
	BuildFiles string `json:"buildFiles"`

	// Specifies Maven-style dependencies for the generated code.
	//
	// The dependency on Java SDK (com.pulumi:pulumi) is special
	// and will be auto-popualted if not specified here.
	//
	// Other dependencies need to be specified if:
	//
	// - the package references types from other packages
	//
	// - the code generator is asked to emit build files, as in
	//   BuildFiles="gradle", and produce a compiling project
	//
	// For example, pulumi-eks referenes pulumi-aws types, and can
	// specify the desired version:
	//
	//     dependencies:
	//       "com.pulumi:aws": "5.4.0"
	Dependencies map[string]string `json:"dependencies,omitempty"`

	// If non-empty and BuildFiles="gradle", enables the use of a
	// given version of io.github.gradle-nexus.publish-plugin in
	// the generated Gradle build files.
	GradleNexusPublishPluginVersion string `json:"gradleNexusPublishPluginVersion"`

	// If non-empty and BuildFiles="gradle", generates a test
	// section to enable `gradle test` command to run unit tests
	// over the generated code. Supported values: "JUnitPlatform".
	GradleTest string `json:"gradleTest"`
}

PackageInfo defines Java-specific extensions to Pulumi Packages Schema.

These options affect how GeneratePackage generates and lays out Java SDKs for Pulumi Packages.

The options are typically set in the .language.java section of the Schema, but can also be overridden during code generation:

pulumi-java-gen generate --override overrides.json

See https://www.pulumi.com/docs/guides/pulumi-packages/schema/#language-specific-extensions

func (PackageInfo) BasePackageOrDefault

func (i PackageInfo) BasePackageOrDefault() string

func (PackageInfo) With added in v0.2.1

func (i PackageInfo) With(overrides PackageInfo) PackageInfo

func (PackageInfo) WithDefaultDependencies added in v0.5.2

func (i PackageInfo) WithDefaultDependencies() PackageInfo

Makes sure dependencies are added for libraries that the generated code may link against.

func (PackageInfo) WithDependencyDefault added in v0.5.2

func (i PackageInfo) WithDependencyDefault(key string, ver semver.Version) PackageInfo

Makes sure Depdendencies contains the key if it does not already. If the key is missing, uses ver as the new version to depend on.

func (PackageInfo) WithJavaSdkDependencyDefault added in v0.5.2

func (i PackageInfo) WithJavaSdkDependencyDefault(ver semver.Version) PackageInfo

Makes sure Depdendencies contains the "com.pulumi:pulumi" key if it does not already. If the key is missing, uses ver as the new version to depend on.

type PropertyInfo

type PropertyInfo struct {
	Name string `json:"name,omitempty"`
}

PropertyInfo represents a Java language-specific info for a property.

type TypeShape

type TypeShape struct {
	Type        names.FQN
	Parameters  []TypeShape
	Annotations []string
}

func (TypeShape) Equal

func (ts TypeShape) Equal(other TypeShape) bool

func (TypeShape) ListType

func (ts TypeShape) ListType(ctx *classFileContext) string

func (TypeShape) Optional

func (ts TypeShape) Optional() TypeShape

func (TypeShape) Output added in v0.4.0

func (ts TypeShape) Output() TypeShape

func (TypeShape) ParameterTypes

func (ts TypeShape) ParameterTypes(imports *names.Imports) []string

func (TypeShape) ParameterTypesTransformed

func (ts TypeShape) ParameterTypesTransformed(f func(TypeShape) string) []string

func (TypeShape) StringJavaTypeShape

func (ts TypeShape) StringJavaTypeShape(imports *names.Imports) string

StringJavaTypeShape returns a Java code representation.

func (TypeShape) ToCode

func (ts TypeShape) ToCode(imports *names.Imports) string

ToCode converts to Java code, may add imports to use short names.

func (TypeShape) ToCodeClassLiteral

func (ts TypeShape) ToCodeClassLiteral(imports *names.Imports) string

ToCodeClassLiteral converts to Java class literal, may add imports to use short names.

func (TypeShape) ToCodeCommentedAnnotations

func (ts TypeShape) ToCodeCommentedAnnotations(imports *names.Imports) string

func (TypeShape) ToCodeErased

func (ts TypeShape) ToCodeErased(imports *names.Imports) string

ToCodeErased converts to Java code with erased generics, may add imports to use short names.

func (TypeShape) ToCodeWithOptions

func (ts TypeShape) ToCodeWithOptions(imports *names.Imports, opts TypeShapeStringOptions) string

func (TypeShape) ToTree added in v0.6.0

func (ts TypeShape) ToTree(imports *names.Imports) (string, string)

func (TypeShape) UnEither

func (ts TypeShape) UnEither() (bool, TypeShape, TypeShape)

func (TypeShape) UnList

func (ts TypeShape) UnList() (bool, TypeShape)

func (TypeShape) UnNullable

func (ts TypeShape) UnNullable() (bool, TypeShape)

func (TypeShape) UnOptional

func (ts TypeShape) UnOptional() (bool, TypeShape)

func (TypeShape) UnOutput

func (ts TypeShape) UnOutput() (bool, TypeShape)

func (TypeShape) WithoutAnnotations

func (ts TypeShape) WithoutAnnotations() TypeShape

type TypeShapeStringOptions

type TypeShapeStringOptions struct {
	// useful for type parameters because (most) annotations are not allowed on a generic parameter type
	CommentOutAnnotations bool
	// useful for annotation parameters and other contexts where comments or annotations are not allowed
	SkipAnnotations bool
	// useful for .class or [].class to skip the generic part of the type
	GenericErasure bool
	// useful to append .class
	AppendClassLiteral bool
	// useful to append [].class
	AppendClassArrayLiteral bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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