예제 #1
0
 /**
  * ApiDoc(
  *      description = "returns the URLs for Tables and Users"
  * )
  * @return JsonResponse
  */
 public function urlsAction()
 {
     //return the URLs for using the user admin
     $roles = $this->getParameter('qcharts.user_roles');
     $authChecker = $this->get("security.authorization_checker");
     $allow_demo_users = $this->getParameter('qcharts.allow_demo_users');
     try {
         ApiController::checkCredentials($authChecker, $roles, ApiController::USER, $allow_demo_users);
         $tableInfo = $this->generateUrl('qcharts.api.table_info');
         $tablesUrl = $this->generateUrl('qcharts.api.tables');
         $connections = $this->generateUrl('qcharts.api.connection_names');
         $connectionSchemas = $this->generateUrl('qcharts.api.connection_schemas');
         //$roleUrl = $this->generateUrl('qcharts.api.user_promote');
         $roleUrl = "";
         $frontendTableInfo = $this->generateUrl('qcharts.frontend.table_information');
         $frontendHomepage = $this->generateUrl('qcharts.frontend.homepage');
         $frontendBase = $this->generateUrl('qcharts.frontend.base');
         $directoryUrl = $this->generateUrl('qcharts.api.directory_get');
         $directoryQuery = $this->generateUrl('qcharts.api.directory_query');
         $snapshots = $this->generateUrl('qcharts.api.snapshot.get');
         $snapshotDownload = $this->generateUrl('qcharts.api.snapshot.snapshot_download');
         $favoritesGet = $this->generateUrl('qcharts.api.favorite_get');
         $options = ["status" => 200, "textStatus" => "Urls returned", "urls" => ["frontend" => ["tableInfo" => $frontendTableInfo, "homepage" => $frontendHomepage, "base" => $frontendBase], "query" => $this->generateUrl('qcharts.api.query_get'), "database" => ["tableInfo" => $tableInfo, "tables" => $tablesUrl, "connections" => $connections, "schemas" => $connectionSchemas], "snapshots" => ["snapshots" => $snapshots, "download" => $snapshotDownload], "favorite" => ["base" => $favoritesGet], "directory" => ["base" => $directoryUrl, "query" => $directoryQuery], "user" => ["role" => $roleUrl], "chart" => $this->generateUrl('qcharts.api.chart_data')]];
         return new JsonResponse($options);
     } catch (InvalidCredentialsException $e) {
         return new JsonResponse(ApiController::getNotValidCredentials());
     }
 }
예제 #2
0
 /**
  * ApiDoc(
  *     description = "Deletes the requested snapshot file",
  *     parameters = {
  *          {
  *              "name" = "snapshot",
  *              "dataType" = "integer",
  *              "description" = "The snapshot name to delete",
  *              "required" = true
  *          },
  *          {
  *              "name" = "q",
  *              "dataType" = "integer",
  *              "description" = "Query request that has the snapshot",
  *              "required" = true
  *          }
  *     },
  *     statusCodes = {
  *          202 = "Snapshot deleted",
  *          402 = "Credentials invalid"
  *     }
  * )
  * @param Request $request
  * @return JsonResponse
  */
 public function deleteSnapshotAction(Request $request)
 {
     $options = [];
     $authChecker = $this->get("security.authorization_checker");
     $roles = $this->getParameter("qcharts.user_roles");
     try {
         ApiController::checkCredentials($authChecker, $roles, ApiController::SUPER_ADMIN);
         $snapshotService = $this->get("qcharts.core.snapshot_service");
         $queryService = $this->get("qcharts.query");
         $snapshotId = $request->request->get("snapshot", null);
         $queryId = $request->request->get("q", null);
         $queryRequest = $queryService->getQueryRequestById($queryId);
         $snapshot = $snapshotService->getSnapshotFile($queryRequest, $snapshotId);
         $snapshotService->deleteSnapshot($queryRequest, $snapshot);
         $options = ["status" => 202, "textStatus" => "The snapshot was deleted"];
     } catch (InvalidCredentialsException $e) {
         $options = ApiController::getNotValidCredentials();
     } catch (SnapshotException $e) {
         $options = ["status" => $e->getCode(), "textStatus" => $e->getMessage()];
     } catch (InstanceNotFoundException $e) {
         $options = ["status" => $e->getCode(), "textStatus" => $e->getMessage()];
     } finally {
         return new JsonResponse($options);
     }
 }
예제 #3
0
 /**
  * ApiDoc(
  *     description = "Removes the given query request from the favorites list of the user",
  *     parameters = {
  *          {
  *              "name" = "q",
  *              "required" = true,
  *              "dataType" = "integer",
  *              "description" = "The query Id to remove from the user's list"
  *          }
  *     },
  *     statusCodes = {
  *          202 = "The query was removed from the user's favorite list",
  *          500 = "Error while attempting to remove the query form the user's favorite list"
  *     }
  * )
  * @param Request $request
  * @return JsonResponse
  */
 public function removeFavoriteAction(Request $request)
 {
     $roles = $this->getParameter("qcharts.user_roles");
     $authService = $this->get("security.authorization_checker");
     $options = [];
     try {
         ApiController::checkCredentials($authService, $roles, "user");
         $user = $this->getUser();
         $queryId = $request->request->get("q", null);
         $queryService = $this->get("qcharts.query");
         $favService = $this->get("qcharts.core.favorite_service");
         $queryRequest = $queryService->getQueryRequestById($queryId);
         $favService->removeFavourite($user, $queryRequest);
         $options = ["status" => 202, "textStatus" => "The favorite was removed from the user's list"];
     } catch (InstanceNotFoundException $e) {
         $options = ["status" => $e->getCode(), "textStatus" => $e->getMessage()];
     } finally {
         return new JsonResponse($options);
     }
 }