use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct WebAnalyticsGetSite<'a> {
client: &'a crate::Client,
account_id: Result<types::RumIdentifier, String>,
site_id: Result<types::RumIdentifier, String>,
}
impl<'a> WebAnalyticsGetSite<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::RumIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `RumIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::RumIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `RumIdentifier` for site_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,
site_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/rum/site_info/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_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: "web_analytics_get_site",
};
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 WebAnalyticsUpdateSite<'a> {
client: &'a crate::Client,
account_id: Result<types::RumIdentifier, String>,
site_id: Result<types::RumIdentifier, String>,
body: Result<types::builder::RumUpdateSiteRequest, String>,
}
impl<'a> WebAnalyticsUpdateSite<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_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<types::RumIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `RumIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::RumIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `RumIdentifier` for site_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::RumUpdateSiteRequest>,
<V as std::convert::TryInto<types::RumUpdateSiteRequest>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `RumUpdateSiteRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::RumUpdateSiteRequest,
) -> types::builder::RumUpdateSiteRequest,
{
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,
site_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::RumUpdateSiteRequest::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/rum/site_info/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_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
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "web_analytics_update_site",
};
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 WebAnalyticsDeleteSite<'a> {
client: &'a crate::Client,
account_id: Result<types::RumIdentifier, String>,
site_id: Result<types::RumIdentifier, String>,
}
impl<'a> WebAnalyticsDeleteSite<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
site_id: Err("site_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::RumIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `RumIdentifier` for account_id failed".to_string());
self
}
pub fn site_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::RumIdentifier>,
{
self.site_id = value
.try_into()
.map_err(|_| "conversion to `RumIdentifier` for site_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,
site_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let site_id = site_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/rum/site_info/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&site_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
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "web_analytics_delete_site",
};
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 WebAnalyticsCreateRule<'a> {
client: &'a crate::Client,
account_id: Result<types::RumIdentifier, String>,
ruleset_id: Result<types::RumRulesetIdentifier, String>,
body: Result<types::builder::RumCreateRuleRequest, String>,
}
impl<'a> WebAnalyticsCreateRule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
ruleset_id: Err("ruleset_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<types::RumIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `RumIdentifier` for account_id failed".to_string());
self
}
pub fn ruleset_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::RumRulesetIdentifier>,
{
self.ruleset_id = value.try_into().map_err(|_| {
"conversion to `RumRulesetIdentifier` for ruleset_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::RumCreateRuleRequest>,
<V as std::convert::TryInto<types::RumCreateRuleRequest>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `RumCreateRuleRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::RumCreateRuleRequest,
) -> types::builder::RumCreateRuleRequest,
{
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,
ruleset_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let ruleset_id = ruleset_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::RumCreateRuleRequest::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/rum/v2/{}/rule",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&ruleset_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: "web_analytics_create_rule",
};
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 WebAnalyticsUpdateRule<'a> {
client: &'a crate::Client,
account_id: Result<types::RumIdentifier, String>,
ruleset_id: Result<types::RumRulesetIdentifier, String>,
rule_id: Result<types::RumRuleIdentifier, String>,
body: Result<types::builder::RumCreateRuleRequest, String>,
}
impl<'a> WebAnalyticsUpdateRule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
ruleset_id: Err("ruleset_id was not initialized".to_string()),
rule_id: Err("rule_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<types::RumIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `RumIdentifier` for account_id failed".to_string());
self
}
pub fn ruleset_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::RumRulesetIdentifier>,
{
self.ruleset_id = value.try_into().map_err(|_| {
"conversion to `RumRulesetIdentifier` for ruleset_id failed".to_string()
});
self
}
pub fn rule_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::RumRuleIdentifier>,
{
self.rule_id = value
.try_into()
.map_err(|_| "conversion to `RumRuleIdentifier` for rule_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::RumCreateRuleRequest>,
<V as std::convert::TryInto<types::RumCreateRuleRequest>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `RumCreateRuleRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::RumCreateRuleRequest,
) -> types::builder::RumCreateRuleRequest,
{
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,
ruleset_id,
rule_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let ruleset_id = ruleset_id.map_err(Error::InvalidRequest)?;
let rule_id = rule_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::RumCreateRuleRequest::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/rum/v2/{}/rule/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&ruleset_id.to_string()),
encode_path(&rule_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
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "web_analytics_update_rule",
};
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 WebAnalyticsDeleteRule<'a> {
client: &'a crate::Client,
account_id: Result<types::RumIdentifier, String>,
ruleset_id: Result<types::RumRulesetIdentifier, String>,
rule_id: Result<types::RumRuleIdentifier, String>,
}
impl<'a> WebAnalyticsDeleteRule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
ruleset_id: Err("ruleset_id was not initialized".to_string()),
rule_id: Err("rule_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::RumIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `RumIdentifier` for account_id failed".to_string());
self
}
pub fn ruleset_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::RumRulesetIdentifier>,
{
self.ruleset_id = value.try_into().map_err(|_| {
"conversion to `RumRulesetIdentifier` for ruleset_id failed".to_string()
});
self
}
pub fn rule_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::RumRuleIdentifier>,
{
self.rule_id = value
.try_into()
.map_err(|_| "conversion to `RumRuleIdentifier` for rule_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,
ruleset_id,
rule_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let ruleset_id = ruleset_id.map_err(Error::InvalidRequest)?;
let rule_id = rule_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/rum/v2/{}/rule/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&ruleset_id.to_string()),
encode_path(&rule_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
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "web_analytics_delete_rule",
};
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 WebAnalyticsListRules<'a> {
client: &'a crate::Client,
account_id: Result<types::RumIdentifier, String>,
ruleset_id: Result<types::RumRulesetIdentifier, String>,
}
impl<'a> WebAnalyticsListRules<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
ruleset_id: Err("ruleset_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::RumIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `RumIdentifier` for account_id failed".to_string());
self
}
pub fn ruleset_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::RumRulesetIdentifier>,
{
self.ruleset_id = value.try_into().map_err(|_| {
"conversion to `RumRulesetIdentifier` for ruleset_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,
ruleset_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let ruleset_id = ruleset_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/rum/v2/{}/rules",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&ruleset_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: "web_analytics_list_rules",
};
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 WebAnalyticsModifyRules<'a> {
client: &'a crate::Client,
account_id: Result<types::RumIdentifier, String>,
ruleset_id: Result<types::RumRulesetIdentifier, String>,
body: Result<types::builder::RumModifyRulesRequest, String>,
}
impl<'a> WebAnalyticsModifyRules<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
ruleset_id: Err("ruleset_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<types::RumIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `RumIdentifier` for account_id failed".to_string());
self
}
pub fn ruleset_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::RumRulesetIdentifier>,
{
self.ruleset_id = value.try_into().map_err(|_| {
"conversion to `RumRulesetIdentifier` for ruleset_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::RumModifyRulesRequest>,
<V as std::convert::TryInto<types::RumModifyRulesRequest>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `RumModifyRulesRequest` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::RumModifyRulesRequest,
) -> types::builder::RumModifyRulesRequest,
{
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,
ruleset_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let ruleset_id = ruleset_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::RumModifyRulesRequest::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/rum/v2/{}/rules",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&ruleset_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: "web_analytics_modify_rules",
};
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)),
}
}
}