pull:初次提交

This commit is contained in:
Yep_Q
2025-09-08 04:48:28 +08:00
parent 5c0619656d
commit f64f498365
11751 changed files with 1953723 additions and 0 deletions

View File

@@ -0,0 +1,100 @@
import type { INodeProperties, IExecuteFunctions, IDataObject } from 'n8n-workflow';
import { updateDisplayOptions } from '../../../../../utils/utilities';
import type { SplunkFeedResponse } from '../../helpers/interfaces';
import { formatFeed, populate } from '../../helpers/utils';
import { splunkApiRequest } from '../../transport';
const properties: INodeProperties[] = [
{
displayName: 'Name',
name: 'name',
description: 'Login name of the user',
type: 'string',
required: true,
default: '',
},
{
// eslint-disable-next-line n8n-nodes-base/node-param-display-name-wrong-for-dynamic-multi-options
displayName: 'Roles',
name: 'roles',
type: 'multiOptions',
description:
'Comma-separated list of roles to assign to the user. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
required: true,
default: ['user'],
typeOptions: {
loadOptionsMethod: 'getRoles',
},
},
{
displayName: 'Password',
name: 'password',
type: 'string',
typeOptions: { password: true },
required: true,
default: '',
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
options: [
{
displayName: 'Email',
name: 'email',
type: 'string',
placeholder: 'name@email.com',
default: '',
},
{
displayName: 'Full Name',
name: 'realname',
type: 'string',
default: '',
description: 'Full name of the user',
},
],
},
];
const displayOptions = {
show: {
resource: ['user'],
operation: ['create'],
},
};
export const description = updateDisplayOptions(displayOptions, properties);
export async function execute(
this: IExecuteFunctions,
i: number,
): Promise<IDataObject | IDataObject[]> {
// https://docs.splunk.com/Documentation/Splunk/8.2.2/RESTREF/RESTaccess#authentication.2Fusers
const roles = this.getNodeParameter('roles', i) as string[];
const body = {
name: this.getNodeParameter('name', i),
roles,
password: this.getNodeParameter('password', i),
} as IDataObject;
const additionalFields = this.getNodeParameter('additionalFields', i);
populate(additionalFields, body);
const endpoint = '/services/authentication/users';
const responseData = (await splunkApiRequest.call(
this,
'POST',
endpoint,
body,
)) as SplunkFeedResponse;
const returnData = formatFeed(responseData);
return returnData;
}

View File

@@ -0,0 +1,30 @@
import type { INodeProperties, IExecuteFunctions, IDataObject } from 'n8n-workflow';
import { updateDisplayOptions } from '../../../../../utils/utilities';
import { userRLC } from '../../helpers/descriptions';
import { splunkApiRequest } from '../../transport';
const properties: INodeProperties[] = [userRLC];
const displayOptions = {
show: {
resource: ['user'],
operation: ['deleteUser'],
},
};
export const description = updateDisplayOptions(displayOptions, properties);
export async function execute(
this: IExecuteFunctions,
i: number,
): Promise<IDataObject | IDataObject[]> {
// https://docs.splunk.com/Documentation/Splunk/8.2.2/RESTREF/RESTaccess#authentication.2Fusers.2F.7Bname.7D
const userId = this.getNodeParameter('userId', i, '', { extractValue: true }) as string;
const endpoint = `/services/authentication/users/${userId}`;
await splunkApiRequest.call(this, 'DELETE', endpoint);
return { success: true };
}

View File

@@ -0,0 +1,30 @@
import type { INodeProperties, IExecuteFunctions, IDataObject } from 'n8n-workflow';
import { updateDisplayOptions } from '../../../../../utils/utilities';
import { userRLC } from '../../helpers/descriptions';
import { splunkApiJsonRequest } from '../../transport';
const properties: INodeProperties[] = [userRLC];
const displayOptions = {
show: {
resource: ['user'],
operation: ['get'],
},
};
export const description = updateDisplayOptions(displayOptions, properties);
export async function execute(
this: IExecuteFunctions,
i: number,
): Promise<IDataObject | IDataObject[]> {
// https://docs.splunk.com/Documentation/Splunk/8.2.2/RESTREF/RESTaccess#authentication.2Fusers.2F.7Bname.7D
const userId = this.getNodeParameter('userId', i, '', { extractValue: true }) as string;
const endpoint = `/services/authentication/users/${userId}`;
const returnData = await splunkApiJsonRequest.call(this, 'GET', endpoint);
return returnData;
}

View File

@@ -0,0 +1,54 @@
import type { INodeProperties, IExecuteFunctions, IDataObject } from 'n8n-workflow';
import { updateDisplayOptions } from '../../../../../utils/utilities';
import { setReturnAllOrLimit } from '../../helpers/utils';
import { splunkApiJsonRequest } from '../../transport';
const properties: INodeProperties[] = [
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
default: false,
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
default: 50,
description: 'Max number of results to return',
typeOptions: {
minValue: 1,
},
displayOptions: {
show: {
returnAll: [false],
},
},
},
];
const displayOptions = {
show: {
resource: ['user'],
operation: ['getAll'],
},
};
export const description = updateDisplayOptions(displayOptions, properties);
export async function execute(
this: IExecuteFunctions,
_i: number,
): Promise<IDataObject | IDataObject[]> {
// https://docs.splunk.com/Documentation/Splunk/8.2.2/RESTREF/RESTaccess#authentication.2Fusers
const qs = {} as IDataObject;
setReturnAllOrLimit.call(this, qs);
const endpoint = '/services/authentication/users';
const returnData = await splunkApiJsonRequest.call(this, 'GET', endpoint, {}, qs);
return returnData;
}

View File

@@ -0,0 +1,62 @@
import type { INodeProperties } from 'n8n-workflow';
import * as create from './create.operation';
import * as deleteUser from './deleteUser.operation';
import * as get from './get.operation';
import * as getAll from './getAll.operation';
import * as update from './update.operation';
export { create, deleteUser, get, getAll, update };
export const description: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['user'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create an user',
action: 'Create a user',
},
{
name: 'Delete',
value: 'deleteUser',
description: 'Delete an user',
action: 'Delete a user',
},
{
name: 'Get',
value: 'get',
description: 'Retrieve an user',
action: 'Get a user',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Retrieve many users',
action: 'Get many users',
},
{
name: 'Update',
value: 'update',
description: 'Update an user',
action: 'Update a user',
},
],
default: 'create',
},
...create.description,
...deleteUser.description,
...get.description,
...getAll.description,
...update.description,
];

View File

@@ -0,0 +1,87 @@
import type { INodeProperties, IExecuteFunctions, IDataObject } from 'n8n-workflow';
import { updateDisplayOptions } from '../../../../../utils/utilities';
import { userRLC } from '../../helpers/descriptions';
import { formatFeed, populate } from '../../helpers/utils';
import { splunkApiRequest } from '../../transport';
const properties: INodeProperties[] = [
userRLC,
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
options: [
{
displayName: 'Email',
name: 'email',
type: 'string',
placeholder: 'name@email.com',
default: '',
},
{
displayName: 'Full Name',
name: 'realname',
type: 'string',
default: '',
description: 'Full name of the user',
},
{
displayName: 'Password',
name: 'password',
type: 'string',
typeOptions: { password: true },
default: '',
},
{
displayName: 'Role Names or IDs',
name: 'roles',
type: 'multiOptions',
description:
'Comma-separated list of roles to assign to the user. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
default: [],
typeOptions: {
loadOptionsMethod: 'getRoles',
},
},
],
},
];
const displayOptions = {
show: {
resource: ['user'],
operation: ['update'],
},
};
export const description = updateDisplayOptions(displayOptions, properties);
export async function execute(
this: IExecuteFunctions,
i: number,
): Promise<IDataObject | IDataObject[]> {
// https://docs.splunk.com/Documentation/Splunk/8.2.2/RESTREF/RESTaccess#authentication.2Fusers.2F.7Bname.7D
const body = {} as IDataObject;
const { roles, ...rest } = this.getNodeParameter('updateFields', i) as IDataObject & {
roles: string[];
};
populate(
{
...(roles && { roles }),
...rest,
},
body,
);
const userId = this.getNodeParameter('userId', i, '', { extractValue: true }) as string;
const endpoint = `/services/authentication/users/${userId}`;
const returnData = await splunkApiRequest.call(this, 'POST', endpoint, body).then(formatFeed);
return returnData;
}