Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Commands/Project/WacsdkProjectCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,22 @@ public WacsdkProjectCommands(WacsdkCommandConfig config, Option<string> repoOpti
AddCommand(new WacsdkProjectGetCommand(config, repoOption));
AddCommand(new WacsdkProjectCreateCommand(config, repoOption, nameOption, descriptionOption));
AddCommand(new WacsdkProjectListCommand(config, repoOption));
AddCommand(new WacsdkProjectDeleteCommand(config, repoOption));

// Add entity property management commands
AddCommand(new EntityNameCommand(config, repoOption, projectIdOption, valueOption));
AddCommand(new EntityDescription(config, repoOption, projectIdOption, valueOption));
AddCommand(new EntityExtendedDescription(config, repoOption, projectIdOption, valueOption));
AddCommand(new EntityIsUnlistedCommand(config, repoOption, projectIdOption, boolValueOption));
AddCommand(new EntityForgetMeCommand(config, repoOption, projectIdOption, nullableBoolValueOption));

// Add collection management commands
AddCommand(new ConnectionsCommand(config, repoOption, projectIdOption, connectionIdOption, connectionValueOption));
AddCommand(new EntityImagesCommand(config, repoOption, projectIdOption, imagePathOption, optionalImageIdOption, requiredImageIdOption, imageNameOption));
AddCommand(new LinksCommand(config, repoOption, projectIdOption, linkIdOption, nameOption, urlOption, descriptionOption));
AddCommand(new UserRolesCommand(config, repoOption, projectIdOption, userIdOption, roleIdOption, roleNameOption, roleDescriptionOption));
AddCommand(new AccentColorCommand(config, repoOption, projectIdOption, colorOption));

// Add project-specific commands
AddCommand(new CategoryCommand(config, repoOption, projectIdOption, categoryOption));
AddCommand(new FeaturesCommand(config, repoOption, projectIdOption, featureOption));
Expand Down
63 changes: 63 additions & 0 deletions src/Commands/Project/WacsdkProjectDeleteCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using OwlCore.Diagnostics;
using OwlCore.Storage;
using System.CommandLine;
using WindowsAppCommunity.Sdk.Nomad;

namespace WindowsAppCommunity.CommandLine.Project
{
/// <summary>
/// Command to delete an existing project.
/// </summary>
public class WacsdkProjectDeleteCommand : Command
{
/// <summary>
/// Initializes a new instance of the <see cref="WacsdkProjectDeleteCommand"/> class.
/// </summary>
public WacsdkProjectDeleteCommand(WacsdkCommandConfig config, Option<string> repoOption)
: base(name: "delete", description: "Deletes a project.")
{
var projectIdOption = new Option<string>(
name: "--project-id",
description: "The ID of the project to delete.")
{
IsRequired = true
};

AddOption(repoOption);
AddOption(projectIdOption);
this.SetHandler(InvokeAsync, repoOption, projectIdOption);

Config = config;
}

/// <summary>
/// Shared command configuration.
/// </summary>
public WacsdkCommandConfig Config { get; }

/// <summary>
/// Handles the command.
/// </summary>
public async Task InvokeAsync(string repoId, string projectId)
{
var thisRepoStorage = (IModifiableFolder)await Config.RepositoryStorage.CreateFolderAsync(repoId, overwrite: false);

Logger.LogInformation($"Getting repo store with ID {repoId} at {thisRepoStorage.GetType().Name} {thisRepoStorage.Id}");
var repoSettings = new WacsdkNomadSettings(thisRepoStorage);
await repoSettings.LoadAsync(Config.CancellationToken);

var repositoryContainer = new RepositoryContainer(Config.KuboOptions, Config.Client, repoSettings.ManagedKeys, repoSettings.ManagedUserConfigs, repoSettings.ManagedProjectConfigs, repoSettings.ManagedPublisherConfigs);

Logger.LogInformation($"Getting project {projectId}");
var project = (ModifiableProject)await repositoryContainer.ProjectRepository.GetAsync(projectId, Config.CancellationToken);

Logger.LogInformation($"Deleting project {projectId}");
await repositoryContainer.ProjectRepository.DeleteAsync(project, Config.CancellationToken);

Logger.LogInformation($"Saving repository changes");
await repoSettings.SaveAsync(Config.CancellationToken);

Logger.LogInformation($"Deleted project {projectId}");
}
}
}
3 changes: 2 additions & 1 deletion src/Commands/Publisher/WacsdkPublisherCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ public WacsdkPublisherCommands(WacsdkCommandConfig config, Option<string> repoOp
AddCommand(new WacsdkPublisherGetCommand(config, repoOption));
AddCommand(new WacsdkPublisherCreateCommand(config, repoOption));
AddCommand(new WacsdkPublisherListCommand(config, repoOption));
AddCommand(new WacsdkPublisherDeleteCommand(config, repoOption));

// Add entity property management commands
AddCommand(new EntityNameCommand(config, repoOption, publisherIdOption, valueOption));
AddCommand(new EntityDescription(config, repoOption, publisherIdOption, valueOption));
AddCommand(new EntityExtendedDescription(config, repoOption, publisherIdOption, valueOption));
AddCommand(new EntityIsUnlistedCommand(config, repoOption, publisherIdOption, boolValueOption));
AddCommand(new EntityForgetMeCommand(config, repoOption, publisherIdOption, nullableBoolValueOption));

// Add collection management commands
AddCommand(new ConnectionsCommand(config, repoOption, publisherIdOption, connectionIdOption, connectionValueOption));
AddCommand(new EntityImagesCommand(config, repoOption, publisherIdOption, imagePathOption, requiredImageIdOption, optionalImageIdOption, imageNameOption));
Expand Down
63 changes: 63 additions & 0 deletions src/Commands/Publisher/WacsdkPublisherDeleteCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using OwlCore.Diagnostics;
using OwlCore.Storage;
using System.CommandLine;
using WindowsAppCommunity.Sdk.Nomad;

namespace WindowsAppCommunity.CommandLine.Publisher
{
/// <summary>
/// Command to delete an existing publisher.
/// </summary>
public class WacsdkPublisherDeleteCommand : Command
{
/// <summary>
/// Initializes a new instance of the <see cref="WacsdkPublisherDeleteCommand"/> class.
/// </summary>
public WacsdkPublisherDeleteCommand(WacsdkCommandConfig config, Option<string> repoOption)
: base(name: "delete", description: "Deletes a publisher.")
{
var publisherIdOption = new Option<string>(
name: "--publisher-id",
description: "The ID of the publisher to delete.")
{
IsRequired = true
};

AddOption(repoOption);
AddOption(publisherIdOption);
this.SetHandler(InvokeAsync, repoOption, publisherIdOption);

Config = config;
}

/// <summary>
/// Shared command configuration.
/// </summary>
public WacsdkCommandConfig Config { get; }

/// <summary>
/// Handles the command.
/// </summary>
public async Task InvokeAsync(string repoId, string publisherId)
{
var thisRepoStorage = (IModifiableFolder)await Config.RepositoryStorage.CreateFolderAsync(repoId, overwrite: false);

Logger.LogInformation($"Getting repo store with ID {repoId} at {thisRepoStorage.GetType().Name} {thisRepoStorage.Id}");
var repoSettings = new WacsdkNomadSettings(thisRepoStorage);
await repoSettings.LoadAsync(Config.CancellationToken);

var repositoryContainer = new RepositoryContainer(Config.KuboOptions, Config.Client, repoSettings.ManagedKeys, repoSettings.ManagedUserConfigs, repoSettings.ManagedProjectConfigs, repoSettings.ManagedPublisherConfigs);

Logger.LogInformation($"Getting publisher {publisherId}");
var publisher = (ModifiablePublisher)await repositoryContainer.PublisherRepository.GetAsync(publisherId, Config.CancellationToken);

Logger.LogInformation($"Deleting publisher {publisherId}");
await repositoryContainer.PublisherRepository.DeleteAsync(publisher, Config.CancellationToken);

Logger.LogInformation($"Saving repository changes");
await repoSettings.SaveAsync(Config.CancellationToken);

Logger.LogInformation($"Deleted publisher {publisherId}");
}
}
}
11 changes: 6 additions & 5 deletions src/Commands/User/WacsdkUserCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,21 @@ public WacsdkUserCommands(WacsdkCommandConfig config, Option<string> repoOption)
var roleIdOption = new Option<string>("--role-id", "The ID of the role.");
var roleNameOption = new Option<string>("--role-name", "The name of the role.");
var roleDescriptionOption = new Option<string>("--role-description", "The description of the role.");


// Add high-level user operations
AddCommand(new WacsdkUserGetCommand(config, repoOption));
AddCommand(new WacsdkUserCreateCommand(config, repoOption, nameOption, descriptionOption));
AddCommand(new WacsdkUserListCommand(config, repoOption));

AddCommand(new WacsdkUserListCommand(config, repoOption));
AddCommand(new WacsdkUserDeleteCommand(config, repoOption));

// Add entity property management commands
AddCommand(new EntityNameCommand(config, repoOption, userIdOption, valueOption));
AddCommand(new EntityDescription(config, repoOption, userIdOption, valueOption));
AddCommand(new EntityExtendedDescription(config, repoOption, userIdOption, valueOption));
AddCommand(new EntityIsUnlistedCommand(config, repoOption, userIdOption, boolValueOption));
AddCommand(new EntityForgetMeCommand(config, repoOption, userIdOption, nullableBoolValueOption));

// Add collection management commands
AddCommand(new ConnectionsCommand(config, repoOption, userIdOption, connectionIdOption, connectionValueOption));
AddCommand(new EntityImagesCommand(config, repoOption, userIdOption, imagePathOption, imageNameOption, optionalImageIdOption, requiredImageIdOption));
Expand Down
64 changes: 64 additions & 0 deletions src/Commands/User/WacsdkUserDeleteCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using OwlCore.Diagnostics;
using OwlCore.Storage;
using System.CommandLine;
using WindowsAppCommunity.Sdk.Nomad;

namespace WindowsAppCommunity.CommandLine.User
{
/// <summary>
/// Command to delete an existing user.
/// </summary>
public class WacsdkUserDeleteCommand : Command
{
/// <summary>
/// Initializes a new instance of the <see cref="WacsdkUserDeleteCommand"/> class.
/// </summary>
public WacsdkUserDeleteCommand(WacsdkCommandConfig config, Option<string> repoOption)
: base(name: "delete", description: "Deletes a user.")
{
var userIdOption = new Option<string>(
name: "--user-id",
description: "The ID of the user to delete.")
{
IsRequired = true
};

AddOption(repoOption);
AddOption(userIdOption);

this.SetHandler(InvokeAsync, repoOption, userIdOption);

Config = config;
}

/// <summary>
/// Shared command configuration.
/// </summary>
public WacsdkCommandConfig Config { get; }

/// <summary>
/// Handles the command.
/// </summary>
public async Task InvokeAsync(string repoId, string userId)
{
var thisRepoStorage = (IModifiableFolder)await Config.RepositoryStorage.CreateFolderAsync(repoId, overwrite: false);

Logger.LogInformation($"Getting repo store with ID {repoId} at {thisRepoStorage.GetType().Name} {thisRepoStorage.Id}");
var repoSettings = new WacsdkNomadSettings(thisRepoStorage);
await repoSettings.LoadAsync(Config.CancellationToken);

var repositoryContainer = new RepositoryContainer(Config.KuboOptions, Config.Client, repoSettings.ManagedKeys, repoSettings.ManagedUserConfigs, repoSettings.ManagedProjectConfigs, repoSettings.ManagedPublisherConfigs);

Logger.LogInformation($"Getting user {userId}");
var user = (ModifiableUser)await repositoryContainer.UserRepository.GetAsync(userId, Config.CancellationToken);

Logger.LogInformation($"Deleting user {userId}");
await repositoryContainer.UserRepository.DeleteAsync(user, Config.CancellationToken);

Logger.LogInformation($"Saving repository changes");
await repoSettings.SaveAsync(Config.CancellationToken);

Logger.LogInformation($"Deleted user {userId}");
}
}
}
Loading