Kaydet (Commit) 07c7e12a authored tarafından mertcelen's avatar mertcelen

ApiDOC re-enabled.

Api Docs Added (WIP)
üst 0858061d
......@@ -23,7 +23,12 @@ jobs:
repository: mertcelen/liman-sandbox-python
path: package/liman/sandbox/python
token: ${{ secrets.CI_TOKEN }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Getting Liman' WebSSH
uses: actions/checkout@v2
with:
......@@ -41,6 +46,22 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Create Docs
run: |
sudo apt install npm -y
cd package/liman/server/
npm install
npm run docs
- name: Push Docs to APIDOCS Repository
uses: cpina/github-action-push-to-another-repository@master
env:
API_TOKEN_GITHUB: ${{ secrets.CI_TOKEN }}
with:
source-directory: 'package/liman/server/storage/docs'
destination-github-username: 'limanmys'
destination-repository-name: 'apidocs'
user-email: mcelen94@gmail.com
- name: Set up Liman Environment
uses: shivammathur/setup-php@v2
with:
......
{
"name": "Liman MYS",
"version": "1.0.0",
"description": "Liman MYS Api Documentation",
"title": "Liman",
"url" : "https://liman.dev"
}
\ No newline at end of file
......@@ -9,6 +9,17 @@ use App\Http\Controllers\Controller;
class MainController extends Controller
{
/**
* @api {post} /sunucu/sertifikaOnayi Add SSL Sertificate
* @apiName Add SSL Sertificate
* @apiGroup Certificate
*
* @apiParam {String} server_hostname Server's hostname.
* @apiParam {String} origin Target port to retrieve certificate.
* @apiParam {String} notification_id Request Notification Id (OPTIONAL)
*
* @apiSuccess {JSON} message Message with status.
*/
public function verifyCert()
{
// Check If Certificate Already Added or not.
......@@ -40,6 +51,15 @@ class MainController extends Controller
return respond("Sertifika Başarıyla Eklendi!", 200);
}
/**
* @api {post} /sunucu/sertifikaSil Remove SSL Sertificate
* @apiName Remove SSL Sertificate
* @apiGroup Certificate
*
* @apiParam {String} certificate_id Certificate Id.
*
* @apiSuccess {JSON} message Message with status.
*/
public function removeCert()
{
$certificate = Certificate::where(
......@@ -57,6 +77,16 @@ class MainController extends Controller
return respond("Sertifika Başarıyla Silindi!", 200);
}
/**
* @api {post} /sunucu/sertifikaTalep Request SSL Sertificate
* @apiName Request SSL Sertificate
* @apiGroup Certificate
*
* @apiParam {String} hostname Target Server' Hostname.
* @apiParam {String} port Target Server' Port.
*
* @apiSuccess {Array} array Requested certificate information..
*/
public function requestCert()
{
list($flag, $message) = retrieveCertificate(
......@@ -70,6 +100,15 @@ class MainController extends Controller
}
}
/**
* @api {post} /sunucu/sertifikaGuncelle Renew SSL Sertificate
* @apiName Renew SSL Sertificate
* @apiGroup Certificate
*
* @apiParam {String} certificate_id Certificate id to renew.
*
* @apiSuccess {JSON} message Message with status.
*/
public function updateCert()
{
$certificate = Certificate::where(
......
......@@ -4,6 +4,9 @@ namespace App\Http\Controllers;
use App\Models\LimanRequest;
use App\Models\Server;
use App\Models\User;
use App\Models\UserSettings;
use App\Models\Extension;
use App\Models\Widget;
class HomeController extends Controller
......@@ -19,10 +22,17 @@ class HomeController extends Controller
}
/**
* Show the application dashboard.
* @api {get} / Homepage
* @apiName HomePage
* @apiDescription Liman' database stats.
* @apiGroup General
*
* @return \Illuminate\Http\Response
* @apiSuccess {Integer} server_count Count of the servers in Liman.
* @apiSuccess {Integer} extension_count Count of the extensions in Liman.
* @apiSuccess {Integer} user_count Count of the users in Liman.
* @apiSuccess {Integer} settings_count Count of the settings in Liman.
*/
public function index()
{
system_log(7, "HOMEPAGE");
......@@ -35,12 +45,26 @@ class HomeController extends Controller
$widget->server_id
)->first()->name;
}
return view('index', [
return magicView('index', [
"widgets" => $widgets,
"server_count" => Server::all()->count(),
"extension_count" => Extension::all()->count(),
"user_count" => User::all()->count(),
"settings_count" => UserSettings::all()->count(),
]);
}
/**
* @api {post} / Liman Stats
* @apiName Liman Stats
* @apiDescription Hardware stats of Liman.
* @apiGroup General
*
* @apiSuccess {String} cpu CPU Usage of Liman.
* @apiSuccess {String} ram Ram Usage of Liman.
* @apiSuccess {String} disk Disk Usage of Liman.
* @apiSuccess {String} network Network Usage of Liman.
*/
public function getLimanStats()
{
$cpuUsage = shell_exec(
......@@ -123,6 +147,13 @@ class HomeController extends Controller
return view('permission.request');
}
/**
* @api {get} /taleplerim Personal Liman Requests List
* @apiName Personal Liman Requests List
* @apiGroup General
*
* @apiSuccess {Array} requests Array of request objects.
*/
public function all()
{
$requests = LimanRequest::where('user_id', auth()->id())->get();
......@@ -145,11 +176,21 @@ class HomeController extends Controller
break;
}
}
return view('permission.all', [
return magicView('permission.all', [
"requests" => $requests,
]);
}
/**
* @api {post} /talep Send Personal Liman Request
* @apiName Send Personal Liman Request
* @apiGroup General
*
* @apiParam {String} note Note of the request
* @apiParam {String} type server,extension,other
* @apiParam {String} speed normal,urgent
*
*/
public function request()
{
LimanRequest::create([
......
......@@ -12,6 +12,14 @@ use Illuminate\Contracts\Bus\Dispatcher;
class MarketController extends Controller
{
/**
* @api {post} /market/kontrol Check Market Access
* @apiName Check Market Access
* @apiGroup Updates
*
* @apiSuccess {JSON} message Status of the connection.
*
*/
public function verifyMarketConnection()
{
if (!env('MARKET_ACCESS_TOKEN')) {
......@@ -40,6 +48,14 @@ class MarketController extends Controller
);
}
/**
* @api {post} /market/guncellemeKontrol Check Liman Updates
* @apiName Check Liman Updates
* @apiGroup Updates
*
* @apiSuccess {Array} array all components of the liman with update statuses.
*
*/
public function checkMarketUpdates($returnRaw = false)
{
$client = self::getClient();
......
......@@ -23,6 +23,16 @@ class UserController extends Controller
]);
}
/**
* @api {post} /kullanici/ekle Add Liman User
* @apiName Add Liman User
* @apiGroup Users
*
* @apiParam {String} name User name
* @apiParam {String} email User Email
*
* @apiSuccess {JSON} message Message with randomly created user password.
*/
public function add()
{
hook('user_add_attempt', [
......@@ -87,6 +97,15 @@ class UserController extends Controller
);
}
/**
* @api {post} /kullanici/sil Remove Liman User
* @apiName Remove Liman User
* @apiGroup Users
*
* @apiParam {String} user_id User's ID
*
* @apiSuccess {JSON} message
*/
public function remove()
{
hook('user_delete_attempt', [
......@@ -110,6 +129,15 @@ class UserController extends Controller
return respond("Kullanıcı Başarıyla Silindi!", 200);
}
/**
* @api {post} /kullanici/parola/sifirla Reset Liman User' Password
* @apiName Reset Liman User' Password
* @apiGroup Users
*
* @apiParam {String} user_id User's ID
*
* @apiSuccess {JSON} message Message with new random password.
*/
public function passwordReset()
{
hook('user_password_reset_attempt', [
......@@ -148,6 +176,17 @@ class UserController extends Controller
return respond("Yeni Parola : " . $password, 200);
}
/**
* @api {post} /profil Update Self Password
* @apiName Update Self Password
* @apiGroup Users
*
* @apiParam {String} old_password User' old password
* @apiParam {String} password New Password
* @apiParam {String} password_confirmation New Password Confirmation
*
* @apiSuccess {JSON} message Message with status.
*/
public function selfUpdate()
{
if (user()->auth_type == "ldap") {
......@@ -209,6 +248,17 @@ class UserController extends Controller
return respond('Kullanıcı Başarıyla Güncellendi', 200);
}
/**
* @api {post} /user/update Update User Data
* @apiName Update User Data
* @apiGroup Users
*
* @apiParam {String} username User' new username
* @apiParam {String} email User' new email
* @apiParam {String} status User' new status, 0 for regular, 1 for administrator.
*
* @apiSuccess {JSON} message Message with status.
*/
public function adminUpdate()
{
$validations = [
......@@ -244,6 +294,15 @@ class UserController extends Controller
return respond('Kullanıcı Güncellendi.', 200);
}
/**
* @api {post} /user/setting/delete Delete Vault Key
* @apiName Delete Vault Key
* @apiGroup Vault
*
* @apiParam {String} setting_id Target setting to delete.
*
* @apiSuccess {JSON} message Message with status.
*/
public function removeSetting()
{
$first = UserSettings::where([
......@@ -280,6 +339,16 @@ class UserController extends Controller
}
}
/**
* @api {post} /user/setting/update Update Vault Key
* @apiName Update Vault Key
* @apiGroup Vault
*
* @apiParam {String} setting_id Target setting to update.
* @apiParam {String} new_value New Value of the setting.
*
* @apiSuccess {JSON} message Message with status.
*/
public function updateSetting()
{
$setting = UserSettings::where("id", request("setting_id"))->first();
......@@ -372,6 +441,14 @@ class UserController extends Controller
);
}
/**
* @api {get} /kasa Get Vault Keys
* @apiName Get Vault Keys
* @apiGroup Vault
*
* @apiSuccess {Array} settings User's Settings/Keys
* @apiSuccess {Array} servers User's granted servers list.
*/
public function userKeyList()
{
$settings = UserSettings::where("user_id", user()->id)->get();
......@@ -398,6 +475,16 @@ class UserController extends Controller
]);
}
/**
* @api {post} /kasa/ekle Add Key
* @apiName Add Key
* @apiGroup Vault
*
* @apiParam {String} username Key Username.
* @apiParam {String} password New Password.
*
* @apiSuccess {JSON} message Message with status.
*/
public function addKey()
{
UserSettings::where([
......@@ -449,11 +536,31 @@ class UserController extends Controller
return respond("Önbellek temizlendi.");
}
/**
* @api {get} /profil/anahtarlarim User' Access Tokens
* @apiName User' Access Tokens
* @apiGroup Access Tokens
*
* @apiSuccess {Array} access_tokens User's access tokens.
*/
public function myAccessTokens()
{
return view("user.keys");
return magicView('user.keys', [
"access_tokens" => user()
->accessTokens()
->get(),
]);
}
/**
* @api {post} /profil/anahtarlarim/ekle Create Access Tokens
* @apiName Create Access Tokens
* @apiGroup Access Tokens
*
* @apiParam {String} name Name of the access token.
*
* @apiSuccess {JSON} message Message with status.
*/
public function createAccessToken()
{
$token = Str::random(64);
......@@ -465,6 +572,15 @@ class UserController extends Controller
return respond("Anahtar Başarıyla Oluşturuldu.");
}
/**
* @api {post} /profil/anahtarlarim/sil Delete Access Tokens
* @apiName Delete Access Tokens
* @apiGroup Access Tokens
*
* @apiParam {String} token_id ID of the token.
*
* @apiSuccess {JSON} message Message with status.
*/
public function revokeAccessToken()
{
$token = AccessToken::find(request("token_id"));
......
......@@ -521,7 +521,7 @@ if (!function_exists('magicView')) {
*/
function magicView($view, $data = [])
{
if (request()->wantsJson()) {
if (request()->wantsJson() && !request()->has('partialRequest')) {
return response()->json($data);
} else {
return response()->view($view, $data);
......
This diff is collapsed.
......@@ -9,7 +9,8 @@
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"docs": "node_modules/apidoc/bin/apidoc -o storage/docs -e vendor -e node_modules -e resources/ -e public/"
},
"pre-commit": [
"pre-commit"
......@@ -29,6 +30,7 @@
"webpack-cli": "^3.3.7"
},
"dependencies": {
"apidoc": "^0.23.0",
"cross-env": "^5.2.1",
"laravel-echo": "^1.6.1",
"pusher-js": "^5.0.2"
......
......@@ -8,7 +8,7 @@
<span class="info-box-icon bg-info"><i class="fas fa-users"></i></span>
<div class="info-box-content">
<span class="info-box-text">{{__("Limandaki Sunucu Sayısı")}}</span>
<span class="info-box-number">{{\App\Models\Server::all()->count()}}</span>
<span class="info-box-number">{{$server_count}}</span>
</div>
</div>
</div>
......@@ -17,7 +17,7 @@
<span class="info-box-icon bg-info"><i class="fas fa-plus"></i></span>
<div class="info-box-content">
<span class="info-box-text">{{__("Limandaki Eklenti Sayısı")}}</span>
<span class="info-box-number">{{\App\Models\Extension::all()->count()}}</span>
<span class="info-box-number">{{$extension_count}}</span>
</div>
</div>
</div>
......@@ -26,7 +26,7 @@
<span class="info-box-icon bg-info"><i class="fas fa-user"></i></span>
<div class="info-box-content">
<span class="info-box-text">{{__("Limandaki Kullanıcı Sayısı")}}</span>
<span class="info-box-number">{{\App\Models\User::all()->count()}}</span>
<span class="info-box-number">{{$user_count}}</span>
</div>
</div>
</div>
......@@ -35,7 +35,7 @@
<span class="info-box-icon bg-info"><i class="fas fa-cog"></i></span>
<div class="info-box-content">
<span class="info-box-text">{{__("Limandaki Ayar Sayısı")}}</span>
<span class="info-box-number">{{\App\Models\UserSettings::all()->count()}}</span>
<span class="info-box-number">{{$settings_count}}</span>
</div>
</div>
</div>
......
......@@ -27,7 +27,7 @@
"text" => "Oluştur"
])<br><br>
@include('table',[
"value" => user()->accessTokens()->get(),
"value" => $access_tokens,
"title" => [
"Adı", "Token", "Son Kullanılan Tarih", "Son Kullanan Ip Adresi", "*hidden*"
],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment