Add apitypes from pulumi-ppc

This commit is contained in:
khyperia 2018-01-10 15:43:44 -08:00
parent 3c644d243f
commit f455689bd4
No known key found for this signature in database
GPG key ID: 1F0C4C4275968713
4 changed files with 156 additions and 3 deletions

View file

@ -13,3 +13,9 @@ type LogEntry struct {
Timestamp int64 `json:"timestamp"`
Message string `json:"message"`
}
// GetStackLogsResponse describes the data returned by the `GET /stack/{stackID}/logs` endpoint of the PPC API.
type GetStackLogsResponse struct {
// LogEntries records the sequence of log entries generated by the stack's resources.
LogEntries []LogEntry `json:"logEntries"`
}

View file

@ -8,6 +8,30 @@ import (
"github.com/pulumi/pulumi/pkg/tokens"
)
// StackSummary presents an overview of a particular stack without enumerating its current resource set.
type StackSummary struct {
// ID is the unique identifier for a stack in the context of its PPC.
ID string `json:"id"`
// ActiveUpdate is the unique identifier for the stack's active update. This may be empty if no update has been applied.
ActiveUpdate string `json:"activeUpdate"`
// ResourceCount is the number of resources associated with this stack. NOTE: this is currently unimplemented.
ResourceCount int `json:"resourceCount"`
}
// ListStacksResponse describes the data returned by the `GET /stacks` endpoint of the PPC API.
type ListStacksResponse struct {
// Stacks contains a list of summaries for each stack that currently exists in the PPC.
Stacks []StackSummary `json:"stacks"`
}
// CreateStackResponse describes the data returned by the `POST /stacks` endpoint of the PPC API.
type CreateStackResponseById struct {
// ID is the unique identifier for the newly-created stack.
ID string `json:"id"`
}
// Resource describes a Cloud resource constructed by Pulumi.
type Resource struct {
Type string `json:"type"`
@ -44,12 +68,33 @@ type CreateStackRequest struct {
StackName string `json:"stackName"`
}
// CreateStackResponse is the response from a create Stack request.
type CreateStackResponse struct {
// CreateStackResponseByName is the response from a create Stack request.
type CreateStackResponseByName struct {
// The name of the cloud used if the default was sent.
CloudName string `json:"cloudName"`
}
// GetStackResponse describes the data returned by the `/GET /stack/{stackID}` endpoint of the PPC API. If the `deployment` query
// parameter is set to `true`, `Deployment` will be set and `Resources will be empty.
type GetStackResponse struct {
// ID is the unique identifier for a stack in the context of its PPC.
ID string `json:"id"`
// ActiveUpdate is the unique identifier for the stack's active update. This may be empty if no update has been applied.
ActiveUpdate string `json:"activeUpdate"`
// UnknownState indicates whether or not the contents of the resources array contained in the response is known to accurately
// represent the cloud resources managed by this stack. A stack that is in an unknown state cannot be updated.
// TODO: [pulumi/pulumi-ppc#29]: make this state recoverable. This could be as simple as import/export.
UnknownState bool `json:"unknownState"`
// Resources provides the list of cloud resources managed by this stack.
Resources []Resource `json:"resources"`
// Deployment provides a view of the stack as an opaque Pulumi deployment.
Deployment json.RawMessage `json:"deployment,omitempty"`
}
// EncryptValueRequest defines the request body for encrypting a value.
type EncryptValueRequest struct {
// The value to encrypt.

View file

@ -10,6 +10,12 @@ type ConfigValue struct {
Secret bool `json:"secret"`
}
// CreateUpdateConfig describes the configuration data for an request to `POST /updates`.
type CreateUpdateConfig struct {
// Contents contains the configuration values for an update as a set of key-value pairs.
Contents map[string]ConfigValue `json:"contents"`
}
// UpdateProgramRequest is the request type for updating (aka deploying) a Pulumi program.
type UpdateProgramRequest struct {
// Properties from the Project file. Subset of pack.Package.
@ -102,3 +108,99 @@ type UpdateResults struct {
Status string `json:"status"`
Events []UpdateEvent `json:"events"`
}
// UpdateProgram describes the metadata associated with an update's Pulumi program. Note that this does not include the contents of the
// program itself.
type UpdateProgram struct {
// Name is the name of the program.
Name string `json:"name"`
// Runtime is the language runtime used to execute the program.
Runtime string `json:"runtime"`
// Main is an optional redirect for the main program location. (e.g. a subfolder under Pulumi.yaml containing package.json.)
Main string `json:"main"`
// Analyzers is the set of analyzers to run when this program is executed.
Analyzers []string `json:"analyzers"`
// Destroy indicates whether or not this program is the nil program (i.e. the program that generates no resources).
Destroy bool `json:"destroy"`
}
// CreateUpdateRequest describe the data provided as the body of a request to the `POST /updates` endpoint of the PPC API.
type CreateUpdateRequest struct {
// Stack is the unqique ID for the stack that this update targets.
Stack string `json:"stack"`
// Import indicates whether or not this update's resources are given by a checkpoint to import rather than an actual Pulumi program.
// If this field is `true`, the client must upload the checkpoint file to the URL returned in the response. Config should be empty, as
// it will be copied from the base update. Program should also be empty, as it will not be used.
IsCheckpointImport bool `json:"import,omitempty"`
// StackAlias is the friendly name for the update's stack that will be exposed to the update's Pulumi program.
StackAlias string `json:"stackAlias,omitempty"`
// Config records the configuration values for an update. Must be nil if IsCheckpointImport is true.
Config *CreateUpdateConfig `json:"config,omitempty"`
// Program records the program metadata for an update. Must be nil if IsCheckpointImport is true.
Program *UpdateProgram `json:"program,omitempty"`
}
// CreateUpdateResponse describes the data returned by a request to the `POST /updates` endpoint of the PPC API.
type CreateUpdateResponse struct {
// ID is the unique identifier of the newly-created update.
ID string `json:"id"`
// Stack is the unique identifier of the stack targeted by the update.
Stack string `json:"stack"`
// BaseUpdate is the unique identifier of the update that was active in the stack indicated above at the time at which this update
// was created.
BaseUpdate string `json:"baseUpdate"`
// UploadURL is a URL that the client must use to upload the contents of the program associated with this update. The client should
// upload the program by sending a `PUT` request to this URL with the contents of the program as a ZIP file in the request body.
// The `PUT` request must also set the `Content-Length` header.
UploadURL string `json:"uploadURL"`
}
// UpdateApplyRequest describes the data provided as the body of a request to the `POST /updates/{updateID}/apply` and
// `POST /updates/{updateID}/preview` endpoints of the PPC API.
type UpdateApplyRequest struct {
// Should we tell the engine to emit information about the configuration during this update.
ShowConfig bool `json:"showConfig,omitempty"`
// Should we tell the engine to emit information about resources that have not changed during this update.
ShowSames bool `json:"showSames,omitempty"`
// Should we tell the engine to emit information about replacement steps during this update.
ShowReplacementSteps bool `json:"showReplacementSteps,omitempty"`
// Should we tell the engine to emit summary information during this update.
Summary bool `json:"summary,omitempty"`
}
// GetUpdateResponse describes the data retuerned by a request to the `GET /updates/{updateID}` endpoint of the PPC API.
type GetUpdateResponse struct {
CreateUpdateResponse
// State indicates which state the update is in.
State string `json:"state"`
// StackAlias is the friendly name for the update's stack that will be exposed to the update's Pulumi program.
StackAlias string `json:"stackAlias,omitempty"`
// Config records the configuration values for an update.
Config map[string]string `json:"config"`
// Program records the program metadata for an update.
Program UpdateProgram `json:"program"`
}
// GetApplyUpdateResultsResponse describes the data returned by the `GET /updates/{updateID}/apply` endpoint of the PPC API.
type GetApplyUpdateResultsResponse UpdateResults
// GetPreviewUpdateResultsResponse describes the data returned by the `GET /updates/{updateID}/preview` endpoint of the PPC API.
type GetPreviewUpdateResultsResponse UpdateResults

View file

@ -95,7 +95,7 @@ func (b *cloudBackend) CreateStack(stackName tokens.QName, opts interface{}) err
StackName: string(stackName),
}
var createStackResp apitype.CreateStackResponse
var createStackResp apitype.CreateStackResponseByName
path := fmt.Sprintf("/orgs/%s/programs/%s/%s/stacks", projID.Owner, projID.Repository, projID.Project)
if err := pulumiRESTCall(b.cloudURL, "POST", path, nil, &createStackReq, &createStackResp); err != nil {
return err