From 262b68df9aa25ab1f58377ff11cea4b4f1448e61 Mon Sep 17 00:00:00 2001 From: Charles Date: Sat, 8 Aug 2020 14:56:09 -0700 Subject: [PATCH] add java codegen from json schema (#16) --- conduit-config/build.gradle | 34 ++++++++++++ .../json/StandardConnectionStatus.json | 17 ++++++ .../resources/json/StandardDataSchema.json | 52 +++++++++++++++++++ .../json/StandardDiscoveryOutput.json | 14 +++++ .../json/StandardScheduleConfiguration.json | 15 ++++++ .../json/StandardSyncConfiguration.json | 17 ++++++ .../resources/json/StandardSyncSummary.json | 47 +++++++++++++++++ settings.gradle | 2 + 8 files changed, 198 insertions(+) create mode 100644 conduit-config/build.gradle create mode 100644 conduit-config/src/main/resources/json/StandardConnectionStatus.json create mode 100644 conduit-config/src/main/resources/json/StandardDataSchema.json create mode 100644 conduit-config/src/main/resources/json/StandardDiscoveryOutput.json create mode 100644 conduit-config/src/main/resources/json/StandardScheduleConfiguration.json create mode 100644 conduit-config/src/main/resources/json/StandardSyncConfiguration.json create mode 100644 conduit-config/src/main/resources/json/StandardSyncSummary.json diff --git a/conduit-config/build.gradle b/conduit-config/build.gradle new file mode 100644 index 000000000000..83e2759f08e7 --- /dev/null +++ b/conduit-config/build.gradle @@ -0,0 +1,34 @@ +group 'io.dataline.conduit' +version '0.1.0' + +// todo: make sure we use the non-deprecated version of this. +// https://github.com/joelittlejohn/jsonschema2pojo/tree/master/jsonschema2pojo-gradle-plugin +apply plugin: 'jsonschema2pojo' + + +buildscript { + repositories { + mavenCentral() + } + + dependencies { + classpath 'org.jsonschema2pojo:jsonschema2pojo-gradle-plugin:1.0.2' + } +} + + +repositories { + mavenCentral() +} + +dependencies { + testCompile group: 'junit', name: 'junit', version: '4.12' + + // Required if generating JSR-303 annotations + compile 'javax.validation:validation-api:1.1.0.CR2' + // Required if generating Jackson 2 annotations + compile 'com.fasterxml.jackson.core:jackson-databind:2.9.7' +} + +jsonSchema2Pojo { +} diff --git a/conduit-config/src/main/resources/json/StandardConnectionStatus.json b/conduit-config/src/main/resources/json/StandardConnectionStatus.json new file mode 100644 index 000000000000..a1fcb8682ad8 --- /dev/null +++ b/conduit-config/src/main/resources/json/StandardConnectionStatus.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "StandardConnectionStatus", + "title": "StandardConnectionStatus", + "description": "describes the result of a 'test connection' action.", + "type": "object", + "required": ["status"], + "properties": { + "status": { + "type": "string", + "enum": ["success", "failure"] + }, + "message": { + "type": "string" + } + } +} diff --git a/conduit-config/src/main/resources/json/StandardDataSchema.json b/conduit-config/src/main/resources/json/StandardDataSchema.json new file mode 100644 index 000000000000..dc55ff16051b --- /dev/null +++ b/conduit-config/src/main/resources/json/StandardDataSchema.json @@ -0,0 +1,52 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "StandardDataSchema", + "title": "StandardDataSchema", + "type": "object", + "definitions": { + "schema": { + "description": "describes the available schema.", + "type": "object", + "properties": { + "tables": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name", + "columns" + ], + "properties": { + "name": { + "type": "string" + }, + "columns": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name", + "dataType" + ], + "properties": { + "name": { + "type": "string" + }, + "dataType": { + "type": "string", + "enum": [ + "string", + "number", + "boolean" + ] + } + } + } + } + } + } + } + } + } + } +} diff --git a/conduit-config/src/main/resources/json/StandardDiscoveryOutput.json b/conduit-config/src/main/resources/json/StandardDiscoveryOutput.json new file mode 100644 index 000000000000..1c37d293a0df --- /dev/null +++ b/conduit-config/src/main/resources/json/StandardDiscoveryOutput.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "StandardDiscoveryOutput", + "title": "StandardDiscoveryOutput", + "description": "describes the standard output for any discovery run.", + "type": "object", + "required": ["schema"], + "properties": { + "schema": { + "description": "describes the available schema.", + "$ref": "StandardDataSchema.json#/definitions/schema" + } + } +} diff --git a/conduit-config/src/main/resources/json/StandardScheduleConfiguration.json b/conduit-config/src/main/resources/json/StandardScheduleConfiguration.json new file mode 100644 index 000000000000..747e079f43e1 --- /dev/null +++ b/conduit-config/src/main/resources/json/StandardScheduleConfiguration.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "StandardScheduleConfiguration", + "title": "StandardScheduleConfiguration", + "type": "object", + "properties": { + "timeUnit": { + "type": "string", + "enum": ["minutes", "hours", "days", "weeks"] + }, + "units": { + "type": "integer" + } + } +} diff --git a/conduit-config/src/main/resources/json/StandardSyncConfiguration.json b/conduit-config/src/main/resources/json/StandardSyncConfiguration.json new file mode 100644 index 000000000000..00b29496d362 --- /dev/null +++ b/conduit-config/src/main/resources/json/StandardSyncConfiguration.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "StandardSyncConfiguration", + "title": "StandardSyncConfiguration", + "description": "configuration required for sync for ALL taps", + "type": "object", + "properties": { + "syncMode": { + "type": "string", + "enum": ["full_refresh", "append"] + }, + "schema": { + "description": "describes the elements of the schema that will be synced.", + "$ref": "StandardDataSchema.json#/definitions/schema" + } + } +} diff --git a/conduit-config/src/main/resources/json/StandardSyncSummary.json b/conduit-config/src/main/resources/json/StandardSyncSummary.json new file mode 100644 index 000000000000..4a4c5bdce9a3 --- /dev/null +++ b/conduit-config/src/main/resources/json/StandardSyncSummary.json @@ -0,0 +1,47 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "StandardSyncSummary", + "title": "StandardSyncSummary", + "description": "standard information output by ALL taps for a sync step (our version of state.json)", + "type": "object", + "properties": { + "attemptId": { + "type": "string", + "format": "uuid" + }, + "status": { + "type": "string", + "enum": ["pending", "in_progress","completed", "failed", "cancelled"] + }, + "recordsSynced": { + "type": "integer", + "minValue": 0 + }, + "version": { + "type": "integer" + }, + "tables": { + "type": "array", + "items": { + "type": "object", + "properties": { + "lastRecord": { + "description": "blob of the last record", + "type": "object" + }, + "version": { + "type": "integer" + } + } + } + }, + "startTime": { + "type": "integer" + }, + "endTime": { + "type": "integer" + }, + "logs": { + } + } +} diff --git a/settings.gradle b/settings.gradle index 03909be23fd7..1dffbfa8109c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,3 +3,5 @@ rootProject.name = 'conduit' include 'conduit-api' include 'conduit-server' include 'conduit-commons' +include 'conduit-config' +