use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct UrlscannerGetResponseText<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
response_id: Result<::std::string::String, String>,
}
impl<'a> UrlscannerGetResponseText<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
response_id: Err("response_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn response_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.response_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for response_id failed".to_string()
});
self
}
pub async fn send(self) -> Result<ResponseValue<ByteStream>, Error<()>> {
let Self {
client,
account_id,
response_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let response_id = response_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/urlscanner/response/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&response_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client.client.get(url).headers(header_map).build()?;
let info = OperationInfo {
operation_id: "urlscanner_get_response_text",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => Ok(ResponseValue::stream(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct UrlscannerGetScan<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
scan_id: Result<::uuid::Uuid, String>,
full: Result<bool, String>,
}
impl<'a> UrlscannerGetScan<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
scan_id: Err("scan_id was not initialized".to_string()),
full: Err("full was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn scan_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::uuid::Uuid>,
{
self.scan_id = value
.try_into()
.map_err(|_| "conversion to `:: uuid :: Uuid` for scan_id failed".to_string());
self
}
pub fn full<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.full = value
.try_into()
.map_err(|_| "conversion to `bool` for full failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
scan_id,
full,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let scan_id = scan_id.map_err(Error::InvalidRequest)?;
let full = full.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/urlscanner/scan/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&scan_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new("full", &full))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "urlscanner_get_scan",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct UrlscannerGetScanHar<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
scan_id: Result<::uuid::Uuid, String>,
}
impl<'a> UrlscannerGetScanHar<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
scan_id: Err("scan_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn scan_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::uuid::Uuid>,
{
self.scan_id = value
.try_into()
.map_err(|_| "conversion to `:: uuid :: Uuid` for scan_id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
scan_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let scan_id = scan_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/urlscanner/scan/{}/har",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&scan_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "urlscanner_get_scan_har",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct UrlscannerGetScanScreenshot<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
scan_id: Result<::uuid::Uuid, String>,
resolution: Result<types::UrlscannerGetScanScreenshotResolution, String>,
}
impl<'a> UrlscannerGetScanScreenshot<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
scan_id: Err("scan_id was not initialized".to_string()),
resolution: Err("resolution was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn scan_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::uuid::Uuid>,
{
self.scan_id = value
.try_into()
.map_err(|_| "conversion to `:: uuid :: Uuid` for scan_id failed".to_string());
self
}
pub fn resolution<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::UrlscannerGetScanScreenshotResolution>,
{
self.resolution = value.try_into().map_err(|_| {
"conversion to `UrlscannerGetScanScreenshotResolution` for resolution failed"
.to_string()
});
self
}
pub async fn send(self) -> Result<ResponseValue<ByteStream>, Error<()>> {
let Self {
client,
account_id,
scan_id,
resolution,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let scan_id = scan_id.map_err(Error::InvalidRequest)?;
let resolution = resolution.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/urlscanner/scan/{}/screenshot",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&scan_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.query(&progenitor_client::QueryParam::new(
"resolution",
&resolution,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "urlscanner_get_scan_screenshot",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => Ok(ResponseValue::stream(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct UrlscannerCreateScanBulkV2<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
body: Result<::std::vec::Vec<types::UrlscannerCreateScanBulkV2BodyItem>, String>,
}
impl<'a> UrlscannerCreateScanBulkV2<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::vec::Vec<types::UrlscannerCreateScanBulkV2BodyItem>>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: std :: vec :: Vec < UrlscannerCreateScanBulkV2BodyItem >` for body failed" . to_string ()) ;
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/urlscanner/v2/bulk",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "urlscanner_create_scan_bulk_v2",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct UrlscannerGetScanDomV2<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
scan_id: Result<::uuid::Uuid, String>,
}
impl<'a> UrlscannerGetScanDomV2<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
scan_id: Err("scan_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn scan_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::uuid::Uuid>,
{
self.scan_id = value
.try_into()
.map_err(|_| "conversion to `:: uuid :: Uuid` for scan_id failed".to_string());
self
}
pub async fn send(self) -> Result<ResponseValue<ByteStream>, Error<()>> {
let Self {
client,
account_id,
scan_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let scan_id = scan_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/urlscanner/v2/dom/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&scan_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client.client.get(url).headers(header_map).build()?;
let info = OperationInfo {
operation_id: "urlscanner_get_scan_dom_v2",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => Ok(ResponseValue::stream(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct UrlscannerGetScanHarV2<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
scan_id: Result<::uuid::Uuid, String>,
}
impl<'a> UrlscannerGetScanHarV2<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
scan_id: Err("scan_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn scan_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::uuid::Uuid>,
{
self.scan_id = value
.try_into()
.map_err(|_| "conversion to `:: uuid :: Uuid` for scan_id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
scan_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let scan_id = scan_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/urlscanner/v2/har/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&scan_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "urlscanner_get_scan_har_v2",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct UrlscannerGetResponseV2<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
response_id: Result<::std::string::String, String>,
}
impl<'a> UrlscannerGetResponseV2<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
response_id: Err("response_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn response_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.response_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for response_id failed".to_string()
});
self
}
pub async fn send(self) -> Result<ResponseValue<ByteStream>, Error<()>> {
let Self {
client,
account_id,
response_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let response_id = response_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/urlscanner/v2/responses/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&response_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client.client.get(url).headers(header_map).build()?;
let info = OperationInfo {
operation_id: "urlscanner_get_response_v2",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => Ok(ResponseValue::stream(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct UrlscannerGetScanV2<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
scan_id: Result<::uuid::Uuid, String>,
}
impl<'a> UrlscannerGetScanV2<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
scan_id: Err("scan_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn scan_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::uuid::Uuid>,
{
self.scan_id = value
.try_into()
.map_err(|_| "conversion to `:: uuid :: Uuid` for scan_id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
scan_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let scan_id = scan_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/urlscanner/v2/result/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&scan_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "urlscanner_get_scan_v2",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct UrlscannerCreateScanV2<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
body: Result<types::builder::UrlscannerCreateScanV2Body, String>,
}
impl<'a> UrlscannerCreateScanV2<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::UrlscannerCreateScanV2Body>,
<V as std::convert::TryInto<types::UrlscannerCreateScanV2Body>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `UrlscannerCreateScanV2Body` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::UrlscannerCreateScanV2Body,
) -> types::builder::UrlscannerCreateScanV2Body,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::UrlscannerCreateScanV2Body::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/urlscanner/v2/scan",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "urlscanner_create_scan_v2",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct UrlscannerGetScanScreenshotV2<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
scan_id: Result<::uuid::Uuid, String>,
resolution: Result<types::UrlscannerGetScanScreenshotV2Resolution, String>,
}
impl<'a> UrlscannerGetScanScreenshotV2<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
scan_id: Err("scan_id was not initialized".to_string()),
resolution: Err("resolution was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn scan_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::uuid::Uuid>,
{
self.scan_id = value
.try_into()
.map_err(|_| "conversion to `:: uuid :: Uuid` for scan_id failed".to_string());
self
}
pub fn resolution<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::UrlscannerGetScanScreenshotV2Resolution>,
{
self.resolution = value.try_into().map_err(|_| {
"conversion to `UrlscannerGetScanScreenshotV2Resolution` for resolution failed"
.to_string()
});
self
}
pub async fn send(self) -> Result<ResponseValue<ByteStream>, Error<()>> {
let Self {
client,
account_id,
scan_id,
resolution,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let scan_id = scan_id.map_err(Error::InvalidRequest)?;
let resolution = resolution.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/urlscanner/v2/screenshots/{}.png",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&scan_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.query(&progenitor_client::QueryParam::new(
"resolution",
&resolution,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "urlscanner_get_scan_screenshot_v2",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => Ok(ResponseValue::stream(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct UrlscannerSearchScansV2<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
q: Result<::std::string::String, String>,
size: Result<i64, String>,
}
impl<'a> UrlscannerSearchScansV2<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
q: Err("q was not initialized".to_string()),
size: Err("size was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn q<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.q = value
.try_into()
.map_err(|_| "conversion to `:: std :: string :: String` for q failed".to_string());
self
}
pub fn size<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i64>,
{
self.size = value
.try_into()
.map_err(|_| "conversion to `i64` for size failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
q,
size,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let q = q.map_err(Error::InvalidRequest)?;
let size = size.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/urlscanner/v2/search",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new("q", &q))
.query(&progenitor_client::QueryParam::new("size", &size))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "urlscanner_search_scans_v2",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}