pulumi/sdk/proto/provider.proto
joeduffy bd613a33e6 Make replacement first class
This change, part of pulumi/coconut#105, rearranges support for
resource replacement.  The old model didn't properly account for
the cascading updates and possible replacement of dependencies.

Namely, we need to model a replacement as a creation followed by
a deletion, inserted into the overall DAG correctly so that any
resources that must be updated are updated after the creation but
prior to the deletion.  This is done by inserting *three* nodes
into the graph per replacement: a physical creation step, a
physical deletion step, and a logical replacement step.  The logical
step simply makes it nicer in the output (the plan output shows
a single "replacement" rather than the fine-grained outputs, unless
they are requested with --show-replace-steps).  It also makes it
easier to fold all of the edges into a single linchpin node.

As part of this, the update step no longer gets to choose whether
to recreate the resource.  Instead, the engine takes care of
orchestrating the replacement through actual create and delete calls.
2017-03-02 09:52:08 -08:00

75 lines
3.3 KiB
Protocol Buffer

// Copyright 2016 Pulumi, Inc. All rights reserved.
syntax = "proto3";
import "google/protobuf/empty.proto";
import "google/protobuf/struct.proto";
package cocorpc;
// TODO: figure out "transactionality" and possibly "tainting".
// ResourceProvider is a service that understands how to create, read, update, or delete resources for types defined
// within a single MuPackage. It is driven by the overall Mu toolchain in response to blueprints and graphs.
service ResourceProvider {
// Name names a given resource. Sometimes this will be assigned by a developer, and so the provider
// simply fetches it from the property bag; other times, the provider will assign this based on its own algorithm.
// In any case, resources with the same name must be safe to use interchangeably with one another.
rpc Name(NameRequest) returns (NameResponse) {}
// Create allocates a new instance of the provided resource and returns its unique ID afterwards. (The input ID
// must be blank.) If this call fails, the resource must not have been created (i.e., it is "transacational").
rpc Create(CreateRequest) returns (CreateResponse) {}
// Read reads the instance state identified by ID, returning a populated resource object, or an error if not found.
rpc Read(ReadRequest) returns (ReadResponse) {}
// Update updates an existing resource with new values.
rpc Update(UpdateRequest) returns (google.protobuf.Empty) {}
// UpdateImpact checks what impacts a hypothetical update will have on the resource's properties.
rpc UpdateImpact(UpdateRequest) returns (UpdateImpactResponse) {}
// Delete tears down an existing resource with the given ID. If it fails, the resource is assumed to still exist.
rpc Delete(DeleteRequest) returns (google.protobuf.Empty) {}
}
message NameRequest {
string type = 1; // the type token of the resource.
google.protobuf.Struct properties = 2; // the full properties to use for name creation.
}
message NameResponse {
string name = 1; // the name of the resource.
}
message CreateRequest {
string type = 1; // the type token of the resource.
google.protobuf.Struct properties = 2; // the properties to set during creation.
}
message CreateResponse {
string id = 1; // the ID of the resource created.
}
message ReadRequest {
string id = 1; // the ID of the resource to read.
string type = 2; // the type token of the resource.
}
message ReadResponse {
google.protobuf.Struct properties = 1; // the properties read from the resource.
}
message UpdateRequest {
string id = 1; // the ID of the resource to update.
string type = 2; // the type token of the resource to update.
google.protobuf.Struct olds = 3; // the old values of properties to update.
google.protobuf.Struct news = 4; // the new values of properties to update.
}
message UpdateImpactResponse {
bool replace = 1; // true if this update triggers replacement of the resource, false otherwise.
google.protobuf.Struct impacts = 2; // the full set of properties that will be altered by this operation.
}
message DeleteRequest {
string id = 1; // the ID of the resource to delete.
string type = 2; // the type token of the resource to update.
}