client

package
v0.9.0-pubtest Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: Apache-2.0 Imports: 21 Imported by: 5

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

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 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, 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)

	// 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 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,
		envName string,
		yaml []byte,
		etag string,
	) ([]EnvironmentDiagnostic, int, error)

	// This method has a legacy signature, please use UpdateEnvironmentWithRevision instead
	// Remove this method once circular dependency between esc and pulumi/pulumi is resolved
	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,
		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,
	) (*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)

	// GetEnvironmentRevision returns a description of the given revision.
	GetEnvironmentRevision(ctx context.Context, orgName, 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,
		envName string,
		options ListEnvironmentRevisionsOptions,
	) ([]EnvironmentRevision, error)

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

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

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

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

	// ListEnvironmentRevisionTags lists the revision tags for the given environment.
	ListEnvironmentRevisionTags(
		ctx context.Context,
		orgName string,
		envName string,
		options ListEnvironmentRevisionTagsOptions,
	) ([]EnvironmentRevisionTag, 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 CreateEnvironmentRevisionTagRequest added in v0.9.0

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

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"`
}

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 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 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
}

type UpdateEnvironmentRevisionTagRequest added in v0.9.0

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

Jump to

Keyboard shortcuts

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