diff --git a/terminus.code.api.inc b/terminus.code.api.inc index 9d6e2fa..73f5282 100644 --- a/terminus.code.api.inc +++ b/terminus.code.api.inc @@ -75,3 +75,17 @@ function terminus_api_code_upstream_update($site_uuid, $updatedb = FALSE, $overw return terminus_request($realm, $site_uuid, $path, $method, $data); } + +/** + * API Call to Enable Redis + */ +function terminus_api_site_redis_enable($site_uuid) { + $realm = 'site'; + $path = 'settings'; + $method = 'PUT'; + $data = array( + 'allow_cacheserver' => true, + ); + + return terminus_request($realm, $site_uuid, $path, $method, $data); + } diff --git a/terminus.drush.inc b/terminus.drush.inc index 9f4ed99..dccfa33 100644 --- a/terminus.drush.inc +++ b/terminus.drush.inc @@ -484,6 +484,15 @@ function terminus_drush_command() { 'bootstrap' => DRUSH_BOOTSTRAP_DRUSH, ); + $items['pantheon-site-redis-enable'] = array( + 'description' => 'Enables redis cache server for site. Requires additional configuration. See http://helpdesk.getpantheon.com/customer/portal/articles/401317-redis/', + 'arguments' => array( + 'site' => 'UUID or name of the site.', + ), + 'aliases' => array('psite-redis-enable'), + 'bootstrap' => DRUSH_BOOTSTRAP_DRUSH, + ); + $items['pantheon-site-environment-redis-clear'] = array( 'description' => 'Clear redis cache of a site environment.', 'arguments' => array( @@ -1737,6 +1746,26 @@ function terminus_notification_poll($site_uuid, $type) { } } +/** + * Enable redis validate + */ +function drush_terminus_pantheon_site_redis_enable_validate($site_uuid = FALSE) { + return terminus_validate_session_data() && terminus_validate_site_uuid_input($site_uuid); +} + +/* Enable redis */ +function drush_terminus_pantheon_site_redis_enable($site_uuid) { + $site_uuid = drush_get_option('site_uuid'); + $result = terminus_api_site_redis_enable($site_uuid); + if (drush_get_option('json')) { + drush_print($result['json']); + } + else { + $redis = json_decode($result['json']); + drush_print('Redis cacheserver enabled. Requires additional configuration. Please see http://helpdesk.getpantheon.com/customer/portal/articles/401317-redis'); + } +} + /** * Validation prior to clearing a site environment's redis cache. */