Skip to content

Commit

Permalink
Added a dev-Api Bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
arnulfojr committed Apr 18, 2016
1 parent ce90b23 commit 5ecbb06
Show file tree
Hide file tree
Showing 31 changed files with 2,822 additions and 56 deletions.
14 changes: 8 additions & 6 deletions QCharts/ApiBundle/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;


/**
* Class ApiController
* @package QCharts\ApiBundle\Controller
*/
class ApiController extends Controller
{
/* Key constants from the user's roles in configuration */
Expand Down Expand Up @@ -59,7 +61,7 @@ public static function checkCredentials($authService, array $roles, $role, $allo
}

/**
* @ApiDoc(
* ApiDoc(
* description = "Save a query request",
* parameters = {
* {
Expand Down Expand Up @@ -214,7 +216,7 @@ public function registerAction(Request $request)

/**
*
* @ApiDoc(
* ApiDoc(
* description = "Edit the given query",
* parameters = {
* {
Expand Down Expand Up @@ -407,7 +409,7 @@ public function editAction(Request $request, $queryId = null)

/**
*
* @ApiDoc(
* ApiDoc(
* description = "Deletes the passed Query",
* parameters = {
* {
Expand Down Expand Up @@ -475,7 +477,7 @@ public function deleteAction(Request $request, $queryId = null)

/**
*
* @ApiDoc(
* ApiDoc(
* description = "Get Action, returns the information of the requested query",
* parameters = {
* {
Expand Down
21 changes: 9 additions & 12 deletions QCharts/ApiBundle/Controller/ApiDirectoryController.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
<?php
/**
* Created by PhpStorm.
* User: tsp-admin
* Date: 1/26/16
* Time: 11:29 AM
*/

namespace QCharts\ApiBundle\Controller;

Expand All @@ -22,14 +16,17 @@
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Component\HttpFoundation\Response;

/**
* Class ApiDirectoryController
* @package QCharts\ApiBundle\Controller
*/
class ApiDirectoryController extends Controller
{

/**
* @ApiDoc(
* ApiDoc(
* description = "Registers a directory at the given directory",
* parameters = {
* {
Expand Down Expand Up @@ -102,7 +99,7 @@ public function registerAction(Request $request)

/**
*
* @ApiDoc(
* ApiDoc(
* description = "",
* parameters = {
* {
Expand Down Expand Up @@ -178,7 +175,7 @@ public function deleteAction(Request $request)
}

/**
* @ApiDoc(
* ApiDoc(
* description = "Edit the desired Directory",
* parameters = {
* {
Expand Down Expand Up @@ -278,7 +275,7 @@ public function editAction(Request $request)
}

/**
* @ApiDoc(
* ApiDoc(
* description="Returns the directories in the given directory",
* parameters = {
* {
Expand Down Expand Up @@ -340,7 +337,7 @@ public function getAction(Request $request)
}

/**
* @ApiDoc(
* ApiDoc(
* description = "Returns the Queries in the requested directory",
* parameters = {
* {
Expand Down
18 changes: 10 additions & 8 deletions QCharts/ApiBundle/Controller/DatabaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@
use QCharts\CoreBundle\Exception\NoTableNamesException;
use QCharts\CoreBundle\Exception\NotFoundException;
use QCharts\CoreBundle\Exception\NotPlotableException;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use QCharts\CoreBundle\Exception\SnapshotException;
use QCharts\CoreBundle\Exception\TypeNotValidException;
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use QCharts\CoreBundle\Entity\QueryRequest;


/**
* Class DatabaseController
* @package QCharts\ApiBundle\Controller
*/
class DatabaseController extends Controller
{
/**
* @ApiDoc(
* ApiDoc(
* description="chartData Action, returns the data formatted for the chart",
* parameters = {
* {
Expand Down Expand Up @@ -182,7 +184,7 @@ public function chartDataAction(Request $request)

/**
*
* @ApiDoc(
* ApiDoc(
* description = "Returns the information of the requested table from the database",
* parameters = {
* {
Expand Down Expand Up @@ -261,7 +263,7 @@ public function tableInformationAction(Request $request)

/**
*
* @ApiDoc(
* ApiDoc(
* description = "Returns the schema tables",
* parameters = {
* {
Expand Down Expand Up @@ -334,7 +336,7 @@ public function tablesAction(Request $request)

/**
*
* @ApiDoc(
* ApiDoc(
* description = "Returns the name of the schemas found in the given connection",
* parameters = {
* {
Expand Down Expand Up @@ -399,7 +401,7 @@ public function schemasAction(Request $request)

/**
*
* @ApiDoc(
* ApiDoc(
* description = "Returns the names of the current supported connections",
* statusCodes = {
* 200 = "Success, connections returned",
Expand Down Expand Up @@ -446,7 +448,7 @@ public function connectionsAction()
}

/**
* @ApiDoc(
* ApiDoc(
* description="Run Action, returns the results directly from database",
* parameters={
* {
Expand Down
11 changes: 7 additions & 4 deletions QCharts/ApiBundle/Controller/FavoriteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
use QCharts\CoreBundle\Exception\OverlappingException;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Component\HttpFoundation\Request;

/**
* Class FavoriteController
* @package QCharts\ApiBundle\Controller
*/
class FavoriteController extends Controller
{

/**
* @ApiDoc(
* ApiDoc(
* description="Returns the favorite Query from the current user",
* statusCodes = {
* 200 = "Returns the favorites from the current user"
Expand Down Expand Up @@ -61,7 +64,7 @@ public function getFavoritesAction()

/**
*
* @ApiDoc(
* ApiDoc(
* description = "Adds the given Query as a favorite of the current user",
* parameters = {
* {
Expand Down Expand Up @@ -135,7 +138,7 @@ public function registerFavoriteAction(Request $request)
}

/**
* @ApiDoc(
* ApiDoc(
* description = "Removes the given query request from the favorites list of the user",
* parameters = {
* {
Expand Down
12 changes: 7 additions & 5 deletions QCharts/ApiBundle/Controller/SnapshotController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;

/**
* Class SnapshotController
* @package QCharts\ApiBundle\Controller
*/
class SnapshotController extends Controller
{
/**
*
* @ApiDoc(
* ApiDoc(
* description = "Returns the list of snapshots from the queried Query",
* parameters = {
* {
Expand Down Expand Up @@ -103,7 +105,7 @@ public function snapshotListAction(Request $request)

/**
*
* @ApiDoc(
* ApiDoc(
* description = "Download snapshot file",
* parameters = {
* {
Expand Down Expand Up @@ -186,7 +188,7 @@ public function downLoadSnapshotAction(Request $request)
}

/**
* @ApiDoc(
* ApiDoc(
* description = "Deletes the requested snapshot file",
* parameters = {
* {
Expand Down
7 changes: 5 additions & 2 deletions QCharts/ApiBundle/Controller/UrlController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
use QCharts\ApiBundle\Exception\InvalidCredentialsException;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;

/**
* Class UrlController
* @package QCharts\ApiBundle\Controller
*/
class UrlController extends Controller
{
/**
* @ApiDoc(
* ApiDoc(
* description = "returns the URLs for Tables and Users"
* )
* @return JsonResponse
Expand Down
17 changes: 7 additions & 10 deletions QCharts/ApiBundle/Controller/UserController.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
<?php
/**
* Created by PhpStorm.
* User: tsp-admin
* Date: 2/18/16
* Time: 3:19 PM
*/

namespace QCharts\ApiBundle\Controller;

Expand All @@ -15,12 +9,15 @@
use Symfony\Component\HttpFoundation\Response;
use QCharts\CoreBundle\Exception\InstanceNotFoundException;
use QCharts\CoreBundle\Exception\UserRoleException;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;

/**
* Class UserController
* @package QCharts\ApiBundle\Controller
*/
class UserController extends Controller
{
/**
* @ApiDoc(
* ApiDoc(
* description = "Returns the users and the information",
* parameters = {
* {
Expand Down Expand Up @@ -79,7 +76,7 @@ public function getUsersAction(Request $request)
}

/**
* @ApiDoc(
* ApiDoc(
* description = "Promotes the given User with username",
* parameters = {
* {
Expand Down Expand Up @@ -142,7 +139,7 @@ public function promoteAction(Request $request)

/**
*
* @ApiDoc(
* ApiDoc(
* description = "Demotes the given User with username",
* parameters = {
* {
Expand Down
9 changes: 8 additions & 1 deletion QCharts/ApiBundle/Exception/ExceptionMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@

namespace QCharts\ApiBundle\Exception;


/**
* Class ExceptionMessage
* @package QCharts\ApiBundle\Exception
*/
class ExceptionMessage
{
/**
* @param $role
* @return string
*/
static public function CREDENTIALS_NOT_VALID($role)
{
return "The given credentials were not valid, the role '{$role}' is needed";
Expand Down
4 changes: 4 additions & 0 deletions QCharts/ApiBundle/Exception/InvalidCredentialsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

namespace QCharts\ApiBundle\Exception;

/**
* Class InvalidCredentialsException
* @package QCharts\ApiBundle\Exception
*/
class InvalidCredentialsException extends \Exception
{
/**
Expand Down
6 changes: 4 additions & 2 deletions QCharts/ApiBundle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ QCharts
ApiBundle Documentation
=======================

+ QCharts offers the ApiDocumentation in the route ```/api/doc```
- ApiDoc Bundle integrated in the dev environment.
+ QCharts offers the Api Documentation in the route ```/api/doc``` under
the ```DevApiBundle```.
- ApiDoc Bundle integrated in the dev environment recommended.
- If using the ApiDoc Bundle use the ```DevApiBundle``` instead.

+ ApiBundle Routing, defined in ```ApiBundle/Resources/config/routing.yml``` and
Actions are found in Controllers found in the ```QCharts/ApiBundle/Controller``` namespace:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
<?php
/**
* Created by PhpStorm.
* User: tsp-admin
* Date: 1/4/16
* Time: 12:52 PM
*/

namespace QCharts\CoreBundle\EventSubscriber;

Expand All @@ -13,6 +7,10 @@
use FOS\UserBundle\FOSUserEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
* Class UserRegistrationSubscriber
* @package QCharts\CoreBundle\EventSubscriber
*/
class UserRegistrationSubscriber implements EventSubscriberInterface
{

Expand Down
Loading

0 comments on commit 5ecbb06

Please sign in to comment.