QCharts/ApiBundle/Controller/SnapshotController.php
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);
        }
    }
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);
        }
    }
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