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]

[src]

Creates a new ApiKey. This removes any leading or trailing whitespace.

[src]

Converts the API key to an Authorization header.

Trait Implementations

impl Debug for ApiKey
[src]

[src]

Formats the value using the given formatter.

impl Clone for ApiKey
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq for ApiKey
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Eq for ApiKey
[src]

impl Scheme for ApiKey
[src]

[src]

An optional Scheme name. Read more

[src]

Format the Scheme data into a header value.

impl From<String> for ApiKey
[src]

[src]

Performs the conversion.

impl<'a> From<&'a str> for ApiKey
[src]

[src]

Performs the conversion.

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.

The associated error which can be returned from parsing.

[src]

Parses a string s to return a value of this type. Read more