@nasebanal/cli 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/auth.js +75 -2
- package/dist/config.js +30 -0
- package/dist/reports/upload.js +2 -3
- package/dist/spec/build.js +4 -5
- package/dist/specs/command.js +2 -0
- package/dist/specs/push.js +57 -0
- package/package.json +1 -1
- package/specs/recorder.yaml +253 -1
- package/specs/specs.yaml +18 -5
- package/specs/target.yaml +187 -1
package/README.md
CHANGED
|
@@ -211,6 +211,20 @@ field). `nb specs specs push` takes the API version from the document: the major
|
|
|
211
211
|
- a breaking change is a new major (`2.0.0`): the same push makes the **v2 spec** and leaves v1 untouched; pushing a document of
|
|
212
212
|
another major to a spec by `--id` is refused (`API_VERSION_MISMATCH`: register it as its own spec).
|
|
213
213
|
|
|
214
|
+
**A CI that names the API once: `--follow-version`.** The versions of one API are a family: each later version names the API's first
|
|
215
|
+
spec (its initial version) as `initial_spec_id`. Give the id of that FIRST spec and never change it:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
nb specs specs push --file openapi.yaml --id <the API's first spec> --follow-version --server-url "$API_URL"
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
The document goes to the spec of ITS API version of that API (found by the API version, whichever spec of the family the id names).
|
|
222
|
+
When the API does not have that version yet the spec is made (named as the first spec is; the catalog keeps the family's group and
|
|
223
|
+
repository), so a new major (`2.0.0`) needs no change of the id. API versions are registered **in order**: the next one after the
|
|
224
|
+
highest the API has (v1, v2, then v3). A version that skips (v1, then v3) fails with the version that is next, and nothing is
|
|
225
|
+
registered (`--dry-run` says the same without writing): register a placeholder of the missing version first, then the real document
|
|
226
|
+
is a new revision of that spec afterwards. Needs `@nasebanal/api-specs-specs` 1.5.0 (`initial_spec_id`) on the catalog side.
|
|
227
|
+
|
|
214
228
|
To maintain several API versions, keep each one on a **branch** of the repository with its own OpenAPI file, and let the same CI
|
|
215
229
|
job push and report from whichever branch it runs on:
|
|
216
230
|
|
|
@@ -618,6 +632,7 @@ Overridable env vars: `NB_AUTH0_DOMAIN`, `NB_AUTH0_AUDIENCE`,
|
|
|
618
632
|
| Option | Description |
|
|
619
633
|
|--------|-------------|
|
|
620
634
|
| `--env <production\|local>` | Target environment; picks the matching `servers` entry from the spec. Also `NB_ENV`. |
|
|
635
|
+
| `NB_<API>_BASE_URL` | The host of ONE API instead of its spec's `servers` entry (origin only; the spec's path is appended): `NB_ASSURANCE_BASE_URL=http://localhost:8791`, `NB_SPECS_BASE_URL=http://localhost:8792`, and `NB_ACCOUNT_BASE_URL` / `NB_RECORD_BASE_URL` / `NB_TARGET_BASE_URL`. `<API>` is the command group, as in `NB_<API>_ORG`. The shared `NB_BASE_URL` (one host for every API) still works but is **deprecated** and says so on stderr: pointing it at one local Worker sent every other command there too. |
|
|
621
636
|
| `--token <token>` | Override stored credentials with a PAT for one invocation. |
|
|
622
637
|
| `-V, --version` | Print the CLI version. |
|
|
623
638
|
|
package/dist/auth.js
CHANGED
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { Command } from "commander";
|
|
11
11
|
import { createInterface } from "node:readline";
|
|
12
|
-
import { loadConfig, saveConfig, resolveToken, resolveEnv, configFilePath } from "./config.js";
|
|
12
|
+
import { loadConfig, saveConfig, resolveToken, resolveEnv, configFilePath, peekBaseUrlOverride } from "./config.js";
|
|
13
|
+
import { API_CATALOG } from "./apis.js";
|
|
14
|
+
import { resolveBaseUrl } from "./http.js";
|
|
15
|
+
import { loadSpec } from "./spec/loader.js";
|
|
16
|
+
import { specsBaseUrl } from "./specs/push.js";
|
|
13
17
|
import { login } from "./oauth.js";
|
|
14
18
|
import { envTokenHint } from "./output.js";
|
|
15
19
|
function readSecretLine(promptText) {
|
|
@@ -90,8 +94,19 @@ export function buildAuthCommand() {
|
|
|
90
94
|
? "stored PAT"
|
|
91
95
|
: "none";
|
|
92
96
|
const masked = token ? `${token.slice(0, 10)}…${token.slice(-4)}` : "(not set)";
|
|
93
|
-
|
|
97
|
+
const env = resolveEnv(config);
|
|
98
|
+
process.stdout.write(`Environment: ${env}\n`);
|
|
99
|
+
process.stdout.write(`Targets (the host each command calls; a NB_<API>_BASE_URL wins over the environment):\n`);
|
|
100
|
+
for (const line of targetLines(env))
|
|
101
|
+
process.stdout.write(` ${line}\n`);
|
|
94
102
|
process.stdout.write(`Token: ${masked} [source: ${source}]\n`);
|
|
103
|
+
// The stored `nb auth login` session is shown whether or not it is the credential in use: NB_TOKEN beats it, and a
|
|
104
|
+
// status that hid it would make "am I logged in, and as whom" unanswerable exactly when the two disagree.
|
|
105
|
+
if (config.auth) {
|
|
106
|
+
const who = loginIdentity(config.auth.id_token) ?? "(not readable)";
|
|
107
|
+
const note = source === "OAuth login" ? "in use; from the login, not checked with the server" : "stored, NOT in use: another credential wins";
|
|
108
|
+
process.stdout.write(`Login: ${who} [${note}]\n`);
|
|
109
|
+
}
|
|
95
110
|
if (config.auth?.expires_at) {
|
|
96
111
|
const expired = config.auth.expires_at <= Date.now();
|
|
97
112
|
process.stdout.write(`Expires: ${new Date(config.auth.expires_at).toLocaleString()}` +
|
|
@@ -101,3 +116,61 @@ export function buildAuthCommand() {
|
|
|
101
116
|
});
|
|
102
117
|
return auth;
|
|
103
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* The word the reader is looking for, next to the URL, decided by the host itself: `*.nasebanal.com` is production, `localhost` /
|
|
121
|
+
* `127.0.0.1` is local, anything else (a stub, a self-hosted copy) is `other`, never claimed to be production.
|
|
122
|
+
*/
|
|
123
|
+
export function hostKind(url) {
|
|
124
|
+
let host;
|
|
125
|
+
try {
|
|
126
|
+
host = new URL(url).hostname.toLowerCase();
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
return "other";
|
|
130
|
+
}
|
|
131
|
+
if (host === "localhost" || host === "127.0.0.1" || host === "[::1]" || host === "::1")
|
|
132
|
+
return "local";
|
|
133
|
+
if (host === "nasebanal.com" || host.endsWith(".nasebanal.com"))
|
|
134
|
+
return "production";
|
|
135
|
+
return "other";
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* What `nb auth status` says about where the commands go: per API, the host the next command would call and whether that is
|
|
139
|
+
* local or production, plus which variable put it there when one did (the environment alone does not tell, because a
|
|
140
|
+
* NB_<API>_BASE_URL beats it).
|
|
141
|
+
*/
|
|
142
|
+
export function targetLines(env) {
|
|
143
|
+
const width = Math.max(...API_CATALOG.map((a) => a.name.length));
|
|
144
|
+
return API_CATALOG.map((api) => {
|
|
145
|
+
// `nb specs` verbs read the catalog's host (NB_SPECS_BASE_URL only); every other group resolves from its spec's `servers`.
|
|
146
|
+
const peek = peekBaseUrlOverride(api.name);
|
|
147
|
+
const via = api.name === "specs"
|
|
148
|
+
? process.env.NB_SPECS_BASE_URL?.trim()
|
|
149
|
+
? { url: specsBaseUrl(env), variable: "NB_SPECS_BASE_URL" }
|
|
150
|
+
: undefined
|
|
151
|
+
: peek;
|
|
152
|
+
const url = api.name === "specs" ? specsBaseUrl(env) : (peek?.url ?? resolveBaseUrl(loadSpec(api.spec).servers, env));
|
|
153
|
+
return `${api.name.padEnd(width)} ${url} [${hostKind(url)}${via ? `, from ${via.variable}` : ""}]`;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Who a `nb auth login` was done as, `Name <email>`, read from the ID token that login stored (the payload is plain base64url JSON).
|
|
158
|
+
* For display only: nothing is authorized on it (the servers verify the access token's signature). null when there is no ID token
|
|
159
|
+
* or it cannot be read.
|
|
160
|
+
*/
|
|
161
|
+
export function loginIdentity(idToken) {
|
|
162
|
+
const payload = idToken?.split(".")[1];
|
|
163
|
+
if (!payload)
|
|
164
|
+
return null;
|
|
165
|
+
try {
|
|
166
|
+
const claims = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
|
|
167
|
+
const email = typeof claims.email === "string" ? claims.email : "";
|
|
168
|
+
const name = typeof claims.name === "string" ? claims.name : typeof claims.nickname === "string" ? claims.nickname : "";
|
|
169
|
+
if (name && email)
|
|
170
|
+
return `${name} <${email}>`;
|
|
171
|
+
return email || name || null;
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
}
|
package/dist/config.js
CHANGED
|
@@ -95,3 +95,33 @@ export function resolveEnv(config = loadConfig()) {
|
|
|
95
95
|
export function configFilePath() {
|
|
96
96
|
return configPath();
|
|
97
97
|
}
|
|
98
|
+
let warnedSharedBaseUrl = false;
|
|
99
|
+
/**
|
|
100
|
+
* The host a command group talks to when the environment names one, or undefined (then the spec's own `servers` entry for the
|
|
101
|
+
* active environment is used). `NB_<API>_BASE_URL` is that API's alone (`NB_ASSURANCE_BASE_URL`, `NB_RECORD_BASE_URL`, ...: the
|
|
102
|
+
* API is the command group's name, as in `NB_<API>_ORG`). The older `NB_BASE_URL` is still read as a fallback, but it applies
|
|
103
|
+
* to EVERY API at once (pointing it at one local Worker sends `nb record` there too), so it is deprecated and says so, once, on stderr.
|
|
104
|
+
* Origin only: the spec's path is appended. A trailing slash is dropped; an empty value counts as unset.
|
|
105
|
+
*/
|
|
106
|
+
export function baseUrlOverride(apiName) {
|
|
107
|
+
const found = peekBaseUrlOverride(apiName);
|
|
108
|
+
if (found?.variable === "NB_BASE_URL" && !warnedSharedBaseUrl) {
|
|
109
|
+
warnedSharedBaseUrl = true;
|
|
110
|
+
process.stderr.write(`nb: NB_BASE_URL applies to every API and is deprecated; set NB_${apiName.toUpperCase()}_BASE_URL (the host of the ${apiName} API) instead.\n`);
|
|
111
|
+
}
|
|
112
|
+
return found?.url;
|
|
113
|
+
}
|
|
114
|
+
/** The same lookup without the deprecation notice, and with the variable that supplied the host (for `nb auth status`). */
|
|
115
|
+
export function peekBaseUrlOverride(apiName) {
|
|
116
|
+
const clean = (v) => v?.trim().replace(/\/$/, "") || undefined;
|
|
117
|
+
const ownName = `NB_${apiName.toUpperCase()}_BASE_URL`;
|
|
118
|
+
const own = clean(process.env[ownName]);
|
|
119
|
+
if (own)
|
|
120
|
+
return { url: own, variable: ownName };
|
|
121
|
+
const shared = clean(process.env.NB_BASE_URL);
|
|
122
|
+
return shared ? { url: shared, variable: "NB_BASE_URL" } : undefined;
|
|
123
|
+
}
|
|
124
|
+
/** Tests: forget that the deprecation was already said. */
|
|
125
|
+
export function resetBaseUrlWarning() {
|
|
126
|
+
warnedSharedBaseUrl = false;
|
|
127
|
+
}
|
package/dist/reports/upload.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { Command, Option } from "commander";
|
|
18
18
|
import { existsSync, lstatSync, readFileSync, readdirSync } from "node:fs";
|
|
19
19
|
import { basename, dirname, join } from "node:path";
|
|
20
|
-
import { resolveAccessToken, resolveEnv } from "../config.js";
|
|
20
|
+
import { baseUrlOverride, resolveAccessToken, resolveEnv } from "../config.js";
|
|
21
21
|
import { request, resolveBaseUrl, ApiError } from "../http.js";
|
|
22
22
|
import { loadSpec } from "../spec/loader.js";
|
|
23
23
|
import { exportGithubOutput, printJson } from "../output.js";
|
|
@@ -493,8 +493,7 @@ export function buildReportUploadCommand() {
|
|
|
493
493
|
process.stderr.write(`(dry run) ${basename(dirname(file)) || "."}/${basename(file)}: ${parsed.note}\n`);
|
|
494
494
|
return;
|
|
495
495
|
}
|
|
496
|
-
const
|
|
497
|
-
const baseUrl = override ?? resolveBaseUrl(loadSpec("assurance.yaml").servers, env);
|
|
496
|
+
const baseUrl = baseUrlOverride("assurance") ?? resolveBaseUrl(loadSpec("assurance.yaml").servers, env);
|
|
498
497
|
// Assurance and the catalog act for the same owner: the organization goes to both (personal is the default and sent as is).
|
|
499
498
|
const orgHeaders = org === "personal" ? undefined : { "X-Active-Organization-Id": org };
|
|
500
499
|
const hits = opts.allSpecs ? await resolveRepositorySpecs(specsConn, ref) : [await resolveSpec(specsConn, ref)];
|
package/dist/spec/build.js
CHANGED
|
@@ -31,7 +31,7 @@ import { Command } from "commander";
|
|
|
31
31
|
import { readFileSync } from "node:fs";
|
|
32
32
|
import { loadSpec, } from "./loader.js";
|
|
33
33
|
import { resolveBaseUrl, request } from "../http.js";
|
|
34
|
-
import { resolveAccessToken, resolveEnv } from "../config.js";
|
|
34
|
+
import { baseUrlOverride, resolveAccessToken, resolveEnv } from "../config.js";
|
|
35
35
|
import { printJson } from "../output.js";
|
|
36
36
|
const METHODS = ["get", "post", "put", "patch", "delete"];
|
|
37
37
|
function stripBasePath(path) {
|
|
@@ -151,11 +151,10 @@ function attachLeaf(parent, name, pathTemplate, method, op, servers, parameters,
|
|
|
151
151
|
const opts = command.optsWithGlobals();
|
|
152
152
|
const env = opts.env || resolveEnv();
|
|
153
153
|
const token = opts.token || (await resolveAccessToken());
|
|
154
|
-
//
|
|
154
|
+
// NB_<API>_BASE_URL overrides server resolution for this API entirely (origin only — the spec
|
|
155
155
|
// path is still appended). Used by the CDD contract test to point the CLI at
|
|
156
|
-
// a Specmatic stub, and available for
|
|
157
|
-
const
|
|
158
|
-
const baseUrl = override ?? resolveBaseUrl(servers, env);
|
|
156
|
+
// a Specmatic stub, and available for local / self-hosted setups. The shared NB_BASE_URL still works but is deprecated.
|
|
157
|
+
const baseUrl = baseUrlOverride(apiName) ?? resolveBaseUrl(servers, env);
|
|
159
158
|
let realPath = pathTemplate;
|
|
160
159
|
params.forEach((p, i) => {
|
|
161
160
|
realPath = realPath.replace(`{${p}}`, encodeURIComponent(positionals[i]));
|
package/dist/specs/command.js
CHANGED
|
@@ -22,6 +22,7 @@ export function buildPushCommand() {
|
|
|
22
22
|
.requiredOption("--file <path>", "the OpenAPI document (YAML or JSON, up to 2 MiB)")
|
|
23
23
|
.option("--name <name>", "the spec's name in the catalog (default: the document's info.title, then the file's name)")
|
|
24
24
|
.option("--id <id>", "push to this spec by id: a rename cannot make a second one")
|
|
25
|
+
.option("--follow-version", "with --id: the id names the FIRST spec of an API (its initial version); the document goes to the spec of ITS API version of that API, found by the API version, and that spec is made when the API does not have it yet (a new major needs no change of the id). API versions are registered in order: the next one after the highest the API has, otherwise nothing is registered and the push fails")
|
|
25
26
|
.option("--rename", "with --id: also rename the spec to --name (default: the document's info.title) when it is called something else")
|
|
26
27
|
.option("--group <name>", "the spec's group, part of its key (the same name may exist in other groups: an environment each): the spec is looked up in this group, and a NEW one is filed there (the group is made when missing). Default: no group, which does not mean any group: a name that exists only in groups is an error that lists them. An existing spec is never moved by a push")
|
|
27
28
|
.option("--api-version <v>", "the spec's API version (v1, v2), part of its key: a new major API version is a new spec. Default: what the document's info.version gives (1.8.0 -> v1, v2.0 -> v2); needed when it gives none (2023-01, latest). A document of another major than an existing spec of that name makes the NEW spec for its API version and leaves the other alone")
|
|
@@ -50,6 +51,7 @@ export function buildPushCommand() {
|
|
|
50
51
|
note: opts.note ?? ciNote(ci, undefined),
|
|
51
52
|
id: opts.id,
|
|
52
53
|
rename: opts.rename,
|
|
54
|
+
followVersion: opts.followVersion,
|
|
53
55
|
// A name asked for wins over the id the pipeline's variable carries.
|
|
54
56
|
repositoryId: opts.repository ? undefined : (opts.repositoryId ?? (process.env.NB_REPOSITORY_ID?.trim() || undefined)),
|
|
55
57
|
repository: opts.repository,
|
package/dist/specs/push.js
CHANGED
|
@@ -226,7 +226,64 @@ export async function pushSpec(p) {
|
|
|
226
226
|
throw err;
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
+
/** The number in an API version ("v2" -> 2), or null when it is not of that form (a calendar version). */
|
|
230
|
+
function versionNumber(v) {
|
|
231
|
+
const m = /^[vV](\d{1,3})$/.exec(v.trim());
|
|
232
|
+
return m ? Number.parseInt(m[1], 10) : null;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* `--follow-version`: the spec of the document's API version in the family of the spec `p.id` names (its initial version, or any spec of the
|
|
236
|
+
* API: the family is found from it). Found: the push goes to that spec. Not there: it is made after the highest version the API has, with
|
|
237
|
+
* `initial_spec_id`, named as the initial spec is (the catalog keeps the group and the repository of the family); a version that is not the
|
|
238
|
+
* next one is refused here as the catalog refuses it (INITIAL_VERSION_NOT_NEXT), which is also what a dry run says.
|
|
239
|
+
*/
|
|
240
|
+
async function pushFollowingVersion(p) {
|
|
241
|
+
if (!p.id)
|
|
242
|
+
throw new Error("--follow-version needs --id: the id of the API's first spec");
|
|
243
|
+
let text = readSpecFile(p.file);
|
|
244
|
+
const explicitVersion = p.apiVersion !== undefined ? checkApiVersion(p.apiVersion) : undefined;
|
|
245
|
+
const apiVersion = explicitVersion ?? apiVersionOf(text) ?? undefined;
|
|
246
|
+
if (apiVersion === undefined) {
|
|
247
|
+
throw new Error("--follow-version needs the document's API version (a major such as 2.0.0 -> v2): say which with --api-version <v1|v2|...>");
|
|
248
|
+
}
|
|
249
|
+
const given = (await findSpec(p.conn, "", p.id));
|
|
250
|
+
const initialId = given.initial_spec_id ?? given.id;
|
|
251
|
+
const res = await request({ ...headersOf(p.conn), method: "GET", path: "/api/v1/specs" });
|
|
252
|
+
const family = res.data.data.data.filter((s) => s.id === initialId || s.initial_spec_id === initialId);
|
|
253
|
+
const initial = family.find((s) => s.id === initialId) ?? given;
|
|
254
|
+
const found = family.find((s) => sameApiVersion(s.api_version ?? "v1", apiVersion));
|
|
255
|
+
if (found)
|
|
256
|
+
return pushSpecInner({ ...p, followVersion: false, id: found.id });
|
|
257
|
+
// Not there yet: it must be the next one after the highest the API has.
|
|
258
|
+
const numbers = family.map((s) => versionNumber(s.api_version ?? "v1")).filter((n) => n !== null);
|
|
259
|
+
const wanted = versionNumber(apiVersion);
|
|
260
|
+
if (wanted !== null && numbers.length > 0 && wanted !== Math.max(...numbers) + 1) {
|
|
261
|
+
throw new Error(`The next API version of '${initial.name}' is v${Math.max(...numbers) + 1}, not ${apiVersion}: register the versions in order (a placeholder document will do for one that is not ready). Nothing was registered.`);
|
|
262
|
+
}
|
|
263
|
+
if (p.serverUrl !== undefined)
|
|
264
|
+
text = setServers(text, checkServerUrl(p.serverUrl)).text;
|
|
265
|
+
const hash = hashText(text);
|
|
266
|
+
const served = p.serverUrl ? { server_url: checkServerUrl(p.serverUrl) } : {};
|
|
267
|
+
if (p.dryRun) {
|
|
268
|
+
return { id: "(new)", name: initial.name, version: 1, api_version: apiVersion, group_id: initial.group_id, action: "created", content_hash: hash, repository_id: initial.repository_id ?? null, ...served };
|
|
269
|
+
}
|
|
270
|
+
try {
|
|
271
|
+
const created = await request({
|
|
272
|
+
...headersOf(p.conn),
|
|
273
|
+
method: "POST",
|
|
274
|
+
path: "/api/v1/specs",
|
|
275
|
+
body: { name: initial.name, content: text, initial_spec_id: initialId, ...(explicitVersion ? { api_version: explicitVersion } : {}), ...(p.description ? { description: p.description } : {}) },
|
|
276
|
+
});
|
|
277
|
+
const row = created.data.data;
|
|
278
|
+
return { id: row.id, name: row.name, version: 1, api_version: row.api_version ?? apiVersion, group_id: row.group_id ?? null, action: "created", content_hash: hash, repository_id: row.repository_id ?? null, ...served };
|
|
279
|
+
}
|
|
280
|
+
catch (err) {
|
|
281
|
+
throw new Error(`The catalog refused the spec: ${reasonOf(err)}`);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
229
284
|
async function pushSpecInner(p) {
|
|
285
|
+
if (p.followVersion)
|
|
286
|
+
return pushFollowingVersion(p);
|
|
230
287
|
let text = readSpecFile(p.file);
|
|
231
288
|
let serverUrl;
|
|
232
289
|
let serversEdit;
|
package/package.json
CHANGED
package/specs/recorder.yaml
CHANGED
|
@@ -47,7 +47,7 @@ info:
|
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
**Note:** The embed displays a snapshot of the data at the time the SNS share was created. To update the data, recreate the SNS share.
|
|
50
|
-
version: 1.
|
|
50
|
+
version: 1.8.0
|
|
51
51
|
license:
|
|
52
52
|
name: MIT
|
|
53
53
|
servers:
|
|
@@ -1946,6 +1946,129 @@ paths:
|
|
|
1946
1946
|
$ref: "#/components/responses/NotFound"
|
|
1947
1947
|
"500":
|
|
1948
1948
|
$ref: "#/components/responses/InternalError"
|
|
1949
|
+
/export:
|
|
1950
|
+
get:
|
|
1951
|
+
summary: Take a complete copy of an organization's data
|
|
1952
|
+
description: "Everything the caller may take, as JSON, one section per request: `tags` and `goals` come in one answer, `records` in keyset pages (`after_id`, `limit` up to 1000) that the caller walks until `next_after_id` is null. An organization admin takes every member's rows, a member only their own. Read-only, so an admin of an organization whose Enterprise contract has ended can still take the data away before deleting the organization. Each record and goal carries `tag_name` and `tag_data_type` (how a restore finds the tag)."
|
|
1953
|
+
operationId: exportData
|
|
1954
|
+
tags:
|
|
1955
|
+
- Backup
|
|
1956
|
+
parameters:
|
|
1957
|
+
- name: X-Active-Organization-Id
|
|
1958
|
+
in: header
|
|
1959
|
+
required: true
|
|
1960
|
+
description: "The organization acted on (an organization id). The backup is a feature of organizations (Enterprise): without it the answer is 403 ORGANIZATION_REQUIRED."
|
|
1961
|
+
schema:
|
|
1962
|
+
type: integer
|
|
1963
|
+
minimum: 1
|
|
1964
|
+
- name: section
|
|
1965
|
+
in: query
|
|
1966
|
+
required: true
|
|
1967
|
+
description: Which part to take.
|
|
1968
|
+
schema:
|
|
1969
|
+
type: string
|
|
1970
|
+
enum:
|
|
1971
|
+
- tags
|
|
1972
|
+
- records
|
|
1973
|
+
- goals
|
|
1974
|
+
- name: after_id
|
|
1975
|
+
in: query
|
|
1976
|
+
description: Return the records after this id (the previous page's `next_after_id`); 0 starts at the beginning.
|
|
1977
|
+
schema:
|
|
1978
|
+
type: integer
|
|
1979
|
+
minimum: 0
|
|
1980
|
+
default: 0
|
|
1981
|
+
- name: limit
|
|
1982
|
+
in: query
|
|
1983
|
+
description: Page size for `records` (at most 1000).
|
|
1984
|
+
schema:
|
|
1985
|
+
type: integer
|
|
1986
|
+
minimum: 1
|
|
1987
|
+
maximum: 1000
|
|
1988
|
+
default: 1000
|
|
1989
|
+
responses:
|
|
1990
|
+
"200":
|
|
1991
|
+
description: One section (or page) of the copy
|
|
1992
|
+
content:
|
|
1993
|
+
application/json:
|
|
1994
|
+
schema:
|
|
1995
|
+
type: object
|
|
1996
|
+
properties:
|
|
1997
|
+
success:
|
|
1998
|
+
type: boolean
|
|
1999
|
+
enum:
|
|
2000
|
+
- true
|
|
2001
|
+
data:
|
|
2002
|
+
$ref: "#/components/schemas/RecorderExportPage"
|
|
2003
|
+
"400":
|
|
2004
|
+
$ref: "#/components/responses/ValidationError"
|
|
2005
|
+
"401":
|
|
2006
|
+
$ref: "#/components/responses/Unauthorized"
|
|
2007
|
+
"403":
|
|
2008
|
+
description: No organization selected (ORGANIZATION_REQUIRED) or no access to the organization
|
|
2009
|
+
content:
|
|
2010
|
+
application/json:
|
|
2011
|
+
schema:
|
|
2012
|
+
$ref: "#/components/schemas/ErrorResponse"
|
|
2013
|
+
example:
|
|
2014
|
+
success: false
|
|
2015
|
+
error:
|
|
2016
|
+
code: ORGANIZATION_REQUIRED
|
|
2017
|
+
message: The complete backup is for organizations (Enterprise)
|
|
2018
|
+
"500":
|
|
2019
|
+
$ref: "#/components/responses/InternalError"
|
|
2020
|
+
/import/full:
|
|
2021
|
+
post:
|
|
2022
|
+
summary: Put a complete copy back
|
|
2023
|
+
description: "Restores an exported file (or a part of it: send `tags` and `goals` once and `records` in chunks) into the active organization, owned by the importer. An organization admin only. Whatever the organization already has is left alone and counted, so putting the same file back twice changes nothing the second time; plan limits apply as on every write. Attachments, authorship and ids are not restored (the response counts the records that had an attachment)."
|
|
2024
|
+
operationId: importFull
|
|
2025
|
+
tags:
|
|
2026
|
+
- Backup
|
|
2027
|
+
parameters:
|
|
2028
|
+
- name: X-Active-Organization-Id
|
|
2029
|
+
in: header
|
|
2030
|
+
required: true
|
|
2031
|
+
description: "The organization acted on (an organization id). The backup is a feature of organizations (Enterprise): without it the answer is 403 ORGANIZATION_REQUIRED."
|
|
2032
|
+
schema:
|
|
2033
|
+
type: integer
|
|
2034
|
+
minimum: 1
|
|
2035
|
+
requestBody:
|
|
2036
|
+
required: true
|
|
2037
|
+
content:
|
|
2038
|
+
application/json:
|
|
2039
|
+
schema:
|
|
2040
|
+
$ref: "#/components/schemas/RecorderImportRequest"
|
|
2041
|
+
responses:
|
|
2042
|
+
"200":
|
|
2043
|
+
description: What was created, what was already there and what was skipped
|
|
2044
|
+
content:
|
|
2045
|
+
application/json:
|
|
2046
|
+
schema:
|
|
2047
|
+
type: object
|
|
2048
|
+
properties:
|
|
2049
|
+
success:
|
|
2050
|
+
type: boolean
|
|
2051
|
+
enum:
|
|
2052
|
+
- true
|
|
2053
|
+
data:
|
|
2054
|
+
$ref: "#/components/schemas/RecorderImportResult"
|
|
2055
|
+
"400":
|
|
2056
|
+
$ref: "#/components/responses/ValidationError"
|
|
2057
|
+
"401":
|
|
2058
|
+
$ref: "#/components/responses/Unauthorized"
|
|
2059
|
+
"403":
|
|
2060
|
+
description: Not an organization admin, no organization selected (ORGANIZATION_REQUIRED), or the organization's contract has ended (ORG_READ_ONLY)
|
|
2061
|
+
content:
|
|
2062
|
+
application/json:
|
|
2063
|
+
schema:
|
|
2064
|
+
$ref: "#/components/schemas/ErrorResponse"
|
|
2065
|
+
example:
|
|
2066
|
+
success: false
|
|
2067
|
+
error:
|
|
2068
|
+
code: FORBIDDEN
|
|
2069
|
+
message: The complete backup is for organizations (Enterprise)
|
|
2070
|
+
"500":
|
|
2071
|
+
$ref: "#/components/responses/InternalError"
|
|
1949
2072
|
components:
|
|
1950
2073
|
securitySchemes:
|
|
1951
2074
|
BearerAuth:
|
|
@@ -2661,6 +2784,133 @@ components:
|
|
|
2661
2784
|
type: object
|
|
2662
2785
|
description: Additional error details
|
|
2663
2786
|
additionalProperties: true
|
|
2787
|
+
RecorderExportPage:
|
|
2788
|
+
type: object
|
|
2789
|
+
description: One section of an organization's complete copy.
|
|
2790
|
+
required:
|
|
2791
|
+
- format
|
|
2792
|
+
- version
|
|
2793
|
+
- section
|
|
2794
|
+
- scope
|
|
2795
|
+
- exported_at
|
|
2796
|
+
- items
|
|
2797
|
+
- next_after_id
|
|
2798
|
+
properties:
|
|
2799
|
+
format:
|
|
2800
|
+
type: string
|
|
2801
|
+
enum:
|
|
2802
|
+
- nb-recorder-export
|
|
2803
|
+
version:
|
|
2804
|
+
type: integer
|
|
2805
|
+
enum:
|
|
2806
|
+
- 1
|
|
2807
|
+
section:
|
|
2808
|
+
type: string
|
|
2809
|
+
enum:
|
|
2810
|
+
- tags
|
|
2811
|
+
- records
|
|
2812
|
+
- goals
|
|
2813
|
+
scope:
|
|
2814
|
+
type: object
|
|
2815
|
+
properties:
|
|
2816
|
+
organization_id:
|
|
2817
|
+
type: integer
|
|
2818
|
+
exported_at:
|
|
2819
|
+
type: string
|
|
2820
|
+
format: date-time
|
|
2821
|
+
items:
|
|
2822
|
+
type: array
|
|
2823
|
+
description: The rows of the section, with every column of the table (a column added later is exported at once).
|
|
2824
|
+
items:
|
|
2825
|
+
type: object
|
|
2826
|
+
additionalProperties: true
|
|
2827
|
+
next_after_id:
|
|
2828
|
+
type: integer
|
|
2829
|
+
nullable: true
|
|
2830
|
+
description: Pass it as `after_id` for the next page of `records`; null when there is none (always null for `tags` and `goals`).
|
|
2831
|
+
RecorderImportRequest:
|
|
2832
|
+
type: object
|
|
2833
|
+
description: An exported file, or a part of it. One request takes at most 500 tags, 500 goals and the records limit of the CSV import.
|
|
2834
|
+
required:
|
|
2835
|
+
- format
|
|
2836
|
+
- version
|
|
2837
|
+
properties:
|
|
2838
|
+
format:
|
|
2839
|
+
type: string
|
|
2840
|
+
enum:
|
|
2841
|
+
- nb-recorder-export
|
|
2842
|
+
version:
|
|
2843
|
+
type: integer
|
|
2844
|
+
enum:
|
|
2845
|
+
- 1
|
|
2846
|
+
tags:
|
|
2847
|
+
type: array
|
|
2848
|
+
items:
|
|
2849
|
+
type: object
|
|
2850
|
+
additionalProperties: true
|
|
2851
|
+
records:
|
|
2852
|
+
type: array
|
|
2853
|
+
items:
|
|
2854
|
+
type: object
|
|
2855
|
+
additionalProperties: true
|
|
2856
|
+
goals:
|
|
2857
|
+
type: array
|
|
2858
|
+
items:
|
|
2859
|
+
type: object
|
|
2860
|
+
additionalProperties: true
|
|
2861
|
+
RecorderImportResult:
|
|
2862
|
+
type: object
|
|
2863
|
+
required:
|
|
2864
|
+
- tags_created
|
|
2865
|
+
- tags_existing
|
|
2866
|
+
- tags_skipped
|
|
2867
|
+
- records_created
|
|
2868
|
+
- records_existing
|
|
2869
|
+
- records_skipped
|
|
2870
|
+
- records_with_attachment_not_restored
|
|
2871
|
+
- goals_created
|
|
2872
|
+
- goals_existing
|
|
2873
|
+
- goals_skipped
|
|
2874
|
+
- skipped
|
|
2875
|
+
properties:
|
|
2876
|
+
tags_created:
|
|
2877
|
+
type: integer
|
|
2878
|
+
tags_existing:
|
|
2879
|
+
type: integer
|
|
2880
|
+
tags_skipped:
|
|
2881
|
+
type: integer
|
|
2882
|
+
records_created:
|
|
2883
|
+
type: integer
|
|
2884
|
+
records_existing:
|
|
2885
|
+
type: integer
|
|
2886
|
+
records_skipped:
|
|
2887
|
+
type: integer
|
|
2888
|
+
records_with_attachment_not_restored:
|
|
2889
|
+
type: integer
|
|
2890
|
+
goals_created:
|
|
2891
|
+
type: integer
|
|
2892
|
+
goals_existing:
|
|
2893
|
+
type: integer
|
|
2894
|
+
goals_skipped:
|
|
2895
|
+
type: integer
|
|
2896
|
+
skipped:
|
|
2897
|
+
type: array
|
|
2898
|
+
description: The first rows that were skipped, with the reason (at most 50).
|
|
2899
|
+
items:
|
|
2900
|
+
type: object
|
|
2901
|
+
properties:
|
|
2902
|
+
section:
|
|
2903
|
+
type: string
|
|
2904
|
+
enum:
|
|
2905
|
+
- tags
|
|
2906
|
+
- records
|
|
2907
|
+
- goals
|
|
2908
|
+
index:
|
|
2909
|
+
type: integer
|
|
2910
|
+
reason:
|
|
2911
|
+
type: string
|
|
2912
|
+
skipped_reported:
|
|
2913
|
+
type: integer
|
|
2664
2914
|
responses:
|
|
2665
2915
|
ValidationError:
|
|
2666
2916
|
description: Validation error
|
|
@@ -2725,3 +2975,5 @@ tags:
|
|
|
2725
2975
|
description: Media file upload and management
|
|
2726
2976
|
- name: Goals
|
|
2727
2977
|
description: Goal tracking and management
|
|
2978
|
+
- name: Backup
|
|
2979
|
+
description: Complete backup and restore of an organization (Enterprise)
|
package/specs/specs.yaml
CHANGED
|
@@ -2,7 +2,7 @@ openapi: 3.0.3
|
|
|
2
2
|
info:
|
|
3
3
|
title: NASEBANAL Specs API
|
|
4
4
|
description: "Backend of the own API specs on the NASEBANAL API Specs site. A person on the Free plan keeps up to 20 specs of their own; an organization on the Enterprise plan keeps up to 100. Either uploads OpenAPI documents, keeps their versions and reads them in the same reference view as the NASEBANAL APIs. A spec belongs to exactly one owner, the person or the organization: every request names it in `X-Active-Organization-Id` (an organization id, or `personal`), and only the owner (for an organization, its members) can see or change its specs. Authenticates users via Auth0 JWT and Personal Access Tokens (PAT) and integrates with the Account API (membership and the Enterprise subscription). Every response is wrapped as `{ success, data }` (or `{ success: false, error }`)."
|
|
5
|
-
version: 1.
|
|
5
|
+
version: 1.5.0
|
|
6
6
|
contact:
|
|
7
7
|
name: NASEBANAL
|
|
8
8
|
url: https://www.nasebanal.com
|
|
@@ -485,7 +485,7 @@ paths:
|
|
|
485
485
|
- Specs
|
|
486
486
|
operationId: createSpec
|
|
487
487
|
summary: Create a spec
|
|
488
|
-
description: Creates the spec and its first revision from the document in `content`, optionally filed in the group `group_id` (without one the spec stands on its own, so no group has to be made first). The document is validated as OpenAPI 3.x before anything is stored; one that is not is refused with `422 INVALID_SPEC` and the reasons. The spec's API version (`api_version`, for example `v1`) is the one given, else the MAJOR of the document's `info.version` (`1.8.0` is `v1`, `v2.0` is `v2`); a version with no major to read (a calendar version such as `2023-01`) needs `api_version` said, or the request is refused with `400 API_VERSION_REQUIRED`. A new major API version is a new spec.
|
|
488
|
+
description: Creates the spec and its first revision from the document in `content`, optionally filed in the group `group_id` (without one the spec stands on its own, so no group has to be made first). The document is validated as OpenAPI 3.x before anything is stored; one that is not is refused with `422 INVALID_SPEC` and the reasons. The spec's API version (`api_version`, for example `v1`) is the one given, else the MAJOR of the document's `info.version` (`1.8.0` is `v1`, `v2.0` is `v2`); a version with no major to read (a calendar version such as `2023-01`) needs `api_version` said, or the request is refused with `400 API_VERSION_REQUIRED`. A new major API version is a new spec. A later version of an API names its initial version (the first spec registered for the API). Send `initial_spec_id` and the new spec is filed in that spec's group and repository (they must be the same if sent too). The API version is the document's, and no spec of that API may have it already (the initial spec's own included). Versions are registered in order, so the API version must be the next one after the highest the API has (v1, v2, then v3), and to leave room for one that is not ready a placeholder of it is registered first. Refused with `404 INITIAL_NOT_FOUND`, `400 INITIAL_NOT_INITIAL`, `400 INITIAL_GROUP_MISMATCH`, `400 INITIAL_REPOSITORY_MISMATCH`, `409 INITIAL_VERSION_TAKEN` or `409 INITIAL_VERSION_NOT_NEXT`. The spec's description is the one sent, else the first paragraph of the document's `info.description`.
|
|
489
489
|
parameters:
|
|
490
490
|
- $ref: "#/components/parameters/ActiveOrganization"
|
|
491
491
|
requestBody:
|
|
@@ -561,7 +561,7 @@ paths:
|
|
|
561
561
|
- Specs
|
|
562
562
|
operationId: updateSpec
|
|
563
563
|
summary: Update a spec
|
|
564
|
-
description: Renames the spec, changes its description or moves it to another group, or out of its group (`group_id`, `null` for none). Send only the fields to change, which include the quality settings of the spec (`public_badge`, `report_access`, `rotate_quality_public_id`). The API version is fixed when the spec is created, so a different `api_version` is refused with `400` (register the other API version as a new spec). The document itself is never edited - upload a new revision instead.
|
|
564
|
+
description: Renames the spec, changes its description or moves it to another group, or out of its group (`group_id`, `null` for none). Send only the fields to change, which include the quality settings of the spec (`public_badge`, `report_access`, `rotate_quality_public_id`). The API version is fixed when the spec is created, so a different `api_version` is refused with `400` (register the other API version as a new spec). The document itself is never edited - upload a new revision instead. `initial_spec_id` makes the spec a later version of an API (the same rules and refusals as when creating) or, with `null`, an API of its own. The specs of one API keep the group and repository of its initial version, so moving one is refused with `409 VERSION_FAMILY_MEMBER` unless it leaves the API in the same request; an initial version that has later versions cannot become a later version (`409 INITIAL_HAS_VERSIONS`).
|
|
565
565
|
requestBody:
|
|
566
566
|
required: true
|
|
567
567
|
content:
|
|
@@ -600,7 +600,7 @@ paths:
|
|
|
600
600
|
- Specs
|
|
601
601
|
operationId: deleteSpec
|
|
602
602
|
summary: Delete a spec
|
|
603
|
-
description: Deletes the spec and every one of its versions. Cannot be undone.
|
|
603
|
+
description: Deletes the spec and every one of its versions. Cannot be undone. The initial version of an API that has later versions cannot be deleted (`409 INITIAL_HAS_VERSIONS`), so delete or detach the later versions first.
|
|
604
604
|
responses:
|
|
605
605
|
"204":
|
|
606
606
|
description: Deleted
|
|
@@ -658,7 +658,7 @@ paths:
|
|
|
658
658
|
- Versions
|
|
659
659
|
operationId: createSpecVersion
|
|
660
660
|
summary: Upload a new version
|
|
661
|
-
description: Adds the document in `content` as the next REVISION of the spec (the number counts up inside the spec's API version). Validated like `createSpec`. A document identical to the latest revision is refused with `409 UNCHANGED` rather than stored twice. A document whose `info.version` has another major than the spec's API version (`v1` spec, `2.0.0` document) is another API version and is refused with `409 API_VERSION_MISMATCH` (register it as a new spec). A document with no major to read is accepted, the spec's API version stands.
|
|
661
|
+
description: Adds the document in `content` as the next REVISION of the spec (the number counts up inside the spec's API version). Validated like `createSpec`. A document identical to the latest revision is refused with `409 UNCHANGED` rather than stored twice. A document whose `info.version` has another major than the spec's API version (`v1` spec, `2.0.0` document) is another API version and is refused with `409 API_VERSION_MISMATCH` (register it as a new spec). A document with no major to read is accepted, the spec's API version stands. The spec's title and description follow the new document (its `info.title` and the first paragraph of its `info.description`, none when it has none).
|
|
662
662
|
requestBody:
|
|
663
663
|
required: true
|
|
664
664
|
content:
|
|
@@ -1200,6 +1200,7 @@ components:
|
|
|
1200
1200
|
- openapi_version
|
|
1201
1201
|
- latest_version
|
|
1202
1202
|
- api_version
|
|
1203
|
+
- initial_spec_id
|
|
1203
1204
|
- reference_access
|
|
1204
1205
|
- public_badge
|
|
1205
1206
|
- report_access
|
|
@@ -1247,6 +1248,10 @@ components:
|
|
|
1247
1248
|
type: string
|
|
1248
1249
|
example: v1
|
|
1249
1250
|
description: "The API version this spec is (`v1`, `v2`: the generation of the API, which changes only with a breaking change). Fixed when the spec is created, from the given `api_version` or the major of the document's `info.version`; a new major API version is a new spec. Results and monitors are about the spec, so they need no version of their own."
|
|
1251
|
+
initial_spec_id:
|
|
1252
|
+
type: string
|
|
1253
|
+
nullable: true
|
|
1254
|
+
description: The first spec registered for the API this spec is a later version of (its initial version), or `null` when this spec is an API of its own or is the initial version itself. The specs of one API share the group and repository of the initial version and have one spec per API version; a CI names the initial version by id and finds the spec of any API version of it.
|
|
1250
1255
|
created_by_user_id:
|
|
1251
1256
|
type: integer
|
|
1252
1257
|
nullable: true
|
|
@@ -1383,6 +1388,10 @@ components:
|
|
|
1383
1388
|
pattern: ^[A-Za-z0-9._-]{1,32}$
|
|
1384
1389
|
example: v1
|
|
1385
1390
|
description: "The API version of the spec (letters, digits, `.`, `_`, `-`; trimmed). Optional: left out, it is the major of the document's `info.version` (`1.8.0` is `v1`). Required when `info.version` has no major to read (`2023-01`), refused with `400 API_VERSION_REQUIRED` otherwise. Fixed for the life of the spec."
|
|
1391
|
+
initial_spec_id:
|
|
1392
|
+
type: string
|
|
1393
|
+
nullable: true
|
|
1394
|
+
description: The initial version of the API this new spec is a later version of. The new spec is filed in that spec's group and repository (taken from it when `group_id` and `repository_id` are left out), and its API version must not be one that API already has. Optional.
|
|
1386
1395
|
SpecUpdate:
|
|
1387
1396
|
type: object
|
|
1388
1397
|
properties:
|
|
@@ -1390,6 +1399,10 @@ components:
|
|
|
1390
1399
|
type: string
|
|
1391
1400
|
pattern: ^[A-Za-z0-9._-]{1,32}$
|
|
1392
1401
|
description: "Not changeable: the API version is fixed when the spec is created. Sending the spec's own value again is accepted; a different one is refused with `400` (a new API version is registered as a new spec)."
|
|
1402
|
+
initial_spec_id:
|
|
1403
|
+
type: string
|
|
1404
|
+
nullable: true
|
|
1405
|
+
description: The initial version of the API this spec is a later version of, with the same rules as when creating; `null` makes the spec an API of its own. A spec in an API cannot change its group or repository (`409 VERSION_FAMILY_MEMBER`) unless it leaves the API in the same request.
|
|
1393
1406
|
group_id:
|
|
1394
1407
|
type: string
|
|
1395
1408
|
nullable: true
|
package/specs/target.yaml
CHANGED
|
@@ -2,7 +2,7 @@ openapi: 3.0.3
|
|
|
2
2
|
info:
|
|
3
3
|
title: NASEBANAL Target API
|
|
4
4
|
description: "Target API for NASEBANAL. Provides hierarchical target management: users define goals and organize them in a tree structure. Parent-child links are persisted via `targets.parent_target_id` (authoritative since migration 0017); a legacy cell-based storage layer is kept in sync best-effort for backward compatibility. Targets can be shared with other users (read/write, optionally including the subtree and linked Recorder data), and ownership of a personal target subtree can be transferred to a recipient via an email-approved migration flow. Supports user authentication via Auth0 JWT and Personal Access Tokens (PAT)."
|
|
5
|
-
version: 1.
|
|
5
|
+
version: 1.6.0
|
|
6
6
|
contact:
|
|
7
7
|
name: NASEBANAL
|
|
8
8
|
url: https://www.nasebanal.com
|
|
@@ -906,6 +906,106 @@ paths:
|
|
|
906
906
|
$ref: "#/components/responses/Unauthorized"
|
|
907
907
|
"404":
|
|
908
908
|
$ref: "#/components/responses/NotFound"
|
|
909
|
+
/api/v1/export:
|
|
910
|
+
get:
|
|
911
|
+
summary: Take a complete copy of an organization's data
|
|
912
|
+
description: "Everything the caller may take, as JSON: targets with their cells, in keyset pages (`after_id`, 50 targets a page) that the caller walks until `next_after_id` is null. An organization admin takes every member's targets, a member only their own. Read-only, so an admin of an organization whose Enterprise contract has ended can still take the data away before deleting the organization."
|
|
913
|
+
operationId: exportData
|
|
914
|
+
tags:
|
|
915
|
+
- Backup
|
|
916
|
+
parameters:
|
|
917
|
+
- name: X-Active-Organization-Id
|
|
918
|
+
in: header
|
|
919
|
+
required: true
|
|
920
|
+
description: "The organization acted on (an organization id). The backup is a feature of organizations (Enterprise): without it the answer is 403 ORGANIZATION_REQUIRED."
|
|
921
|
+
schema:
|
|
922
|
+
type: integer
|
|
923
|
+
minimum: 1
|
|
924
|
+
- name: after_id
|
|
925
|
+
in: query
|
|
926
|
+
description: Return the targets after this id (the previous page's `next_after_id`); empty starts at the beginning.
|
|
927
|
+
schema:
|
|
928
|
+
type: string
|
|
929
|
+
maxLength: 64
|
|
930
|
+
responses:
|
|
931
|
+
"200":
|
|
932
|
+
description: One section (or page) of the copy
|
|
933
|
+
content:
|
|
934
|
+
application/json:
|
|
935
|
+
schema:
|
|
936
|
+
type: object
|
|
937
|
+
properties:
|
|
938
|
+
success:
|
|
939
|
+
type: boolean
|
|
940
|
+
enum:
|
|
941
|
+
- true
|
|
942
|
+
data:
|
|
943
|
+
$ref: "#/components/schemas/TargetExportPage"
|
|
944
|
+
"400":
|
|
945
|
+
$ref: "#/components/responses/ValidationError"
|
|
946
|
+
"401":
|
|
947
|
+
$ref: "#/components/responses/Unauthorized"
|
|
948
|
+
"403":
|
|
949
|
+
description: No organization selected (ORGANIZATION_REQUIRED) or no access to the organization
|
|
950
|
+
content:
|
|
951
|
+
application/json:
|
|
952
|
+
schema:
|
|
953
|
+
$ref: "#/components/schemas/Error"
|
|
954
|
+
example:
|
|
955
|
+
success: false
|
|
956
|
+
error:
|
|
957
|
+
code: ORGANIZATION_REQUIRED
|
|
958
|
+
message: The complete backup is for organizations (Enterprise)
|
|
959
|
+
/api/v1/import/full:
|
|
960
|
+
post:
|
|
961
|
+
summary: Put a complete copy back
|
|
962
|
+
description: "Restores an exported file (or a part of it: up to 40 targets per request) into the active organization, owned by the importer. An organization admin only. Targets the organization already has are left alone and counted, so putting the same file back twice changes nothing the second time."
|
|
963
|
+
operationId: importFull
|
|
964
|
+
tags:
|
|
965
|
+
- Backup
|
|
966
|
+
parameters:
|
|
967
|
+
- name: X-Active-Organization-Id
|
|
968
|
+
in: header
|
|
969
|
+
required: true
|
|
970
|
+
description: "The organization acted on (an organization id). The backup is a feature of organizations (Enterprise): without it the answer is 403 ORGANIZATION_REQUIRED."
|
|
971
|
+
schema:
|
|
972
|
+
type: integer
|
|
973
|
+
minimum: 1
|
|
974
|
+
requestBody:
|
|
975
|
+
required: true
|
|
976
|
+
content:
|
|
977
|
+
application/json:
|
|
978
|
+
schema:
|
|
979
|
+
$ref: "#/components/schemas/TargetImportRequest"
|
|
980
|
+
responses:
|
|
981
|
+
"200":
|
|
982
|
+
description: What was created, what was already there and what was skipped
|
|
983
|
+
content:
|
|
984
|
+
application/json:
|
|
985
|
+
schema:
|
|
986
|
+
type: object
|
|
987
|
+
properties:
|
|
988
|
+
success:
|
|
989
|
+
type: boolean
|
|
990
|
+
enum:
|
|
991
|
+
- true
|
|
992
|
+
data:
|
|
993
|
+
$ref: "#/components/schemas/TargetImportResult"
|
|
994
|
+
"400":
|
|
995
|
+
$ref: "#/components/responses/ValidationError"
|
|
996
|
+
"401":
|
|
997
|
+
$ref: "#/components/responses/Unauthorized"
|
|
998
|
+
"403":
|
|
999
|
+
description: Not an organization admin, no organization selected (ORGANIZATION_REQUIRED), or the organization's contract has ended (ORG_READ_ONLY)
|
|
1000
|
+
content:
|
|
1001
|
+
application/json:
|
|
1002
|
+
schema:
|
|
1003
|
+
$ref: "#/components/schemas/Error"
|
|
1004
|
+
example:
|
|
1005
|
+
success: false
|
|
1006
|
+
error:
|
|
1007
|
+
code: FORBIDDEN
|
|
1008
|
+
message: The complete backup is for organizations (Enterprise)
|
|
909
1009
|
components:
|
|
910
1010
|
securitySchemes:
|
|
911
1011
|
BearerAuth:
|
|
@@ -1463,6 +1563,90 @@ components:
|
|
|
1463
1563
|
details:
|
|
1464
1564
|
type: object
|
|
1465
1565
|
additionalProperties: true
|
|
1566
|
+
TargetExportPage:
|
|
1567
|
+
type: object
|
|
1568
|
+
description: A page of an organization's complete copy.
|
|
1569
|
+
required:
|
|
1570
|
+
- format
|
|
1571
|
+
- version
|
|
1572
|
+
- scope
|
|
1573
|
+
- exported_at
|
|
1574
|
+
- targets
|
|
1575
|
+
- next_after_id
|
|
1576
|
+
properties:
|
|
1577
|
+
format:
|
|
1578
|
+
type: string
|
|
1579
|
+
enum:
|
|
1580
|
+
- nb-target-export
|
|
1581
|
+
version:
|
|
1582
|
+
type: integer
|
|
1583
|
+
enum:
|
|
1584
|
+
- 1
|
|
1585
|
+
scope:
|
|
1586
|
+
type: object
|
|
1587
|
+
properties:
|
|
1588
|
+
organization_id:
|
|
1589
|
+
type: integer
|
|
1590
|
+
exported_at:
|
|
1591
|
+
type: string
|
|
1592
|
+
format: date-time
|
|
1593
|
+
targets:
|
|
1594
|
+
type: array
|
|
1595
|
+
description: Targets with every column of the table, each with its `cells`.
|
|
1596
|
+
items:
|
|
1597
|
+
type: object
|
|
1598
|
+
additionalProperties: true
|
|
1599
|
+
next_after_id:
|
|
1600
|
+
type: string
|
|
1601
|
+
nullable: true
|
|
1602
|
+
description: Pass it as `after_id` for the next page; null when there is none.
|
|
1603
|
+
TargetImportRequest:
|
|
1604
|
+
type: object
|
|
1605
|
+
description: An exported file, or a part of it. One request takes at most 40 targets.
|
|
1606
|
+
required:
|
|
1607
|
+
- format
|
|
1608
|
+
- version
|
|
1609
|
+
properties:
|
|
1610
|
+
format:
|
|
1611
|
+
type: string
|
|
1612
|
+
enum:
|
|
1613
|
+
- nb-target-export
|
|
1614
|
+
version:
|
|
1615
|
+
type: integer
|
|
1616
|
+
enum:
|
|
1617
|
+
- 1
|
|
1618
|
+
targets:
|
|
1619
|
+
type: array
|
|
1620
|
+
items:
|
|
1621
|
+
type: object
|
|
1622
|
+
additionalProperties: true
|
|
1623
|
+
TargetImportResult:
|
|
1624
|
+
type: object
|
|
1625
|
+
required:
|
|
1626
|
+
- targets_created
|
|
1627
|
+
- targets_existing
|
|
1628
|
+
- targets_skipped
|
|
1629
|
+
- cells_in_file
|
|
1630
|
+
- skipped
|
|
1631
|
+
properties:
|
|
1632
|
+
targets_created:
|
|
1633
|
+
type: integer
|
|
1634
|
+
targets_existing:
|
|
1635
|
+
type: integer
|
|
1636
|
+
targets_skipped:
|
|
1637
|
+
type: integer
|
|
1638
|
+
cells_in_file:
|
|
1639
|
+
type: integer
|
|
1640
|
+
skipped:
|
|
1641
|
+
type: array
|
|
1642
|
+
description: The first targets that were skipped, with the reason (at most 50).
|
|
1643
|
+
items:
|
|
1644
|
+
type: object
|
|
1645
|
+
properties:
|
|
1646
|
+
index:
|
|
1647
|
+
type: integer
|
|
1648
|
+
reason:
|
|
1649
|
+
type: string
|
|
1466
1650
|
responses:
|
|
1467
1651
|
Unauthorized:
|
|
1468
1652
|
description: Authentication required or invalid token
|
|
@@ -1530,3 +1714,5 @@ tags:
|
|
|
1530
1714
|
description: Individual storage cell management on a target
|
|
1531
1715
|
- name: Sharing
|
|
1532
1716
|
description: Sharing targets with other users and transferring ownership
|
|
1717
|
+
- name: Backup
|
|
1718
|
+
description: Complete backup and restore of an organization (Enterprise)
|