pulumi/sdk/proto/provider.proto
joeduffy fe0bb4a265 Support replacement IDs
This change introduces a new RPC function to the provider interface;
in pseudo-code:

    UpdateImpact(id ID, t Type, olds PropertyMap, news PropertyMap)
        (bool, PropertyMap, error)

Essentially, during the planning phase, we will consult each provider
about the nature of a proposed update.  This update includes a set of
old properties and the new ones and, if the resource provider will need
to replace the property as a result of the update, it will return true;
in general, the PropertyMap will eventually contain a list of all
properties that will be modified as a result of the operation (see below).

The planning phase reacts to this by propagating the change to dependent
resources, so that they know that the ID will change (and so that they
can recalculate their own state accordingly, possibly leading to a ripple
effect).  This ensures the overall DAG / schedule is ordered correctly.

This change is most of pulumi/coconut#105.  The only missing piece
is to generalize replacing the "ID" property with replacing arbitrary
properties; there are hooks in here for this, but until pulumi/coconut#90
is addressed, it doesn't make sense to make much progress on this.
2017-03-01 09:08:53 -08:00

80 lines
3.5 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. Only those values in the provided property bag are updated
// to new values. The resource ID is returned and may be different if the resource had to be recreated.
rpc Update(UpdateRequest) returns (UpdateResponse) {}
// 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 UpdateResponse {
string id = 1; // the new ID for the resource, if it had to be recreated.
}
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.
}