Redasher 0.1.0
dotnet add package Redasher --version 0.1.0
NuGet\Install-Package Redasher -Version 0.1.0
<PackageReference Include="Redasher" Version="0.1.0" />
paket add Redasher --version 0.1.0
#r "nuget: Redasher, 0.1.0"
// Install Redasher as a Cake Addin
#addin nuget:?package=Redasher&version=0.1.0
// Install Redasher as a Cake Tool
#tool nuget:?package=Redasher&version=0.1.0
Redasher
F# library for Redash API
Install
Install from NuGet (in progress)
> dotnet add package Redasher
How Usage
Before using library you should have
- Url of your redash server
- Api Key for you user
- Open Redasher library and prepare you ConnectionInfo object
open System
open Redash
let connectionInfo = {
ApiKey = Environment.GetEnvironmentVariable "ApiKey"
ConnectionUrl = Environment.GetEnvironmentVariable "BaseUrl"
}
Note: In example we have taken sensitivity data from Environment variables.
- Load information about datasource by his name
let ds = getDataSource connectionInfo "my-data-source"
- Invoke query
let queryResult = getQueryResults<{|id: int; name: string|}> connectionInfo
ds.Value
"SELECT id FROM user LIMIT 5"
for row in queryResult.Data.Rows do
printfn $"User {row.id} {row.name}"
Support API
Official documentation: https://redash.io/help/user-guide/integrations-and-api/api
DataSources
GET /api/data_sources
List of accessible datasources
let dataSources = getDataSources connectionInfo
dataSources: Datasource list
Retrieve datasource bi ID
let ds = getDataSource connectionInfo "data-source-name"
ds: Datasource
Queries
POST /api/query_results
Primary method for extracting data from datasource. This method hide internal flow of Redash and implicitly from you
- create query
- polling job
- retrieve information after job will be done
Firstly we should specify model for query.
Example:
Suppose we have a table users with three columns:
- id: int
- name: string
- age: int
Declare model for that in F#
let User = type {
id: int
name: string
age: int
}
and make query for this table like: 'SELECT * FROM users LIMIT 5'
let queryResult = getQueryResults<User> connectionInfo
"data-source-name"
"SELECT * FROM users LIMIT 5"
for user in queryResult.Data.Rows do
printfn $"User {user.id}, {user.name}, {user.age}"
GET api/query_results/{id}
Retrieve data from prepared query by id. As we mention above, firstly you should prepare model for your query.
let queryResult = getQueryResult<User> connectionInfo 34803
Jobs
GET /api/jobs/<job_id>
Retrieves information of working job. Usually jobs are created implicitly after calling 'POST: /api/query_results' and you dont need thin about that.
let job = getJob connectionInfo "2cc44526-1d5f-40b6-a380-0aa11247e2c8"
Job can be in several statuses:
type JobStatus = | Pending = 1
| Started = 2
| Success = 3
| Failure = 4
| Canceled = 5
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Expecto (>= 10.1.0)
- FSharp.Core (>= 8.0.200)
- FSharp.SystemTextJson (>= 1.2.42)
- FsHttp (>= 14.5.0)
- FsToolkit.ErrorHandling (>= 4.15.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.1.0 | 99 | 3/10/2024 |
First public version