Skip to content

Commit 83088d5

Browse files
committed
Add initial boilerplate
1 parent 306d3f8 commit 83088d5

File tree

5 files changed

+67
-1
lines changed

5 files changed

+67
-1
lines changed

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ requires = ["setuptools"]
4545
build-backend = "setuptools.build_meta"
4646

4747
[tool.setuptools]
48-
packages = ["splunklib", "splunklib.modularinput", "splunklib.searchcommands"]
48+
packages = [
49+
"splunklib",
50+
"splunklib.modularinput",
51+
"splunklib.searchcommands",
52+
"splunklib.mcp",
53+
]
4954

5055
[tool.setuptools.dynamic]
5156
version = { attr = "splunklib.__version__" }

splunklib/mcp/__init__.py

Whitespace-only changes.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python
2+
# coding=utf-8
3+
#
4+
# Copyright © 2011-2024 Splunk, Inc.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License"): you may
7+
# not use this file except in compliance with the License. You may obtain
8+
# a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15+
# License for the specific language governing permissions and limitations
16+
# under the License.
17+
18+
import sys
19+
import time
20+
21+
from splunklib.searchcommands import (
22+
Configuration,
23+
GeneratingCommand,
24+
Option,
25+
dispatch,
26+
validators,
27+
)
28+
29+
30+
@Configuration()
31+
class GeneratingCSC(GeneratingCommand):
32+
count = Option(require=True, validate=validators.Integer(0))
33+
34+
def generate(self):
35+
self.logger.debug("Generating %s events" % self.count)
36+
for i in range(1, self.count + 1):
37+
text = f"Test Event {i}"
38+
yield {"_time": time.time(), "event_no": i, "_raw": text}
39+
40+
41+
dispatch(GeneratingCSC, sys.argv, sys.stdin, sys.stdout, __name__)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# Splunk app configuration file
3+
#
4+
5+
[install]
6+
is_configured = 0
7+
8+
[ui]
9+
is_visible = 1
10+
label = Generating App
11+
12+
[launcher]
13+
description = Generating custom search commands example
14+
version = 1.0.0
15+
author = Splunk
16+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[generatingcsc]
2+
filename = mcp_tool.py
3+
chunked = true
4+
python.version = python3

0 commit comments

Comments
 (0)