Skip to content

Commit

Permalink
streaming_app for CSC tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vmalaviya-splunk committed Jun 7, 2022
1 parent 6907767 commit 8a7d9db
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/searchcommands/test_apps/streaming_app/bin/streamingcsc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python
# coding=utf-8
#
# Copyright © 2011-2015 Splunk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import os,sys

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
from splunklib.searchcommands import dispatch, StreamingCommand, Configuration, Option, validators


@Configuration()
class StreamingCSC(StreamingCommand):
"""
The streamingapp command returns events with a one new field 'fahrenheit'.
Example:
``| makeresults count=5 | eval celsius = random()%100 | streamingcsc``
returns a records with one new filed 'fahrenheit'.
"""

def stream(self, records):
for record in records:
record["fahrenheit"] = (float(record["celsius"]) * 1.8) + 32
yield record


dispatch(StreamingCSC, sys.argv, sys.stdin, sys.stdout, __name__)
16 changes: 16 additions & 0 deletions tests/searchcommands/test_apps/streaming_app/default/app.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Splunk app configuration file
#

[install]
is_configured = 0

[ui]
is_visible = 1
label = Streaming App

[launcher]
description = Streaming custom search commands example
version = 1.0.0
author = Splunk

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[streamingcsc]
filename = streamingcsc.py
chunked = true
python.version = python3
40 changes: 40 additions & 0 deletions tests/searchcommands/test_apps/streaming_app/metadata/default.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

# Application-level permissions

[]
access = read : [ * ], write : [ admin, power ]

### EVENT TYPES

[eventtypes]
export = system


### PROPS

[props]
export = system


### TRANSFORMS

[transforms]
export = system


### LOOKUPS

[lookups]
export = system


### VIEWSTATES: even normal users should be able to create shared viewstates

[viewstates]
access = read : [ * ], write : [ * ]
export = system

[commands/streamingcsc]
access = read : [ * ], write : [ * ]
export = system
owner = nobody

0 comments on commit 8a7d9db

Please sign in to comment.