[][src]Struct extrahop::ApiKey

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().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_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.

impl Scheme for ApiKey[src]

Auto Trait Implementations

impl Send for ApiKey

impl Sync for ApiKey

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<Q, K> Equivalent for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> Erased for T