[−][src]Struct extrahop::ApiKey
A REST API key which authenticates the caller to the ExtraHop.
Clients must pass an API key in the Authorization
header of every request. The
[extrahop::Client
] type handles this automatically, or it can be done manually.
Examples
Manually adding the header to a request:
use reqwest::header::Authorization; use extrahop::ApiKey; let header = Authorization(ApiKey::new("your-key")); let _req = reqwest::Client::new().get("https://extrahop.com/api/v1/devices").header(header).send();
As a best practice, API keys should be collected from the user at runtime, or stored in an environment variable or separate file; they should not be checked in with source code.
Methods
impl ApiKey
[src]
pub fn new<S: Into<String>>(key: S) -> Self
[src]
Creates a new ApiKey
. This removes any leading or trailing whitespace.
pub fn to_header(self) -> Authorization<ApiKey>
[src]
Converts the API key to an Authorization header.
Trait Implementations
impl Eq for ApiKey
[src]
impl Clone for ApiKey
[src]
fn clone(&self) -> ApiKey
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl PartialEq<ApiKey> for ApiKey
[src]
impl From<String> for ApiKey
[src]
impl<'a> From<&'a str> for ApiKey
[src]
impl From<ApiKey> for Authorization<ApiKey>
[src]
impl Debug for ApiKey
[src]
impl FromStr for ApiKey
[src]
Parses a full HTTP header; required by reqwest::header::Scheme
.
This should not be used for converting a regular string into an API key; for
that, use ApiKey::new
instead.
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self>
[src]
impl Scheme for ApiKey
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<Q, K> Equivalent for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,