asteris-llc/converge

View on GitHub
rpc/pb/root.proto

Summary

Maintainability
Test Coverage
syntax = "proto3";

package pb;

import "google/api/annotations.proto";
import "google/protobuf/empty.proto";

message LoadRequest {
  string location = 1;
  map<string, string> parameters = 2;
  bool verify = 3;
}

message ContentResponse {
  string content = 1;
}

message StatusResponse {
  // TODO: preserve for compat but will stop working in 0.4.0. This has moved to
  // meta.id
  string id = 1 [deprecated=true];

  // the stage from which this status response is being sent
  enum Stage {
    UNSPECIFIED_STAGE = 0;
    PLAN = 1;
    APPLY = 2;
  }
  Stage stage = 2;

  // when is this status response being sent?
  enum Run {
    UNSPECIFIED_RUN = 0;
    STARTED = 1;
    FINISHED = 2;
  }
  Run run = 3;

  // the informational message, if present
  message Details {
    repeated string messages = 1;
    map<string, DiffResponse> changes = 2;
    bool hasChanges = 3;
    string error = 4;
    string warning = 5;
  }
  Details details = 4;

  message Meta {
    string id = 1;
  }
  Meta meta = 5;
}

message DiffResponse {
  string original = 1;
  string current = 2;
  bool changes = 3;
}

// Executor is responsible for remote execution on the machine
service Executor {
  // Healthcheck a module given by the location
  rpc HealthCheck (LoadRequest) returns (stream StatusResponse) {
    option (google.api.http) = {
      post: "/api/v1/machine/healthcheck"
      body: "*"
    };
  }

  // Plan out the execution of a module given by the location
  rpc Plan (LoadRequest) returns (stream StatusResponse) {
    option (google.api.http) = {
      post: "/api/v1/machine/plan"
      body: "*"
    };
  }

  // Apply a module given by the location
  rpc Apply (LoadRequest) returns (stream StatusResponse) {
    option (google.api.http) = {
      post: "/api/v1/machine/apply"
      body: "*"
    };
  }
}

// ResourceHost contains the information needed for the system to bootstrap
// itself, as well as hosting modules.
service ResourceHost {
  // GetBinary returns the converge binary itself
  rpc GetBinary (google.protobuf.Empty) returns (ContentResponse) {
    option (google.api.http) = {
      get: "/api/v1/resources/binary"
    };
  }

  // GetModule gets the content of a module at the given path
  rpc GetModule (LoadRequest) returns (ContentResponse) {
    option (google.api.http) = {
      get: "/api/v1/resources/modules/{location=**}"
    };
  }
}

/************
 * GRAPHING *
 ************/

message GraphComponent {
  message Vertex {
    string id = 1;

    // the kind of node, specified as the type used to create a node of this
    // type in the Converge DSL
    string kind = 2;

    // detailed fields of this node, serialized as JSON
    bytes details = 3;
  }

  message Edge {
    string source = 1;
    string dest = 2;
    repeated string attributes = 3;
  }

  oneof component {
    Vertex vertex = 1;
    Edge edge = 2;
  }
}

service Grapher {
  rpc Graph (LoadRequest) returns (stream GraphComponent) {
    option (google.api.http) = {
      post: "/api/v1/machine/graph"
      body: "*"
    };
  }
}

/********
 * INFO *
 ********/

service Info {
  rpc Ping (google.protobuf.Empty) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      get: "/api/v1/ping"
    };
  }
}