client

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: Apache-2.0 Imports: 21 Imported by: 4

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

View Source
const DefaultProject = "default"

Variables

This section is empty.

Functions

func IsNotFound added in v0.9.0

func IsNotFound(err error) bool

IsNotFound returns true if the indicated error is a "not found" error.

Types

type CheckEnvironmentResponse

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

type CheckYAMLOption added in v0.10.0

type CheckYAMLOption struct {
	ShowSecrets bool
}

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)

	// GetRevisionNumber returns the revision number for version.
	GetRevisionNumber(ctx context.Context, orgName, projectName, envName, version string) (int, 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)

	// Deprecated: Use CreateEnvironmentWithProject instead
	CreateEnvironment(ctx context.Context, orgName, envName string) error

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

	// CloneEnvironment clones an source environment into a new destination environment.
	CloneEnvironment(ctx context.Context, orgName, srcEnvProject, srcEnvName string, destEnv CloneEnvironmentRequest) 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 string,
		projectName string,
		envName string,
		version string,
		decrypt bool,
	) (yaml []byte, etag string, revision int, err error)

	// UpdateEnvironmentWithRevision 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.
	UpdateEnvironmentWithRevision(
		ctx context.Context,
		orgName string,
		projectName string,
		envName string,
		yaml []byte,
		etag string,
	) ([]EnvironmentDiagnostic, int, error)

	// Deprecated: Use UpdateEnvironmentWithProject instead
	UpdateEnvironment(
		ctx context.Context,
		orgName string,
		envName string,
		yaml []byte,
		etag string,
	) ([]EnvironmentDiagnostic, error)
	// This method has a legacy signature, please use UpdateEnvironmentWithRevision instead
	// Remove this method once circular dependency between esc and pulumi/pulumi is resolved
	UpdateEnvironmentWithProject(
		ctx context.Context,
		orgName string,
		projectName string,
		envName string,
		yaml []byte,
		etag string,
	) ([]EnvironmentDiagnostic, error)

	// DeleteEnvironment deletes the environment envName in org orgName.
	DeleteEnvironment(ctx context.Context, orgName, projectName, 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,
		projectName string,
		envName string,
		version 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,
		opts ...CheckYAMLOption,
	) (*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)

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

	// GetAnonymousOpenEnvironment returns the AST, values, and schema for the open environment with ID openEnvID in
	// an anonymous environment.
	GetAnonymousOpenEnvironment(ctx context.Context, orgName, 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, projectName, envName, openEnvID, property string) (*esc.Value, error)

	// GetOpenProperty returns the value of a single property in the open environment with ID openEnvID in
	// an anonymous environment.
	GetAnonymousOpenProperty(ctx context.Context, orgName, openEnvID, property string) (*esc.Value, error)

	// ListEnvironmentTags lists the tags for the given environment.
	ListEnvironmentTags(
		ctx context.Context,
		orgName, projectName, envName string,
		options ListEnvironmentTagsOptions,
	) ([]*EnvironmentTag, string, error)

	// CreateEnvironmentTag creates and applies a tag to the given environment.
	CreateEnvironmentTag(
		ctx context.Context,
		orgName, projectName, envName, key, value string,
	) (*EnvironmentTag, error)

	// GetEnvironmentTag returns a tag with the specified name for the given environment.
	GetEnvironmentTag(
		ctx context.Context,
		orgName, projectName, envName, key string,
	) (*EnvironmentTag, error)

	// UpdateEnvironmentTag updates a specified environment tag with a new key / value.
	UpdateEnvironmentTag(
		ctx context.Context,
		orgName, projectName, envName, currentKey, currentValue, newKey, newValue string,
	) (*EnvironmentTag, error)

	// DeleteEnvironmentTag deletes a specified tag on an environment.
	DeleteEnvironmentTag(ctx context.Context, orgName, projectName, envName, tagName string) error

	// GetEnvironmentRevision returns a description of the given revision.
	GetEnvironmentRevision(ctx context.Context, orgName, projectName, envName string, revision int) (*EnvironmentRevision, error)

	// ListEnvironmentRevisions returns a list of revisions to the named environments in reverse order by
	// revision number. The revision at which to start and the number of revisions to return are
	// configurable via the options parameter.
	ListEnvironmentRevisions(
		ctx context.Context,
		orgName string,
		projectName string,
		envName string,
		options ListEnvironmentRevisionsOptions,
	) ([]EnvironmentRevision, error)

	// RetractEnvironmentRevision retracts a specific revision of an environment.
	RetractEnvironmentRevision(
		ctx context.Context,
		orgName string,
		projectName string,
		envName string,
		version string,
		replacement *int,
		reason string,
	) error

	// CreateEnvironmentRevisionTag creates a new revision tag with the given name.
	CreateEnvironmentRevisionTag(ctx context.Context, orgName, projectName, envName, tagName string, revision *int) error

	// GetEnvironmentRevisionTag returns a description of the given revision tag.
	GetEnvironmentRevisionTag(ctx context.Context, orgName, projectName, envName, tagName string) (*EnvironmentRevisionTag, error)

	// UpdateEnvironmentRevisionTag updates the revision tag with the given name.
	UpdateEnvironmentRevisionTag(ctx context.Context, orgName, projectName, envName, tagName string, revision *int) error

	// DeleteEnvironmentRevisionTag deletes the revision tag with the given name.
	DeleteEnvironmentRevisionTag(ctx context.Context, orgName, projectName, envName, tagName string) error

	// ListEnvironmentRevisionTags lists the revision tags for the given environment.
	ListEnvironmentRevisionTags(
		ctx context.Context,
		orgName string,
		projectName string,
		envName string,
		options ListEnvironmentRevisionTagsOptions,
	) ([]EnvironmentRevisionTag, error)

	// EnvironmentExists checks if the specified environment exists.
	EnvironmentExists(
		ctx context.Context,
		orgName string,
		projectName string,
		envName string,
	) (exists bool, err error)
}

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

NOTE: this is not considered a public API, and we reserve the right to make breaking changes, including adding parameters, removing methods, changing types, etc.

However, there is currently a cyclic dependency between the Pulumi CLI and the ESC CLI that causes breaking changes to any part of the client API to break the ESC CLI build. So we're limited to non-breaking changes, including adding variadic args or adding additional methods.

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 CloneEnvironmentRequest added in v0.10.0

type CloneEnvironmentRequest struct {
	Project                 string `json:"project,omitempty"`
	Name                    string `json:"name"`
	Version                 int    `json:"version,omitempty"`
	PreserveHistory         bool   `json:"preserveHistory,omitempty"`
	PreserveAccess          bool   `json:"preserveAccess,omitempty"`
	PreserveEnvironmentTags bool   `json:"preserveEnvironmentTags,omitempty"`
	PreserveRevisionTags    bool   `json:"preserveRevisionTags,omitempty"`
}

type CreateEnvironmentRevisionTagRequest added in v0.9.0

type CreateEnvironmentRevisionTagRequest struct {
	Name     string `json:"name"`
	Revision *int   `json:"revision,omitempty"`
}

type CreateEnvironmentTagRequest added in v0.10.0

type CreateEnvironmentTagRequest = TagRequest

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 EnvironmentRevision added in v0.9.0

type EnvironmentRevision struct {
	Number       int       `json:"number"`
	Created      time.Time `json:"created"`
	CreatorLogin string    `json:"creatorLogin"`
	CreatorName  string    `json:"creatorName"`
	Tags         []string  `json:"tags"`

	Retracted *EnvironmentRevisionRetracted `json:"retracted,omitempty"`
}

type EnvironmentRevisionRetracted added in v0.9.1

type EnvironmentRevisionRetracted struct {
	Replacement int       `json:"replacement"`
	At          time.Time `json:"at"`
	ByLogin     string    `json:"byLogin,omitempty"`
	ByName      string    `json:"byName,omitempty"`
	Reason      string    `json:"reason,omitempty"`
}

type EnvironmentRevisionTag added in v0.9.0

type EnvironmentRevisionTag struct {
	Name        string    `json:"name"`
	Revision    int       `json:"revision"`
	Created     time.Time `json:"created"`
	Modified    time.Time `json:"modified"`
	EditorLogin string    `json:"editorLogin"`
	EditorName  string    `json:"editorName"`
}

type EnvironmentTag added in v0.10.0

type EnvironmentTag struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Value       string    `json:"value"`
	Created     time.Time `json:"created"`
	Modified    time.Time `json:"modified"`
	EditorLogin string    `json:"editorLogin"`
	EditorName  string    `json:"editorName"`
}

type ListEnvironmentRevisionTagsOptions added in v0.9.0

type ListEnvironmentRevisionTagsOptions struct {
	After string `url:"after"`
	Count *int   `url:"count"`
}

type ListEnvironmentRevisionTagsResponse added in v0.9.0

type ListEnvironmentRevisionTagsResponse struct {
	Tags      []EnvironmentRevisionTag `json:"tags"`
	NextToken string                   `json:"nextToken"`
}

type ListEnvironmentRevisionsOptions added in v0.9.0

type ListEnvironmentRevisionsOptions struct {
	Before *int `url:"before"`
	Count  *int `url:"count"`
}

type ListEnvironmentTagsOptions added in v0.10.0

type ListEnvironmentTagsOptions struct {
	After string `url:"after"`
	Count *int   `url:"count"`
}

type ListEnvironmentTagsResponse added in v0.10.0

type ListEnvironmentTagsResponse struct {
	Tags      map[string]*EnvironmentTag `json:"tags"`
	NextToken string                     `json:"nextToken"`
}

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"`
	Project      string `json:"project,omitempty"`
	Name         string `json:"name,omitempty"`
}

type RetractEnvironmentRevisionRequest added in v0.9.1

type RetractEnvironmentRevisionRequest struct {
	Replacement *int   `json:"replacement,omitempty"`
	Reason      string `json:"reason,omitempty"`
}

type TagRequest added in v0.10.0

type TagRequest struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type UpdateEnvironmentResponse

type UpdateEnvironmentResponse struct {
	EnvironmentDiagnosticError
}

type UpdateEnvironmentRevisionTagRequest added in v0.9.0

type UpdateEnvironmentRevisionTagRequest struct {
	Revision *int `json:"revision,omitempty"`
}

type UpdateEnvironmentTagRequest added in v0.10.0

type UpdateEnvironmentTagRequest struct {
	CurrentTag TagRequest `json:"currentTag"`
	NewTag     TagRequest `json:"newTag"`
}

Jump to

Keyboard shortcuts

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