httpstate

package
v3.113.3 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 59 Imported by: 5

Documentation

Overview

Package httpstate implements the logic for interacting with a web backend.

Index

Constants

View Source
const (
	// ConsoleDomainEnvVar overrides the way we infer the domain we assume the Pulumi Console will
	// be served from, and instead just use this value. e.g. so links to the stack update go to
	// https://pulumi.example.com/org/project/stack/updates/2 instead.
	ConsoleDomainEnvVar = "PULUMI_CONSOLE_DOMAIN"

	// PulumiCloudURL is the Cloud URL used if no environment or explicit cloud is chosen.
	PulumiCloudURL = "https://" + defaultAPIDomainPrefix + "pulumi.com"
)
View Source
const (

	// AccessTokenEnvVar is the environment variable used to bypass a prompt on login.
	AccessTokenEnvVar = "PULUMI_ACCESS_TOKEN"
)
View Source
const PulumiAILanguagesClause = "TypeScript, JavaScript, Python, Go, C#, Java, or YAML"

A natural language list of languages supported by Pulumi AI.

Variables

All of the languages supported by Pulumi AI.

Functions

func DefaultURL

func DefaultURL() string

DefaultURL returns the default cloud URL. This may be overridden using the PULUMI_API environment variable. If no override is found, and we are authenticated with a cloud, choose that. Otherwise, we will default to the https://api.pulumi.com/ endpoint.

func IsValidAccessToken

func IsValidAccessToken(ctx context.Context, cloudURL string,
	insecure bool, accessToken string,
) (bool, string, []string, *workspace.TokenInformation, error)

IsValidAccessToken tries to use the provided Pulumi access token and returns if it is accepted or not. Returns error on any unexpected error.

func ValueOrDefaultURL

func ValueOrDefaultURL(cloudURL string) string

ValueOrDefaultURL returns the value if specified, or the default cloud URL otherwise.

func WelcomeUser

func WelcomeUser(opts display.Options)

WelcomeUser prints a Welcome to Pulumi message.

Types

type AIPromptRequestBody added in v3.99.0

type AIPromptRequestBody struct {
	Language       PulumiAILanguage `json:"language"`
	Instructions   string           `json:"instructions"`
	ResponseMode   string           `json:"responseMode"`
	ConversationID string           `json:"conversationId"`
	ConnectionID   string           `json:"connectionId"`
}

type Backend

type Backend interface {
	backend.Backend

	CloudURL() string

	StackConsoleURL(stackRef backend.StackReference) (string, error)
	Client() *client.Client

	RunDeployment(ctx context.Context, stackRef backend.StackReference, req apitype.CreateDeploymentRequest,
		opts display.Options, deploymentInitiator string) error

	// Queries the backend for resources based on the given query parameters.
	Search(
		ctx context.Context, orgName string, queryParams *apitype.PulumiQueryRequest,
	) (*apitype.ResourceSearchResponse, error)
	NaturalLanguageSearch(
		ctx context.Context, orgName string, query string,
	) (*apitype.ResourceSearchResponse, error)
	PromptAI(ctx context.Context, requestBody AIPromptRequestBody) (*http.Response, error)
}

Backend extends the base backend interface with specific information about cloud backends.

func New

func New(d diag.Sink, cloudURL string, project *workspace.Project, insecure bool) (Backend, error)

New creates a new Pulumi backend for the given cloud API URL and token.

type DisplayEventType

type DisplayEventType string
const (
	UpdateEvent   DisplayEventType = "UpdateEvent"
	ShutdownEvent DisplayEventType = "Shutdown"
)

type LoginManager added in v3.43.0

type LoginManager interface {
	// Current returns the current cloud backend if one is already logged in.
	Current(ctx context.Context, cloudURL string, insecure, setCurrent bool) (*workspace.Account, error)

	// Login logs into the target cloud URL and returns the cloud backend for it.
	Login(
		ctx context.Context,
		cloudURL string,
		insecure bool,
		command string,
		message string,
		welcome func(display.Options),
		current bool,
		opts display.Options,
	) (*workspace.Account, error)
}

LoginManager provides a slim wrapper around functions related to backend logins.

func NewLoginManager added in v3.43.0

func NewLoginManager() LoginManager

NewLoginManager returns a LoginManager for handling backend logins.

type MockHTTPBackend added in v3.99.0

type MockHTTPBackend struct {
	backend.MockBackend
	FClient   func() *client.Client
	FCloudURL func() string
	FSearch   func(ctx context.Context,
		orgName string,
		queryParams *apitype.PulumiQueryRequest,
	) (*apitype.ResourceSearchResponse, error)
	FNaturalLanguageSearch func(ctx context.Context, orgName string, query string) (*apitype.ResourceSearchResponse, error)
	FPromptAI              func(ctx context.Context, requestBody AIPromptRequestBody) (*http.Response, error)
	FStackConsoleURL       func(stackRef backend.StackReference) (string, error)
	FRunDeployment         func(
		ctx context.Context,
		stackRef backend.StackReference,
		req apitype.CreateDeploymentRequest,
		opts display.Options,
		deploymentInitiator string,
	) error
}

func (*MockHTTPBackend) Client added in v3.99.0

func (b *MockHTTPBackend) Client() *client.Client

func (*MockHTTPBackend) CloudURL added in v3.99.0

func (b *MockHTTPBackend) CloudURL() string

func (*MockHTTPBackend) NaturalLanguageSearch added in v3.99.0

func (b *MockHTTPBackend) NaturalLanguageSearch(
	ctx context.Context, orgName string, query string,
) (*apitype.ResourceSearchResponse, error)

func (*MockHTTPBackend) PromptAI added in v3.99.0

func (b *MockHTTPBackend) PromptAI(
	ctx context.Context, requestBody AIPromptRequestBody,
) (*http.Response, error)

func (*MockHTTPBackend) RunDeployment added in v3.99.0

func (b *MockHTTPBackend) RunDeployment(
	ctx context.Context,
	stackRef backend.StackReference,
	req apitype.CreateDeploymentRequest,
	opts display.Options,
	deploymentInitiator string,
) error

func (*MockHTTPBackend) Search added in v3.99.0

func (*MockHTTPBackend) StackConsoleURL added in v3.99.0

func (b *MockHTTPBackend) StackConsoleURL(stackRef backend.StackReference) (string, error)

type PulumiAILanguage added in v3.99.0

type PulumiAILanguage string
const (
	PulumiAILanguageTypeScript PulumiAILanguage = "TypeScript"
	PulumiAILanguageJavaScript PulumiAILanguage = "JavaScript"
	PulumiAILanguagePython     PulumiAILanguage = "Python"
	PulumiAILanguageGo         PulumiAILanguage = "Go"
	PulumiAILanguageCSharp     PulumiAILanguage = "C#"
	PulumiAILanguageJava       PulumiAILanguage = "Java"
	PulumiAILanguageYAML       PulumiAILanguage = "YAML"
)

func (*PulumiAILanguage) Set added in v3.99.0

func (e *PulumiAILanguage) Set(v string) error

func (*PulumiAILanguage) String added in v3.99.0

func (e *PulumiAILanguage) String() string

func (*PulumiAILanguage) Type added in v3.99.0

func (e *PulumiAILanguage) Type() string

type Stack

type Stack interface {
	backend.Stack
	OrgName() string                            // the organization that owns this stack.
	CurrentOperation() *apitype.OperationStatus // in progress operation, if applicable.
	StackIdentifier() client.StackIdentifier
}

Stack is a cloud stack. This simply adds some cloud-specific properties atop the standard backend stack interface.

Directories

Path Synopsis
Package client implements a client for the Pulumi Service HTTP/REST API.
Package client implements a client for the Pulumi Service HTTP/REST API.

Jump to

Keyboard shortcuts

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