-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e6e1120
commit 74db947
Showing
10 changed files
with
729 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
'use strict'; | ||
|
||
const BoxCommand = require('../../box-command'); | ||
|
||
class TrashGetCommand extends BoxCommand { | ||
async run() { | ||
const { flags, args } = this.parse(TrashGetCommand); | ||
let options = {}; | ||
|
||
if (flags.fields) { | ||
options.fields = flags.fields; | ||
} | ||
let item; | ||
if (args.type === 'file') { | ||
item = await this.client.files.getTrashedFile(args.id, options); | ||
} else if (args.type === 'folder') { | ||
item = await this.client.folders.getTrashedFolder(args.id, options); | ||
} else if (args.type === 'web_link') { | ||
item = await this.client.wrapWithDefaultHandler(this.client.get)(`/web_links/${args.id}/trash`, {qs: options}); | ||
} | ||
await this.output(item); | ||
} | ||
} | ||
|
||
TrashGetCommand.description = 'Get information about an item in trash'; | ||
TrashGetCommand.examples = ['box trash:get folder 22222']; | ||
|
||
TrashGetCommand.flags = { | ||
...BoxCommand.flags | ||
}; | ||
|
||
TrashGetCommand.args = [ | ||
{ | ||
name: 'type', | ||
required: true, | ||
hidden: false, | ||
description: 'Type of the item to get', | ||
options: [ | ||
'file', | ||
'folder', | ||
'web_link' | ||
], | ||
}, | ||
{ | ||
name: 'id', | ||
required: true, | ||
hidden: false, | ||
description: 'ID of the item to get', | ||
} | ||
]; | ||
|
||
module.exports = TrashGetCommand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
'use strict'; | ||
|
||
const BoxCommand = require('../../box-command'); | ||
const { flags } = require('@oclif/command'); | ||
|
||
class TrashRestoreCommand extends BoxCommand { | ||
async run() { | ||
const { flags, args } = this.parse(TrashRestoreCommand); | ||
let options = {}; | ||
|
||
if (flags.name) { | ||
options.name = flags.name; | ||
} | ||
if (flags['parent-id']) { | ||
options.parent = { | ||
id: flags['parent-id'] | ||
}; | ||
} | ||
let item; | ||
if (args.type === 'file') { | ||
item = await this.client.files.restoreFromTrash(args.id, options); | ||
} else if (args.type === 'folder') { | ||
item = await this.client.folders.restoreFromTrash(args.id, options); | ||
} else if (args.type === 'web_link') { | ||
item = await this.client.wrapWithDefaultHandler(this.client.post)(`/web_links/${args.id}`, {body: options}); | ||
} | ||
await this.output(item); | ||
} | ||
} | ||
|
||
TrashRestoreCommand.description = 'Restore an item from trash'; | ||
TrashRestoreCommand.examples = ['box trash:restore folder 22222']; | ||
|
||
TrashRestoreCommand.flags = { | ||
...BoxCommand.flags, | ||
name: flags.string({ | ||
description: 'The new name for the item' | ||
}), | ||
'parent-id': flags.string({ | ||
description: 'ID of a folder to restore the item to only when the original folder no longer exists' | ||
}) | ||
}; | ||
|
||
TrashRestoreCommand.args = [ | ||
{ | ||
name: 'type', | ||
required: true, | ||
hidden: false, | ||
description: 'Type of the item to restore', | ||
options: [ | ||
'file', | ||
'folder', | ||
'web_link' | ||
], | ||
}, | ||
{ | ||
name: 'id', | ||
required: true, | ||
hidden: false, | ||
description: 'ID of the item to restore', | ||
} | ||
]; | ||
|
||
module.exports = TrashRestoreCommand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"type": "file", | ||
"id": "12345", | ||
"file_version": { | ||
"type": "file_version", | ||
"id": "11223344556677", | ||
"sha1": "97b3dbba6eab7ad0f058240744c8636b7c7bea93" | ||
}, | ||
"sequence_id": "1", | ||
"etag": "1", | ||
"sha1": "97b3dbba6eab7ad0f058240744c8636b7c7bea93", | ||
"name": "test_file_download.txt", | ||
"description": "", | ||
"size": 106833, | ||
"path_collection": { | ||
"total_count": 2, | ||
"entries": [ | ||
{ | ||
"type": "folder", | ||
"id": "0", | ||
"sequence_id": null, | ||
"etag": null, | ||
"name": "All Files" | ||
} | ||
] | ||
}, | ||
"created_at": "2016-11-16T22:01:44-08:00", | ||
"modified_at": "2016-11-16T22:01:51-08:00", | ||
"trashed_at": "2012-12-12T10:53:43-08:00", | ||
"purged_at": "2012-12-12T10:53:43-08:00", | ||
"content_created_at": "2016-10-29T18:33:50-07:00", | ||
"content_modified_at": "2016-10-29T18:33:50-07:00", | ||
"created_by": { | ||
"type": "user", | ||
"id": "1357924680", | ||
"name": "Owner", | ||
"login": "owner@example.com" | ||
}, | ||
"modified_by": { | ||
"type": "user", | ||
"id": "1357924680", | ||
"name": "Owner", | ||
"login": "owner@example.com" | ||
}, | ||
"owned_by": { | ||
"type": "user", | ||
"id": "1357924680", | ||
"name": "Owner", | ||
"login": "owner@example.com" | ||
}, | ||
"shared_link": null, | ||
"parent": { | ||
"type": "folder", | ||
"id": "0", | ||
"sequence_id": "0", | ||
"etag": "0", | ||
"name": "All files" | ||
}, | ||
"item_status": "active" | ||
} |
Oops, something went wrong.