1
0
Fork 0
mirror of synced 2024-07-14 18:55:45 +12:00

Adding documentation for export endpoint.

This commit is contained in:
mike12345567 2023-09-22 13:29:16 +01:00
parent cf24d90f4b
commit 07c7192154
6 changed files with 191 additions and 4 deletions

View file

@ -613,6 +613,23 @@
"data"
]
},
"appExport": {
"type": "object",
"properties": {
"encryptPassword": {
"description": "An optional password used to encrypt the export.",
"type": "string"
},
"excludeRows": {
"description": "Set whether the internal table rows should be excluded from the export.",
"type": "boolean"
}
},
"required": [
"encryptPassword",
"excludeRows"
]
},
"row": {
"description": "The row to be created/updated, based on the table schema.",
"type": "object",
@ -2166,7 +2183,8 @@
"/applications/{appId}/import": {
"post": {
"operationId": "appImport",
"summary": "Import an app to an existing app",
"summary": "Import an app to an existing app 🔒",
"description": "This endpoint is only available on a business or enterprise license.",
"tags": [
"applications"
],
@ -2205,6 +2223,44 @@
}
}
},
"/applications/{appId}/export": {
"post": {
"operationId": "appExport",
"summary": "Export an app 🔒",
"description": "This endpoint is only available on a business or enterprise license.",
"tags": [
"applications"
],
"parameters": [
{
"$ref": "#/components/parameters/appIdUrl"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/appExport"
}
}
}
},
"responses": {
"200": {
"description": "A gzip tarball containing the app export, encrypted if password provided.",
"content": {
"application/gzip": {
"schema": {
"type": "string",
"format": "binary",
"example": "Tarball containing database and object store contents..."
}
}
}
}
}
}
},
"/applications/search": {
"post": {
"operationId": "appSearch",

View file

@ -587,6 +587,19 @@ components:
- appUrl
required:
- data
appExport:
type: object
properties:
encryptPassword:
description: An optional password used to encrypt the export.
type: string
excludeRows:
description: Set whether the internal table rows should be excluded from the
export.
type: boolean
required:
- encryptPassword
- excludeRows
row:
description: The row to be created/updated, based on the table schema.
type: object
@ -1766,7 +1779,8 @@ paths:
"/applications/{appId}/import":
post:
operationId: appImport
summary: Import an app to an existing app
summary: Import an app to an existing app 🔒
description: This endpoint is only available on a business or enterprise license.
tags:
- applications
parameters:
@ -1789,6 +1803,30 @@ paths:
responses:
"204":
description: Application has been updated.
"/applications/{appId}/export":
post:
operationId: appExport
summary: Export an app 🔒
description: This endpoint is only available on a business or enterprise license.
tags:
- applications
parameters:
- $ref: "#/components/parameters/appIdUrl"
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/appExport"
responses:
"200":
description: A gzip tarball containing the app export, encrypted if password
provided.
content:
application/gzip:
schema:
type: string
format: binary
example: Tarball containing database and object store contents...
/applications/search:
post:
operationId: appSearch

View file

@ -134,4 +134,15 @@ export default new Resource()
deploymentOutput: object({
data: deploymentOutputSchema,
}),
appExport: object({
encryptPassword: {
description: "An optional password used to encrypt the export.",
type: "string",
},
excludeRows: {
description:
"Set whether the internal table rows should be excluded from the export.",
type: "boolean",
},
}),
})

View file

@ -2,6 +2,7 @@ import { db as dbCore, context } from "@budibase/backend-core"
import { search as stringSearch, addRev } from "./utils"
import * as controller from "../application"
import * as deployController from "../deploy"
import * as backupController from "../backup"
import { Application } from "../../../definitions/common"
import { UserCtx } from "@budibase/types"
import { Next } from "koa"
@ -94,8 +95,10 @@ export async function publish(ctx: UserCtx, next: Next) {
}
export async function importToApp(ctx: UserCtx, next: Next) {
if (!ctx.request.files?.appExport) {
ctx.throw(400, "Must provide app export file for import.")
}
await context.doInAppContext(ctx.params.appId, async () => {
// TODO: paid control
await controller.importToApp(ctx)
ctx.body = undefined
ctx.status = 204
@ -103,6 +106,19 @@ export async function importToApp(ctx: UserCtx, next: Next) {
})
}
export async function exportApp(ctx: UserCtx, next: Next) {
const { encryptPassword, excludeRows } = ctx.request.body
await context.doInAppContext(ctx.params.appId, async () => {
// make sure no other inputs
ctx.request.body = {
encryptPassword,
excludeRows,
}
await backupController.exportAppDump(ctx)
await next()
})
}
export default {
create,
update,
@ -112,4 +128,5 @@ export default {
unpublish,
publish,
importToApp,
exportApp,
}

View file

@ -142,7 +142,8 @@ write.push(
* /applications/{appId}/import:
* post:
* operationId: appImport
* summary: Import an app to an existing app
* summary: Import an app to an existing app 🔒
* description: This endpoint is only available on a business or enterprise license.
* tags:
* - applications
* parameters:
@ -170,6 +171,36 @@ write.push(
new Endpoint("post", "/applications/:appId/import", controller.importToApp)
)
/**
* @openapi
* /applications/{appId}/export:
* post:
* operationId: appExport
* summary: Export an app 🔒
* description: This endpoint is only available on a business or enterprise license.
* tags:
* - applications
* parameters:
* - $ref: '#/components/parameters/appIdUrl'
* requestBody:
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/appExport'
* responses:
* 200:
* description: A gzip tarball containing the app export, encrypted if password provided.
* content:
* application/gzip:
* schema:
* type: string
* format: binary
* example: Tarball containing database and object store contents...
*/
read.push(
new Endpoint("post", "/applications/:appId/export", controller.exportApp)
)
/**
* @openapi
* /applications/{appId}:

View file

@ -19,8 +19,13 @@ export interface paths {
post: operations["appPublish"];
};
"/applications/{appId}/import": {
/** This endpoint is only available on a business or enterprise license. */
post: operations["appImport"];
};
"/applications/{appId}/export": {
/** This endpoint is only available on a business or enterprise license. */
post: operations["appExport"];
};
"/applications/search": {
/** Based on application properties (currently only name) search for applications. */
post: operations["appSearch"];
@ -161,6 +166,12 @@ export interface components {
appUrl: string;
};
};
appExport: {
/** @description An optional password used to encrypt the export. */
encryptPassword: string;
/** @description Set whether the internal table rows should be excluded from the export. */
excludeRows: boolean;
};
/** @description The row to be created/updated, based on the table schema. */
row: { [key: string]: unknown };
searchOutput: {
@ -892,6 +903,7 @@ export interface operations {
};
};
};
/** This endpoint is only available on a business or enterprise license. */
appImport: {
parameters: {
path: {
@ -917,6 +929,28 @@ export interface operations {
};
};
};
/** This endpoint is only available on a business or enterprise license. */
appExport: {
parameters: {
path: {
/** The ID of the app which this request is targeting. */
appId: components["parameters"]["appIdUrl"];
};
};
responses: {
/** A gzip tarball containing the app export, encrypted if password provided. */
200: {
content: {
"application/gzip": string;
};
};
};
requestBody: {
content: {
"application/json": components["schemas"]["appExport"];
};
};
};
/** Based on application properties (currently only name) search for applications. */
appSearch: {
responses: {