From 2b6a58780a8e29b8e9a054118b4776ea25ad1f6e Mon Sep 17 00:00:00 2001 From: Daniel Vaz Gaspar Date: Wed, 6 Jan 2021 10:29:05 +0000 Subject: [PATCH] fix(database): OpenAPI spec for test_connection (#12274) * fix(database): OpenAPI spec for test_connection * updated OpenAPI spec on superset docs * EOL --- docs/src/resources/openapi.json | 1858 +++++++++++++++++++++++++++---- superset/databases/api.py | 12 +- 2 files changed, 1650 insertions(+), 220 deletions(-) diff --git a/docs/src/resources/openapi.json b/docs/src/resources/openapi.json index f6caec95e..a86724ead 100644 --- a/docs/src/resources/openapi.json +++ b/docs/src/resources/openapi.json @@ -1539,14 +1539,14 @@ "type": "integer" }, "dashboards": { - "$ref": "#/components/schemas/Meta10" + "$ref": "#/components/schemas/Meta9" }, "description": { "nullable": true, "type": "string" }, "owners": { - "$ref": "#/components/schemas/Meta9" + "$ref": "#/components/schemas/Meta10" }, "params": { "nullable": true, @@ -1573,7 +1573,7 @@ "type": "integer" }, "changed_by": { - "$ref": "#/components/schemas/Meta6" + "$ref": "#/components/schemas/Meta5" }, "changed_by_name": { "readOnly": true @@ -1588,7 +1588,7 @@ "readOnly": true }, "created_by": { - "$ref": "#/components/schemas/Meta5" + "$ref": "#/components/schemas/Meta6" }, "datasource_id": { "format": "int32", @@ -1621,7 +1621,7 @@ "type": "integer" }, "owners": { - "$ref": "#/components/schemas/Meta8" + "$ref": "#/components/schemas/Meta7" }, "params": { "nullable": true, @@ -1633,7 +1633,7 @@ "type": "string" }, "table": { - "$ref": "#/components/schemas/Meta7" + "$ref": "#/components/schemas/Meta8" }, "thumbnail_url": { "readOnly": true @@ -1885,7 +1885,7 @@ "DashboardRestApi.get": { "properties": { "changed_by": { - "$ref": "#/components/schemas/Meta18" + "$ref": "#/components/schemas/Meta17" }, "changed_by_name": { "readOnly": true @@ -1919,7 +1919,7 @@ "type": "string" }, "owners": { - "$ref": "#/components/schemas/Meta17" + "$ref": "#/components/schemas/Meta18" }, "position_json": { "nullable": true, @@ -1949,7 +1949,7 @@ "DashboardRestApi.get_list": { "properties": { "changed_by": { - "$ref": "#/components/schemas/Meta16" + "$ref": "#/components/schemas/Meta15" }, "changed_by_name": { "readOnly": true @@ -1984,7 +1984,7 @@ "type": "string" }, "owners": { - "$ref": "#/components/schemas/Meta15" + "$ref": "#/components/schemas/Meta16" }, "position_json": { "nullable": true, @@ -2487,6 +2487,45 @@ }, "type": "object" }, + "DatabaseTestConnectionSchema": { + "properties": { + "database_name": { + "description": "A database name to identify this connection.", + "maxLength": 250, + "minLength": 1, + "nullable": true, + "type": "string" + }, + "encrypted_extra": { + "description": "

JSON string containing additional connection configuration.
This is used to provide connection information for systems like Hive, Presto, and BigQuery, which do not conform to the username:password syntax normally used by SQLAlchemy.

", + "nullable": true, + "type": "string" + }, + "extra": { + "description": "

JSON string containing extra configuration elements.
1. The engine_params object gets unpacked into the sqlalchemy.create_engine call, while the metadata_params gets unpacked into the sqlalchemy.MetaData call.
2. The metadata_cache_timeout is a cache timeout setting in seconds for metadata fetch of this database. Specify it as \"metadata_cache_timeout\": {\"schema_cache_timeout\": 600, \"table_cache_timeout\": 600}. If unset, cache will not be enabled for the functionality. A timeout of 0 indicates that the cache never expires.
3. The schemas_allowed_for_csv_upload is a comma separated list of schemas that CSVs are allowed to upload to. Specify it as \"schemas_allowed_for_csv_upload\": [\"public\", \"csv_upload\"]. If database flavor does not support schema or any schema is allowed to be accessed, just leave the list empty
4. the version field is a string specifying the this db's version. This should be used with Presto DBs so that the syntax is correct
5. The allows_virtual_table_explore field is a boolean specifying whether or not the Explore button in SQL Lab results is shown.

", + "type": "string" + }, + "impersonate_user": { + "description": "If Presto, all the queries in SQL Lab are going to be executed as the currently logged on user who must have permission to run them.
If Hive and hive.server2.enable.doAs is enabled, will run the queries as service account, but impersonate the currently logged on user via hive.server2.proxy.user property.", + "type": "boolean" + }, + "server_cert": { + "description": "

Optional CA_BUNDLE contents to validate HTTPS requests. Only available on certain database engines.

", + "nullable": true, + "type": "string" + }, + "sqlalchemy_uri": { + "description": "

Refer to the SqlAlchemy docs for more information on how to structure your URI.

", + "maxLength": 1024, + "minLength": 1, + "type": "string" + } + }, + "required": [ + "sqlalchemy_uri" + ], + "type": "object" + }, "DatasetColumnsPut": { "properties": { "column_name": { @@ -2670,7 +2709,7 @@ "type": "integer" }, "columns": { - "$ref": "#/components/schemas/Meta25" + "$ref": "#/components/schemas/Meta23" }, "database": { "$ref": "#/components/schemas/Meta26" @@ -2713,7 +2752,7 @@ "type": "string" }, "metrics": { - "$ref": "#/components/schemas/Meta23" + "$ref": "#/components/schemas/Meta25" }, "offset": { "format": "int32", @@ -3034,7 +3073,7 @@ "type": "integer" }, "user": { - "$ref": "#/components/schemas/Meta35" + "$ref": "#/components/schemas/Meta44" }, "user_id": { "format": "int32", @@ -3081,7 +3120,7 @@ "type": "integer" }, "user": { - "$ref": "#/components/schemas/Meta34" + "$ref": "#/components/schemas/Meta43" }, "user_id": { "format": "int32", @@ -3156,16 +3195,28 @@ }, "Meta10": { "properties": { - "dashboard_title": { - "maxLength": 500, - "nullable": true, + "first_name": { + "maxLength": 64, "type": "string" }, "id": { "format": "int32", "type": "integer" + }, + "last_name": { + "maxLength": 64, + "type": "string" + }, + "username": { + "maxLength": 64, + "type": "string" } }, + "required": [ + "first_name", + "last_name", + "username" + ], "type": "object" }, "Meta11": { @@ -3349,6 +3400,18 @@ "type": "object" }, "Meta17": { + "properties": { + "username": { + "maxLength": 64, + "type": "string" + } + }, + "required": [ + "username" + ], + "type": "object" + }, + "Meta18": { "properties": { "first_name": { "maxLength": 64, @@ -3374,18 +3437,6 @@ ], "type": "object" }, - "Meta18": { - "properties": { - "username": { - "maxLength": 64, - "type": "string" - } - }, - "required": [ - "username" - ], - "type": "object" - }, "Meta19": { "properties": { "first_name": { @@ -3477,94 +3528,6 @@ "type": "object" }, "Meta23": { - "properties": { - "changed_on": { - "format": "date-time", - "nullable": true, - "type": "string" - }, - "created_on": { - "format": "date-time", - "nullable": true, - "type": "string" - }, - "d3format": { - "maxLength": 128, - "nullable": true, - "type": "string" - }, - "description": { - "nullable": true, - "type": "string" - }, - "expression": { - "type": "string" - }, - "extra": { - "nullable": true, - "type": "string" - }, - "id": { - "format": "int32", - "type": "integer" - }, - "metric_name": { - "maxLength": 255, - "type": "string" - }, - "metric_type": { - "maxLength": 32, - "nullable": true, - "type": "string" - }, - "uuid": { - "format": "uuid", - "nullable": true, - "type": "string" - }, - "verbose_name": { - "maxLength": 1024, - "nullable": true, - "type": "string" - }, - "warning_text": { - "nullable": true, - "type": "string" - } - }, - "required": [ - "expression", - "metric_name" - ], - "type": "object" - }, - "Meta24": { - "properties": { - "first_name": { - "maxLength": 64, - "type": "string" - }, - "id": { - "format": "int32", - "type": "integer" - }, - "last_name": { - "maxLength": 64, - "type": "string" - }, - "username": { - "maxLength": 64, - "type": "string" - } - }, - "required": [ - "first_name", - "last_name", - "username" - ], - "type": "object" - }, - "Meta25": { "properties": { "changed_on": { "format": "date-time", @@ -3634,35 +3597,7 @@ ], "type": "object" }, - "Meta26": { - "properties": { - "database_name": { - "maxLength": 250, - "type": "string" - }, - "id": { - "format": "int32", - "type": "integer" - } - }, - "required": [ - "database_name" - ], - "type": "object" - }, - "Meta27": { - "properties": { - "database_name": { - "maxLength": 250, - "type": "string" - } - }, - "required": [ - "database_name" - ], - "type": "object" - }, - "Meta28": { + "Meta24": { "properties": { "first_name": { "maxLength": 64, @@ -3688,6 +3623,122 @@ ], "type": "object" }, + "Meta25": { + "properties": { + "changed_on": { + "format": "date-time", + "nullable": true, + "type": "string" + }, + "created_on": { + "format": "date-time", + "nullable": true, + "type": "string" + }, + "d3format": { + "maxLength": 128, + "nullable": true, + "type": "string" + }, + "description": { + "nullable": true, + "type": "string" + }, + "expression": { + "type": "string" + }, + "extra": { + "nullable": true, + "type": "string" + }, + "id": { + "format": "int32", + "type": "integer" + }, + "metric_name": { + "maxLength": 255, + "type": "string" + }, + "metric_type": { + "maxLength": 32, + "nullable": true, + "type": "string" + }, + "uuid": { + "format": "uuid", + "nullable": true, + "type": "string" + }, + "verbose_name": { + "maxLength": 1024, + "nullable": true, + "type": "string" + }, + "warning_text": { + "nullable": true, + "type": "string" + } + }, + "required": [ + "expression", + "metric_name" + ], + "type": "object" + }, + "Meta26": { + "properties": { + "database_name": { + "maxLength": 250, + "type": "string" + }, + "id": { + "format": "int32", + "type": "integer" + } + }, + "required": [ + "database_name" + ], + "type": "object" + }, + "Meta27": { + "properties": { + "first_name": { + "maxLength": 64, + "type": "string" + }, + "id": { + "format": "int32", + "type": "integer" + }, + "last_name": { + "maxLength": 64, + "type": "string" + }, + "username": { + "maxLength": 64, + "type": "string" + } + }, + "required": [ + "first_name", + "last_name", + "username" + ], + "type": "object" + }, + "Meta28": { + "properties": { + "database_name": { + "maxLength": 250, + "type": "string" + } + }, + "required": [ + "database_name" + ], + "type": "object" + }, "Meta29": { "properties": { "id": { @@ -3790,28 +3841,93 @@ }, "Meta34": { "properties": { - "username": { - "maxLength": 64, + "id": { + "format": "int32", + "type": "integer" + }, + "type": { + "maxLength": 50, "type": "string" } }, "required": [ - "username" + "type" ], "type": "object" }, "Meta35": { "properties": { - "username": { + "first_name": { + "maxLength": 64, + "type": "string" + }, + "last_name": { "maxLength": 64, "type": "string" } }, "required": [ - "username" + "first_name", + "last_name" ], "type": "object" }, + "Meta36": { + "properties": { + "first_name": { + "maxLength": 64, + "type": "string" + }, + "last_name": { + "maxLength": 64, + "type": "string" + } + }, + "required": [ + "first_name", + "last_name" + ], + "type": "object" + }, + "Meta37": { + "properties": { + "first_name": { + "maxLength": 64, + "type": "string" + }, + "id": { + "format": "int32", + "type": "integer" + }, + "last_name": { + "maxLength": 64, + "type": "string" + } + }, + "required": [ + "first_name", + "last_name" + ], + "type": "object" + }, + "Meta38": { + "properties": { + "id": { + "format": "int32", + "type": "integer" + } + }, + "type": "object" + }, + "Meta39": { + "properties": { + "id": { + "format": "int32", + "type": "integer" + } + }, + "type": "object" + }, "Meta4": { "properties": { "first_name": { @@ -3829,7 +3945,27 @@ ], "type": "object" }, - "Meta5": { + "Meta40": { + "properties": { + "id": { + "format": "int32", + "type": "integer" + }, + "recipient_config_json": { + "nullable": true, + "type": "string" + }, + "type": { + "maxLength": 50, + "type": "string" + } + }, + "required": [ + "type" + ], + "type": "object" + }, + "Meta41": { "properties": { "first_name": { "maxLength": 64, @@ -3850,12 +3986,66 @@ ], "type": "object" }, + "Meta42": { + "properties": { + "id": { + "format": "int32", + "type": "integer" + } + }, + "type": "object" + }, + "Meta43": { + "properties": { + "username": { + "maxLength": 64, + "type": "string" + } + }, + "required": [ + "username" + ], + "type": "object" + }, + "Meta44": { + "properties": { + "username": { + "maxLength": 64, + "type": "string" + } + }, + "required": [ + "username" + ], + "type": "object" + }, + "Meta5": { + "properties": { + "first_name": { + "maxLength": 64, + "type": "string" + }, + "last_name": { + "maxLength": 64, + "type": "string" + } + }, + "required": [ + "first_name", + "last_name" + ], + "type": "object" + }, "Meta6": { "properties": { "first_name": { "maxLength": 64, "type": "string" }, + "id": { + "format": "int32", + "type": "integer" + }, "last_name": { "maxLength": 64, "type": "string" @@ -3868,6 +4058,32 @@ "type": "object" }, "Meta7": { + "properties": { + "first_name": { + "maxLength": 64, + "type": "string" + }, + "id": { + "format": "int32", + "type": "integer" + }, + "last_name": { + "maxLength": 64, + "type": "string" + }, + "username": { + "maxLength": 64, + "type": "string" + } + }, + "required": [ + "first_name", + "last_name", + "username" + ], + "type": "object" + }, + "Meta8": { "properties": { "default_endpoint": { "nullable": true, @@ -3883,56 +4099,18 @@ ], "type": "object" }, - "Meta8": { - "properties": { - "first_name": { - "maxLength": 64, - "type": "string" - }, - "id": { - "format": "int32", - "type": "integer" - }, - "last_name": { - "maxLength": 64, - "type": "string" - }, - "username": { - "maxLength": 64, - "type": "string" - } - }, - "required": [ - "first_name", - "last_name", - "username" - ], - "type": "object" - }, "Meta9": { "properties": { - "first_name": { - "maxLength": 64, + "dashboard_title": { + "maxLength": 500, + "nullable": true, "type": "string" }, "id": { "format": "int32", "type": "integer" - }, - "last_name": { - "maxLength": 64, - "type": "string" - }, - "username": { - "maxLength": 64, - "type": "string" } }, - "required": [ - "first_name", - "last_name", - "username" - ], "type": "object" }, "QueryRestApi.get": { @@ -4062,7 +4240,7 @@ "type": "string" }, "database": { - "$ref": "#/components/schemas/Meta27" + "$ref": "#/components/schemas/Meta28" }, "end_time": { "nullable": true, @@ -4117,7 +4295,7 @@ "type": "string" }, "user": { - "$ref": "#/components/schemas/Meta28" + "$ref": "#/components/schemas/Meta27" } }, "required": [ @@ -4173,6 +4351,517 @@ }, "type": "object" }, + "ReportExecutionLogRestApi.get": { + "properties": { + "end_dttm": { + "format": "date-time", + "nullable": true, + "type": "string" + }, + "error_message": { + "nullable": true, + "type": "string" + }, + "id": { + "format": "int32", + "type": "integer" + }, + "scheduled_dttm": { + "format": "date-time", + "type": "string" + }, + "start_dttm": { + "format": "date-time", + "nullable": true, + "type": "string" + }, + "state": { + "maxLength": 50, + "type": "string" + }, + "value": { + "format": "float", + "nullable": true, + "type": "number" + }, + "value_row_json": { + "nullable": true, + "type": "string" + } + }, + "required": [ + "scheduled_dttm", + "state" + ], + "type": "object" + }, + "ReportExecutionLogRestApi.get_list": { + "properties": { + "end_dttm": { + "format": "date-time", + "nullable": true, + "type": "string" + }, + "error_message": { + "nullable": true, + "type": "string" + }, + "id": { + "format": "int32", + "type": "integer" + }, + "scheduled_dttm": { + "format": "date-time", + "type": "string" + }, + "start_dttm": { + "format": "date-time", + "nullable": true, + "type": "string" + }, + "state": { + "maxLength": 50, + "type": "string" + }, + "value": { + "format": "float", + "nullable": true, + "type": "number" + }, + "value_row_json": { + "nullable": true, + "type": "string" + } + }, + "required": [ + "scheduled_dttm", + "state" + ], + "type": "object" + }, + "ReportExecutionLogRestApi.post": { + "properties": { + "id": { + "format": "int32", + "type": "integer" + } + }, + "type": "object" + }, + "ReportExecutionLogRestApi.put": { + "properties": { + "id": { + "format": "int32", + "type": "integer" + } + }, + "type": "object" + }, + "ReportRecipient": { + "properties": { + "recipient_config_json": { + "$ref": "#/components/schemas/ReportRecipientConfigJSON" + }, + "type": { + "description": "The recipient type, check spec for valid options", + "enum": [ + "Email", + "Slack" + ], + "type": "string" + } + }, + "required": [ + "type" + ], + "type": "object" + }, + "ReportRecipientConfigJSON": { + "properties": { + "target": { + "type": "string" + } + }, + "type": "object" + }, + "ReportScheduleRestApi.get": { + "properties": { + "active": { + "nullable": true, + "type": "boolean" + }, + "chart": { + "$ref": "#/components/schemas/Meta39" + }, + "context_markdown": { + "nullable": true, + "type": "string" + }, + "crontab": { + "maxLength": 1000, + "type": "string" + }, + "dashboard": { + "$ref": "#/components/schemas/Meta38" + }, + "database": { + "$ref": "#/components/schemas/Meta42" + }, + "description": { + "nullable": true, + "type": "string" + }, + "grace_period": { + "format": "int32", + "nullable": true, + "type": "integer" + }, + "id": { + "format": "int32", + "type": "integer" + }, + "last_eval_dttm": { + "format": "date-time", + "nullable": true, + "type": "string" + }, + "last_state": { + "maxLength": 50, + "nullable": true, + "type": "string" + }, + "last_value": { + "format": "float", + "nullable": true, + "type": "number" + }, + "last_value_row_json": { + "nullable": true, + "type": "string" + }, + "log_retention": { + "format": "int32", + "nullable": true, + "type": "integer" + }, + "name": { + "maxLength": 150, + "type": "string" + }, + "owners": { + "$ref": "#/components/schemas/Meta41" + }, + "recipients": { + "$ref": "#/components/schemas/Meta40" + }, + "sql": { + "nullable": true, + "type": "string" + }, + "type": { + "maxLength": 50, + "type": "string" + }, + "validator_config_json": { + "nullable": true, + "type": "string" + }, + "validator_type": { + "maxLength": 100, + "nullable": true, + "type": "string" + }, + "working_timeout": { + "format": "int32", + "nullable": true, + "type": "integer" + } + }, + "required": [ + "crontab", + "name", + "recipients", + "type" + ], + "type": "object" + }, + "ReportScheduleRestApi.get_list": { + "properties": { + "active": { + "nullable": true, + "type": "boolean" + }, + "changed_by": { + "$ref": "#/components/schemas/Meta36" + }, + "changed_on": { + "format": "date-time", + "nullable": true, + "type": "string" + }, + "changed_on_delta_humanized": { + "readOnly": true + }, + "created_by": { + "$ref": "#/components/schemas/Meta35" + }, + "created_on": { + "format": "date-time", + "nullable": true, + "type": "string" + }, + "crontab": { + "maxLength": 1000, + "type": "string" + }, + "crontab_humanized": { + "readOnly": true + }, + "id": { + "format": "int32", + "type": "integer" + }, + "last_eval_dttm": { + "format": "date-time", + "nullable": true, + "type": "string" + }, + "last_state": { + "maxLength": 50, + "nullable": true, + "type": "string" + }, + "name": { + "maxLength": 150, + "type": "string" + }, + "owners": { + "$ref": "#/components/schemas/Meta37" + }, + "recipients": { + "$ref": "#/components/schemas/Meta34" + }, + "type": { + "maxLength": 50, + "type": "string" + } + }, + "required": [ + "crontab", + "name", + "recipients", + "type" + ], + "type": "object" + }, + "ReportScheduleRestApi.post": { + "properties": { + "active": { + "type": "boolean" + }, + "chart": { + "format": "int32", + "type": "integer" + }, + "context_markdown": { + "description": "Markdown description", + "nullable": true, + "type": "string" + }, + "crontab": { + "description": "A CRON expression.[Crontab Guru](https://crontab.guru/) is a helpful resource that can help you craft a CRON expression.", + "example": "*/5 * * * *", + "maxLength": 1000, + "minLength": 1, + "type": "string" + }, + "dashboard": { + "format": "int32", + "type": "integer" + }, + "database": { + "format": "int32", + "type": "integer" + }, + "description": { + "description": "Use a nice description to give context to this Alert/Report", + "example": "Daily sales dashboard to marketing", + "nullable": true, + "type": "string" + }, + "grace_period": { + "description": "Once an alert is triggered, how long, in seconds, before Superset nags you again. (in seconds)", + "example": 14400, + "format": "int32", + "type": "integer" + }, + "log_retention": { + "description": "How long to keep the logs around for this report (in days)", + "example": 90, + "format": "int32", + "type": "integer" + }, + "name": { + "description": "The report schedule name.", + "example": "Daily dashboard email", + "maxLength": 150, + "minLength": 1, + "type": "string" + }, + "owners": { + "items": { + "description": "Owner are users ids allowed to delete or change this report. If left empty you will be one of the owners of the report.", + "format": "int32", + "type": "integer" + }, + "type": "array" + }, + "recipients": { + "items": { + "$ref": "#/components/schemas/ReportRecipient" + }, + "type": "array" + }, + "sql": { + "description": "A SQL statement that defines whether the alert should get triggered or not. The query is expected to return either NULL or a number value.", + "example": "SELECT value FROM time_series_table", + "type": "string" + }, + "type": { + "description": "The report schedule type", + "enum": [ + "Alert", + "Report" + ], + "type": "string" + }, + "validator_config_json": { + "$ref": "#/components/schemas/ValidatorConfigJSON" + }, + "validator_type": { + "description": "Determines when to trigger alert based off value from alert query. Alerts will be triggered with these validator types:\n- Not Null - When the return value is Not NULL, Empty, or 0\n- Operator - When `sql_return_value comparison_operator threshold` is True e.g. `50 <= 75`
Supports the comparison operators <, <=, >, >=, ==, and !=", + "enum": [ + "not null", + "operator" + ], + "type": "string" + }, + "working_timeout": { + "description": "If an alert is staled at a working state, how long until it's state is reseted to error", + "example": 3600, + "format": "int32", + "type": "integer" + } + }, + "required": [ + "crontab", + "name", + "type" + ], + "type": "object" + }, + "ReportScheduleRestApi.put": { + "properties": { + "active": { + "type": "boolean" + }, + "chart": { + "format": "int32", + "type": "integer" + }, + "context_markdown": { + "description": "Markdown description", + "nullable": true, + "type": "string" + }, + "crontab": { + "description": "A CRON expression.[Crontab Guru](https://crontab.guru/) is a helpful resource that can help you craft a CRON expression.", + "maxLength": 1000, + "minLength": 1, + "type": "string" + }, + "dashboard": { + "format": "int32", + "type": "integer" + }, + "database": { + "format": "int32", + "type": "integer" + }, + "description": { + "description": "Use a nice description to give context to this Alert/Report", + "example": "Daily sales dashboard to marketing", + "nullable": true, + "type": "string" + }, + "grace_period": { + "description": "Once an alert is triggered, how long, in seconds, before Superset nags you again. (in seconds)", + "example": 14400, + "format": "int32", + "type": "integer" + }, + "log_retention": { + "description": "How long to keep the logs around for this report (in days)", + "example": 90, + "format": "int32", + "type": "integer" + }, + "name": { + "description": "The report schedule name.", + "maxLength": 150, + "minLength": 1, + "type": "string" + }, + "owners": { + "items": { + "description": "Owner are users ids allowed to delete or change this report. If left empty you will be one of the owners of the report.", + "format": "int32", + "type": "integer" + }, + "type": "array" + }, + "recipients": { + "items": { + "$ref": "#/components/schemas/ReportRecipient" + }, + "type": "array" + }, + "sql": { + "description": "A SQL statement that defines whether the alert should get triggered or not. The query is expected to return either NULL or a number value.", + "example": "SELECT value FROM time_series_table", + "nullable": true, + "type": "string" + }, + "type": { + "description": "The report schedule type", + "enum": [ + "Alert", + "Report" + ], + "type": "string" + }, + "validator_config_json": { + "$ref": "#/components/schemas/ValidatorConfigJSON" + }, + "validator_type": { + "description": "Determines when to trigger alert based off value from alert query. Alerts will be triggered with these validator types:\n- Not Null - When the return value is Not NULL, Empty, or 0\n- Operator - When `sql_return_value comparison_operator threshold` is True e.g. `50 <= 75`
Supports the comparison operators <, <=, >, >=, ==, and !=", + "enum": [ + "not null", + "operator" + ], + "nullable": true, + "type": "string" + }, + "working_timeout": { + "description": "If an alert is staled at a working state, how long until it's state is reseted to error", + "example": 3600, + "format": "int32", + "nullable": true, + "type": "integer" + } + }, + "type": "object" + }, "SavedQueryRestApi.get": { "properties": { "created_by": { @@ -4485,6 +5174,27 @@ }, "type": "object" }, + "ValidatorConfigJSON": { + "properties": { + "op": { + "description": "The operation to compare with a threshold to apply to the SQL output\n", + "enum": [ + "<", + "<=", + ">", + ">=", + "==", + "!=" + ], + "type": "string" + }, + "threshold": { + "format": "int32", + "type": "integer" + } + }, + "type": "object" + }, "database_schemas_query_schema": { "properties": { "force": { @@ -8641,21 +9351,7 @@ "content": { "application/json": { "schema": { - "properties": { - "encrypted_extra": { - "type": "object" - }, - "extras": { - "type": "object" - }, - "name": { - "type": "string" - }, - "server_cert": { - "type": "string" - } - }, - "type": "object" + "$ref": "#/components/schemas/DatabaseTestConnectionSchema" } } }, @@ -10791,6 +11487,748 @@ ] } }, + "/report/": { + "delete": { + "description": "Deletes multiple report schedules in a bulk operation.", + "parameters": [ + { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_delete_ids_schema" + } + } + }, + "in": "query", + "name": "q" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "properties": { + "message": { + "type": "string" + } + }, + "type": "object" + } + } + }, + "description": "Report Schedule bulk delete" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "404": { + "$ref": "#/components/responses/404" + }, + "422": { + "$ref": "#/components/responses/422" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "jwt": [] + } + ], + "tags": [ + "Report Schedules" + ] + }, + "get": { + "description": "Get a list of report schedules, use Rison or JSON query parameters for filtering, sorting, pagination and for selecting specific columns and metadata.", + "parameters": [ + { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_list_schema" + } + } + }, + "in": "query", + "name": "q" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "properties": { + "count": { + "description": "The total record count on the backend", + "type": "number" + }, + "description_columns": { + "properties": { + "column_name": { + "description": "The description for the column name. Will be translated by babel", + "example": "A Nice description for the column", + "type": "string" + } + }, + "type": "object" + }, + "ids": { + "description": "A list of item ids, useful when you don't know the column id", + "items": { + "type": "string" + }, + "type": "array" + }, + "label_columns": { + "properties": { + "column_name": { + "description": "The label for the column name. Will be translated by babel", + "example": "A Nice label for the column", + "type": "string" + } + }, + "type": "object" + }, + "list_columns": { + "description": "A list of columns", + "items": { + "type": "string" + }, + "type": "array" + }, + "list_title": { + "description": "A title to render. Will be translated by babel", + "example": "List Items", + "type": "string" + }, + "order_columns": { + "description": "A list of allowed columns to sort", + "items": { + "type": "string" + }, + "type": "array" + }, + "result": { + "description": "The result from the get list query", + "items": { + "$ref": "#/components/schemas/ReportScheduleRestApi.get_list" + }, + "type": "array" + } + }, + "type": "object" + } + } + }, + "description": "Items from Model" + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "422": { + "$ref": "#/components/responses/422" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "jwt": [] + } + ], + "tags": [ + "Report Schedules" + ] + }, + "post": { + "description": "Create a report schedule", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ReportScheduleRestApi.post" + } + } + }, + "description": "Report Schedule schema", + "required": true + }, + "responses": { + "201": { + "content": { + "application/json": { + "schema": { + "properties": { + "id": { + "type": "number" + }, + "result": { + "$ref": "#/components/schemas/ReportScheduleRestApi.post" + } + }, + "type": "object" + } + } + }, + "description": "Report schedule added" + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "404": { + "$ref": "#/components/responses/404" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "jwt": [] + } + ], + "tags": [ + "Report Schedules" + ] + } + }, + "/report/_info": { + "get": { + "description": "Get metadata information about this API resource", + "parameters": [ + { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_info_schema" + } + } + }, + "in": "query", + "name": "q" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "properties": { + "add_columns": { + "type": "object" + }, + "edit_columns": { + "type": "object" + }, + "filters": { + "properties": { + "column_name": { + "items": { + "properties": { + "name": { + "description": "The filter name. Will be translated by babel", + "type": "string" + }, + "operator": { + "description": "The filter operation key to use on list filters", + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, + "permissions": { + "description": "The user permissions for this API resource", + "items": { + "type": "string" + }, + "type": "array" + } + }, + "type": "object" + } + } + }, + "description": "Item from Model" + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "422": { + "$ref": "#/components/responses/422" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "jwt": [] + } + ], + "tags": [ + "Report Schedules" + ] + } + }, + "/report/related/{column_name}": { + "get": { + "parameters": [ + { + "in": "path", + "name": "column_name", + "required": true, + "schema": { + "type": "string" + } + }, + { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_related_schema" + } + } + }, + "in": "query", + "name": "q" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RelatedResponseSchema" + } + } + }, + "description": "Related column data" + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "404": { + "$ref": "#/components/responses/404" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "jwt": [] + } + ], + "tags": [ + "Report Schedules" + ] + } + }, + "/report/{pk}": { + "delete": { + "description": "Delete a report schedule", + "parameters": [ + { + "description": "The report schedule pk", + "in": "path", + "name": "pk", + "required": true, + "schema": { + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "properties": { + "message": { + "type": "string" + } + }, + "type": "object" + } + } + }, + "description": "Item deleted" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "404": { + "$ref": "#/components/responses/404" + }, + "422": { + "$ref": "#/components/responses/422" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "jwt": [] + } + ], + "tags": [ + "Report Schedules" + ] + }, + "get": { + "description": "Get a report schedule", + "parameters": [ + { + "in": "path", + "name": "pk", + "required": true, + "schema": { + "type": "integer" + } + }, + { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_item_schema" + } + } + }, + "in": "query", + "name": "q" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "properties": { + "description_columns": { + "properties": { + "column_name": { + "description": "The description for the column name. Will be translated by babel", + "example": "A Nice description for the column", + "type": "string" + } + }, + "type": "object" + }, + "id": { + "description": "The item id", + "type": "string" + }, + "label_columns": { + "properties": { + "column_name": { + "description": "The label for the column name. Will be translated by babel", + "example": "A Nice label for the column", + "type": "string" + } + }, + "type": "object" + }, + "result": { + "$ref": "#/components/schemas/ReportScheduleRestApi.get" + }, + "show_columns": { + "description": "A list of columns", + "items": { + "type": "string" + }, + "type": "array" + }, + "show_title": { + "description": "A title to render. Will be translated by babel", + "example": "Show Item Details", + "type": "string" + } + }, + "type": "object" + } + } + }, + "description": "Item from Model" + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "404": { + "$ref": "#/components/responses/404" + }, + "422": { + "$ref": "#/components/responses/422" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "jwt": [] + } + ], + "tags": [ + "Report Schedules" + ] + }, + "put": { + "description": "Update a report schedule", + "parameters": [ + { + "description": "The Report Schedule pk", + "in": "path", + "name": "pk", + "required": true, + "schema": { + "type": "integer" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ReportScheduleRestApi.put" + } + } + }, + "description": "Report Schedule schema", + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "properties": { + "id": { + "type": "number" + }, + "result": { + "$ref": "#/components/schemas/ReportScheduleRestApi.put" + } + }, + "type": "object" + } + } + }, + "description": "Report Schedule changed" + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "403": { + "$ref": "#/components/responses/403" + }, + "404": { + "$ref": "#/components/responses/404" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "jwt": [] + } + ], + "tags": [ + "Report Schedules" + ] + } + }, + "/report/{pk}/log/": { + "get": { + "description": "Get a list of report schedule logs, use Rison or JSON query parameters for filtering, sorting, pagination and for selecting specific columns and metadata.", + "parameters": [ + { + "description": "The report schedule id for these logs", + "in": "path", + "name": "pk", + "required": true, + "schema": { + "type": "integer" + } + }, + { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_list_schema" + } + } + }, + "in": "query", + "name": "q" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "properties": { + "count": { + "description": "The total record count on the backend", + "type": "number" + }, + "ids": { + "description": "A list of log ids", + "items": { + "type": "string" + }, + "type": "array" + }, + "result": { + "description": "The result from the get list query", + "items": { + "$ref": "#/components/schemas/ReportExecutionLogRestApi.get_list" + }, + "type": "array" + } + }, + "type": "object" + } + } + }, + "description": "Items from logs" + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "422": { + "$ref": "#/components/responses/422" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "jwt": [] + } + ], + "tags": [ + "Report Schedules" + ] + } + }, + "/report/{pk}/log/{log_id}": { + "get": { + "description": "Get a report schedule log", + "parameters": [ + { + "description": "The report schedule pk for log", + "in": "path", + "name": "pk", + "required": true, + "schema": { + "type": "integer" + } + }, + { + "description": "The log pk", + "in": "path", + "name": "log_id", + "required": true, + "schema": { + "type": "integer" + } + }, + { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/get_item_schema" + } + } + }, + "in": "query", + "name": "q" + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "properties": { + "id": { + "description": "The log id", + "type": "string" + }, + "result": { + "$ref": "#/components/schemas/ReportExecutionLogRestApi.get" + } + }, + "type": "object" + } + } + }, + "description": "Item log" + }, + "400": { + "$ref": "#/components/responses/400" + }, + "401": { + "$ref": "#/components/responses/401" + }, + "404": { + "$ref": "#/components/responses/404" + }, + "422": { + "$ref": "#/components/responses/422" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "security": [ + { + "jwt": [] + } + ], + "tags": [ + "Report Schedules" + ] + } + }, "/saved_query/": { "delete": { "description": "Deletes multiple saved queries in a bulk operation.", diff --git a/superset/databases/api.py b/superset/databases/api.py index 33f9f38be..01b23bcc2 100644 --- a/superset/databases/api.py +++ b/superset/databases/api.py @@ -179,6 +179,7 @@ class DatabaseRestApi(BaseSupersetModelRestApi): openapi_spec_tag = "Database" openapi_spec_component_schemas = ( DatabaseRelatedObjectsResponse, + DatabaseTestConnectionSchema, TableMetadataResponseSchema, SelectStarResponseSchema, SchemasResponseSchema, @@ -560,16 +561,7 @@ class DatabaseRestApi(BaseSupersetModelRestApi): content: application/json: schema: - type: object - properties: - encrypted_extra: - type: object - extras: - type: object - name: - type: string - server_cert: - type: string + $ref: "#/components/schemas/DatabaseTestConnectionSchema" responses: 200: description: Database Test Connection