Struct splunk::ServerConfig
source · pub struct ServerConfig {
pub hostname: String,
pub port: u16,
/* private fields */
}
Expand description
What we’re going to use to connect to the server
Fields§
§hostname: String
Server hostname - just something like example.com (or an IP, if you’re like that)
port: u16
Port - defaults to 8089
Implementations§
source§impl ServerConfig
impl ServerConfig
sourcepub fn get_url(&self, endpoint: &str) -> Result<Url, String>
pub fn get_url(&self, endpoint: &str) -> Result<Url, String>
build a url based on the server/endpoint
use std::str::FromStr;
use reqwest::Url;
use splunk::hec::HecClient;
let client = HecClient::new("token", "localhost");
let expected_response = Url::from_str("https://localhost:8088/hello").unwrap();
assert_eq!(client.serverconfig.get_url("/hello").unwrap(), expected_response);
sourcepub fn with_token(self, token: String) -> Self
pub fn with_token(self, token: String) -> Self
Set the authentication method to token and set the token
sourcepub fn with_username_password(self, username: String, password: String) -> Self
pub fn with_username_password(self, username: String, password: String) -> Self
Set the authentication method to basic and set the credentials
sourcepub async fn do_get(&self, endpoint: &str) -> Result<Response, String>
pub async fn do_get(&self, endpoint: &str) -> Result<Response, String>
make a get request to a given endpoint
sourcepub async fn do_get_with_headers(
&self,
endpoint: &str,
add_headers: HeaderMap
) -> Result<Response, String>
pub async fn do_get_with_headers( &self, endpoint: &str, add_headers: HeaderMap ) -> Result<Response, String>
make a get request to a given endpoint and set the headers
sourcepub fn with_hostname(self, hostname: String) -> Self
pub fn with_hostname(self, hostname: String) -> Self
Set the hostname
sourcepub fn with_verify_tls(self, verify_tls: bool) -> Self
pub fn with_verify_tls(self, verify_tls: bool) -> Self
Do we verify TLS on send?
sourcepub fn try_from_env(
configtype: ServerConfigType
) -> Result<ServerConfig, String>
pub fn try_from_env( configtype: ServerConfigType ) -> Result<ServerConfig, String>
Grabs a ServerConfig from environment variables
Trait Implementations§
source§impl Clone for ServerConfig
impl Clone for ServerConfig
source§fn clone(&self) -> ServerConfig
fn clone(&self) -> ServerConfig
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ServerConfig
impl Debug for ServerConfig
source§impl Default for ServerConfig
impl Default for ServerConfig
source§impl<'de> Deserialize<'de> for ServerConfig
impl<'de> Deserialize<'de> for ServerConfig
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more