-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
68 changed files
with
1,317 additions
and
121 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[ssh_connection] | ||
ssh_args= |
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,2 @@ | ||
--- | ||
platform_api_version: "develop" |
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,6 @@ | ||
$ANSIBLE_VAULT;1.1;AES256 | ||
61346232653030613664363330616361363164306434323730613839306139356437383534343532 | ||
3036343331636266656663663036303966336536303430390a356438333330373862646161656665 | ||
39653537303438396538343338346634303434376139363763333435616330626630623137303131 | ||
3133376663353437660a396432633965323736373131633137306666336130366661393430393737 | ||
6639 |
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,25 @@ | ||
$ANSIBLE_VAULT;1.1;AES256 | ||
62663066333665383661343433303033623239613936306361336134666566613136326535363532 | ||
6637393865376636663233666432386338343837363035620a633332343536363531316339613464 | ||
38366132313537343033656662373030316135613934316236616231633638666266626335613866 | ||
3365633335616361650a646637656139623531653939383537323666346238393136613737393133 | ||
36656661316337393739346236313865313637613135316165616137666235653865636539393163 | ||
62353031353638616533303664663238313135346164613537393733616465313435393866616535 | ||
33363335666438613461326364656265333730363163393937626562336266383064393236636231 | ||
35303534333332306539386438373236623535396639373361366661313761393533303735313933 | ||
32393561393637633664383632373930353962646661663439323839646536613433313933373064 | ||
62313462316561646362323032336164303434613637303232613864386163633632313666356266 | ||
31613034343838623832363662623331326461366538613231633738623134366335633765313861 | ||
34363931633965626265656365343561623361623834353232366132316530313035303161353139 | ||
65653864333165643661646261376536303534666266303535363135623932643364386638316665 | ||
66396531316337303066353233386238396461386534643738326131306536623330356262326236 | ||
30376233316463303265643532633663653630376565373066343065656332643934326232623766 | ||
36343866373464653934353661313839366366366438303364666631626234653362626635623165 | ||
35616163663562643034313564376435633335303165333962613832656434306533393133623964 | ||
65633064656661326637643265303465656561323739383730383864353738366331363832373432 | ||
61383831343261303331333163363762306239376632386532376331336239353237613639663536 | ||
61353633333438623438393064356431613934366532346634663531333865393938383062303566 | ||
64303730646138643164386566306337313030343031396562346331303835373034616131373663 | ||
64616564616133323463336266363337636532303036663763303861356137343466303339613733 | ||
32656363643033396133323963336663633437653034623664306535366266313730656536643264 | ||
62383235656266653037 |
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,6 @@ | ||
--- | ||
- name: deploy platform-api code | ||
hosts: platform | ||
|
||
roles: | ||
- platform-api-code |
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,3 @@ | ||
- src: git+https://github.com/ushahidi/ansible-platform-api-code.git | ||
version: master | ||
name: platform-api-code |
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,77 @@ | ||
<?php defined('SYSPATH') OR die('No direct access allowed.'); | ||
|
||
/** | ||
* Ushahidi API Migration Controller | ||
* | ||
* @author Ushahidi Team <[email protected]> | ||
* @package Ushahidi\Application\Controllers | ||
* @copyright 2013 Ushahidi | ||
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3) | ||
*/ | ||
|
||
class Controller_Api_Migration extends Ushahidi_Rest { | ||
|
||
protected $_action_map = array | ||
( | ||
Http_Request::GET => 'get', | ||
Http_Request::POST => 'post', | ||
Http_Request::OPTIONS => 'options' | ||
); | ||
|
||
protected function _scope() | ||
{ | ||
return 'migrate'; | ||
} | ||
|
||
public function action_get_index_collection($command = 'status') | ||
{ | ||
|
||
$user = service('session.user'); | ||
|
||
if ('admin' != $user->role) { | ||
throw new HTTP_Exception_403('Must be an admin to access this service'); | ||
} | ||
|
||
$commands = [ | ||
'status' => 'getStatus', | ||
'rollback' => 'getRollback', | ||
]; | ||
|
||
// add return status if invalid command is selected | ||
|
||
if (!array_key_exists($command, $commands)) { | ||
$command = 'status'; | ||
} | ||
|
||
$db = service('db.config'); | ||
$phinx_config = ['configuration' => realpath(APPPATH . '../application/phinx.php'), | ||
'parser' => 'php', | ||
]; | ||
|
||
$phinx_app = new Phinx\Console\PhinxApplication(); | ||
|
||
$phinx_wrapper = new Phinx\Wrapper\TextWrapper($phinx_app, $phinx_config); | ||
|
||
$migration_results = call_user_func([$phinx_wrapper, $commands[$command]], 'ushahidi', null); | ||
$error = $phinx_wrapper->getExitCode() > 0; | ||
|
||
$this->_response_payload = [ | ||
'results' => explode("\n", $migration_results, -1), | ||
]; | ||
} | ||
|
||
public function action_post_migrate_collection() | ||
{ | ||
$this->action_get_index_collection('migrate'); | ||
} | ||
|
||
public function action_post_rollback_collection() | ||
{ | ||
$this->action_get_index_collection('rollback'); | ||
} | ||
|
||
public function action_get_status_collection() | ||
{ | ||
$this->action_get_index_collection('status'); | ||
} | ||
} |
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,53 @@ | ||
<?php defined('SYSPATH') OR die('No direct access allowed.'); | ||
|
||
/** | ||
* Ushahidi API Posts Exports Controller | ||
* | ||
* @author Ushahidi Team <[email protected]> | ||
* @package Ushahidi\Application\Controllers | ||
* @copyright 2013 Ushahidi | ||
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3) | ||
*/ | ||
|
||
class Controller_Api_Posts_Export extends Ushahidi_Rest | ||
{ | ||
protected $_action_map = array | ||
( | ||
Http_Request::GET => 'get', | ||
Http_Request::OPTIONS => 'options', | ||
); | ||
|
||
protected function _scope() | ||
{ | ||
return 'posts'; | ||
} | ||
|
||
protected function _resource() | ||
{ | ||
return 'posts_export'; | ||
} | ||
|
||
public function action_get_index_collection() | ||
{ | ||
// Get usecase with default formatter | ||
$this->_usecase = service('factory.usecase') | ||
->get($this->_resource(), 'export') | ||
->setFilters($this->_filters()); | ||
|
||
// ...or use a different one if requested | ||
$format = strtolower($this->request->query('format')); | ||
|
||
if ($format) { | ||
$this->_usecase->setFormatter(service("formatter.entity.post.$format")); | ||
} | ||
} | ||
|
||
public function action_get_index() | ||
{ | ||
throw HTTP_Exception::factory(405, 'The :method method is not supported. Supported methods are :allowed_methods', array( | ||
':method' => $this->request->method(), | ||
':allowed_methods' => implode(', ', array_keys($this->_action_map)), | ||
)) | ||
->allowed(array_keys($this->_action_map)); | ||
} | ||
} |
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,50 @@ | ||
<?php defined('SYSPATH') OR die('No direct access allowed.'); | ||
|
||
/** | ||
* Ushahidi API Migration Controller | ||
* | ||
* @author Ushahidi Team <[email protected]> | ||
* @package Ushahidi\Application\Controllers | ||
* @copyright 2013 Ushahidi | ||
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3) | ||
*/ | ||
|
||
class Controller_Migrate extends Ushahidi_Rest { | ||
|
||
protected $_action_map = array | ||
( | ||
Http_Request::GET => 'get', | ||
Http_Request::OPTIONS => 'options' | ||
); | ||
|
||
protected function _scope() | ||
{ | ||
return 'migrate'; | ||
} | ||
|
||
protected function _is_auth_required() | ||
{ | ||
return FALSE; | ||
} | ||
|
||
public function action_get_index_collection() | ||
{ | ||
|
||
$db = service('db.config'); | ||
$phinx_config = ['configuration' => realpath(APPPATH . '../application/phinx.php'), | ||
'parser' => 'php', | ||
]; | ||
|
||
$phinx_app = new Phinx\Console\PhinxApplication(); | ||
|
||
$phinx_wrapper = new Phinx\Wrapper\TextWrapper($phinx_app, $phinx_config); | ||
|
||
$migration_results = call_user_func([$phinx_wrapper, 'getMigrate'], 'ushahidi', null); | ||
$error = $phinx_wrapper->getExitCode() > 0; | ||
|
||
$this->_response_payload = [ | ||
'results' => explode("\n", $migration_results, -1), | ||
]; | ||
} | ||
|
||
} |
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
Oops, something went wrong.