first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled

This commit is contained in:
2026-03-17 16:22:57 +03:30
commit 3d5eaf9445
15349 changed files with 2847338 additions and 0 deletions
@@ -0,0 +1,103 @@
import type {
IExecuteFunctions,
IDataObject,
ILoadOptionsFunctions,
JsonObject,
IHttpRequestMethods,
IRequestOptions,
} from 'n8n-workflow';
import { NodeApiError, NodeOperationError } from 'n8n-workflow';
import type { GrafanaCredentials } from './types';
export function tolerateTrailingSlash(baseUrl: string) {
return baseUrl.endsWith('/') ? baseUrl.substr(0, baseUrl.length - 1) : baseUrl;
}
export async function grafanaApiRequest(
this: IExecuteFunctions | ILoadOptionsFunctions,
method: IHttpRequestMethods,
endpoint: string,
body: IDataObject = {},
qs: IDataObject = {},
) {
const { baseUrl: rawBaseUrl } = await this.getCredentials<GrafanaCredentials>('grafanaApi');
const baseUrl = tolerateTrailingSlash(rawBaseUrl);
const options: IRequestOptions = {
headers: {
'Content-Type': 'application/json',
},
method,
body,
qs,
uri: `${baseUrl}/api${endpoint}`,
json: true,
};
if (!Object.keys(body).length) {
delete options.body;
}
if (!Object.keys(qs).length) {
delete options.qs;
}
try {
return await this.helpers.requestWithAuthentication.call(this, 'grafanaApi', options);
} catch (error) {
if (error?.response?.data?.message === 'Team member not found') {
error.response.data.message += '. Are you sure the user is a member of this team?';
}
if (error?.response?.data?.message === 'Team not found') {
error.response.data.message += ' with the provided ID';
}
if (
error?.response?.data?.message ===
'A dashboard with the same name in the folder already exists'
) {
error.response.data.message =
'A dashboard with the same name already exists in the selected folder';
}
if (error?.response?.data?.message === 'Team name taken') {
error.response.data.message = 'This team name is already taken. Please choose a new one.';
}
if (error?.code === 'ECONNREFUSED') {
error.message =
'Invalid credentials or error in establishing connection with given credentials';
}
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
export function throwOnEmptyUpdate(
this: IExecuteFunctions,
resource: string,
updateFields: IDataObject,
) {
if (!Object.keys(updateFields).length) {
throw new NodeOperationError(
this.getNode(),
`Please enter at least one field to update for the ${resource}.`,
);
}
}
export function deriveUid(this: IExecuteFunctions, uidOrUrl: string) {
if (!uidOrUrl.startsWith('http')) return uidOrUrl;
const urlSegments = uidOrUrl.split('/');
const uid = urlSegments[urlSegments.indexOf('d') + 1];
if (!uid) {
throw new NodeOperationError(this.getNode(), 'Failed to derive UID from URL');
}
return uid;
}
@@ -0,0 +1,19 @@
{
"node": "n8n-nodes-base.grafana",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": ["Development", "Analytics"],
"resources": {
"credentialDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/credentials/grafana/"
}
],
"primaryDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.grafana/"
}
]
},
"alias": ["Prometheus"]
}
@@ -0,0 +1,494 @@
import type {
IExecuteFunctions,
IDataObject,
ILoadOptionsFunctions,
INodeExecutionData,
INodePropertyOptions,
INodeType,
INodeTypeDescription,
} from 'n8n-workflow';
import { NodeConnectionTypes, NodeApiError } from 'n8n-workflow';
import {
dashboardFields,
dashboardOperations,
teamFields,
teamMemberFields,
teamMemberOperations,
teamOperations,
userFields,
userOperations,
} from './descriptions';
import { deriveUid, grafanaApiRequest, throwOnEmptyUpdate } from './GenericFunctions';
import type {
DashboardUpdateFields,
DashboardUpdatePayload,
LoadedDashboards,
LoadedFolders,
LoadedTeams,
LoadedUsers,
} from './types';
export class Grafana implements INodeType {
description: INodeTypeDescription = {
displayName: 'Grafana',
name: 'grafana',
icon: 'file:grafana.svg',
group: ['transform'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Consume the Grafana API',
defaults: {
name: 'Grafana',
},
usableAsTool: true,
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.Main],
credentials: [
{
name: 'grafanaApi',
required: true,
},
],
properties: [
{
displayName: 'Resource',
name: 'resource',
noDataExpression: true,
type: 'options',
options: [
{
name: 'Dashboard',
value: 'dashboard',
},
{
name: 'Team',
value: 'team',
},
{
name: 'Team Member',
value: 'teamMember',
},
{
name: 'User',
value: 'user',
},
],
default: 'dashboard',
},
...dashboardOperations,
...dashboardFields,
...teamOperations,
...teamFields,
...teamMemberOperations,
...teamMemberFields,
...userOperations,
...userFields,
],
};
methods = {
loadOptions: {
async getDashboards(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const dashboards = (await grafanaApiRequest.call(
this,
'GET',
'/search',
{},
{ qs: 'dash-db' },
)) as LoadedDashboards;
return dashboards.map(({ id, title }) => ({ value: id, name: title }));
},
async getFolders(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const folders = (await grafanaApiRequest.call(this, 'GET', '/folders')) as LoadedFolders;
return folders.map(({ id, title }) => ({ value: id, name: title }));
},
async getTeams(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const res = (await grafanaApiRequest.call(this, 'GET', '/teams/search')) as LoadedTeams;
return res.teams.map(({ id, name }) => ({ value: id, name }));
},
async getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const users = (await grafanaApiRequest.call(this, 'GET', '/org/users')) as LoadedUsers;
return users.map(({ userId, email }) => ({ value: userId, name: email }));
},
},
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0);
let responseData;
for (let i = 0; i < items.length; i++) {
try {
if (resource === 'dashboard') {
// **********************************************************************
// dashboard
// **********************************************************************
if (operation === 'create') {
// ----------------------------------------
// dashboard: create
// ----------------------------------------
// https://grafana.com/docs/grafana/latest/http_api/dashboard/#create--update-dashboard
const body = {
dashboard: {
id: null,
title: this.getNodeParameter('title', i),
},
};
const additionalFields = this.getNodeParameter('additionalFields', i);
if (Object.keys(additionalFields).length) {
if (additionalFields.folderId === '') delete additionalFields.folderId;
Object.assign(body, additionalFields);
}
responseData = await grafanaApiRequest.call(this, 'POST', '/dashboards/db', body);
} else if (operation === 'delete') {
// ----------------------------------------
// dashboard: delete
// ----------------------------------------
// https://grafana.com/docs/grafana/latest/http_api/dashboard/#delete-dashboard-by-uid
const uidOrUrl = this.getNodeParameter('dashboardUidOrUrl', i) as string;
const uid = deriveUid.call(this, uidOrUrl);
const endpoint = `/dashboards/uid/${uid}`;
responseData = await grafanaApiRequest.call(this, 'DELETE', endpoint);
} else if (operation === 'get') {
// ----------------------------------------
// dashboard: get
// ----------------------------------------
// https://grafana.com/docs/grafana/latest/http_api/dashboard/#get-dashboard-by-uid
const uidOrUrl = this.getNodeParameter('dashboardUidOrUrl', i) as string;
const uid = deriveUid.call(this, uidOrUrl);
const endpoint = `/dashboards/uid/${uid}`;
responseData = await grafanaApiRequest.call(this, 'GET', endpoint);
} else if (operation === 'getAll') {
// ----------------------------------------
// dashboard: getAll
// ----------------------------------------
// https://grafana.com/docs/grafana/latest/http_api/folder_dashboard_search/#search-folders-and-dashboards
const qs = {
type: 'dash-db',
};
const filters = this.getNodeParameter('filters', i);
if (Object.keys(filters).length) {
Object.assign(qs, filters);
}
const returnAll = this.getNodeParameter('returnAll', i);
if (!returnAll) {
const limit = this.getNodeParameter('limit', i);
Object.assign(qs, { limit });
}
responseData = await grafanaApiRequest.call(this, 'GET', '/search', {}, qs);
} else if (operation === 'update') {
// ----------------------------------------
// dashboard: update
// ----------------------------------------
// https://grafana.com/docs/grafana/latest/http_api/dashboard/#create--update-dashboard
const uidOrUrl = this.getNodeParameter('dashboardUidOrUrl', i) as string;
const uid = deriveUid.call(this, uidOrUrl);
// ensure dashboard to update exists
await grafanaApiRequest.call(this, 'GET', `/dashboards/uid/${uid}`);
const body: DashboardUpdatePayload = {
overwrite: true,
dashboard: { uid },
};
const updateFields = this.getNodeParameter('updateFields', i) as DashboardUpdateFields;
throwOnEmptyUpdate.call(this, resource, updateFields);
const { title, ...rest } = updateFields;
if (!title) {
const { dashboard } = await grafanaApiRequest.call(
this,
'GET',
`/dashboards/uid/${uid}`,
);
body.dashboard.title = dashboard.title;
} else {
const dashboards = (await grafanaApiRequest.call(this, 'GET', '/search')) as Array<{
title: string;
}>;
const titles = dashboards.map(({ title: entry }) => entry);
if (titles.includes(title)) {
throw new NodeApiError(this.getNode(), {
message: 'A dashboard with the same name already exists in the selected folder',
});
}
body.dashboard.title = title;
}
if (title) {
body.dashboard.title = title;
}
if (Object.keys(rest).length) {
if (rest.folderId === '') delete rest.folderId;
Object.assign(body, rest);
}
responseData = await grafanaApiRequest.call(this, 'POST', '/dashboards/db', body);
}
} else if (resource === 'team') {
// **********************************************************************
// team
// **********************************************************************
if (operation === 'create') {
// ----------------------------------------
// team: create
// ----------------------------------------
// https://grafana.com/docs/grafana/latest/http_api/team/#add-team
const body = {
name: this.getNodeParameter('name', i) as string,
};
const additionalFields = this.getNodeParameter('additionalFields', i);
if (Object.keys(additionalFields).length) {
Object.assign(body, additionalFields);
}
responseData = await grafanaApiRequest.call(this, 'POST', '/teams', body);
} else if (operation === 'delete') {
// ----------------------------------------
// team: delete
// ----------------------------------------
// https://grafana.com/docs/grafana/latest/http_api/team/#delete-team-by-id
const teamId = this.getNodeParameter('teamId', i);
responseData = await grafanaApiRequest.call(this, 'DELETE', `/teams/${teamId}`);
} else if (operation === 'get') {
// ----------------------------------------
// team: get
// ----------------------------------------
// https://grafana.com/docs/grafana/latest/http_api/team/#get-team-by-id
const teamId = this.getNodeParameter('teamId', i);
responseData = await grafanaApiRequest.call(this, 'GET', `/teams/${teamId}`);
} else if (operation === 'getAll') {
// ----------------------------------------
// team: getAll
// ----------------------------------------
// https://grafana.com/docs/grafana/latest/http_api/team/#team-search-with-paging
const qs = {} as IDataObject;
const filters = this.getNodeParameter('filters', i);
if (Object.keys(filters).length) {
Object.assign(qs, filters);
}
responseData = await grafanaApiRequest.call(this, 'GET', '/teams/search', {}, qs);
responseData = responseData.teams;
const returnAll = this.getNodeParameter('returnAll', i);
if (!returnAll) {
const limit = this.getNodeParameter('limit', i);
responseData = responseData.slice(0, limit);
}
} else if (operation === 'update') {
// ----------------------------------------
// team: update
// ----------------------------------------
// https://grafana.com/docs/grafana/latest/http_api/team/#update-team
const updateFields = this.getNodeParameter('updateFields', i);
throwOnEmptyUpdate.call(this, resource, updateFields);
const body: IDataObject = {};
const teamId = this.getNodeParameter('teamId', i);
// check if team exists, since API does not specify update failure reason
await grafanaApiRequest.call(this, 'GET', `/teams/${teamId}`);
// prevent email from being overridden to empty
if (!updateFields.email) {
const { email } = await grafanaApiRequest.call(this, 'GET', `/teams/${teamId}`);
body.email = email;
}
if (Object.keys(updateFields).length) {
Object.assign(body, updateFields);
}
responseData = await grafanaApiRequest.call(this, 'PUT', `/teams/${teamId}`, body);
}
} else if (resource === 'teamMember') {
// **********************************************************************
// teamMember
// **********************************************************************
if (operation === 'add') {
// ----------------------------------------
// teamMember: add
// ----------------------------------------
// https://grafana.com/docs/grafana/latest/http_api/team/#add-team-member
const userId = this.getNodeParameter('userId', i) as string;
const body = {
userId: parseInt(userId, 10),
};
const teamId = this.getNodeParameter('teamId', i);
const endpoint = `/teams/${teamId}/members`;
responseData = await grafanaApiRequest.call(this, 'POST', endpoint, body);
} else if (operation === 'remove') {
// ----------------------------------------
// teamMember: remove
// ----------------------------------------
// https://grafana.com/docs/grafana/latest/http_api/team/#remove-member-from-team
const teamId = this.getNodeParameter('teamId', i);
const memberId = this.getNodeParameter('memberId', i);
const endpoint = `/teams/${teamId}/members/${memberId}`;
responseData = await grafanaApiRequest.call(this, 'DELETE', endpoint);
} else if (operation === 'getAll') {
// ----------------------------------------
// teamMember: getAll
// ----------------------------------------
// https://grafana.com/docs/grafana/latest/http_api/team/#get-team-members
const teamId = this.getNodeParameter('teamId', i);
// check if team exists, since API returns all members if team does not exist
await grafanaApiRequest.call(this, 'GET', `/teams/${teamId}`);
const endpoint = `/teams/${teamId}/members`;
responseData = await grafanaApiRequest.call(this, 'GET', endpoint);
const returnAll = this.getNodeParameter('returnAll', i);
if (!returnAll) {
const limit = this.getNodeParameter('limit', i);
responseData = responseData.slice(0, limit);
}
}
} else if (resource === 'user') {
// **********************************************************************
// user
// **********************************************************************
if (operation === 'create') {
// ----------------------------------------
// user: create
// ----------------------------------------
// https://grafana.com/docs/grafana/latest/http_api/org/#add-a-new-user-to-the-current-organization
const body = {
role: this.getNodeParameter('role', i),
loginOrEmail: this.getNodeParameter('loginOrEmail', i),
};
responseData = await grafanaApiRequest.call(this, 'POST', '/org/users', body);
} else if (operation === 'delete') {
// ----------------------------------------
// user: delete
// ----------------------------------------
// https://grafana.com/docs/grafana/latest/http_api/org/#delete-user-in-current-organization
const userId = this.getNodeParameter('userId', i);
responseData = await grafanaApiRequest.call(this, 'DELETE', `/org/users/${userId}`);
} else if (operation === 'getAll') {
// ----------------------------------------
// user: getAll
// ----------------------------------------
// https://grafana.com/docs/grafana/latest/http_api/org/#get-all-users-within-the-current-organization
responseData = await grafanaApiRequest.call(this, 'GET', '/org/users');
const returnAll = this.getNodeParameter('returnAll', i);
if (!returnAll) {
const limit = this.getNodeParameter('limit', i);
responseData = responseData.slice(0, limit);
}
} else if (operation === 'update') {
// ----------------------------------------
// user: update
// ----------------------------------------
// https://grafana.com/docs/grafana/latest/http_api/org/#updates-the-given-user
const body: IDataObject = {};
const updateFields = this.getNodeParameter('updateFields', i);
throwOnEmptyUpdate.call(this, resource, updateFields);
if (Object.keys(updateFields).length) {
Object.assign(body, updateFields);
}
const userId = this.getNodeParameter('userId', i) as string;
responseData = await grafanaApiRequest.call(
this,
'PATCH',
`/org/users/${userId}`,
body,
);
}
}
Array.isArray(responseData)
? returnData.push(...(responseData as IDataObject[]))
: returnData.push(responseData as IDataObject);
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ error: error.message });
continue;
}
throw error;
}
}
return [this.helpers.returnJsonArray(returnData)];
}
}
@@ -0,0 +1,678 @@
{
"type": "object",
"properties": {
"dashboard": {
"type": "object",
"properties": {
"annotations": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"type": "object",
"properties": {
"builtIn": {
"type": "integer"
},
"datasource": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"uid": {
"type": "string"
}
}
},
"enable": {
"type": "boolean"
},
"hide": {
"type": "boolean"
},
"iconColor": {
"type": "string"
},
"name": {
"type": "string"
},
"target": {
"type": "object",
"properties": {
"limit": {
"type": "integer"
},
"matchAny": {
"type": "boolean"
},
"type": {
"type": "string"
}
}
},
"type": {
"type": "string"
}
}
}
}
}
},
"editable": {
"type": "boolean"
},
"fiscalYearStartMonth": {
"type": "integer"
},
"graphTooltip": {
"type": "integer"
},
"id": {
"type": "integer"
},
"links": {
"type": "array",
"items": {
"type": "object",
"properties": {
"asDropdown": {
"type": "boolean"
},
"icon": {
"type": "string"
},
"includeVars": {
"type": "boolean"
},
"keepTime": {
"type": "boolean"
},
"targetBlank": {
"type": "boolean"
},
"title": {
"type": "string"
},
"tooltip": {
"type": "string"
},
"type": {
"type": "string"
},
"url": {
"type": "string"
}
}
}
},
"panels": {
"type": "array",
"items": {
"type": "object",
"properties": {
"datasource": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"uid": {
"type": "string"
}
}
},
"description": {
"type": "string"
},
"fieldConfig": {
"type": "object",
"properties": {
"defaults": {
"type": "object",
"properties": {
"color": {
"type": "object",
"properties": {
"fixedColor": {
"type": "string"
},
"mode": {
"type": "string"
}
}
},
"custom": {
"type": "object",
"properties": {
"axisBorderShow": {
"type": "boolean"
},
"axisCenteredZero": {
"type": "boolean"
},
"axisColorMode": {
"type": "string"
},
"axisGridShow": {
"type": "boolean"
},
"axisLabel": {
"type": "string"
},
"axisPlacement": {
"type": "string"
},
"barAlignment": {
"type": "integer"
},
"barWidthFactor": {
"type": "number"
},
"drawStyle": {
"type": "string"
},
"fillOpacity": {
"type": "integer"
},
"gradientMode": {
"type": "string"
},
"hideFrom": {
"type": "object",
"properties": {
"legend": {
"type": "boolean"
},
"tooltip": {
"type": "boolean"
},
"viz": {
"type": "boolean"
}
}
},
"insertNulls": {
"type": "boolean"
},
"lineInterpolation": {
"type": "string"
},
"lineStyle": {
"type": "object",
"properties": {
"fill": {
"type": "string"
}
}
},
"lineWidth": {
"type": "integer"
},
"pointSize": {
"type": "integer"
},
"scaleDistribution": {
"type": "object",
"properties": {
"type": {
"type": "string"
}
}
},
"showPoints": {
"type": "string"
},
"spanNulls": {
"type": "boolean"
},
"stacking": {
"type": "object",
"properties": {
"group": {
"type": "string"
},
"mode": {
"type": "string"
}
}
},
"thresholdsStyle": {
"type": "object",
"properties": {
"mode": {
"type": "string"
}
}
}
}
},
"min": {
"type": "integer"
},
"thresholds": {
"type": "object",
"properties": {
"mode": {
"type": "string"
},
"steps": {
"type": "array",
"items": {
"type": "object",
"properties": {
"color": {
"type": "string"
}
}
}
}
}
},
"unit": {
"type": "string"
}
}
},
"overrides": {
"type": "array",
"items": {
"type": "object",
"properties": {
"matcher": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"options": {
"type": "string"
}
}
},
"properties": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
}
}
}
}
}
}
}
}
},
"gridPos": {
"type": "object",
"properties": {
"h": {
"type": "integer"
},
"w": {
"type": "integer"
},
"x": {
"type": "integer"
},
"y": {
"type": "integer"
}
}
},
"id": {
"type": "integer"
},
"interval": {
"type": "string"
},
"options": {
"type": "object",
"properties": {
"legend": {
"type": "object",
"properties": {
"calcs": {
"type": "array",
"items": {
"type": "string"
}
},
"displayMode": {
"type": "string"
},
"placement": {
"type": "string"
},
"showLegend": {
"type": "boolean"
}
}
},
"tooltip": {
"type": "object",
"properties": {
"mode": {
"type": "string"
},
"sort": {
"type": "string"
}
}
}
}
},
"pluginVersion": {
"type": "string"
},
"targets": {
"type": "array",
"items": {
"type": "object",
"properties": {
"datasource": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"uid": {
"type": "string"
}
}
},
"disableTextWrap": {
"type": "boolean"
},
"editorMode": {
"type": "string"
},
"expr": {
"type": "string"
},
"format": {
"type": "string"
},
"fullMetaSearch": {
"type": "boolean"
},
"hide": {
"type": "boolean"
},
"includeNullMetadata": {
"type": "boolean"
},
"instant": {
"type": "boolean"
},
"interval": {
"type": "string"
},
"intervalFactor": {
"type": "integer"
},
"legendFormat": {
"type": "string"
},
"refId": {
"type": "string"
},
"useBackend": {
"type": "boolean"
}
}
}
},
"title": {
"type": "string"
},
"transparent": {
"type": "boolean"
},
"type": {
"type": "string"
}
}
}
},
"preload": {
"type": "boolean"
},
"schemaVersion": {
"type": "integer"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
},
"templating": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"type": "object",
"properties": {
"current": {
"type": "object",
"properties": {
"selected": {
"type": "boolean"
}
}
},
"datasource": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"uid": {
"type": "string"
}
}
},
"definition": {
"type": "string"
},
"hide": {
"type": "integer"
},
"includeAll": {
"type": "boolean"
},
"label": {
"type": "string"
},
"multi": {
"type": "boolean"
},
"name": {
"type": "string"
},
"options": {
"type": "array",
"items": {
"type": "object",
"properties": {
"selected": {
"type": "boolean"
},
"text": {
"type": "string"
},
"value": {
"type": "string"
}
}
}
},
"query": {
"type": "object",
"properties": {
"query": {
"type": "string"
}
}
},
"refresh": {
"type": "integer"
},
"regex": {
"type": "string"
},
"skipUrlSync": {
"type": "boolean"
},
"sort": {
"type": "integer"
},
"type": {
"type": "string"
}
}
}
}
}
},
"time": {
"type": "object",
"properties": {
"from": {
"type": "string"
},
"to": {
"type": "string"
}
}
},
"timezone": {
"type": "string"
},
"title": {
"type": "string"
},
"uid": {
"type": "string"
},
"version": {
"type": "integer"
},
"weekStart": {
"type": "string"
}
}
},
"meta": {
"type": "object",
"properties": {
"annotationsPermissions": {
"type": "object",
"properties": {
"dashboard": {
"type": "object",
"properties": {
"canAdd": {
"type": "boolean"
},
"canDelete": {
"type": "boolean"
},
"canEdit": {
"type": "boolean"
}
}
},
"organization": {
"type": "object",
"properties": {
"canAdd": {
"type": "boolean"
},
"canDelete": {
"type": "boolean"
},
"canEdit": {
"type": "boolean"
}
}
}
}
},
"canAdmin": {
"type": "boolean"
},
"canDelete": {
"type": "boolean"
},
"canEdit": {
"type": "boolean"
},
"canSave": {
"type": "boolean"
},
"canStar": {
"type": "boolean"
},
"created": {
"type": "string"
},
"createdBy": {
"type": "string"
},
"expires": {
"type": "string"
},
"folderId": {
"type": "integer"
},
"folderTitle": {
"type": "string"
},
"folderUid": {
"type": "string"
},
"folderUrl": {
"type": "string"
},
"hasAcl": {
"type": "boolean"
},
"isFolder": {
"type": "boolean"
},
"provisioned": {
"type": "boolean"
},
"provisionedExternalId": {
"type": "string"
},
"slug": {
"type": "string"
},
"type": {
"type": "string"
},
"updated": {
"type": "string"
},
"updatedBy": {
"type": "string"
},
"url": {
"type": "string"
},
"version": {
"type": "integer"
}
}
}
},
"version": 1
}
@@ -0,0 +1,236 @@
import type { INodeProperties } from 'n8n-workflow';
export const dashboardOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['dashboard'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a dashboard',
action: 'Create a dashboard',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a dashboard',
action: 'Delete a dashboard',
},
{
name: 'Get',
value: 'get',
description: 'Get a dashboard',
action: 'Get a dashboard',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get many dashboards',
action: 'Get many dashboards',
},
{
name: 'Update',
value: 'update',
description: 'Update a dashboard',
action: 'Update a dashboard',
},
],
default: 'create',
},
];
export const dashboardFields: INodeProperties[] = [
{
displayName: 'Title',
name: 'title',
description: 'Title of the dashboard to create',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: ['dashboard'],
operation: ['create'],
},
},
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['dashboard'],
operation: ['create'],
},
},
options: [
{
displayName: 'Folder Name or ID',
name: 'folderId',
type: 'options',
default: '',
description:
'Folder to create the dashboard in - if the folder is unspecified, the dashboard will be saved to the General folder. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
typeOptions: {
loadOptionsMethod: 'getFolders',
},
},
],
},
// ----------------------------------------
// dashboard: delete
// ----------------------------------------
{
displayName: 'Dashboard UID or URL',
name: 'dashboardUidOrUrl',
description: 'Unique alphabetic identifier or URL of the dashboard to delete',
placeholder: 'cIBgcSjkk',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: ['dashboard'],
operation: ['delete'],
},
},
},
// ----------------------------------------
// dashboard: get
// ----------------------------------------
{
displayName: 'Dashboard UID or URL',
name: 'dashboardUidOrUrl',
description: 'Unique alphabetic identifier or URL of the dashboard to retrieve',
placeholder: 'cIBgcSjkk',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: ['dashboard'],
operation: ['get'],
},
},
},
// ----------------------------------
// dashboard: getAll
// ----------------------------------
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
default: false,
description: 'Whether to return all results or only up to a given limit',
displayOptions: {
show: {
resource: ['dashboard'],
operation: ['getAll'],
},
},
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
default: 50,
description: 'Max number of results to return',
typeOptions: {
minValue: 1,
maxValue: 100,
},
displayOptions: {
show: {
resource: ['dashboard'],
operation: ['getAll'],
returnAll: [false],
},
},
},
{
displayName: 'Filters',
name: 'filters',
type: 'collection',
placeholder: 'Add Filter',
default: {},
displayOptions: {
show: {
resource: ['dashboard'],
operation: ['getAll'],
},
},
options: [
{
displayName: 'Search Query',
name: 'query',
type: 'string',
default: '',
},
],
},
// ----------------------------------------
// dashboard: update
// ----------------------------------------
{
displayName: 'Dashboard UID or URL',
name: 'dashboardUidOrUrl',
description: 'Unique alphabetic identifier or URL of the dashboard to update',
placeholder: 'cIBgcSjkk',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: ['dashboard'],
operation: ['update'],
},
},
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['dashboard'],
operation: ['update'],
},
},
options: [
{
displayName: 'Folder Name or ID',
name: 'folderId',
type: 'options',
default: '',
description:
'Folder to move the dashboard into - if the folder is unspecified, the dashboard will be saved to the General folder. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
typeOptions: {
loadOptionsMethod: 'getFolders',
},
},
{
displayName: 'Title',
name: 'title',
type: 'string',
default: '',
description: 'New title of the dashboard',
},
],
},
];
@@ -0,0 +1,233 @@
import type { INodeProperties } from 'n8n-workflow';
export const teamOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['team'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a team',
action: 'Create a team',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a team',
action: 'Delete a team',
},
{
name: 'Get',
value: 'get',
description: 'Get a team',
action: 'Get a team',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Retrieve many teams',
action: 'Get many teams',
},
{
name: 'Update',
value: 'update',
description: 'Update a team',
action: 'Update a team',
},
],
default: 'create',
},
];
export const teamFields: INodeProperties[] = [
// ----------------------------------------
// team: create
// ----------------------------------------
{
displayName: 'Name',
name: 'name',
description: 'Name of the team to create',
placeholder: 'Engineering',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: ['team'],
operation: ['create'],
},
},
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['team'],
operation: ['create'],
},
},
options: [
{
displayName: 'Email',
name: 'email',
type: 'string',
placeholder: 'engineering@n8n.io',
default: '',
description: 'Email of the team to create',
},
],
},
// ----------------------------------------
// team: delete
// ----------------------------------------
{
displayName: 'Team ID',
name: 'teamId',
description: 'ID of the team to delete',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: ['team'],
operation: ['delete'],
},
},
},
// ----------------------------------------
// team: get
// ----------------------------------------
{
displayName: 'Team ID',
name: 'teamId',
description: 'ID of the team to retrieve',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: ['team'],
operation: ['get'],
},
},
},
// ----------------------------------------
// team: getAll
// ----------------------------------------
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
default: false,
description: 'Whether to return all results or only up to a given limit',
displayOptions: {
show: {
resource: ['team'],
operation: ['getAll'],
},
},
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
default: 50,
description: 'Max number of results to return',
typeOptions: {
minValue: 1,
},
displayOptions: {
show: {
resource: ['team'],
operation: ['getAll'],
returnAll: [false],
},
},
},
{
displayName: 'Filters',
name: 'filters',
type: 'collection',
placeholder: 'Add Filter',
default: {},
displayOptions: {
show: {
resource: ['team'],
operation: ['getAll'],
},
},
options: [
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
description: 'Name of the team to filter by',
},
],
},
// ----------------------------------------
// team: update
// ----------------------------------------
{
displayName: 'Team ID',
name: 'teamId',
description: 'ID of the team to update',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: ['team'],
operation: ['update'],
},
},
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['team'],
operation: ['update'],
},
},
options: [
{
displayName: 'Email',
name: 'email',
type: 'string',
placeholder: 'engineering@n8n.io',
default: '',
description: 'Email of the team to update',
},
{
displayName: 'Name',
name: 'name',
type: 'string',
placeholder: 'Engineering Team',
default: '',
description: 'Name of the team to update',
},
],
},
];
@@ -0,0 +1,170 @@
import type { INodeProperties } from 'n8n-workflow';
export const teamMemberOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['teamMember'],
},
},
options: [
{
name: 'Add',
value: 'add',
description: 'Add a member to a team',
action: 'Add a team member',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Retrieve many team members',
action: 'Get many team members',
},
{
name: 'Remove',
value: 'remove',
description: 'Remove a member from a team',
action: 'Remove a team member',
},
],
default: 'add',
},
];
export const teamMemberFields: INodeProperties[] = [
// ----------------------------------------
// teamMember: add
// ----------------------------------------
{
displayName: 'User Name or ID',
name: 'userId',
description:
'User to add to a team. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
type: 'options',
required: true,
default: '',
typeOptions: {
loadOptionsMethod: 'getUsers',
},
displayOptions: {
show: {
resource: ['teamMember'],
operation: ['add'],
},
},
},
{
displayName: 'Team Name or ID',
name: 'teamId',
description:
'Team to add the user to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
type: 'options',
required: true,
default: '',
typeOptions: {
loadOptionsMethod: 'getTeams',
},
displayOptions: {
show: {
resource: ['teamMember'],
operation: ['add'],
},
},
},
// ----------------------------------------
// teamMember: remove
// ----------------------------------------
{
displayName: 'User Name or ID',
name: 'memberId',
description:
'User to remove from the team. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
type: 'options',
required: true,
default: '',
typeOptions: {
loadOptionsMethod: 'getUsers',
},
displayOptions: {
show: {
resource: ['teamMember'],
operation: ['remove'],
},
},
},
{
displayName: 'Team Name or ID',
name: 'teamId',
description:
'Team to remove the user from. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
type: 'options',
required: true,
default: '',
typeOptions: {
loadOptionsMethod: 'getTeams',
},
displayOptions: {
show: {
resource: ['teamMember'],
operation: ['remove'],
},
},
},
// ----------------------------------------
// teamMember: getAll
// ----------------------------------------
{
displayName: 'Team Name or ID',
name: 'teamId',
description:
'Team to retrieve all members from. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
typeOptions: {
loadOptionsMethod: 'getTeams',
},
type: 'options',
required: true,
default: '',
displayOptions: {
show: {
resource: ['teamMember'],
operation: ['getAll'],
},
},
},
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
default: false,
description: 'Whether to return all results or only up to a given limit',
displayOptions: {
show: {
resource: ['teamMember'],
operation: ['getAll'],
},
},
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
default: 50,
description: 'Max number of results to return',
typeOptions: {
minValue: 1,
},
displayOptions: {
show: {
resource: ['teamMember'],
operation: ['getAll'],
returnAll: [false],
},
},
},
];
@@ -0,0 +1,144 @@
import type { INodeProperties } from 'n8n-workflow';
export const userOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['user'],
},
},
options: [
{
name: 'Delete',
value: 'delete',
description: 'Delete a user from the current organization',
action: 'Delete a user',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Retrieve many users in the current organization',
action: 'Get many users',
},
{
name: 'Update',
value: 'update',
description: 'Update a user in the current organization',
action: 'Update a user',
},
],
default: 'getAll',
},
];
export const userFields: INodeProperties[] = [
// ----------------------------------------
// user: update
// ----------------------------------------
{
displayName: 'User ID',
name: 'userId',
description: 'ID of the user to update',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: ['user'],
operation: ['update'],
},
},
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['user'],
operation: ['update'],
},
},
options: [
{
displayName: 'Role',
name: 'role',
type: 'options',
default: 'Admin',
description: 'New role for the user',
options: [
{
name: 'Admin',
value: 'Admin',
},
{
name: 'Editor',
value: 'Editor',
},
{
name: 'Viewer',
value: 'Viewer',
},
],
},
],
},
// ----------------------------------------
// user: delete
// ----------------------------------------
{
displayName: 'User ID',
name: 'userId',
description: 'ID of the user to delete',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: ['user'],
operation: ['delete'],
},
},
},
// ----------------------------------------
// user: getAll
// ----------------------------------------
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
default: false,
description: 'Whether to return all results or only up to a given limit',
displayOptions: {
show: {
resource: ['user'],
operation: ['getAll'],
},
},
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
default: 50,
description: 'Max number of results to return',
typeOptions: {
minValue: 1,
},
displayOptions: {
show: {
resource: ['user'],
operation: ['getAll'],
returnAll: [false],
},
},
},
];
@@ -0,0 +1,4 @@
export * from './DashboardDescription';
export * from './TeamDescription';
export * from './TeamMemberDescription';
export * from './UserDescription';
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.5 KiB

@@ -0,0 +1,36 @@
export type GrafanaCredentials = {
apiKey: string;
baseUrl: string;
};
export type DashboardUpdatePayload = {
overwrite: true;
dashboard: {
uid: string;
title?: string;
};
};
export type DashboardUpdateFields = {
title?: string;
folderId?: string;
};
export type LoadedDashboards = Array<{
id: number;
title: string;
}>;
export type LoadedFolders = LoadedDashboards;
export type LoadedTeams = {
teams: Array<{
id: number;
name: string;
}>;
};
export type LoadedUsers = Array<{
userId: number;
email: string;
}>;