Automate Linear Integration Tasks from PowerShell
The CData ADO.NET Provider for Linear is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Linear.
ADO.NET Provider
The ADO.NET Provider provides a SQL interface for Linear; this tutorial shows how to use the Provider to retrieve Linear data.
Once you have acquired the necessary connection properties, accessing Linear data in PowerShell can be enabled in three steps.
You can authenticate to Linear with a personal API key or with OAuth 2.0. The API key is the simplest option for connecting with your own Linear account.
Authenticating with an API Key
Set the following connection properties:
- AuthScheme: Set this to APIKey.
- APIKey: A Linear personal API key.
To create a personal API key, log in to Linear, open Settings > Security & access > Personal API keys, select New API key, and create it. Copy the key immediately, because Linear shows it only once.
Authenticating with OAuth
OAuth requires a custom OAuth application registered in Linear (Settings > API > OAuth applications), which provides the OAuthClientId and OAuthClientSecret. Two flows are supported:
- Authorization code: Set AuthScheme to OAuth, InitiateOAuth to GETANDREFRESH, and provide OAuthClientId, OAuthClientSecret, and the CallbackURL defined in your application (e.g., http://localhost:33333). The driver opens Linear in your browser so you can grant access.
- Client credentials: Set AuthScheme to OAuthClient and provide OAuthClientId and OAuthClientSecret. This authenticates the application itself, with no browser interaction, and suits machine-to-machine integrations.
By default, the driver requests the read,write scopes. The driver refreshes the access token automatically when it expires.
-
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Linear\lib\System.Data.CData.Linear.dll") -
Connect to Linear:
$conn= New-Object System.Data.CData.Linear.LinearConnection("AuthScheme=APIKey;APIKey=myAPIKey;") $conn.Open() -
Instantiate the LinearDataAdapter, execute an SQL query, and output the results:
$sql="SELECT id, name from Team" $da= New-Object System.Data.CData.Linear.LinearDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.id $_.name }