From 21f3a39b06c278dfaad9434bb51da3962e7fb05b Mon Sep 17 00:00:00 2001 From: Jonathan Treffler Date: Sat, 2 Nov 2024 20:17:40 +0100 Subject: [PATCH] added occ commands to get organization folder by id and to remove organization folder --- appinfo/info.xml | 2 ++ .../GetOrganizationFolder.php | 34 +++++++++++++++++++ .../ListOrganizationFolders.php | 4 +-- .../RemoveOrganizationFolder.php | 34 +++++++++++++++++++ lib/Model/OrganizationFolder.php | 8 +++++ 5 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 lib/Command/OrganizationFolder/GetOrganizationFolder.php create mode 100644 lib/Command/OrganizationFolder/RemoveOrganizationFolder.php diff --git a/appinfo/info.xml b/appinfo/info.xml index 606c70d..7d87662 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -19,8 +19,10 @@ + OCA\OrganizationFolders\Command\OrganizationFolder\GetOrganizationFolder OCA\OrganizationFolders\Command\OrganizationFolder\ListOrganizationFolders OCA\OrganizationFolders\Command\OrganizationFolder\CreateOrganizationFolder + OCA\OrganizationFolders\Command\OrganizationFolder\RemoveOrganizationFolder OCA\OrganizationFolders\Command\Resource\CreateResource OCA\OrganizationFolders\Command\Resource\ListResources OCA\OrganizationFolders\Command\ResourceMember\CreateResourceMember diff --git a/lib/Command/OrganizationFolder/GetOrganizationFolder.php b/lib/Command/OrganizationFolder/GetOrganizationFolder.php new file mode 100644 index 0000000..21a6ce5 --- /dev/null +++ b/lib/Command/OrganizationFolder/GetOrganizationFolder.php @@ -0,0 +1,34 @@ +setName('organization-folders:get') + ->setDescription('Get organization folder by id') + ->addArgument('id', null, InputArgument::REQUIRED, 'Id of the organization folder to get'); + parent::configure(); + } + + protected function execute(InputInterface $input, OutputInterface $output): int { + $id = (int)$input->getArgument('id'); + + try { + $organizationFolder = $this->organizationFolderService->find($id); + + $this->writeTableInOutputFormat($input, $output, [$this->formatTableSerializable($organizationFolder)]); + return 0; + } catch (Exception $e) { + $output->writeln("Exception \"{$e->getMessage()}\" at {$e->getFile()} line {$e->getLine()}"); + return 1; + } + } +} diff --git a/lib/Command/OrganizationFolder/ListOrganizationFolders.php b/lib/Command/OrganizationFolder/ListOrganizationFolders.php index c284fc9..98b6349 100644 --- a/lib/Command/OrganizationFolder/ListOrganizationFolders.php +++ b/lib/Command/OrganizationFolder/ListOrganizationFolders.php @@ -19,9 +19,9 @@ class ListOrganizationFolders extends BaseCommand { protected function execute(InputInterface $input, OutputInterface $output): int { try { - $organizationFolderGroupfolders = $this->organizationFolderService->findAll(); + $organizationFolders = $this->organizationFolderService->findAll(); - $this->writeTableInOutputFormat($input, $output, $this->formatTableSerializables($organizationFolderGroupfolders)); + $this->writeTableInOutputFormat($input, $output, $this->formatTableSerializables($organizationFolders)); return 0; } catch (Exception $e) { $output->writeln("Exception \"{$e->getMessage()}\" at {$e->getFile()} line {$e->getLine()}"); diff --git a/lib/Command/OrganizationFolder/RemoveOrganizationFolder.php b/lib/Command/OrganizationFolder/RemoveOrganizationFolder.php new file mode 100644 index 0000000..c70b9dc --- /dev/null +++ b/lib/Command/OrganizationFolder/RemoveOrganizationFolder.php @@ -0,0 +1,34 @@ +setName('organization-folders:remove') + ->setDescription('Remove a new organization folder') + ->addArgument('id', null, InputArgument::REQUIRED, 'Id of the organization folder to remove'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int { + $id = (int)$input->getArgument('id'); + + try { + $this->organizationFolderService->remove($id); + + $output->writeln("done"); + + return 0; + } catch (Exception $e) { + $output->writeln("Exception \"{$e->getMessage()}\" at {$e->getFile()} line {$e->getLine()}"); + return 1; + } + } +} diff --git a/lib/Model/OrganizationFolder.php b/lib/Model/OrganizationFolder.php index 1c66d14..bf06ef8 100644 --- a/lib/Model/OrganizationFolder.php +++ b/lib/Model/OrganizationFolder.php @@ -27,6 +27,14 @@ class OrganizationFolder implements JsonSerializable, TableSerializable { return $this->quota; } + public function getOrganizationProvider(): string { + return $this->organizationProvider; + } + + public function getOrganizationId(): int { + return $this->organizationId; + } + public function jsonSerialize(): array { return [ 'id' => $this->id,