setName('organization-folders:members:create') ->setDescription('Create a new member of an organization folder') ->addOption('organization-folder-id', null, InputOption::VALUE_REQUIRED, 'Id of organization folder to create member of') ->addOption('permission-level', null, InputOption::VALUE_REQUIRED, 'Permissions level of member (valid values: MEMBER, MANAGER, ADMIN)') ->addOption('principal-type', null, InputOption::VALUE_REQUIRED, 'Type of principal (valid values: GROUP, ROLE)') ->addOption('principal-id', null, InputOption::VALUE_OPTIONAL, 'For type group: "[group_name]", for type role: "[organization_provider_id]:[role_id]"'); parent::configure(); } protected function execute(InputInterface $input, OutputInterface $output): int { $organizationFolderId = $input->getOption('organization-folder-id'); $permissionLevel = OrganizationFolderMemberPermissionLevel::fromNameOrValue($input->getOption('permission-level')); $principalType = PrincipalType::fromNameOrValue($input->getOption('principal-type')); $principalId = $input->getOption('principal-id'); try { $member = $this->organizationFolderMemberService->create( organizationFolderId: $organizationFolderId, permissionLevel: $permissionLevel, principal: new Principal($principalType, $principalId), ); $this->writeTableInOutputFormat($input, $output, [$this->formatTableSerializable($member)]); return 0; } catch (Exception $e) { $output->writeln("Exception \"{$e->getMessage()}\" at {$e->getFile()} line {$e->getLine()}"); return 1; } } }