igorsgm / laravel-redash
📊 • A Laravel wrapper to empower your applications with Redash.io APIs. Extract, analyze, and leverage your Redash data right from your app!
1.1.0
2024-10-29 11:54 UTC
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.0
- illuminate/contracts: ^10.0|^11.0
- illuminate/http: ^10.0|^11.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.11.0|^8.4.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0|^9.0
- pestphp/pest: ^2.36|^3.0
- pestphp/pest-plugin-arch: ^2.0|^3.0
- pestphp/pest-plugin-laravel: ^2.0|^3.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- spatie/laravel-ray: ^1.26
README
Unleash the power of Redash.io APIs in your Laravel applications. This package allows you to easily extract, analyze, and leverage your data directly within your application. Transform your data management today!
✨ Features
- Queries: Easily create, edit, or archive query objects directly from your Laravel application. The package returns paginated arrays of query objects and supports the extraction of individual query objects too.
- Query Results: Initiate a new query execution or return a cached result effortlessly. Handle parameterized queries and manage max_age for cache bypassing with provided methods.
- Dashboards: Create, edit, or archive dashboard objects seamlessly. Fetch an array of dashboard objects or individual ones directly from your Laravel application.
- Jobs: Monitor the status of your query tasks effectively.
1️⃣ Installation
- You can install the package via composer:
composer require igorsgm/laravel-redash
- You can publish the config file with:
php artisan vendor:publish --tag="laravel-redash-config"
2️⃣ Usage
Define Redash API credentials in your .env
file. i.e.:
REDASH_BASE_URL=foo:bar
REDASH_API_KEY=12345678900987654321
Summary
- Redash API Documentation: https://redash.io/help/user-guide/integrations-and-api/api
Queries
// Returns a paginated array of query objects. Redash::queries()->all(); // Returns an individual query object. Redash::queries()->get($queryId); // Create a new query object. Redash::queries()->create([ 'name' => 'My Query', 'data_source_id' => 1, 'query' => 'SELECT * FROM table', 'description' => 'My Query Description', // ... ]); // Edit an existing query object. Redash::queries()->update($queryId, [ 'name' => 'My New Query Name', // ... ]); // Archive an existing query. Redash::queries()->delete($queryId); // Get a cached result for this query ID Redash::queries()->getCachedResult($queryId); // Initiates a new query execution or returns a cached result. Redash::queries()->executeOrGetResult($queryId, [ 'parameters' => [ 'foo' => 'bar', ], 'max_age' => 0, ]);
- Execute a Query and return its result once ready (custom method).
// The maximum age (in milliseconds) of a cached result that the method should return. // If a cached result is older than this, a new query execution will begin. // Set to `0` to always start a new execution. $maxAge = 1800; // The number of times to retry the query execution if it is still in progress. $retryAttempts = 20; Redash::queries()->getResult($queryId, [ 'foo' => 'bar', ], $maxAge, $retryAttempts);
Query Results
// Returns a query result Redash::queryResults()->get($queryResultId);
Dashboards
Redash::dashboards()->all(); Redash::dashboards()->get($dashboardId); Redash::dashboards()->create([ // ... ]); Redash::dashboards()->update($dashboardId, [ // ... ]); Redash::dashboards()->delete($dashboardId);
Jobs
Redash::jobs()->get($jobId);
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email igor.sgm@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.