Create apitype package
This commit is contained in:
parent
823b64d2ef
commit
3c644d243f
41
pkg/apitype/clouds.go
Normal file
41
pkg/apitype/clouds.go
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
package apitype
|
||||||
|
|
||||||
|
// Cloud describes a Pulumi Private Cloud (PPC).
|
||||||
|
type Cloud struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
OrganizationLogin string `json:"organizationLogin"`
|
||||||
|
Endpoint string `json:"endpoint"`
|
||||||
|
|
||||||
|
// IsDefault flags the Cloud as being the default cloud for new stacks in
|
||||||
|
// the parent organization.
|
||||||
|
IsDefault bool `json:"isDefault"`
|
||||||
|
|
||||||
|
StackLimit int `json:"stackLimit"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateCloudRequest is the request to associate a new Cloud with an organization.
|
||||||
|
// (The target organization is inferred from the REST URL.)
|
||||||
|
type CreateCloudRequest struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Endpoint string `json:"endpoint"`
|
||||||
|
AccessToken string `json:"accessToken"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CloudConfigurationRule is a rule for how the Cloud manages Pulumi program configuration.
|
||||||
|
type CloudConfigurationRule struct {
|
||||||
|
Key string `json:"key"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Value string `json:"value"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCloudConfigurationRequest is the request to set the cloud's configuration.
|
||||||
|
// It is expected to be a full replacement, not a partial update.
|
||||||
|
type SetCloudConfigurationRequest struct {
|
||||||
|
Configuration []CloudConfigurationRule `json:"configuration"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CloudStatus describes the state of a Pulumi Private Cloud.
|
||||||
|
type CloudStatus struct {
|
||||||
|
Status string `json:"status"`
|
||||||
|
Versions map[string]string `json:"versions"`
|
||||||
|
}
|
17
pkg/apitype/errors.go
Normal file
17
pkg/apitype/errors.go
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
|
||||||
|
|
||||||
|
package apitype
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
// ErrorResponse is returned from the API when an actual response body is not appropriate. i.e.
|
||||||
|
// in all error situations.
|
||||||
|
type ErrorResponse struct {
|
||||||
|
Code int `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error implements the Error interface.
|
||||||
|
func (err ErrorResponse) Error() string {
|
||||||
|
return fmt.Sprintf("[%d] %s", err.Code, err.Message)
|
||||||
|
}
|
15
pkg/apitype/logs.go
Normal file
15
pkg/apitype/logs.go
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright 2016-2018, Pulumi Corporation. All rights reserved.
|
||||||
|
|
||||||
|
package apitype
|
||||||
|
|
||||||
|
// LogsResult is the JSON shape of responses to a Logs operation.
|
||||||
|
type LogsResult struct {
|
||||||
|
Logs []LogEntry `json:"logs"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogEntry is the individual entries in a JSON response to a Logs operation.
|
||||||
|
type LogEntry struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Timestamp int64 `json:"timestamp"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
15
pkg/apitype/organizations.go
Normal file
15
pkg/apitype/organizations.go
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
|
||||||
|
|
||||||
|
package apitype
|
||||||
|
|
||||||
|
// Organization represents a Pulumi organization.
|
||||||
|
type Organization struct {
|
||||||
|
GitHubLogin string `json:"githubLogin"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
AvatarURL string `json:"avatarUrl"`
|
||||||
|
|
||||||
|
Clouds []Cloud `json:"clouds"`
|
||||||
|
DefaultCloud string `json:"defaultCloud"`
|
||||||
|
|
||||||
|
Repositories []PulumiRepository `json:"repos"`
|
||||||
|
}
|
31
pkg/apitype/programs.go
Normal file
31
pkg/apitype/programs.go
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
package apitype
|
||||||
|
|
||||||
|
// GitHubRepo is a subset of the information returned from the GitHub Repo API.
|
||||||
|
type GitHubRepo struct {
|
||||||
|
OwnerLogin string `json:"ownerLogin"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
IsPrivate bool `json:"isPrivate"`
|
||||||
|
|
||||||
|
HTMLURL string `json:"htmlUrl"`
|
||||||
|
Homepage string `json:"homepage"`
|
||||||
|
Topics []string `json:"topics"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PulumiRepository is a grouping of "Projects". We also return a subset of the organization's
|
||||||
|
// GitHub repo with the same name, should it exist.
|
||||||
|
type PulumiRepository struct {
|
||||||
|
OrgName string `json:"orgName"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
GitHubRepo *GitHubRepo `json:"githubRepo"`
|
||||||
|
Projects []PulumiProject `json:"projects"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PulumiProject has a 1:1 correspondence to pulumi.yaml files.
|
||||||
|
type PulumiProject struct {
|
||||||
|
OrgName string `json:"orgName"`
|
||||||
|
RepoName string `json:"repoName"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Stacks []string `json:"stacks"`
|
||||||
|
}
|
92
pkg/apitype/stacks.go
Normal file
92
pkg/apitype/stacks.go
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
// Copyright 2016-2018, Pulumi Corporation. All rights reserved.
|
||||||
|
|
||||||
|
package apitype
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/pulumi/pulumi/pkg/tokens"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Resource describes a Cloud resource constructed by Pulumi.
|
||||||
|
type Resource struct {
|
||||||
|
Type string `json:"type"`
|
||||||
|
URN string `json:"urn"`
|
||||||
|
Custom bool `json:"custom"`
|
||||||
|
ID string `json:"id"`
|
||||||
|
Inputs map[string]interface{} `json:"inputs"`
|
||||||
|
Defaults map[string]interface{} `json:"defaults"` // TODO: extra in pulumi
|
||||||
|
Outputs map[string]interface{} `json:"outputs"`
|
||||||
|
Parent string `json:"parent"`
|
||||||
|
Protect bool `json:"protect"` // TODO: extra in pulumi
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stack describes a Stack running on a Pulumi Cloud.
|
||||||
|
type Stack struct {
|
||||||
|
CloudName string `json:"cloudName"`
|
||||||
|
OrgName string `json:"orgName"`
|
||||||
|
|
||||||
|
RepoName string `json:"repoName"`
|
||||||
|
ProjectName string `json:"projName"`
|
||||||
|
StackName tokens.QName `json:"stackName"`
|
||||||
|
|
||||||
|
ActiveUpdate string `json:"activeUpdate"`
|
||||||
|
Resources []Resource `json:"resources,omitempty"`
|
||||||
|
|
||||||
|
Version int `json:"version"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateStackRequest defines the request body for creating a new Stack
|
||||||
|
type CreateStackRequest struct {
|
||||||
|
// If empty means use the default cloud.
|
||||||
|
CloudName string `json:"cloudName"`
|
||||||
|
// The rest of the StackIdentifier (repo, project) is in the URL.
|
||||||
|
StackName string `json:"stackName"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateStackResponse is the response from a create Stack request.
|
||||||
|
type CreateStackResponse struct {
|
||||||
|
// The name of the cloud used if the default was sent.
|
||||||
|
CloudName string `json:"cloudName"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// EncryptValueRequest defines the request body for encrypting a value.
|
||||||
|
type EncryptValueRequest struct {
|
||||||
|
// The value to encrypt.
|
||||||
|
Plaintext []byte `json:"plaintext"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// EncryptValueResponse defines the response body for an encrypted value.
|
||||||
|
type EncryptValueResponse struct {
|
||||||
|
// The encrypted value.
|
||||||
|
Ciphertext []byte `json:"ciphertext"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DecryptValueRequest defines the request body for decrypting a value.
|
||||||
|
type DecryptValueRequest struct {
|
||||||
|
// The value to decrypt.
|
||||||
|
Ciphertext []byte `json:"ciphertext"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DecryptValueResponse defines the response body for a decrypted value.
|
||||||
|
type DecryptValueResponse struct {
|
||||||
|
// The decrypted value.
|
||||||
|
Plaintext []byte `json:"plaintext"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// StackExport describes an exported stack.
|
||||||
|
type StackExport struct {
|
||||||
|
// The opaque Pulumi deployment.
|
||||||
|
Deployment json.RawMessage `json:"deployment,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExportStackResponse defines the response body for exporting a Stack.
|
||||||
|
type ExportStackResponse StackExport
|
||||||
|
|
||||||
|
// ImportStackRequest defines the request body for importing a Stack.
|
||||||
|
type ImportStackRequest StackExport
|
||||||
|
|
||||||
|
// ImportStackResponse defines the response body for importing a Stack.
|
||||||
|
type ImportStackResponse struct {
|
||||||
|
UpdateID string `json:"updateId"`
|
||||||
|
}
|
104
pkg/apitype/updates.go
Normal file
104
pkg/apitype/updates.go
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
package apitype
|
||||||
|
|
||||||
|
import "github.com/pulumi/pulumi/pkg/tokens"
|
||||||
|
|
||||||
|
// ConfigValue describes a single (possibly secret) configuration value.
|
||||||
|
type ConfigValue struct {
|
||||||
|
// String is either the plaintext value (for non-secrets) or the base64-encoded ciphertext (for secrets).
|
||||||
|
String string `json:"string"`
|
||||||
|
// Secret is true if this value is a secret and false otherwise.
|
||||||
|
Secret bool `json:"secret"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateProgramRequest is the request type for updating (aka deploying) a Pulumi program.
|
||||||
|
type UpdateProgramRequest struct {
|
||||||
|
// Properties from the Project file. Subset of pack.Package.
|
||||||
|
Name tokens.PackageName `json:"name"`
|
||||||
|
Runtime string `json:"runtime"`
|
||||||
|
Main string `json:"main"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
|
||||||
|
// Configuration values.
|
||||||
|
Config map[tokens.ModuleMember]ConfigValue `json:"config"`
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// ConfigValue describes a single (possibly secret) configuration value.
|
||||||
|
type ConfigValue struct {
|
||||||
|
// String is either the plaintext value (for non-secrets) or the base64-encoded ciphertext (for secrets).
|
||||||
|
String string `json:"string"`
|
||||||
|
// Secret is true if this value is a secret and false otherwise.
|
||||||
|
Secret bool `json:"secret"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateProgramRequest is the request type for updating (aka deploying) a Pulumi program.
|
||||||
|
type UpdateProgramRequest struct {
|
||||||
|
// Properties from the Project file.
|
||||||
|
Name string `json:"name"`
|
||||||
|
Runtime string `json:"runtime"`
|
||||||
|
Main string `json:"main"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
|
||||||
|
// Configuration values. Note that although the element type of this map is an `interface{}`, the value must be
|
||||||
|
// either a string or a ConfigValue.
|
||||||
|
Config map[string]interface{} `json:"config"`
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// UpdateProgramResponse is the result of an update program request.
|
||||||
|
type UpdateProgramResponse struct {
|
||||||
|
// UpdateID is the opaque identifier of the requested update. This value is needed to begin
|
||||||
|
// an update, as well as poll for its progress.
|
||||||
|
UpdateID string `json:"updateID"`
|
||||||
|
|
||||||
|
// UploadURL is a URL the client can use to upload their program's contents into. Ignored
|
||||||
|
// for destroys.
|
||||||
|
UploadURL string `json:"uploadURL"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartUpdateResponse is the result of the command to start an update.
|
||||||
|
type StartUpdateResponse struct {
|
||||||
|
// Version is the version of the program once the update is complete.
|
||||||
|
// (Will be the current, unchanged value for previews.)
|
||||||
|
Version int `json:"version"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateEventKind is an enum for the type of update events.
|
||||||
|
type UpdateEventKind string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// StdoutEvent is used to mark the event being emitted to STDOUT.
|
||||||
|
StdoutEvent UpdateEventKind = "stdout"
|
||||||
|
// StderrEvent is used to mark the event being emitted to STDERR.
|
||||||
|
StderrEvent UpdateEventKind = "stderr"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UpdateEvent describes an event that happened on the Pulumi Cloud while processing an update.
|
||||||
|
type UpdateEvent struct {
|
||||||
|
Index string `json:"index"`
|
||||||
|
Kind string `json:"kind"`
|
||||||
|
Fields map[string]interface{} `json:"fields"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStatus is an enum describing the current state during the lifecycle of an update.
|
||||||
|
type UpdateStatus string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// StatusNotStarted is returned when the Update has been created but not applied.
|
||||||
|
StatusNotStarted UpdateStatus = "not started"
|
||||||
|
// StatusRequested is returned when the Update application has been requested but not started.
|
||||||
|
StatusRequested UpdateStatus = "requested"
|
||||||
|
// StatusRunning is returned when the Update is in progress.
|
||||||
|
StatusRunning UpdateStatus = "running"
|
||||||
|
// StatusFailed is returned when the update has failed.
|
||||||
|
StatusFailed UpdateStatus = "failed"
|
||||||
|
// StatusSucceeded is returned when the update has succeeded.
|
||||||
|
StatusSucceeded UpdateStatus = "succeeded"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UpdateResults returns a series of events and the current status of an update. The vents can
|
||||||
|
// be filtered. See API call for more details.
|
||||||
|
type UpdateResults struct {
|
||||||
|
Status string `json:"status"`
|
||||||
|
Events []UpdateEvent `json:"events"`
|
||||||
|
}
|
12
pkg/apitype/users.go
Normal file
12
pkg/apitype/users.go
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
|
||||||
|
|
||||||
|
package apitype
|
||||||
|
|
||||||
|
// User represents a Pulumi user.
|
||||||
|
type User struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
GitHubLogin string `json:"githubLogin"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
AvatarURL string `json:"avatarUrl"`
|
||||||
|
Organizations []Organization `json:"organizations"` // TODO: This used to be interface{} in pulumi
|
||||||
|
}
|
|
@ -15,7 +15,7 @@ import (
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/pulumi/pulumi/pkg/backend/cloud/apitype"
|
"github.com/pulumi/pulumi/pkg/apitype"
|
||||||
"github.com/pulumi/pulumi/pkg/tokens"
|
"github.com/pulumi/pulumi/pkg/tokens"
|
||||||
"github.com/pulumi/pulumi/pkg/util/contract"
|
"github.com/pulumi/pulumi/pkg/util/contract"
|
||||||
"github.com/pulumi/pulumi/pkg/workspace"
|
"github.com/pulumi/pulumi/pkg/workspace"
|
||||||
|
|
|
@ -19,8 +19,8 @@ import (
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
|
"github.com/pulumi/pulumi/pkg/apitype"
|
||||||
"github.com/pulumi/pulumi/pkg/backend"
|
"github.com/pulumi/pulumi/pkg/backend"
|
||||||
"github.com/pulumi/pulumi/pkg/backend/cloud/apitype"
|
|
||||||
"github.com/pulumi/pulumi/pkg/backend/state"
|
"github.com/pulumi/pulumi/pkg/backend/state"
|
||||||
"github.com/pulumi/pulumi/pkg/diag"
|
"github.com/pulumi/pulumi/pkg/diag"
|
||||||
"github.com/pulumi/pulumi/pkg/diag/colors"
|
"github.com/pulumi/pulumi/pkg/diag/colors"
|
||||||
|
|
|
@ -5,8 +5,8 @@ package cloud
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/pulumi/pulumi/pkg/apitype"
|
||||||
"github.com/pulumi/pulumi/pkg/backend"
|
"github.com/pulumi/pulumi/pkg/backend"
|
||||||
"github.com/pulumi/pulumi/pkg/backend/cloud/apitype"
|
|
||||||
"github.com/pulumi/pulumi/pkg/engine"
|
"github.com/pulumi/pulumi/pkg/engine"
|
||||||
"github.com/pulumi/pulumi/pkg/operations"
|
"github.com/pulumi/pulumi/pkg/operations"
|
||||||
"github.com/pulumi/pulumi/pkg/pack"
|
"github.com/pulumi/pulumi/pkg/pack"
|
||||||
|
|
Loading…
Reference in a new issue