-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #230 from cnovak/drush_create_role
Drush command to create Apigee Edge role
- Loading branch information
Showing
21 changed files
with
1,888 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
description: 'Create Apigee role for Drupal' | ||
help: 'Create a custom Apigee role that limits permissions for Drupal connections to the Apigee API. ' | ||
arguments: | ||
org: 'The Apigee Edge org to create the role in' | ||
email: 'An Apigee user email address with orgadmin role for this org' | ||
options: | ||
password: 'Password for the Apigee orgadmin user (if not passed in you will be prompted)' | ||
base-url: 'Base URL to use, defaults to public cloud URL https://api.enterprise.apigee.com/v1' | ||
role-name: 'The role to create in the Apigee Edge org, defaults to "drupalportal"' | ||
force: 'Force running of permissions on a role that already exists. Note that permissions are only added, any current permissions not not removed.' | ||
questions: | ||
password: 'Enter password for Apigee orgadmin user' | ||
messages: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
services: | ||
apigee_edge.commands: | ||
class: \Drupal\apigee_edge\Commands\ApigeeEdgeCommands | ||
arguments: ['@apigee_edge.cli'] | ||
arguments: ['@apigee_edge.cli', '@apigee_edge.apigee_edge_mgmt_cli_service'] | ||
tags: | ||
- { name: drush.command } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2019 Google Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License version 2 as published by the | ||
* Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., 51 | ||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
namespace Drupal\apigee_edge\Command; | ||
|
||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* Developer synchronization command class for Drupal Console. | ||
* | ||
* @Drupal\Console\Annotations\DrupalCommand ( | ||
* extension="apigee_edge", | ||
* extensionType="module" | ||
* ) | ||
*/ | ||
class CreateEdgeRoleCommand extends CommandBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function configure() { | ||
$this | ||
->setName('apigee_edge:role:create') | ||
->setDescription($this->trans('commands.apigee_edge.role.create.description')) | ||
->setHelp('commands.apigee_edge.role.create.help') | ||
->addArgument( | ||
'org', | ||
InputArgument::REQUIRED, | ||
$this->trans('commands.apigee_edge.role.create.arguments.org') | ||
) | ||
->addArgument( | ||
'email', | ||
InputArgument::REQUIRED, | ||
$this->trans('commands.apigee_edge.role.create.arguments.email') | ||
) | ||
->addOption( | ||
'password', | ||
'p', | ||
InputArgument::OPTIONAL, | ||
$this->trans('commands.apigee_edge.role.create.options.password') | ||
) | ||
->addOption( | ||
'base-url', | ||
'b', | ||
InputArgument::OPTIONAL, | ||
$this->trans('commands.apigee_edge.role.create.options.base-url') | ||
) | ||
->addOption( | ||
'role-name', | ||
'r', | ||
InputArgument::OPTIONAL, | ||
$this->trans('commands.apigee_edge.role.create.options.role-name') | ||
)->addOption( | ||
'force', | ||
'f', | ||
InputOption::VALUE_NONE, | ||
$this->trans('commands.apigee_edge.role.create.options.force') | ||
); | ||
|
||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function interact(InputInterface $input, OutputInterface $output) { | ||
$this->setupIo($input, $output); | ||
$password = $input->getOption('password'); | ||
if (!$password) { | ||
$password = $this->getIo()->askHidden( | ||
$this->trans('commands.apigee_edge.role.create.questions.password') | ||
); | ||
$input->setOption('password', $password); | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function execute(InputInterface $input, OutputInterface $output) { | ||
$this->setupIo($input, $output); | ||
$org = $input->getArgument('org'); | ||
$email = $input->getArgument('email'); | ||
$password = $input->getOption('password'); | ||
$base_url = $input->getOption('base-url'); | ||
$role_name = $input->getOption('role-name'); | ||
$force = $input->getOption('force'); | ||
|
||
$this->cliService->createEdgeRoleForDrupal($this->getIo(), 't', $org, $email, $password, $base_url, $role_name, $force); | ||
} | ||
|
||
} |
Oops, something went wrong.