client

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 20 Imported by: 2

Documentation

Overview

Package client implements a client for the Pulumi Service HTTP/REST API. Important note: This client is not versioned, and not intended for external use at this time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckEnvironmentResponse

type CheckEnvironmentResponse struct {
	Diagnostics []EnvironmentDiagnostic `json:"diagnostics,omitempty"`
}

type Client

type Client interface {
	// Insecure returns true if this client is insecure (i.e. has TLS disabled).
	Insecure() bool

	// URL returns the URL of the API endpoint this client interacts with
	URL() string

	// GetPulumiAccountDetails returns the user implied by the API token associated with this client.
	GetPulumiAccountDetails(ctx context.Context) (string, []string, *workspace.TokenInformation, error)

	// ListEnvironments lists all environments in the given org that are accessible to the calling user.
	//
	// Each call to ListEnvironments returns a page of results and a continuation token. If there are no
	// more results, the continuation token will be empty. Otherwise, the continuattion token should be
	// passed to the next call to ListEnvironments to fetch the next page of results.
	ListEnvironments(
		ctx context.Context,
		orgName string,
		continuationToken string,
	) (environments []OrgEnvironment, nextToken string, err error)

	// CreateEnvironment creats an environment named envName in orgName.
	CreateEnvironment(ctx context.Context, orgName, envName string) error

	// GetEnvironment returns the YAML + ETag for the environment envName in org orgName. If decrypt is
	// true, any { fn::secret: { ciphertext: "..." } } constructs in the definition will be decrypted and
	// replaced with { fn::secret: "plaintext" }.
	//
	// The etag returned by GetEnvironment can be passed to UpdateEnvironment in order to avoid RMW issues
	// when editing envirionments.
	GetEnvironment(ctx context.Context, orgName, envName string, decrypt bool) (yaml []byte, etag string, err error)

	// UpdateEnvironment updates the YAML for the environment envName in org orgName.
	//
	// If the new environment definition contains errors, the update will fail with diagnostics.
	//
	// If etag is not the empty string and the environment's current etag does not match the provided etag
	// (i.e. because a different entity has called UpdateEnvironment), the update will fail with a 409
	// error.
	UpdateEnvironment(
		ctx context.Context,
		orgName string,
		envName string,
		yaml []byte,
		etag string,
	) ([]EnvironmentDiagnostic, error)

	// DeleteEnvironment deletes the environment envName in org orgName.
	DeleteEnvironment(ctx context.Context, orgName, envName string) error

	// OpenEnvironment evaluates the environment envName in org orgName and returns the ID of the opened
	// environment. The opened environment will be available for the indicated duration, after which it
	// will expire.
	//
	// If the environment contains errors, the open will fail with diagnostics.
	OpenEnvironment(
		ctx context.Context,
		orgName string,
		envName string,
		duration time.Duration,
	) (string, []EnvironmentDiagnostic, error)

	// CheckYAMLEnvironment checks the given environment YAML for errors within the context of org orgName.
	//
	// This call returns the checked environment's AST, values, schema, and any diagnostics issued by the
	// evaluator.
	CheckYAMLEnvironment(
		ctx context.Context,
		orgName string,
		yaml []byte,
	) (*esc.Environment, []EnvironmentDiagnostic, error)

	// OpenYAMLEnvironment evaluates the given environment YAML within the context of org orgName and
	// returns the ID of the opened environment. The opened environment will be available for the indicated
	// duration, after which it will expire.
	//
	// If the environment contains errors, the open will fail with diagnostics.
	OpenYAMLEnvironment(
		ctx context.Context,
		orgName string,
		yaml []byte,
		duration time.Duration,
	) (string, []EnvironmentDiagnostic, error)

	// GetOpenEnvironment returns the AST, values, and schema for the open environment with ID openEnvID in
	// environment envName and org orgName.
	GetOpenEnvironment(ctx context.Context, orgName, envName, openEnvID string) (*esc.Environment, error)

	// GetOpenProperty returns the value of a single property in the open environment with ID openEnvID in
	// environment envName and org orgName.
	//
	// The property parameter is a Pulumi property path. Property paths may contain dotted accessors and
	// numeric or string subscripts. For example:
	//
	//     foo.bar[0]["baz"]
	//     aws.login
	//     environmentVariables["AWS_ACCESS_KEY_ID"]
	//
	GetOpenProperty(ctx context.Context, orgName, envName, openEnvID, property string) (*esc.Value, error)
}

Client provides a slim wrapper around the Pulumi HTTP/REST API.

func New

func New(userAgent, apiURL, apiToken string, insecure bool) Client

New creates a new Pulumi API client with the given URL and API token.

func NewDefaultClient added in v0.8.2

func NewDefaultClient(apiToken string) Client

New creates a new Pulumi API client with the given URL and API token.

type EnvironmentDiagnostic

type EnvironmentDiagnostic struct {
	Range   *esc.Range `json:"range,omitempty"`
	Summary string     `json:"summary,omitempty"`
	Detail  string     `json:"detail,omitempty"`
}

type EnvironmentDiagnosticError

type EnvironmentDiagnosticError struct {
	Diagnostics []EnvironmentDiagnostic `json:"diagnostics,omitempty"`
}

func (EnvironmentDiagnosticError) Error

func (err EnvironmentDiagnosticError) Error() string

Error implements the Error interface.

type EnvironmentErrorResponse

type EnvironmentErrorResponse struct {
	Code        int                     `json:"code,omitempty"`
	Message     string                  `json:"message,omitempty"`
	Diagnostics []EnvironmentDiagnostic `json:"diagnostics,omitempty"`
}

func (EnvironmentErrorResponse) Error

func (err EnvironmentErrorResponse) Error() string

type ListEnvironmentsResponse

type ListEnvironmentsResponse struct {
	Environments []OrgEnvironment `json:"environments,omitempty"`
	NextToken    string           `json:"nextToken,omitempty"`
}

type OpenEnvironmentResponse

type OpenEnvironmentResponse struct {
	ID          string                  `json:"id"`
	Diagnostics []EnvironmentDiagnostic `json:"diagnostics,omitempty"`
}

type OrgEnvironment

type OrgEnvironment struct {
	Organization string `json:"organization,omitempty"`
	Name         string `json:"name,omitempty"`
}

type UpdateEnvironmentResponse

type UpdateEnvironmentResponse struct {
	EnvironmentDiagnosticError
}

Jump to

Keyboard shortcuts

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