|
| 1 | +syntax = "proto3"; |
| 2 | +package cloudquery.plugin.v3; |
| 3 | + |
| 4 | +import "google/protobuf/timestamp.proto"; |
| 5 | + |
| 6 | +option go_package = "github.com/cloudquery/plugin-pb-go/pb/plugin/v3;plugin"; |
| 7 | +option java_package = "io.cloudquery.plugin.v3"; |
| 8 | +option java_multiple_files = true; |
| 9 | + |
| 10 | +service Plugin { |
| 11 | + // Get the name of the plugin |
| 12 | + rpc GetName(GetName.Request) returns (GetName.Response); |
| 13 | + // Get the current version of the plugin |
| 14 | + rpc GetVersion(GetVersion.Request) returns (GetVersion.Response); |
| 15 | + // Get plugin spec schema. |
| 16 | + // This will allow validating the input even before calling Init. |
| 17 | + // Should be called before Init. |
| 18 | + rpc GetSpecSchema(GetSpecSchema.Request) returns (GetSpecSchema.Response); |
| 19 | + // Configure the plugin with the given credentials and mode |
| 20 | + rpc Init(Init.Request) returns (Init.Response); |
| 21 | + // Get all tables the source plugin supports. Must be called after Init |
| 22 | + rpc GetTables(GetTables.Request) returns (GetTables.Response); |
| 23 | + // Start a sync on the source plugin. It streams messages as output. |
| 24 | + rpc Sync(Sync.Request) returns (stream Sync.Response); |
| 25 | + // Start a Read on the source plugin for a given table and schema. It streams messages as output. |
| 26 | + // The plugin assume that that schema was used to also write the data beforehand |
| 27 | + rpc Read(Read.Request) returns (stream Read.Response); |
| 28 | + // Write resources. Write is the mirror of Sync, expecting a stream of messages as input. |
| 29 | + rpc Write(stream Write.Request) returns (Write.Response); |
| 30 | + // Transform resources. |
| 31 | + rpc Transform(stream Transform.Request) returns (stream Transform.Response); |
| 32 | + // Transform schemas. |
| 33 | + rpc TransformSchema(TransformSchema.Request) returns (TransformSchema.Response); |
| 34 | + // Send signal to flush and close open connections |
| 35 | + rpc Close(Close.Request) returns (Close.Response); |
| 36 | + // Validate and test the connections used by the plugin |
| 37 | + rpc TestConnection(TestConnection.Request) returns (TestConnection.Response); |
| 38 | +} |
| 39 | + |
| 40 | +message GetName { |
| 41 | + message Request {} |
| 42 | + message Response { |
| 43 | + string name = 1; |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +message GetVersion { |
| 48 | + message Request {} |
| 49 | + message Response { |
| 50 | + string version = 1; |
| 51 | + } |
| 52 | +} |
| 53 | + |
| 54 | +message GetSpecSchema { |
| 55 | + message Request {} |
| 56 | + message Response { |
| 57 | + // Should be a valid JSON schema for the plugin spec. |
| 58 | + // See https://json-schema.org for more details. |
| 59 | + optional string json_schema = 1; |
| 60 | + } |
| 61 | +} |
| 62 | + |
| 63 | +message Init { |
| 64 | + message Request { |
| 65 | + bytes spec = 1; // Internal plugin-specific spec |
| 66 | + bool no_connection = 2; // A flag to indicate plugins should skip establishing a connection |
| 67 | + string invocation_id = 3; // unique execution_id that will identify the invocation (sync, migrate etc) |
| 68 | + } |
| 69 | + message Response {} |
| 70 | +} |
| 71 | + |
| 72 | +message GetTables { |
| 73 | + message Request { |
| 74 | + repeated string tables = 1; |
| 75 | + repeated string skip_tables = 2; |
| 76 | + bool skip_dependent_tables = 3; |
| 77 | + } |
| 78 | + message Response { |
| 79 | + // marshalled []arrow.Schema |
| 80 | + repeated bytes tables = 1; |
| 81 | + } |
| 82 | +} |
| 83 | + |
| 84 | +message Sync { |
| 85 | + message MessageInsert { |
| 86 | + // marshalled arrow.Record |
| 87 | + bytes record = 1; |
| 88 | + } |
| 89 | + message MessageMigrateTable { |
| 90 | + // marshalled arrow.Schema |
| 91 | + bytes table = 1; |
| 92 | + } |
| 93 | + message MessageDeleteRecord { |
| 94 | + string table_name = 1; |
| 95 | + repeated PredicatesGroup where_clause = 2; |
| 96 | + repeated TableRelation table_relations = 3; |
| 97 | + } |
| 98 | + message MessageError { |
| 99 | + string table_name = 1; |
| 100 | + string error = 2; |
| 101 | + } |
| 102 | + |
| 103 | + |
| 104 | + message BackendOptions { |
| 105 | + // table name to use for state backend |
| 106 | + string table_name = 1; |
| 107 | + // connection path to use for state backend |
| 108 | + string connection = 2; |
| 109 | + } |
| 110 | + message Request { |
| 111 | + message Shard { |
| 112 | + int32 num = 1; |
| 113 | + int32 total = 2; |
| 114 | + } |
| 115 | + repeated string tables = 1; |
| 116 | + repeated string skip_tables = 2; |
| 117 | + bool skip_dependent_tables = 3; |
| 118 | + bool deterministic_cq_id = 4; |
| 119 | + BackendOptions backend = 5; |
| 120 | + optional Shard shard = 6; |
| 121 | + bool withErrorMessages = 7; // If true, the plugin will send error messages in the response stream |
| 122 | + } |
| 123 | + message Response { |
| 124 | + oneof message { |
| 125 | + Sync.MessageMigrateTable migrate_table = 1; |
| 126 | + Sync.MessageInsert insert = 2; |
| 127 | + Sync.MessageDeleteRecord delete_record = 3; |
| 128 | + Sync.MessageError error = 4; |
| 129 | + } |
| 130 | + } |
| 131 | +} |
| 132 | + |
| 133 | +message Read { |
| 134 | + message Request { |
| 135 | + // marshalled arrow.Schema |
| 136 | + bytes table = 1; |
| 137 | + } |
| 138 | + message Response { |
| 139 | + // marshalled arrow.Record |
| 140 | + bytes record = 1; |
| 141 | + } |
| 142 | +} |
| 143 | + |
| 144 | +message TableRelation { |
| 145 | + string table_name = 1; |
| 146 | + string parent_table = 2; |
| 147 | +} |
| 148 | + |
| 149 | + |
| 150 | + |
| 151 | +message Predicate { |
| 152 | + enum Operator { |
| 153 | + EQ = 0; |
| 154 | + // LT = 1; |
| 155 | + // LTE = 2; |
| 156 | + // GT = 3; |
| 157 | + // GTE = 4; |
| 158 | + } |
| 159 | + |
| 160 | + Operator operator = 1; |
| 161 | + string column = 2; |
| 162 | + // marshalled arrow.Record |
| 163 | + bytes record = 3; |
| 164 | +} |
| 165 | + |
| 166 | +message PredicatesGroup { |
| 167 | + enum GroupingType { |
| 168 | + AND = 0; |
| 169 | + OR = 1; |
| 170 | + } |
| 171 | + GroupingType grouping_type = 1; |
| 172 | + repeated Predicate predicates = 2; |
| 173 | + |
| 174 | +} |
| 175 | + |
| 176 | +message Write { |
| 177 | + message MessageMigrateTable { |
| 178 | + // marshalled arrow.Schema |
| 179 | + bytes table = 1; |
| 180 | + bool migrate_force = 2; |
| 181 | + } |
| 182 | + message MessageInsert { |
| 183 | + // marshalled arrow.Record |
| 184 | + bytes record = 1; |
| 185 | + } |
| 186 | + message MessageDeleteStale { |
| 187 | + // marshalled arrow.Schema |
| 188 | + bytes table = 1 [deprecated = true]; |
| 189 | + string source_name = 2; |
| 190 | + google.protobuf.Timestamp sync_time = 3; |
| 191 | + string table_name = 4; |
| 192 | + } |
| 193 | + message MessageDeleteRecord { |
| 194 | + string table_name = 1; |
| 195 | + repeated PredicatesGroup where_clause = 2; |
| 196 | + repeated TableRelation table_relations = 3; |
| 197 | + } |
| 198 | + message Request { |
| 199 | + oneof message { |
| 200 | + Write.MessageMigrateTable migrate_table = 1; |
| 201 | + Write.MessageInsert insert = 2; |
| 202 | + Write.MessageDeleteStale delete = 3; |
| 203 | + Write.MessageDeleteRecord delete_record = 4; |
| 204 | + } |
| 205 | + } |
| 206 | + message Response {} |
| 207 | +} |
| 208 | + |
| 209 | +message Transform { |
| 210 | + message Request { |
| 211 | + // marshalled arrow.Record |
| 212 | + bytes record = 1; |
| 213 | + } |
| 214 | + message Response { |
| 215 | + // marshalled arrow.Record |
| 216 | + bytes record = 1; |
| 217 | + } |
| 218 | +} |
| 219 | + |
| 220 | +message TransformSchema { |
| 221 | + message Request { |
| 222 | + // marshalled arrow.Schema |
| 223 | + bytes schema = 1; |
| 224 | + } |
| 225 | + message Response { |
| 226 | + // marshalled arrow.Schema |
| 227 | + bytes schema = 1; |
| 228 | + } |
| 229 | +} |
| 230 | + |
| 231 | +message Close { |
| 232 | + message Request {} |
| 233 | + message Response {} |
| 234 | +} |
| 235 | + |
| 236 | +message TestConnection { |
| 237 | + message Request{ |
| 238 | + bytes spec = 1; // Internal plugin-specific spec |
| 239 | + } |
| 240 | + message Response{ |
| 241 | + bool success = 1; |
| 242 | + string failure_code = 2; |
| 243 | + string failure_description = 3; |
| 244 | + } |
| 245 | +} |
0 commit comments