Skip to content
This repository has been archived by the owner on Dec 20, 2020. It is now read-only.

Commit

Permalink
Added REST API endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
pcbaldwin committed Sep 27, 2018
1 parent 04919fa commit 764d0e8
Show file tree
Hide file tree
Showing 2 changed files with 172 additions and 0 deletions.
89 changes: 89 additions & 0 deletions api/certificates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

/**
* Let's Encrypt certificates API controller.
*
* @category apps
* @package lets-encrypt
* @subpackage rest-api
* @author eGloo <developer@egloo.ca>
* @copyright 2018 Marc Laporte
* @license http://www.gnu.org/copyleft/lgpl.html GNU Lesser General Public License version 3 or later
* @link https://github.com/WikiSuite/app-lets-encrypt
*/

///////////////////////////////////////////////////////////////////////////////
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////
// B O O T S T R A P
///////////////////////////////////////////////////////////////////////////////

$bootstrap = getenv('CLEAROS_BOOTSTRAP') ? getenv('CLEAROS_BOOTSTRAP') : '/usr/clearos/framework/shared';
require_once $bootstrap . '/bootstrap.php';

///////////////////////////////////////////////////////////////////////////////
// D E P E N D E N C I E S
///////////////////////////////////////////////////////////////////////////////

// Classes
//--------

use \clearos\apps\lets_encrypt\Certificates_Class as Certificates_Class;

clearos_load_library('lets_encrypt/Certificates_Class');

///////////////////////////////////////////////////////////////////////////////
// C L A S S
///////////////////////////////////////////////////////////////////////////////

/**
* Let's Encrypt certificates API controller.
*
* @category apps
* @package lets-encrypt
* @subpackage rest-api
* @author eGloo <developer@egloo.ca>
* @copyright 2018 Marc Laporte
* @license http://www.gnu.org/copyleft/lgpl.html GNU Lesser General Public License version 3 or later
* @link https://github.com/WikiSuite/app-lets-encrypt
*/

class Certificates extends ClearOS_REST_Controller
{
/**
* Let's Encrypt overview.
*
* @return view
*/

function index_get($name = null)
{
try {
$system = new Certificates_Class();

if (is_null($name))
$data = $system->listing();
else
$data = $system->get($name);

$this->respond_success($data);
} catch (\Exception $e) {
$this->exception_handler($e);
}
}
}
83 changes: 83 additions & 0 deletions api/lets_encrypt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

/**
* Let's Encrypt API controller.
*
* @category apps
* @package lets-encrypt
* @subpackage rest-api
* @author eGloo <developer@egloo.ca>
* @copyright 2018 Marc Laporte
* @license http://www.gnu.org/copyleft/lgpl.html GNU Lesser General Public License version 3 or later
* @link https://github.com/WikiSuite/app-lets-encrypt
*/

///////////////////////////////////////////////////////////////////////////////
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////
// B O O T S T R A P
///////////////////////////////////////////////////////////////////////////////

$bootstrap = getenv('CLEAROS_BOOTSTRAP') ? getenv('CLEAROS_BOOTSTRAP') : '/usr/clearos/framework/shared';
require_once $bootstrap . '/bootstrap.php';

///////////////////////////////////////////////////////////////////////////////
// D E P E N D E N C I E S
///////////////////////////////////////////////////////////////////////////////

// Classes
//--------

use \clearos\apps\lets_encrypt\Lets_Encrypt_Class as Lets_Encrypt_Class;

clearos_load_library('lets_encrypt/Lets_Encrypt_Class');

///////////////////////////////////////////////////////////////////////////////
// C L A S S
///////////////////////////////////////////////////////////////////////////////

/**
* Let's Encrypt API controller.
*
* @category apps
* @package lets-encrypt
* @subpackage rest-api
* @author eGloo <developer@egloo.ca>
* @copyright 2018 Marc Laporte
* @license http://www.gnu.org/copyleft/lgpl.html GNU Lesser General Public License version 3 or later
* @link https://github.com/WikiSuite/app-lets-encrypt
*/

class Lets_Encrypt extends ClearOS_REST_Controller
{
/**
* Let's Encrypt overview.
*
* @return view
*/

function index_get()
{
$data['capabilities'] = [
'/api/v1/lets_encrypt' => 'General Let\'s Encrypt API',
'/api/v1/lets_encrypt/certificates' => 'Certificates API'
];

$this->respond_success($data);
}
}

0 comments on commit 764d0e8

Please sign in to comment.