[−][src]Struct tenable::Tenable
Tenable Client which allows requests against the tenable API
Fields
auth: String
Authentication string
uri: Cow<'a, str>
Uri to send requests against
Implementations
impl<'_> Tenable<'_>
[src]
#[must_use]pub fn new(access_key: &str, secret_key: &str) -> Self
[src]
Creates a new Tenable
client with the given credentials
Arguments
access_key
: Tenable User Access Keysecret_key
: Tenable User Access Key
Example
use tenable::Tenable; let tenable = Tenable::new( "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000" );
pub fn request<'a, O, R, CR, RE, F>(request: CR, fun: F) -> Result<O, Error<RE>> where
CR: Into<Cow<'a, R>>,
R: 'a + HttpRequest<RE, Output = O>,
RE: Debug,
F: FnOnce(Request<Vec<u8>>) -> Result<Response, Error<RE>>,
[src]
CR: Into<Cow<'a, R>>,
R: 'a + HttpRequest<RE, Output = O>,
RE: Debug,
F: FnOnce(Request<Vec<u8>>) -> Result<Response, Error<RE>>,
Executes a synchronous http request using the given function
Arguments
request
: Request to send. Use one of the functions in therequests
module to create a requestfun
: Function which implements sending synchronous requests.
Errors
Fails in the following cases:
- Unable to create a valid Request
- Server responded with error code
- Unable to deserialize the server response
- Custom Errors returned by the function given as
fun
parameter
Example
use std::convert::Infallible; use tenable::{requests::AssetReq, Error, Response, Tenable}; let tenable = Tenable::new( "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000", ); let req = tenable.assets(); let _assets = Tenable::request(req, |_| { Result::<Response, Error<Infallible>>::Ok(todo!("Define a method to send http requests")) }).expect("Unable to list all assets");
pub fn request_with_backoff<'a, O, R, CR, RE, F, BF>(
request: CR,
fun: F,
backoff_fun: BF
) -> Result<O, Error<RE>> where
CR: Into<Cow<'a, R>>,
R: 'a + HttpRequest<RE, Output = O>,
RE: Debug,
F: Fn(Request<Vec<u8>>) -> Result<Response, Error<RE>>,
BF: Fn(Duration),
[src]
request: CR,
fun: F,
backoff_fun: BF
) -> Result<O, Error<RE>> where
CR: Into<Cow<'a, R>>,
R: 'a + HttpRequest<RE, Output = O>,
RE: Debug,
F: Fn(Request<Vec<u8>>) -> Result<Response, Error<RE>>,
BF: Fn(Duration),
Executes a synchronous http request using the given function. Automatically backs off when a Rate Limit is hit
Arguments
request
: Request to send. Use one of the functions in therequests
module to create a requestfun
: Function which implements sending synchronous requests.backoff_fun
: Function which waits for the given Duration
Errors
Fails in the following cases:
- Unable to create a valid Request
- Server responded with error code
- Unable to deserialize the server response
- Custom Errors returned by the function given as
fun
parameter
Example
use std::{convert::Infallible, thread::sleep}; use tenable::{requests::AssetReq, Error, Response, Tenable}; let tenable = Tenable::new( "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000", ); let req = tenable.assets(); let _assets = Tenable::request_with_backoff(req, |_| { Result::<Response, Error<Infallible>>::Ok(todo!("Define a method to send http requests")) }, sleep).expect("Unable to list all assets");
pub async fn request_async<'a, O, R, CR, RE, F, Fut>(
request: CR,
fun: F
) -> Result<O, Error<RE>> where
CR: Into<Cow<'a, R>>,
R: 'a + HttpRequest<RE, Output = O>,
RE: Debug,
F: FnOnce(Request<Vec<u8>>) -> Fut,
Fut: Future<Output = Result<Response, Error<RE>>>,
[src]
request: CR,
fun: F
) -> Result<O, Error<RE>> where
CR: Into<Cow<'a, R>>,
R: 'a + HttpRequest<RE, Output = O>,
RE: Debug,
F: FnOnce(Request<Vec<u8>>) -> Fut,
Fut: Future<Output = Result<Response, Error<RE>>>,
Executes an asynchronous http request using the given function
Arguments
request
: Request to send. Use one of the functions in therequests
module to create a requestfun
: Function which implements sending asynchronous requests.
Errors
Fails in the following cases:
- Unable to create a valid Request
- Server responded with error code
- Unable to deserialize the server response
- Custom Errors returned by the function given as
fun
parameter
Example
tokio
use http::Request; use std::convert::Infallible; use tenable::{requests::AssetReq, Error, Response, Tenable}; async fn request(_req: Request<Vec<u8>>) -> Result::<Response, Error<Infallible>> { Ok(todo!("Define a method to send http requests")) } let tenable = Tenable::new( "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000", ); let req = tenable.assets(); let _assets = Tenable::request_async(req, request).await .expect("Unable to list all assets");
async_std
use http::Request; use std::convert::Infallible; use tenable::{requests::AssetReq, Error, Response, Tenable}; async fn request(_req: Request<Vec<u8>>) -> Result::<Response, Error<Infallible>> { Ok(todo!("Define a method to send http requests")) } let tenable = Tenable::new( "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000", ); let req = tenable.assets(); let _assets = Tenable::request_async(req, request).await .expect("Unable to list all assets");
pub async fn request_with_backoff_async<'a, O, R, CR, RE, F, Fut, BF, FutBF>(
request: CR,
fun: F,
backoff_fun: BF
) -> Result<O, Error<RE>> where
CR: Into<Cow<'a, R>>,
R: 'a + HttpRequest<RE, Output = O>,
RE: Debug,
F: Fn(Request<Vec<u8>>) -> Fut,
Fut: Future<Output = Result<Response, Error<RE>>>,
BF: Fn(Duration) -> FutBF,
FutBF: Future<Output = ()>,
[src]
request: CR,
fun: F,
backoff_fun: BF
) -> Result<O, Error<RE>> where
CR: Into<Cow<'a, R>>,
R: 'a + HttpRequest<RE, Output = O>,
RE: Debug,
F: Fn(Request<Vec<u8>>) -> Fut,
Fut: Future<Output = Result<Response, Error<RE>>>,
BF: Fn(Duration) -> FutBF,
FutBF: Future<Output = ()>,
Executes an asynchronous http request using the given function. Automatically backs off when a Rate Limit is hit
Arguments
request
: Request to send. Use one of the functions in therequests
module to create a requestfun
: Function which implements sending asynchronous requests.backoff_fun
: Function which waits for the given Duration
Errors
Fails in the following cases:
- Unable to create a valid Request
- Server responded with error code
- Unable to deserialize the server response
- Custom Errors returned by the function given as
fun
parameter
Example
tokio
use tokio::time::delay_for; use http::Request; use std::convert::Infallible; use tenable::{requests::AssetReq, Error, Response, Tenable}; async fn request(_req: Request<Vec<u8>>) -> Result::<Response, Error<Infallible>> { Ok(todo!("Define a method to send http requests")) } let tenable = Tenable::new( "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000", ); let req = tenable.assets(); let _assets = Tenable::request_with_backoff_async(req, request, delay_for).await .expect("Unable to list all assets");
async_std
use async_std::task; use http::Request; use std::convert::Infallible; use tenable::{requests::AssetReq, Error, Response, Tenable}; async fn request(_req: Request<Vec<u8>>) -> Result::<Response, Error<Infallible>> { Ok(todo!("Define a method to send http requests")) } let tenable = Tenable::new( "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000", ); let req = tenable.assets(); let _assets = Tenable::request_with_backoff_async(req, request, task::sleep).await .expect("Unable to list all assets");
Trait Implementations
impl<'_> AssetReq for Tenable<'_>
[src]
fn assets(&self) -> AssetsReq<'_>
[src]
fn asset_by_uuid<'a, I: Into<Cow<'a, str>>>(
&'a self,
asset_uuid: I
) -> AssetByUuidReq<'a>
[src]
&'a self,
asset_uuid: I
) -> AssetByUuidReq<'a>
fn acr_update<'a, I: Into<Cow<'a, [Acr]>>>(&'a self, acrs: I) -> AcrUpdate<'a>
[src]
fn assets_move<'a, I: Into<Cow<'a, AssetsMoveDef>>>(
&'a self,
assets_move_def: I
) -> AssetsMove<'a>
[src]
&'a self,
assets_move_def: I
) -> AssetsMove<'a>
impl<'a> Clone for Tenable<'a>
[src]
impl<'a> Debug for Tenable<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for Tenable<'a>
impl<'a> Send for Tenable<'a>
impl<'a> Sync for Tenable<'a>
impl<'a> Unpin for Tenable<'a>
impl<'a> UnwindSafe for Tenable<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
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, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,