From 4b3dccf71502b5aa8251d0ef9a1cd39e21e9ccc6 Mon Sep 17 00:00:00 2001 From: Varsha-dr <114489823+varshadr@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:01:51 +0530 Subject: [PATCH 1/5] Added links path to the custom preprocessing hook --- config/settings/openapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/settings/openapi.py b/config/settings/openapi.py index 1095acbd77..a9f1a91e58 100644 --- a/config/settings/openapi.py +++ b/config/settings/openapi.py @@ -2,7 +2,7 @@ def custom_preprocessing_hook(endpoints): filtered = [] for (path, path_regex, method, callback) in endpoints: # Remove all but DRF API endpoints - if path.startswith("/api/db/v0/databases/") or path.startswith("/api/db/v0/data_files/") or path.startswith("/api/db/v0/schemas/") or path.startswith("/api/db/v0/tables/"): + if path.startswith("/api/db/v0/databases/") or path.startswith("/api/db/v0/data_files/") or path.startswith("/api/db/v0/schemas/") or path.startswith("/api/db/v0/tables/") or path.startswith("/api/db/v0/links/") : filtered.append((path, path_regex, method, callback)) return filtered From e6eee95e18e1cbf158d7860b18bc3d8992357039 Mon Sep 17 00:00:00 2001 From: Varsha-dr <114489823+varshadr@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:03:08 +0530 Subject: [PATCH 2/5] Added openAPI spec for 'links' endpoint --- schema.yml | 229 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 222 insertions(+), 7 deletions(-) diff --git a/schema.yml b/schema.yml index 25491467bc..cefe640aab 100644 --- a/schema.yml +++ b/schema.yml @@ -200,6 +200,32 @@ paths: schema: $ref: '#/components/schemas/PaginatedDatabaseList' description: '' + post: + operationId: databases_create + tags: + - databases + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Database' + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/Database' + multipart/form-data: + schema: + $ref: '#/components/schemas/Database' + required: true + security: + - tokenAuth: [] + - cookieAuth: [] + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/Database' + description: '' /api/db/v0/databases/{id}/: get: operationId: databases_retrieve @@ -222,6 +248,88 @@ paths: schema: $ref: '#/components/schemas/Database' description: '' + put: + operationId: databases_update + parameters: + - in: path + name: id + schema: + type: integer + description: A unique integer value identifying this database. + required: true + tags: + - databases + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Database' + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/Database' + multipart/form-data: + schema: + $ref: '#/components/schemas/Database' + required: true + security: + - tokenAuth: [] + - cookieAuth: [] + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Database' + description: '' + patch: + operationId: databases_partial_update + parameters: + - in: path + name: id + schema: + type: integer + description: A unique integer value identifying this database. + required: true + tags: + - databases + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PatchedDatabase' + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/PatchedDatabase' + multipart/form-data: + schema: + $ref: '#/components/schemas/PatchedDatabase' + security: + - tokenAuth: [] + - cookieAuth: [] + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Database' + description: '' + delete: + operationId: databases_destroy + parameters: + - in: path + name: id + schema: + type: integer + description: A unique integer value identifying this database. + required: true + tags: + - databases + security: + - tokenAuth: [] + - cookieAuth: [] + responses: + '204': + description: No response body /api/db/v0/databases/{id}/functions/: get: operationId: databases_functions_retrieve @@ -266,6 +374,33 @@ paths: schema: $ref: '#/components/schemas/Database' description: '' + /api/db/v0/links/: + post: + operationId: links_create + tags: + - links + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/LinksMapping' + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/LinksMapping' + multipart/form-data: + schema: + $ref: '#/components/schemas/LinksMapping' + required: true + security: + - tokenAuth: [] + - cookieAuth: [] + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/LinksMapping' + description: '' /api/db/v0/schemas/: get: operationId: schemas_list @@ -1593,6 +1728,9 @@ components: has_dependents: type: string readOnly: true + description: + type: string + nullable: true required: - has_dependents - valid_target_types @@ -1683,6 +1821,10 @@ components: type: integer maximum: 2147483647 minimum: -2147483648 + sheet_index: + type: integer + maximum: 2147483647 + minimum: -2147483648 required: - created_from - id @@ -1696,18 +1838,54 @@ components: readOnly: true name: type: string - readOnly: true + maxLength: 128 + db_name: + type: string + maxLength: 128 deleted: type: boolean readOnly: true + editable: + type: boolean + readOnly: true supported_types_url: type: string readOnly: true + username: + type: string + maxLength: 255 + password: + type: string + writeOnly: true + maxLength: 255 + host: + type: string + maxLength: 255 + port: + type: integer + maximum: 2147483647 + minimum: -2147483648 required: + - db_name - deleted + - editable + - host - id - name + - password + - port - supported_types_url + - username + LinksMapping: + type: object + description: |- + This serializer mixin is helpful in serializing polymorphic models, + by switching to correct serializer based on the mapping field value. + properties: + link_type: + type: string + required: + - link_type PaginatedColumnList: type: object properties: @@ -1888,6 +2066,9 @@ components: has_dependents: type: string readOnly: true + description: + type: string + nullable: true PatchedDataFile: type: object properties: @@ -1935,6 +2116,45 @@ components: type: integer maximum: 2147483647 minimum: -2147483648 + sheet_index: + type: integer + maximum: 2147483647 + minimum: -2147483648 + PatchedDatabase: + type: object + properties: + id: + type: integer + readOnly: true + name: + type: string + maxLength: 128 + db_name: + type: string + maxLength: 128 + deleted: + type: boolean + readOnly: true + editable: + type: boolean + readOnly: true + supported_types_url: + type: string + readOnly: true + username: + type: string + maxLength: 255 + password: + type: string + writeOnly: true + maxLength: 255 + host: + type: string + maxLength: 255 + port: + type: integer + maximum: 2147483647 + minimum: -2147483648 PatchedSchema: type: object properties: @@ -2033,9 +2253,6 @@ components: type: array items: type: integer - maximum: 2147483647 - minimum: -2147483648 - nullable: true PreviewColumn: type: object properties: @@ -2181,10 +2398,8 @@ components: type: array items: type: integer - maximum: 2147483647 - minimum: -2147483648 - nullable: true required: + - column_order - id - preview_settings TypeOption: From 0a75be557727b20a182f5b7bd64c4e6d7e8ed45e Mon Sep 17 00:00:00 2001 From: Varsha-dr <114489823+varshadr@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:11:30 +0530 Subject: [PATCH 3/5] Removed blank space before : to fix the lint error --- config/settings/openapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/settings/openapi.py b/config/settings/openapi.py index a9f1a91e58..e5210f658c 100644 --- a/config/settings/openapi.py +++ b/config/settings/openapi.py @@ -2,7 +2,7 @@ def custom_preprocessing_hook(endpoints): filtered = [] for (path, path_regex, method, callback) in endpoints: # Remove all but DRF API endpoints - if path.startswith("/api/db/v0/databases/") or path.startswith("/api/db/v0/data_files/") or path.startswith("/api/db/v0/schemas/") or path.startswith("/api/db/v0/tables/") or path.startswith("/api/db/v0/links/") : + if path.startswith("/api/db/v0/databases/") or path.startswith("/api/db/v0/data_files/") or path.startswith("/api/db/v0/schemas/") or path.startswith("/api/db/v0/tables/") or path.startswith("/api/db/v0/links/"): filtered.append((path, path_regex, method, callback)) return filtered From 756bf4a357d2503c738715f3ed0d393781ff4c15 Mon Sep 17 00:00:00 2001 From: Varsha-dr <114489823+varshadr@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:17:38 +0530 Subject: [PATCH 4/5] Add queries endpoint to the preprocessing hook --- config/settings/openapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/settings/openapi.py b/config/settings/openapi.py index e5210f658c..891ad127d0 100644 --- a/config/settings/openapi.py +++ b/config/settings/openapi.py @@ -2,7 +2,7 @@ def custom_preprocessing_hook(endpoints): filtered = [] for (path, path_regex, method, callback) in endpoints: # Remove all but DRF API endpoints - if path.startswith("/api/db/v0/databases/") or path.startswith("/api/db/v0/data_files/") or path.startswith("/api/db/v0/schemas/") or path.startswith("/api/db/v0/tables/") or path.startswith("/api/db/v0/links/"): + if path.startswith("/api/db/v0/databases/") or path.startswith("/api/db/v0/data_files/") or path.startswith("/api/db/v0/schemas/") or path.startswith("/api/db/v0/tables/") or path.startswith("/api/db/v0/links/") or path.startswith("/api/db/v0/queries/"): filtered.append((path, path_regex, method, callback)) return filtered From 9563c98209efb299a17fd0744e4c61f27d0a1a1f Mon Sep 17 00:00:00 2001 From: Varsha-dr <114489823+varshadr@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:19:11 +0530 Subject: [PATCH 5/5] Add openAPI spec for queries endpoint to the schema file --- schema.yml | 423 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 423 insertions(+) diff --git a/schema.yml b/schema.yml index cefe640aab..0f8b1f0a44 100644 --- a/schema.yml +++ b/schema.yml @@ -401,6 +401,300 @@ paths: schema: $ref: '#/components/schemas/LinksMapping' description: '' + /api/db/v0/queries/: + get: + operationId: queries_list + parameters: + - in: query + name: database + schema: + type: array + items: + type: string + description: Multiple values may be separated by commas. + explode: false + style: form + - name: limit + required: false + in: query + description: Number of results to return per page. + schema: + type: integer + - in: query + name: name + schema: + type: array + items: + type: string + description: Multiple values may be separated by commas. + explode: false + style: form + - name: offset + required: false + in: query + description: The initial index from which to return the results. + schema: + type: integer + - in: query + name: sort_by + schema: + type: array + items: + type: string + enum: + - -id + - -name + - id + - name + description: |- + Sort By + + * `id` - Id + * `-id` - Id (descending) + * `name` - Name + * `-name` - Name (descending) + explode: false + style: form + tags: + - queries + security: + - tokenAuth: [] + - cookieAuth: [] + - {} + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/PaginatedQueryList' + description: '' + post: + operationId: queries_create + tags: + - queries + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Query' + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/Query' + multipart/form-data: + schema: + $ref: '#/components/schemas/Query' + required: true + security: + - tokenAuth: [] + - cookieAuth: [] + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/Query' + description: '' + /api/db/v0/queries/{id}/: + get: + operationId: queries_retrieve + parameters: + - in: path + name: id + schema: + type: integer + description: A unique integer value identifying this ui query. + required: true + tags: + - queries + security: + - tokenAuth: [] + - cookieAuth: [] + - {} + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Query' + description: '' + put: + operationId: queries_update + parameters: + - in: path + name: id + schema: + type: integer + description: A unique integer value identifying this ui query. + required: true + tags: + - queries + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Query' + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/Query' + multipart/form-data: + schema: + $ref: '#/components/schemas/Query' + required: true + security: + - tokenAuth: [] + - cookieAuth: [] + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Query' + description: '' + patch: + operationId: queries_partial_update + parameters: + - in: path + name: id + schema: + type: integer + description: A unique integer value identifying this ui query. + required: true + tags: + - queries + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PatchedQuery' + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/PatchedQuery' + multipart/form-data: + schema: + $ref: '#/components/schemas/PatchedQuery' + security: + - tokenAuth: [] + - cookieAuth: [] + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Query' + description: '' + delete: + operationId: queries_destroy + parameters: + - in: path + name: id + schema: + type: integer + description: A unique integer value identifying this ui query. + required: true + tags: + - queries + security: + - tokenAuth: [] + - cookieAuth: [] + responses: + '204': + description: No response body + /api/db/v0/queries/{id}/columns/: + get: + operationId: queries_columns_retrieve + parameters: + - in: path + name: id + schema: + type: integer + description: A unique integer value identifying this ui query. + required: true + tags: + - queries + security: + - tokenAuth: [] + - cookieAuth: [] + - {} + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Query' + description: '' + /api/db/v0/queries/{id}/records/: + get: + operationId: queries_records_retrieve + parameters: + - in: path + name: id + schema: + type: integer + description: A unique integer value identifying this ui query. + required: true + tags: + - queries + security: + - tokenAuth: [] + - cookieAuth: [] + - {} + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Query' + description: '' + /api/db/v0/queries/{id}/results/: + get: + operationId: queries_results_retrieve + parameters: + - in: path + name: id + schema: + type: integer + description: A unique integer value identifying this ui query. + required: true + tags: + - queries + security: + - tokenAuth: [] + - cookieAuth: [] + - {} + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Query' + description: '' + /api/db/v0/queries/run/: + post: + operationId: queries_run_create + tags: + - queries + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Query' + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/Query' + multipart/form-data: + schema: + $ref: '#/components/schemas/Query' + required: true + security: + - tokenAuth: [] + - cookieAuth: [] + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Query' + description: '' /api/db/v0/schemas/: get: operationId: schemas_list @@ -1966,6 +2260,26 @@ components: type: array items: $ref: '#/components/schemas/Database' + PaginatedQueryList: + type: object + properties: + count: + type: integer + example: 123 + next: + type: string + nullable: true + format: uri + example: http://api.example.org/accounts/?offset=400&limit=100 + previous: + type: string + nullable: true + format: uri + example: http://api.example.org/accounts/?offset=200&limit=100 + results: + type: array + items: + $ref: '#/components/schemas/Query' PaginatedSchemaList: type: object properties: @@ -2155,6 +2469,55 @@ components: type: integer maximum: 2147483647 minimum: -2147483648 + PatchedQuery: + type: object + properties: + id: + type: integer + readOnly: true + schema: + type: string + readOnly: true + base_table: + type: integer + results_url: + type: string + readOnly: true + records_url: + type: string + readOnly: true + columns_url: + type: string + readOnly: true + created_at: + type: string + format: date-time + readOnly: true + updated_at: + type: string + format: date-time + readOnly: true + name: + type: string + maxLength: 128 + description: + type: string + nullable: true + initial_columns: + type: object + additionalProperties: {} + transformations: + type: object + additionalProperties: {} + nullable: true + display_options: + type: object + additionalProperties: {} + nullable: true + display_names: + type: object + additionalProperties: {} + nullable: true PatchedSchema: type: object properties: @@ -2263,6 +2626,66 @@ components: type: string required: - template + Query: + type: object + properties: + id: + type: integer + readOnly: true + schema: + type: string + readOnly: true + base_table: + type: integer + results_url: + type: string + readOnly: true + records_url: + type: string + readOnly: true + columns_url: + type: string + readOnly: true + created_at: + type: string + format: date-time + readOnly: true + updated_at: + type: string + format: date-time + readOnly: true + name: + type: string + maxLength: 128 + description: + type: string + nullable: true + initial_columns: + type: object + additionalProperties: {} + transformations: + type: object + additionalProperties: {} + nullable: true + display_options: + type: object + additionalProperties: {} + nullable: true + display_names: + type: object + additionalProperties: {} + nullable: true + required: + - base_table + - columns_url + - created_at + - id + - initial_columns + - name + - records_url + - results_url + - schema + - updated_at Schema: type: object properties: