Skip to content

Commit

Permalink
Removed SyncState from CSV model for creating folders, enabled descri…
Browse files Browse the repository at this point in the history
…ption to be added when creating a folder
  • Loading branch information
amgrobelny-box committed Dec 11, 2017
1 parent 76b0db5 commit 411fdfc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public BoxFolderCreateRequestMap()
{
Map(m => m.Name);
Map(m => m.Description);
Map(m => m.SyncState);
References<BoxFolderRequestParentMap>(m => m.Parent);
}
}
Expand Down
10 changes: 10 additions & 0 deletions BoxCLI/Commands/FolderSubCommands/FolderCreateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 <DESCRIPTION>", CommandOptionType.SingleValue);
command.OnExecute(async () =>
{
return await this.Execute();
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions BoxCLI/Commands/FolderSubCommands/FolderSubCommandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <token_string>`. Certain commands may fail based on the permissions of the user to which the token you use belongs.
Expand Down

0 comments on commit 411fdfc

Please sign in to comment.