diff --git a/protos/plugin/v3/plugin.proto b/protos/plugin/v3/plugin.proto index 0916ecf..b823fb5 100644 --- a/protos/plugin/v3/plugin.proto +++ b/protos/plugin/v3/plugin.proto @@ -12,6 +12,10 @@ service Plugin { rpc GetName(GetName.Request) returns (GetName.Response); // Get the current version of the plugin rpc GetVersion(GetVersion.Request) returns (GetVersion.Response); + // Get plugin spec schema. + // This will allow validating the input even before calling Init. + // Should be called before Init. + rpc GetSpecSchema(GetSpecSchema.Request) returns (GetSpecSchema.Response); // Configure the plugin with the given credentials and mode rpc Init(Init.Request) returns (Init.Response); // Get all tables the source plugin supports. Must be called after Init @@ -41,6 +45,15 @@ message GetVersion { } } +message GetSpecSchema { + message Request {} + message Response { + // Should be a valid JSON schema for the plugin spec. + // See https://json-schema.org for more details. + optional string json_schema = 1; + } +} + message Init { message Request { bytes spec = 1; // Internal plugin-specific spec diff --git a/protos/plugin/v3/plugin.ts b/protos/plugin/v3/plugin.ts index b2f293c..6c5ef7e 100644 --- a/protos/plugin/v3/plugin.ts +++ b/protos/plugin/v3/plugin.ts @@ -305,6 +305,167 @@ export namespace cloudquery.plugin.v3 { } } } + export class GetSpecSchema extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | {}) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { } + } + static fromObject(data: {}): GetSpecSchema { + const message = new GetSpecSchema({}); + return message; + } + toObject() { + const data: {} = {}; + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): GetSpecSchema { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new GetSpecSchema(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): GetSpecSchema { + return GetSpecSchema.deserialize(bytes); + } + } + export namespace GetSpecSchema { + export class Request extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | {}) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { } + } + static fromObject(data: {}): Request { + const message = new Request({}); + return message; + } + toObject() { + const data: {} = {}; + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Request { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Request(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): Request { + return Request.deserialize(bytes); + } + } + export class Response extends pb_1.Message { + #one_of_decls: number[][] = [[1]]; + constructor(data?: any[] | ({} & (({ + json_schema?: string; + })))) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("json_schema" in data && data.json_schema != undefined) { + this.json_schema = data.json_schema; + } + } + } + get json_schema() { + return pb_1.Message.getFieldWithDefault(this, 1, "") as string; + } + set json_schema(value: string) { + pb_1.Message.setOneofField(this, 1, this.#one_of_decls[0], value); + } + get has_json_schema() { + return pb_1.Message.getField(this, 1) != null; + } + get _json_schema() { + const cases: { + [index: number]: "none" | "json_schema"; + } = { + 0: "none", + 1: "json_schema" + }; + return cases[pb_1.Message.computeOneofCase(this, [1])]; + } + static fromObject(data: { + json_schema?: string; + }): Response { + const message = new Response({}); + if (data.json_schema != null) { + message.json_schema = data.json_schema; + } + return message; + } + toObject() { + const data: { + json_schema?: string; + } = {}; + if (this.json_schema != null) { + data.json_schema = this.json_schema; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.has_json_schema) + writer.writeString(1, this.json_schema); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Response { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Response(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.json_schema = reader.readString(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): Response { + return Response.deserialize(bytes); + } + } + } export class Init extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | {}) { @@ -2696,6 +2857,15 @@ export namespace cloudquery.plugin.v3 { responseSerialize: (message: GetVersion.Response) => Buffer.from(message.serialize()), responseDeserialize: (bytes: Buffer) => GetVersion.Response.deserialize(new Uint8Array(bytes)) }, + GetSpecSchema: { + path: "/cloudquery.plugin.v3.Plugin/GetSpecSchema", + requestStream: false, + responseStream: false, + requestSerialize: (message: GetSpecSchema.Request) => Buffer.from(message.serialize()), + requestDeserialize: (bytes: Buffer) => GetSpecSchema.Request.deserialize(new Uint8Array(bytes)), + responseSerialize: (message: GetSpecSchema.Response) => Buffer.from(message.serialize()), + responseDeserialize: (bytes: Buffer) => GetSpecSchema.Response.deserialize(new Uint8Array(bytes)) + }, Init: { path: "/cloudquery.plugin.v3.Plugin/Init", requestStream: false, @@ -2754,6 +2924,7 @@ export namespace cloudquery.plugin.v3 { [method: string]: grpc_1.UntypedHandleCall; abstract GetName(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; abstract GetVersion(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; + abstract GetSpecSchema(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; abstract Init(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; abstract GetTables(call: grpc_1.ServerUnaryCall, callback: grpc_1.sendUnaryData): void; abstract Sync(call: grpc_1.ServerWritableStream): void; @@ -2771,6 +2942,9 @@ export namespace cloudquery.plugin.v3 { GetVersion: GrpcUnaryServiceInterface = (message: GetVersion.Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { return super.GetVersion(message, metadata, options, callback); }; + GetSpecSchema: GrpcUnaryServiceInterface = (message: GetSpecSchema.Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { + return super.GetSpecSchema(message, metadata, options, callback); + }; Init: GrpcUnaryServiceInterface = (message: Init.Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback, options?: grpc_1.CallOptions | grpc_1.requestCallback, callback?: grpc_1.requestCallback): grpc_1.ClientUnaryCall => { return super.Init(message, metadata, options, callback); };