public static async Task <bool> DoesFileExistInFolder(IBoxClient client, string folderId, string fileName) { // TODO: Paging BoxCollection <BoxItem> boxCollection = await client.FoldersManager.GetFolderItemsAsync(folderId, 1000); return(boxCollection.Entries.Any(item => item.Name == fileName)); }
public static async Task AssemblyInitialize(TestContext testContext) { var jsonConfig = Environment.GetEnvironmentVariable("INTEGRATION_TESTING_CONFIG"); if (string.IsNullOrEmpty(jsonConfig)) { Debug.WriteLine("No json config found in environment variables Reading from config.json."); jsonConfig = ReadFromJson("config.json"); } var config = BoxConfigBuilder.CreateFromJsonString(jsonConfig) .Build(); var session = new BoxJWTAuth(config); var json = JObject.Parse(jsonConfig); var adminToken = await session.AdminTokenAsync(); AdminClient = session.AdminClient(adminToken); if (json["userID"] != null && json["userID"].ToString().Length != 0) { UserId = json["userID"].ToString(); } else { var user = await CreateNewUser(AdminClient); UserId = user.Id; } var userToken = await session.UserTokenAsync(UserId); UserClient = session.UserClient(userToken, UserId); EnterpriseId = config.EnterpriseId; }
public async Task <string> Execute(IBoxClient client) { var retentionPolicyRequest = new BoxRetentionPolicyRequest { PolicyName = _policyName, PolicyType = "finite", RetentionLength = 1, DispositionAction = DispositionAction.permanently_delete.ToString(), }; var response = await client.RetentionPoliciesManager.CreateRetentionPolicyAsync(retentionPolicyRequest); Policy = response; PolicyId = Policy.Id; var assignmentRequest = new BoxRetentionPolicyAssignmentRequest() { PolicyId = PolicyId, AssignTo = new BoxRequestEntity() { Type = BoxType.folder, Id = _folderId } }; await client.RetentionPoliciesManager.CreateRetentionPolicyAssignmentAsync(assignmentRequest); return(PolicyId); }
public async Task <string> Execute(IBoxClient client) { var whitelistTargetEntry = await client.CollaborationWhitelistManager.AddCollaborationWhitelistExemptUserAsync(_userId); WhitelistTargetEntry = whitelistTargetEntry; return(WhitelistTargetEntry.Id); }
public async Task Dispose(IBoxClient client) { var retentionPolicyRequest = new BoxRetentionPolicyRequest { Status = "retired" }; await client.RetentionPoliciesManager.UpdateRetentionPolicyAsync(PolicyId, retentionPolicyRequest); }
private static async Task DisposeCommands(Stack <IDisposableCommand> commands) { while (commands.Count > 0) { var command = commands.Pop(); IBoxClient client = GetClient(command); await command.Dispose(client); } }
public async Task Dispose(IBoxClient client) { await client.FilesManager.DeleteAsync(FileId); // for some reason file uploaded as admin cannot be purged from trash if (AccessLevel != CommandAccessLevel.Admin) { await client.FilesManager.PurgeTrashedAsync(FileId); } }
protected static Task <BoxUser> CreateNewUser(IBoxClient client) { var userRequest = new BoxUserRequest { Name = "IT App User - " + Guid.NewGuid().ToString(), IsPlatformAccessOnly = true }; var user = client.UsersManager.CreateEnterpriseUserAsync(userRequest); UserCreated = true; return(user); }
public async Task <string> Execute(IBoxClient client) { var userRequest = new BoxUserRequest { Name = _name, IsPlatformAccessOnly = true, ExternalAppUserId = _externalAppUserId }; BoxUser = await client.UsersManager.CreateEnterpriseUserAsync(userRequest); _id = BoxUser.Id; return(BoxUser.Id); }
public async Task <string> Execute(IBoxClient client) { var createFolderRequest = new BoxFolderRequest { Name = _folderName, Parent = new BoxRequestEntity { Id = _parentId } }; Folder = await client.FoldersManager.CreateAsync(createFolderRequest); FolderId = Folder.Id; return(FolderId); }
public static async Task <string> ExecuteCommand(IDisposableCommand command) { IBoxClient client = GetClient(command); var resourceId = await command.Execute(client); if (command.Scope == CommandScope.Test) { TestCommands.Push(command); } else { ClassCommands.Push(command); } return(resourceId); }
public async Task <string> Execute(IBoxClient client) { var metadataTemplate = new BoxMetadataTemplate { DisplayName = TemplateKey, TemplateKey = TemplateKey, Scope = "enterprise", Fields = _metadataFields }; var response = await client.MetadataManager.CreateMetadataTemplate(metadataTemplate); MetadataTemplate = response; return(response.Id); }
public async Task <string> Execute(IBoxClient client) { var webLinkRequest = new BoxWebLinkRequest() { Url = new Uri("http://www.box.com"), Name = _name, Description = "A weblink to Box.com", Parent = new BoxRequestEntity() { Id = _parentFolderId } }; WebLink = await client.WebLinksManager.CreateWebLinkAsync(webLinkRequest); _webLinkId = WebLink.Id; return(_webLinkId); }
public async Task <string> Execute(IBoxClient client) { using (var fileStream = new FileStream(_filePath, FileMode.OpenOrCreate)) { var requestParams = new BoxFileRequest() { Name = _fileName, Parent = new BoxRequestEntity() { Id = _folderId } }; var response = await client.FilesManager.UploadAsync(requestParams, fileStream); File = response; FileId = File.Id; return(FileId); } }
public static async Task ExecuteCommand(ICleanupCommand command) { IBoxClient client = GetClient(command); await command.Execute(client); }
public async Task Dispose(IBoxClient client) { await client.MetadataManager.DeleteFileMetadataAsync(_fileId, "enterprise", _templateKey); }
public async Task <string> Execute(IBoxClient client) { await client.MetadataManager.CreateFileMetadataAsync(_fileId, _metadata, "enterprise", _templateKey); return(_templateKey); }
public async Task Dispose(IBoxClient client) { await client.UsersManager.DeleteEnterpriseUserAsync(_id, false, true); }
public async Task Dispose(IBoxClient client) { await client.CollaborationWhitelistManager.DeleteCollaborationWhitelistExemptUserAsync(WhitelistTargetEntry.Id); }
public async Task Execute(IBoxClient client) { await client.FilesManager.DeleteAsync(_fileId); await client.FilesManager.PurgeTrashedAsync(_fileId); }
public async Task Dispose(IBoxClient client) { await client.MetadataManager.DeleteMetadataTemplate("enterprise", TemplateKey); }
public async Task Dispose(IBoxClient client) { await client.WebLinksManager.DeleteWebLinkAsync(_webLinkId); }
public async Task Dispose(IBoxClient client) { await client.FoldersManager.DeleteAsync(FolderId, true); await client.FoldersManager.PurgeTrashedFolderAsync(FolderId); }