@rockset/cli
Version:
Official Rockset CLI
87 lines (83 loc) • 3.78 kB
JavaScript
;
/* eslint-disable unicorn/filename-case */
// Generated file, please do not edit directly
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const core_2 = require("@rockset/core");
const util_1 = require("../../../helper/util");
const base_command_1 = require("../../../base-command");
const chalk = require("chalk");
const cli_ux_1 = require("cli-ux");
const bodySchema = `data:
- _id: ca2d6832-1bfd-f88f-0620-d2aa27a5d86c
patch:
- op: ADD
path: /foo/bar
value: baz
from: null
`;
let PatchDocuments = /** @class */ (() => {
class PatchDocuments extends base_command_1.RockCommand {
async run() {
const { args, flags } = await this.parse(PatchDocuments);
// Rockset client object
const client = await core_2.main.createClient();
const namedArgs = PatchDocuments.args;
// apicall
const apicall = client.documents.patchDocuments.bind(client.documents);
// endpoint
const endpoint = '/v1/orgs/self/ws/{workspace}/collections/{collection}/docs';
const method = 'PATCH';
await util_1.runApiCall.bind(this)({ args, flags, namedArgs, apicall, method, endpoint, bodySchema });
}
}
PatchDocuments.flags = Object.assign(Object.assign({ help: core_1.Flags.help({ char: 'h' }), body: core_1.Flags.string({
required: true,
description: 'Path to a file whose contents will be passed as the POST body of this request. Format must be [json|yaml]. An example schema is shown below.',
}), raw: core_1.Flags.boolean({
description: 'Show the raw output from the server, instead of grabbing the results. Usually used in conjunction with --output=json',
}) }, cli_ux_1.cli.table.flags({ only: ['columns', 'output'] })), { loadTestRps: core_1.Flags.integer({
char: 'l',
description: 'If this flag is active, a load test will be conducted using this endpoint. The value passed to this flag determines how many requests per second will be sent',
}), yes: core_1.Flags.boolean({
char: 'y',
description: 'Skip all safety prompts',
default: false,
}) });
PatchDocuments.args = [
{
name: 'workspace',
description: 'Name of the workspace.',
required: true,
hidden: false,
},
{
name: 'collection',
description: 'Name of the collection.',
required: true,
hidden: false,
},
];
PatchDocuments.description = `update existing documents in a collection
Arguments to this command will be passed as URL parameters to ${chalk.bold(`PATCH: /v1/orgs/self/ws/{workspace}/collections/{collection}/docs`)}
${chalk.bold(`This endpoint REQUIRES a PATCH body. To specify a PATCH body, please pass a JSON or YAML file to the --body flag.
`)}
Example Body (YAML):
data:
- _id: ca2d6832-1bfd-f88f-0620-d2aa27a5d86c
patch:
- op: ADD
path: /foo/bar
value: baz
from: null
Endpoint Reference
PATCH: /v1/orgs/self/ws/{workspace}/collections/{collection}/docs
Patch Documents
Update existing documents in a collection.
More documentation at ${chalk.underline(`https://docs.rockset.com/rest-api#patchdocuments`)}`;
PatchDocuments.examples = [
'$ rockset api:documents:patchDocuments WORKSPACE COLLECTION --body body.yaml\n$ cat body.yaml\ndata:\n - _id: ca2d6832-1bfd-f88f-0620-d2aa27a5d86c\n patch:\n - op: ADD\n path: /foo/bar\n value: baz\n from: null\n\n',
];
return PatchDocuments;
})();
exports.default = PatchDocuments;