dremiojs 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -19
- package/docs/catalog.md +76 -0
- package/docs/client.md +55 -0
- package/docs/configuration.md +150 -0
- package/docs/governance_collaboration.md +41 -0
- package/docs/provisioning.md +15 -0
- package/docs/reflections.md +54 -0
- package/docs/scripts_lineage_tokens.md +45 -0
- package/docs/service_users.md +77 -0
- package/docs/sources.md +53 -0
- package/docs/sql_and_jobs.md +59 -0
- package/docs/users.md +19 -0
- package/package.json +10 -2
- package/src/api/collaboration.ts +55 -0
- package/src/api/credentials.ts +74 -0
- package/src/api/governance.ts +52 -0
- package/src/api/lineage.ts +19 -0
- package/src/api/provisioning.ts +32 -0
- package/src/api/scripts.ts +64 -0
- package/src/api/token.ts +50 -0
- package/src/api/user.ts +39 -3
- package/src/client/base.ts +25 -0
- package/src/client/cloud.ts +51 -5
- package/src/client/software.ts +77 -33
- package/src/factory.ts +20 -0
- package/src/index.ts +1 -1
- package/src/types/config.ts +28 -5
- package/src/utils/config.ts +113 -0
- package/tests/integration_manual.ts +49 -0
- package/tests/verify_profiles.ts +28 -0
package/README.md
CHANGED
|
@@ -10,6 +10,49 @@ npm install dremiojs
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
+
The recommended way to use `dremiojs` is by configuring your connection in `~/.dremio/profiles.yaml` (compatible with `dremio-cli`).
|
|
14
|
+
|
|
15
|
+
### 1. Setup Profile
|
|
16
|
+
Create `~/.dremio/profiles.yaml`:
|
|
17
|
+
|
|
18
|
+
```yaml
|
|
19
|
+
profiles:
|
|
20
|
+
cloud:
|
|
21
|
+
type: cloud
|
|
22
|
+
base_url: https://api.dremio.cloud
|
|
23
|
+
project_id: <PROJECT_ID>
|
|
24
|
+
auth:
|
|
25
|
+
type: pat
|
|
26
|
+
token: <PAT>
|
|
27
|
+
local:
|
|
28
|
+
type: software
|
|
29
|
+
base_url: http://localhost:9047
|
|
30
|
+
auth:
|
|
31
|
+
type: username_password
|
|
32
|
+
username: admin
|
|
33
|
+
password: password1
|
|
34
|
+
default_profile: cloud
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 2. Connect & Query
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { Dremio } from 'dremiojs';
|
|
41
|
+
|
|
42
|
+
async function main() {
|
|
43
|
+
// Automatically loads 'default' profile from yaml
|
|
44
|
+
const client = await Dremio.fromProfile();
|
|
45
|
+
|
|
46
|
+
// Execute SQL
|
|
47
|
+
const results = await client.jobs.executeQuery('SELECT 1');
|
|
48
|
+
console.log(results);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Advanced Usage (Explicit Configuration)
|
|
53
|
+
|
|
54
|
+
You can also configure clients manually without a profile file.
|
|
55
|
+
|
|
13
56
|
### Dremio Cloud
|
|
14
57
|
|
|
15
58
|
```typescript
|
|
@@ -20,16 +63,6 @@ const client = new DremioCloudClient({
|
|
|
20
63
|
authToken: 'YOUR_PAT',
|
|
21
64
|
projectId: 'YOUR_PROJECT_ID'
|
|
22
65
|
});
|
|
23
|
-
|
|
24
|
-
async function main() {
|
|
25
|
-
// List catalog
|
|
26
|
-
const catalog = await client.catalog.getByPath([]);
|
|
27
|
-
console.log(catalog.children);
|
|
28
|
-
|
|
29
|
-
// Execute SQL
|
|
30
|
-
const results = await client.jobs.executeQuery('SELECT * FROM sys.version');
|
|
31
|
-
console.log(results);
|
|
32
|
-
}
|
|
33
66
|
```
|
|
34
67
|
|
|
35
68
|
### Dremio Software
|
|
@@ -37,23 +70,40 @@ async function main() {
|
|
|
37
70
|
```typescript
|
|
38
71
|
import { DremioSoftwareClient } from 'dremiojs';
|
|
39
72
|
|
|
73
|
+
// OAuth (Client Credentials)
|
|
40
74
|
const client = new DremioSoftwareClient({
|
|
41
|
-
baseUrl: '
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
75
|
+
baseUrl: 'https://dremio.local/api/v3',
|
|
76
|
+
auth: {
|
|
77
|
+
type: 'oauth',
|
|
78
|
+
client_id: 'service-id',
|
|
79
|
+
client_secret: 'secret'
|
|
80
|
+
}
|
|
46
81
|
});
|
|
47
|
-
|
|
48
|
-
async function main() {
|
|
49
|
-
const results = await client.jobs.executeQuery('SELECT 1');
|
|
50
|
-
}
|
|
51
82
|
```
|
|
52
83
|
|
|
53
84
|
## Features
|
|
54
85
|
|
|
86
|
+
- **Profile Support**: Seamless `profiles.yaml` integration for Cloud/Software.
|
|
87
|
+
- **Advanced Auth**: Support for PAT Exchange and OAuth Client Credentials.
|
|
55
88
|
- **Universal Support**: Works with both Dremio Cloud and Dremio Software.
|
|
56
89
|
- **Strict Typing**: Full TypeScript definitions for Catalog, Jobs, Reflections, etc.
|
|
57
90
|
- **SQL Helper**: Easy `executeQuery` method that handles job submission and polling.
|
|
58
91
|
- **Catalog Management**: Create, update, delete Spaces, Sources, Folders, and Datasets.
|
|
59
92
|
- **Reflections**: Manage reflections programmatically.
|
|
93
|
+
|
|
94
|
+
- [Configuration & Environment Variables](docs/configuration.md)
|
|
95
|
+
- [Client Usage](docs/client.md)
|
|
96
|
+
- [Catalog API](docs/catalog.md)
|
|
97
|
+
## Documentation
|
|
98
|
+
|
|
99
|
+
- [Configuration & Environment Variables](docs/configuration.md)
|
|
100
|
+
- [Client Usage](docs/client.md)
|
|
101
|
+
- [Catalog API](docs/catalog.md)
|
|
102
|
+
- [SQL & Jobs API](docs/sql_and_jobs.md)
|
|
103
|
+
- [Reflections API](docs/reflections.md)
|
|
104
|
+
- [Sources API](docs/sources.md)
|
|
105
|
+
- [Users API](docs/users.md)
|
|
106
|
+
- [Governance & Collaboration](docs/governance_collaboration.md)
|
|
107
|
+
- [Scripts, Lineage & Tokens](docs/scripts_lineage_tokens.md)
|
|
108
|
+
- [Provisioning (Engines)](docs/provisioning.md)
|
|
109
|
+
- [Service Users & Credentials](docs/service_users.md)
|
package/docs/catalog.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Catalog API Guide
|
|
2
|
+
|
|
3
|
+
The Catalog API is the primary way to interact with Dremio's semantic layer (Spaces, Folders, Virtual Datasets) and physical sources.
|
|
4
|
+
|
|
5
|
+
## Accessing the Catalog
|
|
6
|
+
|
|
7
|
+
### Listing the Root
|
|
8
|
+
To list the top-level items (Spaces and Sources):
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
const root = await client.catalog.getByPath([]);
|
|
12
|
+
console.log(root.children);
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Getting Items by Path
|
|
16
|
+
You can traverse the catalog hierarchy using an array of path segments.
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
// Get a specific dataset: "MarketingSpace.Campaigns.Q1_Results"
|
|
20
|
+
const dataset = await client.catalog.getByPath(['MarketingSpace', 'Campaigns', 'Q1_Results']);
|
|
21
|
+
console.log(dataset.id, dataset.type);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Getting Items by ID
|
|
25
|
+
If you already have the immutable ID of an object (e.g., from a search or list operation):
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
const item = await client.catalog.get('dremio-dataset-uuid-1234');
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Creating Items
|
|
32
|
+
|
|
33
|
+
### Creating a Space
|
|
34
|
+
```typescript
|
|
35
|
+
await client.catalog.create({
|
|
36
|
+
type: 'SPACE',
|
|
37
|
+
name: 'NewMarketingSpace'
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Creating a Folder
|
|
42
|
+
```typescript
|
|
43
|
+
await client.catalog.create({
|
|
44
|
+
type: 'FOLDER',
|
|
45
|
+
path: ['NewMarketingSpace', 'Folder A']
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Creating a Virtual Dataset (View)
|
|
50
|
+
To create a VDS, you must provide the SQL definition and the context (path).
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
await client.catalog.create({
|
|
54
|
+
type: 'DATASET',
|
|
55
|
+
path: ['NewMarketingSpace', 'MyView'],
|
|
56
|
+
sql: 'SELECT * FROM "Samples"."samples.dremio.com"."SF_incidents"',
|
|
57
|
+
format: { type: 'VIRTUAL_DATASET' } // Required specific to API v3/Cloud
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Updating Items
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
// Rename or Move (check API specifics for move vs update)
|
|
65
|
+
await client.catalog.update('item-id', {
|
|
66
|
+
...item,
|
|
67
|
+
tag: item.tag, // Optimistic locking tag is often required
|
|
68
|
+
sql: 'SELECT * FROM new_table' // Updating SQL of a view
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Deleting Items
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
await client.catalog.delete('item-id');
|
|
76
|
+
```
|
package/docs/client.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Client Instance Guide
|
|
2
|
+
|
|
3
|
+
The library provides two distinct clients to handle the subtle differences between Dremio Cloud and Dremio Software APIs. Both clients share a common interface for most resources, making it easy to switch between them or support hybrid deployments.
|
|
4
|
+
|
|
5
|
+
## Dremio Cloud Client
|
|
6
|
+
|
|
7
|
+
The `DremioCloudClient` is optimized for Dremio Cloud's multi-tenant architecture. It automatically handles the `projectId` context required for most API calls.
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { DremioCloudClient } from 'dremiojs';
|
|
11
|
+
|
|
12
|
+
const cloudClient = new DremioCloudClient({
|
|
13
|
+
baseUrl: 'https://api.dremio.cloud/v0',
|
|
14
|
+
authToken: process.env.DREMIO_CLOUD_TOKEN,
|
|
15
|
+
projectId: process.env.DREMIO_CLOUD_PROJECT_ID
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// The client automatically appends /projects/{id} to relevant paths
|
|
19
|
+
await cloudClient.catalog.getByPath(['space', 'dataset']);
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Dremio Software Client
|
|
23
|
+
|
|
24
|
+
The `DremioSoftwareClient` supports standard Dremio Software deployments (Docker, K8s, RPM). It includes logic for:
|
|
25
|
+
- API v2 Login (username/password) exchange for tokens.
|
|
26
|
+
- Automatic token management (if using username/pass).
|
|
27
|
+
- Standard v3 API usage.
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { DremioSoftwareClient } from 'dremiojs';
|
|
31
|
+
|
|
32
|
+
const softwareClient = new DremioSoftwareClient({
|
|
33
|
+
baseUrl: 'http://localhost:9047/api/v3',
|
|
34
|
+
authToken: process.env.DREMIO_PAT
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Or using Login
|
|
38
|
+
const legacyClient = new DremioSoftwareClient({
|
|
39
|
+
baseUrl: 'http://localhost:9047/api/v3',
|
|
40
|
+
username: 'admin',
|
|
41
|
+
password: 'password123'
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// The client performs login on the first request if no token is present
|
|
45
|
+
await legacyClient.jobs.executeQuery('SELECT 1');
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Shared Capabilities
|
|
49
|
+
|
|
50
|
+
Both clients extend `BaseClient` and expose:
|
|
51
|
+
- `catalog`: Manage datasets, spaces, folders.
|
|
52
|
+
- `jobs`: Execute SQL and track jobs.
|
|
53
|
+
- `reflections`: specific Reflection management.
|
|
54
|
+
- `sources`: specific Source management.
|
|
55
|
+
- `users`: User and Role lookups.
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Configuration & Authentication
|
|
2
|
+
|
|
3
|
+
`dremiojs` offers a flexible configuration system that supports:
|
|
4
|
+
1. **Profiles (New):** Automatically load configuration from `~/.dremio/profiles.yaml`.
|
|
5
|
+
2. **Explicit Config:** Pass configuration objects directly to the client constructor.
|
|
6
|
+
3. **Environment Variables:** Fallback support for standard environment variables.
|
|
7
|
+
|
|
8
|
+
## 1. Using Profiles (Recommended)
|
|
9
|
+
|
|
10
|
+
The easiest way to specificy connection details is using the `Dremio` factory, which reads from your local `~/.dremio/profiles.yaml` file (compatible with `dremio-cli` and `dremio-simple-query`).
|
|
11
|
+
|
|
12
|
+
### Installation
|
|
13
|
+
Ensure you have a profiles file at `~/.dremio/profiles.yaml`.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Dremio } from 'dremiojs';
|
|
17
|
+
|
|
18
|
+
async function main() {
|
|
19
|
+
// 1. Load the 'default' profile
|
|
20
|
+
const client = await Dremio.fromProfile();
|
|
21
|
+
|
|
22
|
+
// 2. Load a specific named profile (e.g. 'prod')
|
|
23
|
+
const prodClient = await Dremio.fromProfile('prod');
|
|
24
|
+
|
|
25
|
+
const results = await client.jobs.executeQuery('SELECT 1');
|
|
26
|
+
console.log(results);
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Profile Reference (`profiles.yaml`)
|
|
31
|
+
|
|
32
|
+
Below is a complete reference of supported profile types.
|
|
33
|
+
|
|
34
|
+
```yaml
|
|
35
|
+
profiles:
|
|
36
|
+
# --- Dremio Cloud (PAT Auth) ---
|
|
37
|
+
cloud:
|
|
38
|
+
type: cloud
|
|
39
|
+
# Base URL (defaults to https://api.dremio.cloud)
|
|
40
|
+
base_url: https://api.dremio.cloud
|
|
41
|
+
project_id: <YOUR_PROJECT_ID>
|
|
42
|
+
auth:
|
|
43
|
+
type: pat
|
|
44
|
+
token: <YOUR_PAT_TOKEN>
|
|
45
|
+
|
|
46
|
+
# --- Dremio Software (PAT Auth) ---
|
|
47
|
+
software_pat:
|
|
48
|
+
type: software
|
|
49
|
+
base_url: https://dremio.company.com
|
|
50
|
+
auth:
|
|
51
|
+
type: pat
|
|
52
|
+
token: <YOUR_PAT_TOKEN>
|
|
53
|
+
|
|
54
|
+
# --- Dremio Software (Username/Password) ---
|
|
55
|
+
# Useful for local development or legacy auth
|
|
56
|
+
local:
|
|
57
|
+
type: software
|
|
58
|
+
base_url: http://localhost:9047
|
|
59
|
+
ssl: 'false' # Disable SSL verification for localhost
|
|
60
|
+
auth:
|
|
61
|
+
type: username_password
|
|
62
|
+
username: admin
|
|
63
|
+
password: password123
|
|
64
|
+
|
|
65
|
+
# --- Dremio Software (OAuth 2.0 / Service Account) ---
|
|
66
|
+
# Uses Client Credentials Grant
|
|
67
|
+
service_account:
|
|
68
|
+
type: software
|
|
69
|
+
base_url: https://dremio.company.com
|
|
70
|
+
auth:
|
|
71
|
+
type: oauth
|
|
72
|
+
client_id: <CLIENT_ID>
|
|
73
|
+
client_secret: <CLIENT_SECRET>
|
|
74
|
+
# Scope is optional, defaults to implicit or 'dremio.all' on retry
|
|
75
|
+
scope: dremio.all
|
|
76
|
+
|
|
77
|
+
default_profile: cloud
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## 2. Explicit Configuration
|
|
81
|
+
|
|
82
|
+
You can also instantiate clients manually, which is useful for web applications or when configuration is injected at runtime.
|
|
83
|
+
|
|
84
|
+
### Dremio Cloud Client
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import { DremioCloudClient } from 'dremiojs';
|
|
88
|
+
|
|
89
|
+
const client = new DremioCloudClient({
|
|
90
|
+
projectId: 'your-project-id',
|
|
91
|
+
authToken: 'your-pat', // Can be a PAT or a Session Token
|
|
92
|
+
baseUrl: 'https://api.dremio.cloud/v0', // Optional
|
|
93
|
+
// Or use the auth object
|
|
94
|
+
auth: {
|
|
95
|
+
type: 'pat',
|
|
96
|
+
token: 'your-pat'
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Dremio Software Client
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { DremioSoftwareClient } from 'dremiojs';
|
|
105
|
+
|
|
106
|
+
// PAT Auth
|
|
107
|
+
const client = new DremioSoftwareClient({
|
|
108
|
+
baseUrl: 'http://localhost:9047/api/v3',
|
|
109
|
+
authToken: 'your-pat'
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Username/Password
|
|
113
|
+
const client = new DremioSoftwareClient({
|
|
114
|
+
baseUrl: 'http://localhost:9047/api/v3',
|
|
115
|
+
auth: {
|
|
116
|
+
type: 'username_password',
|
|
117
|
+
username: 'admin',
|
|
118
|
+
password: 'password123'
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// OAuth (Client Credentials)
|
|
123
|
+
const client = new DremioSoftwareClient({
|
|
124
|
+
baseUrl: 'https://dremio.example.com/api/v3',
|
|
125
|
+
auth: {
|
|
126
|
+
type: 'oauth',
|
|
127
|
+
client_id: '...',
|
|
128
|
+
client_secret: '...'
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## 3. Environment Variables (Fallback)
|
|
134
|
+
|
|
135
|
+
If no profiles are found, `ConfigLoader` checks for these legacy environment variables:
|
|
136
|
+
|
|
137
|
+
- **Cloud**: `DREMIO_CLOUD_TOKEN`, `DREMIO_CLOUD_PROJECTID`, `DREMIO_CLOUD_BASE_URL`
|
|
138
|
+
- **Software**: `DREMIO_SOFTWARE_TOKEN`, `DREMIO_SOFTWARE_BASE_URL`, `DREMIO_USER`, `DREMIO_PASSWORD`
|
|
139
|
+
|
|
140
|
+
## SSL/TLS Configuration
|
|
141
|
+
|
|
142
|
+
For self-signed certificates (common in local software deployments), set `checkSSLCerts: false`. In `profiles.yaml`, set `ssl: 'false'`.
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
const client = new DremioSoftwareClient({
|
|
146
|
+
baseUrl: 'https://localhost:9047',
|
|
147
|
+
checkSSLCerts: false
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Governance & Collaboration API Guide
|
|
2
|
+
|
|
3
|
+
## Governance (Grants)
|
|
4
|
+
|
|
5
|
+
Manage access control lists (ACLs) and grants for Catalog entities.
|
|
6
|
+
|
|
7
|
+
### Getting Grants
|
|
8
|
+
```typescript
|
|
9
|
+
const grants = await client.governance.getGrants('entity-id');
|
|
10
|
+
// Output: [{ granteeType: 'USER', id: '...', privileges: ['SELECT'] }]
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Updating Grants
|
|
14
|
+
```typescript
|
|
15
|
+
await client.governance.updateGrants('entity-id', [
|
|
16
|
+
{ granteeType: 'ROLE', id: 'role-id', privileges: ['SELECT', 'ALTER'] }
|
|
17
|
+
]);
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Collaboration (Tags & Wiki)
|
|
21
|
+
|
|
22
|
+
Manage metadata that helps users discover and understand data.
|
|
23
|
+
|
|
24
|
+
### Tags
|
|
25
|
+
```typescript
|
|
26
|
+
// Get Tags
|
|
27
|
+
const tags = await client.collaboration.getTags('dataset-id');
|
|
28
|
+
|
|
29
|
+
// Set Tags
|
|
30
|
+
await client.collaboration.setTags('dataset-id', ['marketing', 'q1-2024']);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Wiki
|
|
34
|
+
```typescript
|
|
35
|
+
// Get Wiki Markdown
|
|
36
|
+
const wiki = await client.collaboration.getWiki('dataset-id');
|
|
37
|
+
console.log(wiki.text);
|
|
38
|
+
|
|
39
|
+
// Set Wiki
|
|
40
|
+
await client.collaboration.setWiki('dataset-id', '# Sales Data\n\nThis dataset contains...');
|
|
41
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Provisioning API Guide
|
|
2
|
+
|
|
3
|
+
Manage Dremio Engines (Cloud) or Queues (Software WLM).
|
|
4
|
+
|
|
5
|
+
## Engines (Dremio Cloud)
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// List available engines
|
|
9
|
+
const engines = await client.provisioning.listEngines();
|
|
10
|
+
engines.forEach(engine => {
|
|
11
|
+
console.log(`Engine: ${engine.name} (${engine.size}) - ${engine.status}`);
|
|
12
|
+
});
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
*Note: Software WLM Queue management is structurally different and may be added to this namespace in future updates.*
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Reflections API Guide
|
|
2
|
+
|
|
3
|
+
Reflections are Dremio's query acceleration technology. This API allows you to manage raw and aggregation reflections programmatically.
|
|
4
|
+
|
|
5
|
+
## Listing Reflections
|
|
6
|
+
|
|
7
|
+
You can list all reflections or filter by dataset.
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
// List all accessible reflections
|
|
11
|
+
const allReflections = await client.reflections.list();
|
|
12
|
+
|
|
13
|
+
// List reflections for a specific dataset
|
|
14
|
+
const datasetReflections = await client.reflections.list({
|
|
15
|
+
datasetId: 'dataset-uuid-123'
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Getting a Reflection
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
const reflection = await client.reflections.get('reflection-uuid');
|
|
23
|
+
console.log(reflection.name, reflection.status);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Creating a Reflection
|
|
27
|
+
|
|
28
|
+
Creating a reflection implies defining which dataset it accelerates and its configuration (dimensions, measures, etc.).
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
await client.reflections.create({
|
|
32
|
+
type: 'RAW',
|
|
33
|
+
name: 'Raw_Acceleration',
|
|
34
|
+
datasetId: 'dataset-uuid-123',
|
|
35
|
+
enabled: true,
|
|
36
|
+
displayFieldIds: ['col1', 'col2'] // Fields to include
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Updating a Reflection
|
|
41
|
+
|
|
42
|
+
Commonly used to enable/disable reflections or update their definition.
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
await client.reflections.update('reflection-uuid', {
|
|
46
|
+
enabled: false // Disable reflection
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Deleting a Reflection
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
await client.reflections.delete('reflection-uuid');
|
|
54
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Scripts, Lineage & Tokens Guide
|
|
2
|
+
|
|
3
|
+
## Scripts API
|
|
4
|
+
|
|
5
|
+
Manage saved SQL scripts (Dremio Cloud & Software).
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// List Scripts
|
|
9
|
+
const scripts = await client.scripts.list({ maxResults: 10 });
|
|
10
|
+
|
|
11
|
+
// Get a Script
|
|
12
|
+
const myScript = await client.scripts.get('script-id');
|
|
13
|
+
|
|
14
|
+
// Create a Script
|
|
15
|
+
const newScript = await client.scripts.create({
|
|
16
|
+
name: 'Daily Report',
|
|
17
|
+
content: 'SELECT count(*) FROM sales',
|
|
18
|
+
context: ['Marketing']
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Update
|
|
22
|
+
await client.scripts.update('script-id', { content: 'SELECT * FROM sales' });
|
|
23
|
+
|
|
24
|
+
// Delete
|
|
25
|
+
await client.scripts.delete('script-id');
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Lineage API
|
|
29
|
+
|
|
30
|
+
Explore the data lineage graph for a dataset.
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
const graph = await client.lineage.get('dataset-id');
|
|
34
|
+
console.log(graph);
|
|
35
|
+
// Returns nodes and edges representing parent/child relationships
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Token Management
|
|
39
|
+
|
|
40
|
+
Programmatically generate Personal Access Tokens (PATs) (where supported).
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
const tokenResponse = await client.tokens.createToken('user-id', 'My New Token');
|
|
44
|
+
console.log('New PAT:', tokenResponse.token);
|
|
45
|
+
```
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Service Users & Credentials Guide
|
|
2
|
+
|
|
3
|
+
Managing non-human accounts (Service Users) is essential for CI/CD and automated workflows. dremiojs provides full lifecycle management for Service Users and their OAuth credentials.
|
|
4
|
+
|
|
5
|
+
> **Note**: Service Users are primarily a **Dremio Enterprise** feature. Calls to these endpoints may fail on Community Edition.
|
|
6
|
+
|
|
7
|
+
## Service User Lifecycle
|
|
8
|
+
|
|
9
|
+
### 1. Create a Service User
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
const serviceUser = await client.users.create({
|
|
13
|
+
name: 'ci_pipeline_bot',
|
|
14
|
+
identityType: 'SERVICE_USER',
|
|
15
|
+
active: true
|
|
16
|
+
});
|
|
17
|
+
console.log('Service User Created:', serviceUser.id);
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### 2. Create Client Credentials (Secret)
|
|
21
|
+
|
|
22
|
+
Generate a Client ID and Secret for this user. This secret is only shown ONCE.
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
const credential = await client.credentials.create(
|
|
26
|
+
serviceUser.id,
|
|
27
|
+
'gitlab-access-token',
|
|
28
|
+
180 // Lifetime in days
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
console.log('Client ID:', credential.clientSecretConfig.clientId);
|
|
32
|
+
console.log('Client Secret:', credential.clientSecretConfig.clientSecret);
|
|
33
|
+
// SAVE THE SECRET NOW! It cannot be retrieved again.
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 3. List Credentials
|
|
37
|
+
|
|
38
|
+
View active credentials for a user.
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
const creds = await client.credentials.list(serviceUser.id);
|
|
42
|
+
creds.forEach(c => console.log(c.name, c.credentialType));
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 4. Delete Credentials
|
|
46
|
+
|
|
47
|
+
Revoke a specific credential.
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
await client.credentials.delete(serviceUser.id, credential.id);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 5. Delete Service User
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
await client.users.delete(serviceUser.id, serviceUser.tag);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Dremio Cloud Service Accounts
|
|
60
|
+
|
|
61
|
+
In Dremio Cloud, "Service Users" are typically handled as regular users with **Personal Access Tokens (PATs)**.
|
|
62
|
+
|
|
63
|
+
### Creating a Token Programmatically
|
|
64
|
+
|
|
65
|
+
You can generate tokens for users (if you have permissions) using the `TokensResource`.
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
// Create a token for a specific user ID
|
|
69
|
+
const { token } = await client.tokens.createToken(
|
|
70
|
+
'user-uuid-1234',
|
|
71
|
+
'ci-pipeline-token',
|
|
72
|
+
90 // Lifetime in days (default 30)
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
console.log('Generated PAT:', token);
|
|
76
|
+
```
|
|
77
|
+
|
package/docs/sources.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Sources API Guide
|
|
2
|
+
|
|
3
|
+
Sources are the physical connections to your data lakes and databases (e.g., S3, HDFS, PostgreSQL, Snowflake).
|
|
4
|
+
|
|
5
|
+
## Listing Sources
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
const sources = await client.sources.list();
|
|
9
|
+
sources.forEach(source => {
|
|
10
|
+
console.log(source.name, source.type); // e.g. "MyS3", "S3"
|
|
11
|
+
});
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Getting a Source
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
const source = await client.sources.get('source-id');
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Creating a Source
|
|
21
|
+
|
|
22
|
+
Creating a source requires a specific configuration object that varies by source type (S3, Nessie, etc.). *Note: The specific config payload structure depends on the Dremio version and source type.*
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// Example: Creating an S3 Source
|
|
26
|
+
await client.sources.create({
|
|
27
|
+
name: 'MyS3Source',
|
|
28
|
+
type: 'S3',
|
|
29
|
+
config: {
|
|
30
|
+
bucketName: 'my-bucket',
|
|
31
|
+
accessKey: '...',
|
|
32
|
+
accessSecret: '...'
|
|
33
|
+
// ... other S3 specific props
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Updating a Source
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
await client.sources.update('source-id', {
|
|
42
|
+
config: {
|
|
43
|
+
...oldConfig,
|
|
44
|
+
accessSecret: 'NEW_SECRET'
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Deleting a Source
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
await client.sources.delete('source-id');
|
|
53
|
+
```
|