Struct extrahop::ApiKey
[−]
[src]
pub struct 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().unwrap().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]
fn new<S: Into<String>>(key: S) -> Self
[src]
Creates a new ApiKey
. This removes any leading or trailing whitespace.
fn to_header(self) -> Authorization<ApiKey>
[src]
Converts the API key to an Authorization header.
Trait Implementations
impl Debug for ApiKey
[src]
impl Clone for ApiKey
[src]
fn clone(&self) -> ApiKey
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl PartialEq for ApiKey
[src]
fn eq(&self, __arg_0: &ApiKey) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &ApiKey) -> bool
[src]
This method tests for !=
.
impl Eq for ApiKey
[src]
impl Scheme for ApiKey
[src]
fn scheme() -> Option<&'static str>
[src]
An optional Scheme name. Read more
fn fmt_scheme(&self, f: &mut Formatter) -> Result
[src]
Format the Scheme data into a header value.
impl From<String> for ApiKey
[src]
impl<'a> From<&'a str> 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.