From 411fdfc348e95a0f61a77209d7270245554bd498 Mon Sep 17 00:00:00 2001 From: amgrobelny-box Date: Mon, 11 Dec 2017 14:54:55 -0600 Subject: [PATCH] Removed SyncState from CSV model for creating folders, enabled description to be added when creating a folder --- .../CsvModels/BoxFolderCreateRequestMap.cs | 1 - .../Commands/FolderSubCommands/FolderCreateCommand.cs | 10 ++++++++++ .../Commands/FolderSubCommands/FolderSubCommandBase.cs | 7 +++++++ CHANGELOG.md | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/BoxCLI/CommandUtilities/CsvModels/BoxFolderCreateRequestMap.cs b/BoxCLI/CommandUtilities/CsvModels/BoxFolderCreateRequestMap.cs index b4c1ac6a..88fb00d4 100644 --- a/BoxCLI/CommandUtilities/CsvModels/BoxFolderCreateRequestMap.cs +++ b/BoxCLI/CommandUtilities/CsvModels/BoxFolderCreateRequestMap.cs @@ -10,7 +10,6 @@ public BoxFolderCreateRequestMap() { Map(m => m.Name); Map(m => m.Description); - Map(m => m.SyncState); References(m => m.Parent); } } diff --git a/BoxCLI/Commands/FolderSubCommands/FolderCreateCommand.cs b/BoxCLI/Commands/FolderSubCommands/FolderCreateCommand.cs index af357479..aa1878f3 100644 --- a/BoxCLI/Commands/FolderSubCommands/FolderCreateCommand.cs +++ b/BoxCLI/Commands/FolderSubCommands/FolderCreateCommand.cs @@ -19,6 +19,7 @@ public class FolderCreateCommand : FolderSubCommandBase private CommandOption _fileFormat; private CommandOption _save; private CommandOption _idOnly; + private CommandOption _description; private CommandLineApplication _app; private IBoxHome _home; @@ -40,6 +41,8 @@ public override void Configure(CommandLineApplication command) _parentFolderId = command.Argument("parentFolderId", "Id of parent folder to add new folder to, use '0' for the root folder"); _name = command.Argument("name", "Name of new folder"); + _description = command.Option("--description", + "A description for folder ", CommandOptionType.SingleValue); command.OnExecute(async () => { return await this.Execute(); @@ -73,6 +76,13 @@ await this.CreateFoldersFromFile(this._bulkPath.Value(), this._save.HasValue(), folderRequest.Parent.Id = this._parentFolderId.Value; folderRequest.Name = this._name.Value; var folder = await BoxClient.FoldersManager.CreateAsync(folderRequest); + var update = new BoxFolderRequest(); + if (this._description.HasValue()) + { + update.Description = this._description.Value(); + update.Id = folder.Id; + folder = await BoxClient.FoldersManager.UpdateInformationAsync(update); + } if (this._idOnly.HasValue()) { Reporter.WriteInformation(folder.Id); diff --git a/BoxCLI/Commands/FolderSubCommands/FolderSubCommandBase.cs b/BoxCLI/Commands/FolderSubCommands/FolderSubCommandBase.cs index 127dc9d4..cea2ba3e 100644 --- a/BoxCLI/Commands/FolderSubCommands/FolderSubCommandBase.cs +++ b/BoxCLI/Commands/FolderSubCommands/FolderSubCommandBase.cs @@ -114,6 +114,13 @@ protected async virtual Task CreateFoldersFromFile(string path, try { createdFolder = await boxClient.FoldersManager.CreateAsync(folderRequest); + var update = new BoxFolderRequest(); + if (!string.IsNullOrEmpty(folderRequest.Description)) + { + update.Description = folderRequest.Description; + update.Id = createdFolder.Id; + createdFolder = await boxClient.FoldersManager.UpdateInformationAsync(update); + } } catch (Exception e) { diff --git a/CHANGELOG.md b/CHANGELOG.md index ccd301ac..72ad6f01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - Fixed bug preventing removal of a user from an Enterprise and conversion to a free user account. - Fixed bug that returned incorrect total count when using `box list users -m` to only list managed users. - Added CreatedAt field to CSV output for events. +- Removed SyncState from CSV for creating folders. +- Enabled setting a description for a folder when creating the folder. ## 1.1.0 - Added new feature on all commands for using an individual token. Add the `--token` option to perform an individual command with the Box CLI using a specific token you provide. The feature is most useful when paired with the Developer Token you can generate through the Box Developer Console. When working with an application you create in the Box Developer Console, you will not need to authorize the application into a Box Enterprise before working with the Developer Token. For example usage: `box users get me --token `. Certain commands may fail based on the permissions of the user to which the token you use belongs.