Splunk Enterprise

splunk sd for python

chakrad8
Observer

Hi

I'm trying to create dynamic apps using a python script below:

 

import os
import requests
from requests.auth import HTTPBasicAuth
from requests.exceptions import RequestException

def get_config():
    config = {
        'base_url': 'https://localhost:8089',
        'csv_filename': "test9.csv",
        'template_name': 'template_placeholder',
        'username' : 'chakrad8',
        'password'  : 'random_password'
    }
    config['app_name'] = os.path.splitext(config['csv_filename'])[0]
    return config
config = get_config()
def make_request(method,url,data=None):
    try:
        response = requests.request(method,f"{config['base_url']}{url}",auth=HTTPBasicAuth(config['username'],config['password']),data=data,verify=False)
        return response
    except RequestException as e:
        print(f"An error occurred while making the request: {e}")
        return None
response = make_request("GET",f"/services/apps/local/{config['app_name']}")
if response.status_code == 200:
    print(f"App '{config['app_name']}' already exists.")
else:
    response = make_request('POST',"/services/apps/local/",{'name':config['app_name'],'template':config['template_name']})
    print(response)
    if response and response.status_code == 201:
        print(f"App '{config['app_name']}' created successfully.")
    else:
        print(f"Error Creating app: {response.text}")

 


I've created a custom template app called 'template_placeholder'  and i want to use it as a template when creating the new app so i was calling 

response = make_request('POST',"/services/apps/local/",{'name':config['app_name'],'template':config['template_name']})
 
This is creating the app but the label is remaining same as the custom template app that is 'template_placeholder'.

is there any workaround to this or is my request malformed in some way? , please help with this.
0 Karma
Get Updates on the Splunk Community!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...