splunkd

package
v2.0.0-alpha-4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KVStoreFieldTypeNone   string = ""
	KVStoreFieldTypeArray  string = "array"
	KVStoreFieldTypeNumber string = "number"
	KVStoreFieldTypeBool   string = "bool"
	KVStoreFieldTypeString string = "string"
	KVStoreFieldTypeCIDR   string = "cidr"
	KVStoreFieldTypeTime   string = "time"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessControlList

type AccessControlList struct {
	App     string `json:"app" url:"app"`
	Owner   string `json:"owner" url:"owner"`
	Sharing string `json:"sharing" url:"sharing"`
	Perms   struct {
		Read  []string `json:"read" url:"perms.read"`
		Write []string `json:"write" url:"perms.write"`
	}
	// CanWrite Indicates whether or not the current user can edit this item
	CanWrite bool `json:"can_write" url:"-"`
	// CanShareGlobal indicates whether or not the current user can change the sharing state to Global
	CanShareGlobal bool `json:"can_share_global" url:"-"`
	// CanShareApp indicates whether or not the current user can change the sharing state to App
	CanShareApp bool `json:"can_share_app" url:"-"`
	// CanShareUser indicates whether or not the current user can change the sharing state to User
	CanShareUser bool `json:"can_share_user" url:"-"`
}

func (*AccessControlList) ServicesNSPath

func (acl *AccessControlList) ServicesNSPath() string

ServicesNSPath returns the user/app path which needs be added after ../servcesNS/ in an API call to splunkd Returns a url-fragment in the form '<user>/app/'. The fragment DOES NOT start with a slash and ENDS with a slash. See: https://docs.splunk.com/Documentation/Splunk/9.0.5/RESTUM/RESTusing#Namespace

func (*AccessControlList) ToURL

func (acl *AccessControlList) ToURL() *url.Values

ToURL encodes the ACL information into URL values which can be used to set properties on the splunkd API

type AppResource

type AppResource struct {
	Label                      string `json:"label"`
	Description                string `json:"description"`
	Author                     string `json:"author"`
	Version                    string `json:"username"`
	Configured                 bool   `json:"configured"`
	Core                       bool   `json:"core"`
	StateChangeRequiresRestart bool   `json:"state_change_requires_restart"`
	Disabled                   bool   `json:"disabled"`
	Visible                    bool   `json:"visible"`
	ShowInNav                  bool   `json:"show_in_nav"`
	ManagedByDeploymentClient  bool   `json:"managed_by_deployment_client"`
	CheckForUpdates            bool   `json:"check_for_updates"`
}

type AppsCollection

type AppsCollection struct {
	// contains filtered or unexported fields
}

func (*AppsCollection) Create

func (col *AppsCollection) Create(entryName string, params *url.Values) (*entry[T], error)

func (*AppsCollection) CreateNS

func (col *AppsCollection) CreateNS(ns *Namespace, entryName string, params *url.Values) (*entry[T], error)

func (*AppsCollection) Delete

func (col *AppsCollection) Delete(entryName string) error

func (*AppsCollection) DeleteEntry

func (col *AppsCollection) DeleteEntry(e *entry[T]) error

func (*AppsCollection) Exists

func (col *AppsCollection) Exists(entryName string) bool

func (*AppsCollection) Get

func (col *AppsCollection) Get(entryName string) (*entry[T], error)

func (*AppsCollection) List

func (col *AppsCollection) List() ([]entry[T], error)

List provides a list of all entres of the collection

func (*AppsCollection) Search

func (col *AppsCollection) Search(filter string) ([]entry[T], error)

Search provides a list of all entres of the collection filtered by 'filter'. 'filter' can be just a value, or a fieldname=value tuple

func (*AppsCollection) Update

func (col *AppsCollection) Update(entryName string, params *url.Values) error

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(splunkdUrl string, insecureSkipVerify bool, proxy string) (*Client, error)

func NewFromDefaults

func NewFromDefaults() (*Client, error)

NewFromDefaults instantiates a client using splunkd's default API endpoint: https://localhost:8089

func NewInteractive

func NewInteractive() (*Client, error)

NewInteractive interactively asks the end-user for necessary configuration parameters to instantiate a splunkd client and login into the API

func (*Client) AuthContext

func (ss *Client) AuthContext() (*ContextResource, error)

Info retrieves generic information about the Splunk instance the client is connected to It caches such information locally, as this is not something which regularly varies

func (*Client) Can

func (ss *Client) Can(capability string) (bool, error)

Can checks whether the logged-in user has the specified capability

func (*Client) GetCredentials

func (ss *Client) GetCredentials() *CredentialsCollection

func (*Client) GetKVStore

func (ss *Client) GetKVStore() *KVStoreCollCollection

func (*Client) GetSessionKey

func (ss *Client) GetSessionKey() string

func (*Client) GetSplunkdURI

func (ss *Client) GetSplunkdURI() string

func (*Client) GetUsers

func (ss *Client) GetUsers() *UsersCollection

func (*Client) Has

func (ss *Client) Has(role string) (bool, error)

Has checks whether the logged-in user has the specified role assigned

func (*Client) Info

func (ss *Client) Info() (*InfoResource, error)

Info retrieves generic information about the Splunk instance the client is connected to It caches such information locally, as this is not something which regularly varies

func (*Client) Login

func (ss *Client) Login(username, password, passcode2FA string) error

func (*Client) LoginWithSessionKey

func (ss *Client) LoginWithSessionKey(sessionKey string) error

func (*Client) LoginWithToken

func (ss *Client) LoginWithToken(authToken string) error

func (*Client) NewLogger

func (ss *Client) NewLogger(name string, flag int, index, host, source, sourcetype string) *log.Logger

func (*Client) SetNamespace

func (ss *Client) SetNamespace(owner, app string, sharing SplunkSharing) error

SetNamespace updates the NameSpace configurations for the session

func (*Client) SetNamespaceFromNS

func (ss *Client) SetNamespaceFromNS(ns Namespace)

SetNamespaceFromNS updates the NameSpace configurations for the session using an existing NameSpace

func (*Client) Username

func (ss *Client) Username() (string, error)

type ConfigResource

type ConfigResource map[string]interface{}

ConfigResource represents the contents of a configuration file stanza.

func (*ConfigResource) GetFloat

func (cr *ConfigResource) GetFloat(key string) (val float32, err error)

func (*ConfigResource) GetInt

func (cr *ConfigResource) GetInt(key string) (val int, err error)

func (*ConfigResource) GetString

func (cr *ConfigResource) GetString(key string) (val string, err error)

type ConfigsCollection

type ConfigsCollection struct {
	// contains filtered or unexported fields
}

ConfigsCollection represents a generic configuration file as managed by the /services/configs/conf-<confFileName> endpoint. You can manage config file stanzas through this endpoint. This also supports custom configuration files defined with a custom SPEC file within etc/apps/<someapp>/README/<somefile>.conf.spec. See: https://docs.splunk.com/Documentation/Splunk/9.0.5/RESTTUT/RESTconfigurations#Updating_Configuration_Files See:https://docs.splunk.com/Documentation/Splunk/9.0.5/RESTREF/RESTconf#configs.2Fconf-.7Bfile.7D

func NewConfigsCollection

func NewConfigsCollection(ss *Client, configFileName string) *ConfigsCollection

func NewConfigsCollectionNS

func NewConfigsCollectionNS(ss *Client, configFileName, owner, app string) *ConfigsCollection

func (*ConfigsCollection) Create

func (col *ConfigsCollection) Create(entryName string, params *url.Values) (*entry[T], error)

func (*ConfigsCollection) CreateNS

func (col *ConfigsCollection) CreateNS(ns *Namespace, entryName string, params *url.Values) (*entry[T], error)

func (*ConfigsCollection) CreateStanza

func (col *ConfigsCollection) CreateStanza(name string, params *url.Values) (*entry[ConfigResource], error)

func (*ConfigsCollection) Delete

func (col *ConfigsCollection) Delete(entryName string) error

func (*ConfigsCollection) DeleteEntry

func (col *ConfigsCollection) DeleteEntry(e *entry[T]) error

func (*ConfigsCollection) Exists

func (col *ConfigsCollection) Exists(entryName string) bool

func (*ConfigsCollection) Get

func (col *ConfigsCollection) Get(entryName string) (*entry[T], error)

func (*ConfigsCollection) GetConfigAsFloat

func (col *ConfigsCollection) GetConfigAsFloat(stanza, configName string) (float32, error)

GetConfigAsFloat retrieves the value of configuration configName of the selected stanza

func (*ConfigsCollection) GetConfigAsInt

func (col *ConfigsCollection) GetConfigAsInt(stanza, configName string) (int, error)

GetConfigAsInt retrieves the value of configuration configName of the selected stanza

func (*ConfigsCollection) GetConfigAsString

func (col *ConfigsCollection) GetConfigAsString(stanza, configName string) (string, error)

GetConfigAsString retrieves the value of configuration configName of the selected stanza

func (*ConfigsCollection) GetStanza

func (col *ConfigsCollection) GetStanza(name string) (*ConfigResource, error)

func (*ConfigsCollection) List

func (col *ConfigsCollection) List() ([]entry[T], error)

List provides a list of all entres of the collection

func (*ConfigsCollection) Search

func (col *ConfigsCollection) Search(filter string) ([]entry[T], error)

Search provides a list of all entres of the collection filtered by 'filter'. 'filter' can be just a value, or a fieldname=value tuple

func (*ConfigsCollection) Update

func (col *ConfigsCollection) Update(entryName string, params *url.Values) error

func (*ConfigsCollection) UpdateACL

func (col *ConfigsCollection) UpdateACL(entryName string, acl AccessControlList) error

https://docs.splunk.com/Documentation/Splunk/9.0.5/RESTUM/RESTusing#Access_Control_List

type ContextResource

type ContextResource struct {
	Capabilities   []string `json:"capabilities"`
	Version        string   `json:"version"`
	DefaultApp     string   `json:"defaultApp"`
	Email          string   `json:"email"`
	LockedOut      bool     `json:"locked-out"`
	Realname       string   `json:"realname"`
	Roles          []string `json:"roles"`
	Username       string   `json:"username"`
	LastLoginEpoch int64    `json:"last_successful_login"`
	LastLogin      time.Time
}

ContextResource is the structure containing the data returned by the current-contex URL

type CredentialResource

type CredentialResource struct {
	Realm         string `json:"realm"`
	Username      string `json:"username"`
	ClearPassword string `json:"clear_password"`
	EncrPassword  string `json:"encr_password"`
}

type CredentialsCollection

type CredentialsCollection struct {
	// contains filtered or unexported fields
}

func NewCredentialsCollection

func NewCredentialsCollection(ss *Client) *CredentialsCollection

func (*CredentialsCollection) Create

func (col *CredentialsCollection) Create(entryName string, params *url.Values) (*entry[T], error)

func (*CredentialsCollection) CreateCred

func (col *CredentialsCollection) CreateCred(user, realm, password string) (*entry[CredentialResource], error)

func (*CredentialsCollection) CreateNS

func (col *CredentialsCollection) CreateNS(ns *Namespace, entryName string, params *url.Values) (*entry[T], error)

func (*CredentialsCollection) Delete

func (col *CredentialsCollection) Delete(entryName string) error

func (*CredentialsCollection) DeleteEntry

func (col *CredentialsCollection) DeleteEntry(e *entry[T]) error

func (*CredentialsCollection) Exists

func (col *CredentialsCollection) Exists(entryName string) bool

func (*CredentialsCollection) Get

func (col *CredentialsCollection) Get(entryName string) (*entry[T], error)

func (*CredentialsCollection) GetCred

func (col *CredentialsCollection) GetCred(user, realm string) (*entry[CredentialResource], error)

func (*CredentialsCollection) List

func (col *CredentialsCollection) List() ([]entry[T], error)

List provides a list of all entres of the collection

func (*CredentialsCollection) Search

func (col *CredentialsCollection) Search(filter string) ([]entry[T], error)

Search provides a list of all entres of the collection filtered by 'filter'. 'filter' can be just a value, or a fieldname=value tuple

func (*CredentialsCollection) Update

func (col *CredentialsCollection) Update(entryName string, params *url.Values) error

func (*CredentialsCollection) UpdateACL

func (col *CredentialsCollection) UpdateACL(entryName string, acl AccessControlList) error

https://docs.splunk.com/Documentation/Splunk/9.0.5/RESTUM/RESTusing#Access_Control_List

func (*CredentialsCollection) UpdateCred

func (col *CredentialsCollection) UpdateCred(user, realm, newPassword string) error

type InfoResource

type InfoResource struct {
	Version              string `json:"version"`
	Build                string `json:"build"`
	CpuArch              string `json:"cpu_arch"`
	Guid                 string `json:"guid"`
	HealthInfo           string `json:"health_info"`
	ServerName           string `json:"serverName"`
	NumberOfCores        int    `json:"numberOfCores"`
	NumberOfVirtualCores int    `json:"numberOfVirtualCores"`
	PhysicalMemoryMB     int    `json:"physicalMemoryMB"`
	OsBuild              string `json:"os_build"`
	OsName               string `json:"os_name"`
	OsVersion            string `json:"os_version"`
}

InfoResource is the structure containing the data returned by the pathInfo URL

type KVStoreCollCollection

type KVStoreCollCollection struct {
	// contains filtered or unexported fields
}

KVStoreCollCollection represents a collection of definitions of KV Store collections as managed by the /services/storage/collections/config endpoint. This also supports custom configuration files defined with a custom SPEC file within etc/apps/<someapp>/README/<somefile>.conf.spec. See: https://docs.splunk.com/Documentation/Splunk/9.0.5/RESTREF/RESTkvstore#storage.2Fcollections.2Fconfig.2F.7Bcollection.7D

func NewKVStoreCollCollection

func NewKVStoreCollCollection(ss *Client) *KVStoreCollCollection

func (*KVStoreCollCollection) Create

func (col *KVStoreCollCollection) Create(entryName string, params *url.Values) (*entry[T], error)

func (*KVStoreCollCollection) CreateKVStoreColl

func (col *KVStoreCollCollection) CreateKVStoreColl(ns *Namespace, entryName string, fields map[string]string, acceleratedFields map[string]string, enforceTypes bool, replicate bool) (*entry[KVStoreCollResource], error)

func (*KVStoreCollCollection) CreateNS

func (col *KVStoreCollCollection) CreateNS(ns *Namespace, entryName string, params *url.Values) (*entry[T], error)

func (*KVStoreCollCollection) Delete

func (col *KVStoreCollCollection) Delete(entryName string) error

func (*KVStoreCollCollection) DeleteEntry

func (col *KVStoreCollCollection) DeleteEntry(e *entry[T]) error

func (*KVStoreCollCollection) Exists

func (col *KVStoreCollCollection) Exists(entryName string) bool

func (*KVStoreCollCollection) Get

func (col *KVStoreCollCollection) Get(entryName string) (*entry[T], error)

func (*KVStoreCollCollection) List

func (col *KVStoreCollCollection) List() ([]entry[T], error)

List provides a list of all entres of the collection

func (*KVStoreCollCollection) Search

func (col *KVStoreCollCollection) Search(filter string) ([]entry[T], error)

Search provides a list of all entres of the collection filtered by 'filter'. 'filter' can be just a value, or a fieldname=value tuple

func (*KVStoreCollCollection) Update

func (col *KVStoreCollCollection) Update(entryName string, params *url.Values) error

func (*KVStoreCollCollection) UpdateACL

func (col *KVStoreCollCollection) UpdateACL(entryName string, acl AccessControlList) error

https://docs.splunk.com/Documentation/Splunk/9.0.5/RESTUM/RESTusing#Access_Control_List

type KVStoreCollResource

type KVStoreCollResource struct {
	Disabled     bool `json:"disabled"`
	EnforceTypes bool `json:"enforceTypes"`
	Replicate    bool `json:"replicate"`

	Fields            map[string]string
	AcceleratedFields map[string]string
}

KVStoreCollResource represents the definition of a KVStore collection

func (*KVStoreCollResource) UnmarshalJSON

func (kvcr *KVStoreCollResource) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the JSON custom unmarshaller interface to properly convert from the API JSON based results to the internal data structure

type KVStoreFieldDefinition

type KVStoreFieldDefinition struct {
	Name string
	Type string
}

type LoginResponse

type LoginResponse struct {
	// LoginResponse manages the results of a login attempt
	// Splunk responds either
	// With HTTP 401
	// 	{"messages":[{"type":"WARN","code":"incorrect_username_or_password","text":"Login failed"}]}
	// or HTTP 200
	//	{"sessionKey":"FKPT2miFNvbSStAl68_IywfGIMQSN5hreU^ss....",
	//	"message":"","code":""}
	SessionKey string `json:"sessionKey"`
	Message    string `json:"message"`
	Code       string `json:"code"`
}

LoginResponse is the structure containing the data returned by the pathLogin URL

type Namespace

type Namespace struct {
	// contains filtered or unexported fields
}

func NewNamespace

func NewNamespace(owner, app string, sharing SplunkSharing) (*Namespace, error)

GetNamespace instantiates a new Splunk namespace

func (*Namespace) GetServicesNSUrl

func (ns *Namespace) GetServicesNSUrl() string

type PropertiesCollection

type PropertiesCollection struct {
	// contains filtered or unexported fields
}

ConfigsCollection represents a generic configuration file as managed by the /services/configs/conf-<confFileName> endpoint. You can manage config file stanzas through this endpoint. This also supports custom configuration files defined with a custom SPEC file within etc/apps/<someapp>/README/<somefile>.conf.spec. See: https://docs.splunk.com/Documentation/Splunk/9.0.5/RESTTUT/RESTconfigurations#Updating_Configuration_Files See:https://docs.splunk.com/Documentation/Splunk/9.0.5/RESTREF/RESTconf#configs.2Fconf-.7Bfile.7D

func NewPropertiesCollection

func NewPropertiesCollection(ss *Client, configFileName string) *PropertiesCollection

func NewPropertiesCollectionNS

func NewPropertiesCollectionNS(ss *Client, configFileName, owner, app string) *PropertiesCollection

func (*PropertiesCollection) Create

func (col *PropertiesCollection) Create(name string, properties *url.Values) error

func (*PropertiesCollection) CreateNS

func (col *PropertiesCollection) CreateNS(ns *Namespace, entryName string, params *url.Values) (*entry[T], error)

func (*PropertiesCollection) CreateStanza

func (col *PropertiesCollection) CreateStanza(name string, properties *url.Values) error

func (*PropertiesCollection) Delete

func (col *PropertiesCollection) Delete(entryName string) error

func (*PropertiesCollection) DeleteEntry

func (col *PropertiesCollection) DeleteEntry(e *entry[T]) error

func (*PropertiesCollection) DeleteStanza

func (col *PropertiesCollection) DeleteStanza(stanza string) error

func (*PropertiesCollection) Exists

func (col *PropertiesCollection) Exists(entryName string) bool

func (*PropertiesCollection) Get

func (col *PropertiesCollection) Get(entryName string) (*entry[T], error)

func (*PropertiesCollection) GetProperty

func (col *PropertiesCollection) GetProperty(stanza, propertyName string) (string, error)

func (*PropertiesCollection) GetStanza

func (col *PropertiesCollection) GetStanza(name string) (map[string]string, error)

func (*PropertiesCollection) List

func (col *PropertiesCollection) List() ([]entry[T], error)

List provides a list of all entres of the collection

func (*PropertiesCollection) Search

func (col *PropertiesCollection) Search(filter string) ([]entry[T], error)

Search provides a list of all entres of the collection filtered by 'filter'. 'filter' can be just a value, or a fieldname=value tuple

func (*PropertiesCollection) SetProperties

func (col *PropertiesCollection) SetProperties(stanza string, properties *url.Values) error

func (*PropertiesCollection) SetProperty

func (col *PropertiesCollection) SetProperty(stanza, propertyName, value string) error

func (*PropertiesCollection) Update

func (col *PropertiesCollection) Update(entryName string, params *url.Values) error

func (*PropertiesCollection) UpdateACL

func (col *PropertiesCollection) UpdateACL(entryName string, acl AccessControlList) error

https://docs.splunk.com/Documentation/Splunk/9.0.5/RESTUM/RESTusing#Access_Control_List

type PropertyResource

type PropertyResource string

ConfigResource represents the contents of a configuration file stanza.

type SplunkSharing

type SplunkSharing string
const (
	SplunkSharingUser   SplunkSharing = "user"
	SplunkSharingApp    SplunkSharing = "app"
	SplunkSharingSystem SplunkSharing = "system"
	SplunkSharingGlobal SplunkSharing = "global"
)

type UserResource

type UserResource struct {
	Realname   string `json:"realname" url:"realname,omitempty"`
	Email      string `json:"email" url:"email,omitempty"`
	DefaultApp string `json:"defaultApp" url:"defaultApp,omitempty"`
	// Password is only needed when creating a new user, or updating its password
	Password string `url:"password,omitempty"`
	// OldPassword is only needed when changing password of an existing user
	OldPassword string   `url:"oldpassword,omitempty"`
	Roles       []string `json:"roles" url:"roles,omitempty"`
	Lang        string   `json:"lang" url:"lang,omitempty"`
	Tz          string   `json:"tz" url:"tz,omitempty"`
	// Indicates whether to force user password change.
	ForceChangePass bool `url:"force-change-pass,omitempty"`
	//DefaultAppIsUserOverride bool     `json:"defaultAppIsUserOverride",url:""`
	//DefaultAppSourceRole     string   `json:"defaultAppSourceRole",url:""`
	LastSuccessfulLogin int64    `json:"last_successful_login" url:"-"`
	LockedOut           bool     `json:"locked-out" url:"-"`
	Capabilities        []string `json:"capabilities" url:"-"`
	UserType            string   `json:"type" url:"-"`
}

type UsersCollection

type UsersCollection struct {
	// contains filtered or unexported fields
}

func NewUsersCollection

func NewUsersCollection(ss *Client) *UsersCollection

func (*UsersCollection) Create

func (col *UsersCollection) Create(entryName string, params *url.Values) (*entry[T], error)

func (*UsersCollection) CreateNS

func (col *UsersCollection) CreateNS(ns *Namespace, entryName string, params *url.Values) (*entry[T], error)

func (*UsersCollection) CreateUser

func (col *UsersCollection) CreateUser(name string, details UserResource) (*entry[UserResource], error)

func (*UsersCollection) Delete

func (col *UsersCollection) Delete(entryName string) error

func (*UsersCollection) DeleteEntry

func (col *UsersCollection) DeleteEntry(e *entry[T]) error

func (*UsersCollection) Exists

func (col *UsersCollection) Exists(entryName string) bool

func (*UsersCollection) Get

func (col *UsersCollection) Get(entryName string) (*entry[T], error)

func (*UsersCollection) List

func (col *UsersCollection) List() ([]entry[T], error)

List provides a list of all entres of the collection

func (*UsersCollection) Search

func (col *UsersCollection) Search(filter string) ([]entry[T], error)

Search provides a list of all entres of the collection filtered by 'filter'. 'filter' can be just a value, or a fieldname=value tuple

func (*UsersCollection) Update

func (col *UsersCollection) Update(entryName string, params *url.Values) error

func (*UsersCollection) UpdateACL

func (col *UsersCollection) UpdateACL(entryName string, acl AccessControlList) error

https://docs.splunk.com/Documentation/Splunk/9.0.5/RESTUM/RESTusing#Access_Control_List

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL