1
0
Fork 0
mirror of synced 2024-08-14 17:42:01 +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" "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": { "row": {
"description": "The row to be created/updated, based on the table schema.", "description": "The row to be created/updated, based on the table schema.",
"type": "object", "type": "object",
@ -2166,7 +2183,8 @@
"/applications/{appId}/import": { "/applications/{appId}/import": {
"post": { "post": {
"operationId": "appImport", "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": [ "tags": [
"applications" "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": { "/applications/search": {
"post": { "post": {
"operationId": "appSearch", "operationId": "appSearch",

View file

@ -587,6 +587,19 @@ components:
- appUrl - appUrl
required: required:
- data - 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: row:
description: The row to be created/updated, based on the table schema. description: The row to be created/updated, based on the table schema.
type: object type: object
@ -1766,7 +1779,8 @@ paths:
"/applications/{appId}/import": "/applications/{appId}/import":
post: post:
operationId: appImport 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: tags:
- applications - applications
parameters: parameters:
@ -1789,6 +1803,30 @@ paths:
responses: responses:
"204": "204":
description: Application has been updated. 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: /applications/search:
post: post:
operationId: appSearch operationId: appSearch

View file

@ -134,4 +134,15 @@ export default new Resource()
deploymentOutput: object({ deploymentOutput: object({
data: deploymentOutputSchema, 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 { search as stringSearch, addRev } from "./utils"
import * as controller from "../application" import * as controller from "../application"
import * as deployController from "../deploy" import * as deployController from "../deploy"
import * as backupController from "../backup"
import { Application } from "../../../definitions/common" import { Application } from "../../../definitions/common"
import { UserCtx } from "@budibase/types" import { UserCtx } from "@budibase/types"
import { Next } from "koa" import { Next } from "koa"
@ -94,8 +95,10 @@ export async function publish(ctx: UserCtx, next: Next) {
} }
export async function importToApp(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 () => { await context.doInAppContext(ctx.params.appId, async () => {
// TODO: paid control
await controller.importToApp(ctx) await controller.importToApp(ctx)
ctx.body = undefined ctx.body = undefined
ctx.status = 204 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 { export default {
create, create,
update, update,
@ -112,4 +128,5 @@ export default {
unpublish, unpublish,
publish, publish,
importToApp, importToApp,
exportApp,
} }

View file

@ -142,7 +142,8 @@ write.push(
* /applications/{appId}/import: * /applications/{appId}/import:
* post: * post:
* operationId: appImport * 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: * tags:
* - applications * - applications
* parameters: * parameters:
@ -170,6 +171,36 @@ write.push(
new Endpoint("post", "/applications/:appId/import", controller.importToApp) 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 * @openapi
* /applications/{appId}: * /applications/{appId}:

View file

@ -19,8 +19,13 @@ export interface paths {
post: operations["appPublish"]; post: operations["appPublish"];
}; };
"/applications/{appId}/import": { "/applications/{appId}/import": {
/** This endpoint is only available on a business or enterprise license. */
post: operations["appImport"]; post: operations["appImport"];
}; };
"/applications/{appId}/export": {
/** This endpoint is only available on a business or enterprise license. */
post: operations["appExport"];
};
"/applications/search": { "/applications/search": {
/** Based on application properties (currently only name) search for applications. */ /** Based on application properties (currently only name) search for applications. */
post: operations["appSearch"]; post: operations["appSearch"];
@ -161,6 +166,12 @@ export interface components {
appUrl: string; 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. */ /** @description The row to be created/updated, based on the table schema. */
row: { [key: string]: unknown }; row: { [key: string]: unknown };
searchOutput: { searchOutput: {
@ -892,6 +903,7 @@ export interface operations {
}; };
}; };
}; };
/** This endpoint is only available on a business or enterprise license. */
appImport: { appImport: {
parameters: { parameters: {
path: { 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. */ /** Based on application properties (currently only name) search for applications. */
appSearch: { appSearch: {
responses: { responses: {