use std::collections::HashMap;
use std::cell::RefCell;
use std::default::Default;
use std::collections::BTreeSet;
use std::error::Error as StdError;
use serde_json as json;
use std::io;
use std::fs;
use std::mem;
use hyper::client::connect;
use tokio::io::{AsyncRead, AsyncWrite};
use tokio::time::sleep;
use tower_service;
use serde::{Serialize, Deserialize};
use crate::{client, client::GetToken, client::serde_with};
#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
pub enum Scope {
UserlocationBeaconRegistry,
}
impl AsRef<str> for Scope {
fn as_ref(&self) -> &str {
match *self {
Scope::UserlocationBeaconRegistry => "https://www.googleapis.com/auth/userlocation.beacon.registry",
}
}
}
impl Default for Scope {
fn default() -> Scope {
Scope::UserlocationBeaconRegistry
}
}
#[derive(Clone)]
pub struct Proximitybeacon<S> {
pub client: hyper::Client<S, hyper::body::Body>,
pub auth: Box<dyn client::GetToken>,
_user_agent: String,
_base_url: String,
_root_url: String,
}
impl<'a, S> client::Hub for Proximitybeacon<S> {}
impl<'a, S> Proximitybeacon<S> {
pub fn new<A: 'static + client::GetToken>(client: hyper::Client<S, hyper::body::Body>, auth: A) -> Proximitybeacon<S> {
Proximitybeacon {
client,
auth: Box::new(auth),
_user_agent: "google-api-rust-client/5.0.4".to_string(),
_base_url: "https://proximitybeacon.googleapis.com/".to_string(),
_root_url: "https://proximitybeacon.googleapis.com/".to_string(),
}
}
pub fn beaconinfo(&'a self) -> BeaconinfoMethods<'a, S> {
BeaconinfoMethods { hub: &self }
}
pub fn beacons(&'a self) -> BeaconMethods<'a, S> {
BeaconMethods { hub: &self }
}
pub fn methods(&'a self) -> MethodMethods<'a, S> {
MethodMethods { hub: &self }
}
pub fn namespaces(&'a self) -> NamespaceMethods<'a, S> {
NamespaceMethods { hub: &self }
}
pub fn user_agent(&mut self, agent_name: String) -> String {
mem::replace(&mut self._user_agent, agent_name)
}
pub fn base_url(&mut self, new_base_url: String) -> String {
mem::replace(&mut self._base_url, new_base_url)
}
pub fn root_url(&mut self, new_root_url: String) -> String {
mem::replace(&mut self._root_url, new_root_url)
}
}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AdvertisedId {
#[serde_as(as = "Option<::client::serde::standard_base64::Wrapper>")]
pub id: Option<Vec<u8>>,
#[serde(rename="type")]
pub type_: Option<String>,
}
impl client::Part for AdvertisedId {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct AttachmentInfo {
#[serde_as(as = "Option<::client::serde::standard_base64::Wrapper>")]
pub data: Option<Vec<u8>>,
#[serde(rename="maxDistanceMeters")]
pub max_distance_meters: Option<f64>,
#[serde(rename="namespacedType")]
pub namespaced_type: Option<String>,
}
impl client::Part for AttachmentInfo {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Beacon {
#[serde(rename="advertisedId")]
pub advertised_id: Option<AdvertisedId>,
#[serde(rename="beaconName")]
pub beacon_name: Option<String>,
pub description: Option<String>,
#[serde(rename="ephemeralIdRegistration")]
pub ephemeral_id_registration: Option<EphemeralIdRegistration>,
#[serde(rename="expectedStability")]
pub expected_stability: Option<String>,
#[serde(rename="indoorLevel")]
pub indoor_level: Option<IndoorLevel>,
#[serde(rename="latLng")]
pub lat_lng: Option<LatLng>,
#[serde(rename="placeId")]
pub place_id: Option<String>,
pub properties: Option<HashMap<String, String>>,
#[serde(rename="provisioningKey")]
#[serde_as(as = "Option<::client::serde::standard_base64::Wrapper>")]
pub provisioning_key: Option<Vec<u8>>,
pub status: Option<String>,
}
impl client::RequestValue for Beacon {}
impl client::Resource for Beacon {}
impl client::ResponseResult for Beacon {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct BeaconAttachment {
#[serde(rename="attachmentName")]
pub attachment_name: Option<String>,
#[serde(rename="creationTimeMs")]
pub creation_time_ms: Option<client::chrono::DateTime<client::chrono::offset::Utc>>,
#[serde_as(as = "Option<::client::serde::standard_base64::Wrapper>")]
pub data: Option<Vec<u8>>,
#[serde(rename="maxDistanceMeters")]
pub max_distance_meters: Option<f64>,
#[serde(rename="namespacedType")]
pub namespaced_type: Option<String>,
}
impl client::RequestValue for BeaconAttachment {}
impl client::ResponseResult for BeaconAttachment {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct BeaconInfo {
#[serde(rename="advertisedId")]
pub advertised_id: Option<AdvertisedId>,
pub attachments: Option<Vec<AttachmentInfo>>,
#[serde(rename="beaconName")]
pub beacon_name: Option<String>,
}
impl client::Part for BeaconInfo {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Date {
pub day: Option<i32>,
pub month: Option<i32>,
pub year: Option<i32>,
}
impl client::Part for Date {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct DeleteAttachmentsResponse {
#[serde(rename="numDeleted")]
pub num_deleted: Option<i32>,
}
impl client::ResponseResult for DeleteAttachmentsResponse {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Diagnostics {
pub alerts: Option<Vec<String>>,
#[serde(rename="beaconName")]
pub beacon_name: Option<String>,
#[serde(rename="estimatedLowBatteryDate")]
pub estimated_low_battery_date: Option<Date>,
}
impl client::Part for Diagnostics {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Empty { _never_set: Option<bool> }
impl client::ResponseResult for Empty {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct EphemeralIdRegistration {
#[serde(rename="beaconEcdhPublicKey")]
#[serde_as(as = "Option<::client::serde::standard_base64::Wrapper>")]
pub beacon_ecdh_public_key: Option<Vec<u8>>,
#[serde(rename="beaconIdentityKey")]
#[serde_as(as = "Option<::client::serde::standard_base64::Wrapper>")]
pub beacon_identity_key: Option<Vec<u8>>,
#[serde(rename="initialClockValue")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub initial_clock_value: Option<u64>,
#[serde(rename="initialEid")]
#[serde_as(as = "Option<::client::serde::standard_base64::Wrapper>")]
pub initial_eid: Option<Vec<u8>>,
#[serde(rename="rotationPeriodExponent")]
pub rotation_period_exponent: Option<u32>,
#[serde(rename="serviceEcdhPublicKey")]
#[serde_as(as = "Option<::client::serde::standard_base64::Wrapper>")]
pub service_ecdh_public_key: Option<Vec<u8>>,
}
impl client::Part for EphemeralIdRegistration {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct EphemeralIdRegistrationParams {
#[serde(rename="maxRotationPeriodExponent")]
pub max_rotation_period_exponent: Option<u32>,
#[serde(rename="minRotationPeriodExponent")]
pub min_rotation_period_exponent: Option<u32>,
#[serde(rename="serviceEcdhPublicKey")]
#[serde_as(as = "Option<::client::serde::standard_base64::Wrapper>")]
pub service_ecdh_public_key: Option<Vec<u8>>,
}
impl client::ResponseResult for EphemeralIdRegistrationParams {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GetInfoForObservedBeaconsRequest {
#[serde(rename="namespacedTypes")]
pub namespaced_types: Option<Vec<String>>,
pub observations: Option<Vec<Observation>>,
}
impl client::RequestValue for GetInfoForObservedBeaconsRequest {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct GetInfoForObservedBeaconsResponse {
pub beacons: Option<Vec<BeaconInfo>>,
}
impl client::ResponseResult for GetInfoForObservedBeaconsResponse {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct IndoorLevel {
pub name: Option<String>,
}
impl client::Part for IndoorLevel {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct LatLng {
pub latitude: Option<f64>,
pub longitude: Option<f64>,
}
impl client::Part for LatLng {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct ListBeaconAttachmentsResponse {
pub attachments: Option<Vec<BeaconAttachment>>,
}
impl client::ResponseResult for ListBeaconAttachmentsResponse {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct ListBeaconsResponse {
pub beacons: Option<Vec<Beacon>>,
#[serde(rename="nextPageToken")]
pub next_page_token: Option<String>,
#[serde(rename="totalCount")]
#[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")]
pub total_count: Option<i64>,
}
impl client::ResponseResult for ListBeaconsResponse {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct ListDiagnosticsResponse {
pub diagnostics: Option<Vec<Diagnostics>>,
#[serde(rename="nextPageToken")]
pub next_page_token: Option<String>,
}
impl client::ResponseResult for ListDiagnosticsResponse {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct ListNamespacesResponse {
pub namespaces: Option<Vec<Namespace>>,
}
impl client::ResponseResult for ListNamespacesResponse {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Namespace {
#[serde(rename="namespaceName")]
pub namespace_name: Option<String>,
#[serde(rename="servingVisibility")]
pub serving_visibility: Option<String>,
}
impl client::RequestValue for Namespace {}
impl client::Resource for Namespace {}
impl client::ResponseResult for Namespace {}
#[serde_with::serde_as(crate = "::client::serde_with")]
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct Observation {
#[serde(rename="advertisedId")]
pub advertised_id: Option<AdvertisedId>,
#[serde_as(as = "Option<::client::serde::standard_base64::Wrapper>")]
pub telemetry: Option<Vec<u8>>,
#[serde(rename="timestampMs")]
pub timestamp_ms: Option<client::chrono::DateTime<client::chrono::offset::Utc>>,
}
impl client::Part for Observation {}
pub struct BeaconinfoMethods<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
}
impl<'a, S> client::MethodsBuilder for BeaconinfoMethods<'a, S> {}
impl<'a, S> BeaconinfoMethods<'a, S> {
pub fn getforobserved(&self, request: GetInfoForObservedBeaconsRequest) -> BeaconinfoGetforobservedCall<'a, S> {
BeaconinfoGetforobservedCall {
hub: self.hub,
_request: request,
_delegate: Default::default(),
_additional_params: Default::default(),
}
}
}
pub struct BeaconMethods<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
}
impl<'a, S> client::MethodsBuilder for BeaconMethods<'a, S> {}
impl<'a, S> BeaconMethods<'a, S> {
pub fn attachments_batch_delete(&self, beacon_name: &str) -> BeaconAttachmentBatchDeleteCall<'a, S> {
BeaconAttachmentBatchDeleteCall {
hub: self.hub,
_beacon_name: beacon_name.to_string(),
_project_id: Default::default(),
_namespaced_type: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn attachments_create(&self, request: BeaconAttachment, beacon_name: &str) -> BeaconAttachmentCreateCall<'a, S> {
BeaconAttachmentCreateCall {
hub: self.hub,
_request: request,
_beacon_name: beacon_name.to_string(),
_project_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn attachments_delete(&self, attachment_name: &str) -> BeaconAttachmentDeleteCall<'a, S> {
BeaconAttachmentDeleteCall {
hub: self.hub,
_attachment_name: attachment_name.to_string(),
_project_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn attachments_list(&self, beacon_name: &str) -> BeaconAttachmentListCall<'a, S> {
BeaconAttachmentListCall {
hub: self.hub,
_beacon_name: beacon_name.to_string(),
_project_id: Default::default(),
_namespaced_type: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn diagnostics_list(&self, beacon_name: &str) -> BeaconDiagnosticListCall<'a, S> {
BeaconDiagnosticListCall {
hub: self.hub,
_beacon_name: beacon_name.to_string(),
_project_id: Default::default(),
_page_token: Default::default(),
_page_size: Default::default(),
_alert_filter: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn activate(&self, beacon_name: &str) -> BeaconActivateCall<'a, S> {
BeaconActivateCall {
hub: self.hub,
_beacon_name: beacon_name.to_string(),
_project_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn deactivate(&self, beacon_name: &str) -> BeaconDeactivateCall<'a, S> {
BeaconDeactivateCall {
hub: self.hub,
_beacon_name: beacon_name.to_string(),
_project_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn decommission(&self, beacon_name: &str) -> BeaconDecommissionCall<'a, S> {
BeaconDecommissionCall {
hub: self.hub,
_beacon_name: beacon_name.to_string(),
_project_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn delete(&self, beacon_name: &str) -> BeaconDeleteCall<'a, S> {
BeaconDeleteCall {
hub: self.hub,
_beacon_name: beacon_name.to_string(),
_project_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn get(&self, beacon_name: &str) -> BeaconGetCall<'a, S> {
BeaconGetCall {
hub: self.hub,
_beacon_name: beacon_name.to_string(),
_project_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn list(&self) -> BeaconListCall<'a, S> {
BeaconListCall {
hub: self.hub,
_q: Default::default(),
_project_id: Default::default(),
_page_token: Default::default(),
_page_size: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn register(&self, request: Beacon) -> BeaconRegisterCall<'a, S> {
BeaconRegisterCall {
hub: self.hub,
_request: request,
_project_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn update(&self, request: Beacon, beacon_name: &str) -> BeaconUpdateCall<'a, S> {
BeaconUpdateCall {
hub: self.hub,
_request: request,
_beacon_name: beacon_name.to_string(),
_project_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
pub struct NamespaceMethods<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
}
impl<'a, S> client::MethodsBuilder for NamespaceMethods<'a, S> {}
impl<'a, S> NamespaceMethods<'a, S> {
pub fn list(&self) -> NamespaceListCall<'a, S> {
NamespaceListCall {
hub: self.hub,
_project_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn update(&self, request: Namespace, namespace_name: &str) -> NamespaceUpdateCall<'a, S> {
NamespaceUpdateCall {
hub: self.hub,
_request: request,
_namespace_name: namespace_name.to_string(),
_project_id: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
pub struct MethodMethods<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
}
impl<'a, S> client::MethodsBuilder for MethodMethods<'a, S> {}
impl<'a, S> MethodMethods<'a, S> {
pub fn get_eidparams(&self) -> MethodGetEidparamCall<'a, S> {
MethodGetEidparamCall {
hub: self.hub,
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
pub struct BeaconinfoGetforobservedCall<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
_request: GetInfoForObservedBeaconsRequest,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, S> client::CallBuilder for BeaconinfoGetforobservedCall<'a, S> {}
impl<'a, S> BeaconinfoGetforobservedCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, GetInfoForObservedBeaconsResponse)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "proximitybeacon.beaconinfo.getforobserved",
http_method: hyper::Method::POST });
for &field in ["alt"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v1beta1/beaconinfo:getforobserved";
match dlg.api_key() {
Some(value) => params.push("key", value),
None => {
dlg.finished(false);
return Err(client::Error::MissingAPIKey)
}
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader =
{
let mut value = json::value::to_value(&self._request).expect("serde to work");
client::remove_json_null_values(&mut value);
let mut dst = io::Cursor::new(Vec::with_capacity(128));
json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let client::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(client::Error::HttpError(err))
}
Ok(mut res) => {
if !res.status().is_success() {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
let (parts, _) = res.into_parts();
let body = hyper::Body::from(res_body_string.clone());
let restored_response = hyper::Response::from_parts(parts, body);
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
continue;
}
dlg.finished(false);
return match server_response {
Some(error_value) => Err(client::Error::BadRequest(error_value)),
None => Err(client::Error::Failure(restored_response)),
}
}
let result_value = {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
match json::from_str(&res_body_string) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&res_body_string, &err);
return Err(client::Error::JsonDecodeError(res_body_string, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
pub fn request(mut self, new_value: GetInfoForObservedBeaconsRequest) -> BeaconinfoGetforobservedCall<'a, S> {
self._request = new_value;
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> BeaconinfoGetforobservedCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> BeaconinfoGetforobservedCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
}
pub struct BeaconAttachmentBatchDeleteCall<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
_beacon_name: String,
_project_id: Option<String>,
_namespaced_type: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for BeaconAttachmentBatchDeleteCall<'a, S> {}
impl<'a, S> BeaconAttachmentBatchDeleteCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, DeleteAttachmentsResponse)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "proximitybeacon.beacons.attachments.batchDelete",
http_method: hyper::Method::POST });
for &field in ["alt", "beaconName", "projectId", "namespacedType"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("beaconName", self._beacon_name);
if let Some(value) = self._project_id.as_ref() {
params.push("projectId", value);
}
if let Some(value) = self._namespaced_type.as_ref() {
params.push("namespacedType", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v1beta1/{+beaconName}/attachments:batchDelete";
if self._scopes.is_empty() {
self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string());
}
for &(find_this, param_name) in [("{+beaconName}", "beaconName")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["beaconName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.body(hyper::body::Body::empty());
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let client::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(client::Error::HttpError(err))
}
Ok(mut res) => {
if !res.status().is_success() {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
let (parts, _) = res.into_parts();
let body = hyper::Body::from(res_body_string.clone());
let restored_response = hyper::Response::from_parts(parts, body);
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
continue;
}
dlg.finished(false);
return match server_response {
Some(error_value) => Err(client::Error::BadRequest(error_value)),
None => Err(client::Error::Failure(restored_response)),
}
}
let result_value = {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
match json::from_str(&res_body_string) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&res_body_string, &err);
return Err(client::Error::JsonDecodeError(res_body_string, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
pub fn beacon_name(mut self, new_value: &str) -> BeaconAttachmentBatchDeleteCall<'a, S> {
self._beacon_name = new_value.to_string();
self
}
pub fn project_id(mut self, new_value: &str) -> BeaconAttachmentBatchDeleteCall<'a, S> {
self._project_id = Some(new_value.to_string());
self
}
pub fn namespaced_type(mut self, new_value: &str) -> BeaconAttachmentBatchDeleteCall<'a, S> {
self._namespaced_type = Some(new_value.to_string());
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> BeaconAttachmentBatchDeleteCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> BeaconAttachmentBatchDeleteCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> BeaconAttachmentBatchDeleteCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> BeaconAttachmentBatchDeleteCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> BeaconAttachmentBatchDeleteCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct BeaconAttachmentCreateCall<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
_request: BeaconAttachment,
_beacon_name: String,
_project_id: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for BeaconAttachmentCreateCall<'a, S> {}
impl<'a, S> BeaconAttachmentCreateCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, BeaconAttachment)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "proximitybeacon.beacons.attachments.create",
http_method: hyper::Method::POST });
for &field in ["alt", "beaconName", "projectId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("beaconName", self._beacon_name);
if let Some(value) = self._project_id.as_ref() {
params.push("projectId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v1beta1/{+beaconName}/attachments";
if self._scopes.is_empty() {
self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string());
}
for &(find_this, param_name) in [("{+beaconName}", "beaconName")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["beaconName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader =
{
let mut value = json::value::to_value(&self._request).expect("serde to work");
client::remove_json_null_values(&mut value);
let mut dst = io::Cursor::new(Vec::with_capacity(128));
json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let client::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(client::Error::HttpError(err))
}
Ok(mut res) => {
if !res.status().is_success() {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
let (parts, _) = res.into_parts();
let body = hyper::Body::from(res_body_string.clone());
let restored_response = hyper::Response::from_parts(parts, body);
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
continue;
}
dlg.finished(false);
return match server_response {
Some(error_value) => Err(client::Error::BadRequest(error_value)),
None => Err(client::Error::Failure(restored_response)),
}
}
let result_value = {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
match json::from_str(&res_body_string) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&res_body_string, &err);
return Err(client::Error::JsonDecodeError(res_body_string, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
pub fn request(mut self, new_value: BeaconAttachment) -> BeaconAttachmentCreateCall<'a, S> {
self._request = new_value;
self
}
pub fn beacon_name(mut self, new_value: &str) -> BeaconAttachmentCreateCall<'a, S> {
self._beacon_name = new_value.to_string();
self
}
pub fn project_id(mut self, new_value: &str) -> BeaconAttachmentCreateCall<'a, S> {
self._project_id = Some(new_value.to_string());
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> BeaconAttachmentCreateCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> BeaconAttachmentCreateCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> BeaconAttachmentCreateCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> BeaconAttachmentCreateCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> BeaconAttachmentCreateCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct BeaconAttachmentDeleteCall<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
_attachment_name: String,
_project_id: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for BeaconAttachmentDeleteCall<'a, S> {}
impl<'a, S> BeaconAttachmentDeleteCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Empty)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "proximitybeacon.beacons.attachments.delete",
http_method: hyper::Method::DELETE });
for &field in ["alt", "attachmentName", "projectId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("attachmentName", self._attachment_name);
if let Some(value) = self._project_id.as_ref() {
params.push("projectId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v1beta1/{+attachmentName}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string());
}
for &(find_this, param_name) in [("{+attachmentName}", "attachmentName")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["attachmentName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::DELETE)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.body(hyper::body::Body::empty());
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let client::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(client::Error::HttpError(err))
}
Ok(mut res) => {
if !res.status().is_success() {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
let (parts, _) = res.into_parts();
let body = hyper::Body::from(res_body_string.clone());
let restored_response = hyper::Response::from_parts(parts, body);
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
continue;
}
dlg.finished(false);
return match server_response {
Some(error_value) => Err(client::Error::BadRequest(error_value)),
None => Err(client::Error::Failure(restored_response)),
}
}
let result_value = {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
match json::from_str(&res_body_string) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&res_body_string, &err);
return Err(client::Error::JsonDecodeError(res_body_string, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
pub fn attachment_name(mut self, new_value: &str) -> BeaconAttachmentDeleteCall<'a, S> {
self._attachment_name = new_value.to_string();
self
}
pub fn project_id(mut self, new_value: &str) -> BeaconAttachmentDeleteCall<'a, S> {
self._project_id = Some(new_value.to_string());
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> BeaconAttachmentDeleteCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> BeaconAttachmentDeleteCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> BeaconAttachmentDeleteCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> BeaconAttachmentDeleteCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> BeaconAttachmentDeleteCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct BeaconAttachmentListCall<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
_beacon_name: String,
_project_id: Option<String>,
_namespaced_type: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for BeaconAttachmentListCall<'a, S> {}
impl<'a, S> BeaconAttachmentListCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, ListBeaconAttachmentsResponse)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "proximitybeacon.beacons.attachments.list",
http_method: hyper::Method::GET });
for &field in ["alt", "beaconName", "projectId", "namespacedType"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("beaconName", self._beacon_name);
if let Some(value) = self._project_id.as_ref() {
params.push("projectId", value);
}
if let Some(value) = self._namespaced_type.as_ref() {
params.push("namespacedType", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v1beta1/{+beaconName}/attachments";
if self._scopes.is_empty() {
self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string());
}
for &(find_this, param_name) in [("{+beaconName}", "beaconName")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["beaconName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.body(hyper::body::Body::empty());
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let client::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(client::Error::HttpError(err))
}
Ok(mut res) => {
if !res.status().is_success() {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
let (parts, _) = res.into_parts();
let body = hyper::Body::from(res_body_string.clone());
let restored_response = hyper::Response::from_parts(parts, body);
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
continue;
}
dlg.finished(false);
return match server_response {
Some(error_value) => Err(client::Error::BadRequest(error_value)),
None => Err(client::Error::Failure(restored_response)),
}
}
let result_value = {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
match json::from_str(&res_body_string) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&res_body_string, &err);
return Err(client::Error::JsonDecodeError(res_body_string, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
pub fn beacon_name(mut self, new_value: &str) -> BeaconAttachmentListCall<'a, S> {
self._beacon_name = new_value.to_string();
self
}
pub fn project_id(mut self, new_value: &str) -> BeaconAttachmentListCall<'a, S> {
self._project_id = Some(new_value.to_string());
self
}
pub fn namespaced_type(mut self, new_value: &str) -> BeaconAttachmentListCall<'a, S> {
self._namespaced_type = Some(new_value.to_string());
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> BeaconAttachmentListCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> BeaconAttachmentListCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> BeaconAttachmentListCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> BeaconAttachmentListCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> BeaconAttachmentListCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct BeaconDiagnosticListCall<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
_beacon_name: String,
_project_id: Option<String>,
_page_token: Option<String>,
_page_size: Option<i32>,
_alert_filter: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for BeaconDiagnosticListCall<'a, S> {}
impl<'a, S> BeaconDiagnosticListCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, ListDiagnosticsResponse)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "proximitybeacon.beacons.diagnostics.list",
http_method: hyper::Method::GET });
for &field in ["alt", "beaconName", "projectId", "pageToken", "pageSize", "alertFilter"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(7 + self._additional_params.len());
params.push("beaconName", self._beacon_name);
if let Some(value) = self._project_id.as_ref() {
params.push("projectId", value);
}
if let Some(value) = self._page_token.as_ref() {
params.push("pageToken", value);
}
if let Some(value) = self._page_size.as_ref() {
params.push("pageSize", value.to_string());
}
if let Some(value) = self._alert_filter.as_ref() {
params.push("alertFilter", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v1beta1/{+beaconName}/diagnostics";
if self._scopes.is_empty() {
self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string());
}
for &(find_this, param_name) in [("{+beaconName}", "beaconName")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["beaconName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.body(hyper::body::Body::empty());
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let client::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(client::Error::HttpError(err))
}
Ok(mut res) => {
if !res.status().is_success() {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
let (parts, _) = res.into_parts();
let body = hyper::Body::from(res_body_string.clone());
let restored_response = hyper::Response::from_parts(parts, body);
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
continue;
}
dlg.finished(false);
return match server_response {
Some(error_value) => Err(client::Error::BadRequest(error_value)),
None => Err(client::Error::Failure(restored_response)),
}
}
let result_value = {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
match json::from_str(&res_body_string) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&res_body_string, &err);
return Err(client::Error::JsonDecodeError(res_body_string, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
pub fn beacon_name(mut self, new_value: &str) -> BeaconDiagnosticListCall<'a, S> {
self._beacon_name = new_value.to_string();
self
}
pub fn project_id(mut self, new_value: &str) -> BeaconDiagnosticListCall<'a, S> {
self._project_id = Some(new_value.to_string());
self
}
pub fn page_token(mut self, new_value: &str) -> BeaconDiagnosticListCall<'a, S> {
self._page_token = Some(new_value.to_string());
self
}
pub fn page_size(mut self, new_value: i32) -> BeaconDiagnosticListCall<'a, S> {
self._page_size = Some(new_value);
self
}
pub fn alert_filter(mut self, new_value: &str) -> BeaconDiagnosticListCall<'a, S> {
self._alert_filter = Some(new_value.to_string());
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> BeaconDiagnosticListCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> BeaconDiagnosticListCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> BeaconDiagnosticListCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> BeaconDiagnosticListCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> BeaconDiagnosticListCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct BeaconActivateCall<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
_beacon_name: String,
_project_id: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for BeaconActivateCall<'a, S> {}
impl<'a, S> BeaconActivateCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Empty)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "proximitybeacon.beacons.activate",
http_method: hyper::Method::POST });
for &field in ["alt", "beaconName", "projectId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("beaconName", self._beacon_name);
if let Some(value) = self._project_id.as_ref() {
params.push("projectId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v1beta1/{+beaconName}:activate";
if self._scopes.is_empty() {
self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string());
}
for &(find_this, param_name) in [("{+beaconName}", "beaconName")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["beaconName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.body(hyper::body::Body::empty());
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let client::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(client::Error::HttpError(err))
}
Ok(mut res) => {
if !res.status().is_success() {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
let (parts, _) = res.into_parts();
let body = hyper::Body::from(res_body_string.clone());
let restored_response = hyper::Response::from_parts(parts, body);
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
continue;
}
dlg.finished(false);
return match server_response {
Some(error_value) => Err(client::Error::BadRequest(error_value)),
None => Err(client::Error::Failure(restored_response)),
}
}
let result_value = {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
match json::from_str(&res_body_string) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&res_body_string, &err);
return Err(client::Error::JsonDecodeError(res_body_string, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
pub fn beacon_name(mut self, new_value: &str) -> BeaconActivateCall<'a, S> {
self._beacon_name = new_value.to_string();
self
}
pub fn project_id(mut self, new_value: &str) -> BeaconActivateCall<'a, S> {
self._project_id = Some(new_value.to_string());
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> BeaconActivateCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> BeaconActivateCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> BeaconActivateCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> BeaconActivateCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> BeaconActivateCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct BeaconDeactivateCall<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
_beacon_name: String,
_project_id: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for BeaconDeactivateCall<'a, S> {}
impl<'a, S> BeaconDeactivateCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Empty)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "proximitybeacon.beacons.deactivate",
http_method: hyper::Method::POST });
for &field in ["alt", "beaconName", "projectId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("beaconName", self._beacon_name);
if let Some(value) = self._project_id.as_ref() {
params.push("projectId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v1beta1/{+beaconName}:deactivate";
if self._scopes.is_empty() {
self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string());
}
for &(find_this, param_name) in [("{+beaconName}", "beaconName")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["beaconName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.body(hyper::body::Body::empty());
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let client::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(client::Error::HttpError(err))
}
Ok(mut res) => {
if !res.status().is_success() {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
let (parts, _) = res.into_parts();
let body = hyper::Body::from(res_body_string.clone());
let restored_response = hyper::Response::from_parts(parts, body);
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
continue;
}
dlg.finished(false);
return match server_response {
Some(error_value) => Err(client::Error::BadRequest(error_value)),
None => Err(client::Error::Failure(restored_response)),
}
}
let result_value = {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
match json::from_str(&res_body_string) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&res_body_string, &err);
return Err(client::Error::JsonDecodeError(res_body_string, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
pub fn beacon_name(mut self, new_value: &str) -> BeaconDeactivateCall<'a, S> {
self._beacon_name = new_value.to_string();
self
}
pub fn project_id(mut self, new_value: &str) -> BeaconDeactivateCall<'a, S> {
self._project_id = Some(new_value.to_string());
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> BeaconDeactivateCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> BeaconDeactivateCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> BeaconDeactivateCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> BeaconDeactivateCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> BeaconDeactivateCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct BeaconDecommissionCall<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
_beacon_name: String,
_project_id: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for BeaconDecommissionCall<'a, S> {}
impl<'a, S> BeaconDecommissionCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Empty)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "proximitybeacon.beacons.decommission",
http_method: hyper::Method::POST });
for &field in ["alt", "beaconName", "projectId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("beaconName", self._beacon_name);
if let Some(value) = self._project_id.as_ref() {
params.push("projectId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v1beta1/{+beaconName}:decommission";
if self._scopes.is_empty() {
self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string());
}
for &(find_this, param_name) in [("{+beaconName}", "beaconName")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["beaconName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.body(hyper::body::Body::empty());
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let client::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(client::Error::HttpError(err))
}
Ok(mut res) => {
if !res.status().is_success() {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
let (parts, _) = res.into_parts();
let body = hyper::Body::from(res_body_string.clone());
let restored_response = hyper::Response::from_parts(parts, body);
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
continue;
}
dlg.finished(false);
return match server_response {
Some(error_value) => Err(client::Error::BadRequest(error_value)),
None => Err(client::Error::Failure(restored_response)),
}
}
let result_value = {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
match json::from_str(&res_body_string) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&res_body_string, &err);
return Err(client::Error::JsonDecodeError(res_body_string, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
pub fn beacon_name(mut self, new_value: &str) -> BeaconDecommissionCall<'a, S> {
self._beacon_name = new_value.to_string();
self
}
pub fn project_id(mut self, new_value: &str) -> BeaconDecommissionCall<'a, S> {
self._project_id = Some(new_value.to_string());
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> BeaconDecommissionCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> BeaconDecommissionCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> BeaconDecommissionCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> BeaconDecommissionCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> BeaconDecommissionCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct BeaconDeleteCall<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
_beacon_name: String,
_project_id: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for BeaconDeleteCall<'a, S> {}
impl<'a, S> BeaconDeleteCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Empty)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "proximitybeacon.beacons.delete",
http_method: hyper::Method::DELETE });
for &field in ["alt", "beaconName", "projectId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("beaconName", self._beacon_name);
if let Some(value) = self._project_id.as_ref() {
params.push("projectId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v1beta1/{+beaconName}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string());
}
for &(find_this, param_name) in [("{+beaconName}", "beaconName")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["beaconName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::DELETE)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.body(hyper::body::Body::empty());
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let client::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(client::Error::HttpError(err))
}
Ok(mut res) => {
if !res.status().is_success() {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
let (parts, _) = res.into_parts();
let body = hyper::Body::from(res_body_string.clone());
let restored_response = hyper::Response::from_parts(parts, body);
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
continue;
}
dlg.finished(false);
return match server_response {
Some(error_value) => Err(client::Error::BadRequest(error_value)),
None => Err(client::Error::Failure(restored_response)),
}
}
let result_value = {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
match json::from_str(&res_body_string) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&res_body_string, &err);
return Err(client::Error::JsonDecodeError(res_body_string, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
pub fn beacon_name(mut self, new_value: &str) -> BeaconDeleteCall<'a, S> {
self._beacon_name = new_value.to_string();
self
}
pub fn project_id(mut self, new_value: &str) -> BeaconDeleteCall<'a, S> {
self._project_id = Some(new_value.to_string());
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> BeaconDeleteCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> BeaconDeleteCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> BeaconDeleteCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> BeaconDeleteCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> BeaconDeleteCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct BeaconGetCall<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
_beacon_name: String,
_project_id: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for BeaconGetCall<'a, S> {}
impl<'a, S> BeaconGetCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Beacon)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "proximitybeacon.beacons.get",
http_method: hyper::Method::GET });
for &field in ["alt", "beaconName", "projectId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
params.push("beaconName", self._beacon_name);
if let Some(value) = self._project_id.as_ref() {
params.push("projectId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v1beta1/{+beaconName}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string());
}
for &(find_this, param_name) in [("{+beaconName}", "beaconName")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["beaconName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.body(hyper::body::Body::empty());
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let client::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(client::Error::HttpError(err))
}
Ok(mut res) => {
if !res.status().is_success() {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
let (parts, _) = res.into_parts();
let body = hyper::Body::from(res_body_string.clone());
let restored_response = hyper::Response::from_parts(parts, body);
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
continue;
}
dlg.finished(false);
return match server_response {
Some(error_value) => Err(client::Error::BadRequest(error_value)),
None => Err(client::Error::Failure(restored_response)),
}
}
let result_value = {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
match json::from_str(&res_body_string) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&res_body_string, &err);
return Err(client::Error::JsonDecodeError(res_body_string, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
pub fn beacon_name(mut self, new_value: &str) -> BeaconGetCall<'a, S> {
self._beacon_name = new_value.to_string();
self
}
pub fn project_id(mut self, new_value: &str) -> BeaconGetCall<'a, S> {
self._project_id = Some(new_value.to_string());
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> BeaconGetCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> BeaconGetCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> BeaconGetCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> BeaconGetCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> BeaconGetCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct BeaconListCall<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
_q: Option<String>,
_project_id: Option<String>,
_page_token: Option<String>,
_page_size: Option<i32>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for BeaconListCall<'a, S> {}
impl<'a, S> BeaconListCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, ListBeaconsResponse)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "proximitybeacon.beacons.list",
http_method: hyper::Method::GET });
for &field in ["alt", "q", "projectId", "pageToken", "pageSize"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
if let Some(value) = self._q.as_ref() {
params.push("q", value);
}
if let Some(value) = self._project_id.as_ref() {
params.push("projectId", value);
}
if let Some(value) = self._page_token.as_ref() {
params.push("pageToken", value);
}
if let Some(value) = self._page_size.as_ref() {
params.push("pageSize", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v1beta1/beacons";
if self._scopes.is_empty() {
self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string());
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.body(hyper::body::Body::empty());
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let client::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(client::Error::HttpError(err))
}
Ok(mut res) => {
if !res.status().is_success() {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
let (parts, _) = res.into_parts();
let body = hyper::Body::from(res_body_string.clone());
let restored_response = hyper::Response::from_parts(parts, body);
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
continue;
}
dlg.finished(false);
return match server_response {
Some(error_value) => Err(client::Error::BadRequest(error_value)),
None => Err(client::Error::Failure(restored_response)),
}
}
let result_value = {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
match json::from_str(&res_body_string) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&res_body_string, &err);
return Err(client::Error::JsonDecodeError(res_body_string, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
pub fn q(mut self, new_value: &str) -> BeaconListCall<'a, S> {
self._q = Some(new_value.to_string());
self
}
pub fn project_id(mut self, new_value: &str) -> BeaconListCall<'a, S> {
self._project_id = Some(new_value.to_string());
self
}
pub fn page_token(mut self, new_value: &str) -> BeaconListCall<'a, S> {
self._page_token = Some(new_value.to_string());
self
}
pub fn page_size(mut self, new_value: i32) -> BeaconListCall<'a, S> {
self._page_size = Some(new_value);
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> BeaconListCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> BeaconListCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> BeaconListCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> BeaconListCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> BeaconListCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct BeaconRegisterCall<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
_request: Beacon,
_project_id: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for BeaconRegisterCall<'a, S> {}
impl<'a, S> BeaconRegisterCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Beacon)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "proximitybeacon.beacons.register",
http_method: hyper::Method::POST });
for &field in ["alt", "projectId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
if let Some(value) = self._project_id.as_ref() {
params.push("projectId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v1beta1/beacons:register";
if self._scopes.is_empty() {
self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string());
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader =
{
let mut value = json::value::to_value(&self._request).expect("serde to work");
client::remove_json_null_values(&mut value);
let mut dst = io::Cursor::new(Vec::with_capacity(128));
json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::POST)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let client::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(client::Error::HttpError(err))
}
Ok(mut res) => {
if !res.status().is_success() {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
let (parts, _) = res.into_parts();
let body = hyper::Body::from(res_body_string.clone());
let restored_response = hyper::Response::from_parts(parts, body);
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
continue;
}
dlg.finished(false);
return match server_response {
Some(error_value) => Err(client::Error::BadRequest(error_value)),
None => Err(client::Error::Failure(restored_response)),
}
}
let result_value = {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
match json::from_str(&res_body_string) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&res_body_string, &err);
return Err(client::Error::JsonDecodeError(res_body_string, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
pub fn request(mut self, new_value: Beacon) -> BeaconRegisterCall<'a, S> {
self._request = new_value;
self
}
pub fn project_id(mut self, new_value: &str) -> BeaconRegisterCall<'a, S> {
self._project_id = Some(new_value.to_string());
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> BeaconRegisterCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> BeaconRegisterCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> BeaconRegisterCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> BeaconRegisterCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> BeaconRegisterCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct BeaconUpdateCall<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
_request: Beacon,
_beacon_name: String,
_project_id: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for BeaconUpdateCall<'a, S> {}
impl<'a, S> BeaconUpdateCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Beacon)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "proximitybeacon.beacons.update",
http_method: hyper::Method::PUT });
for &field in ["alt", "beaconName", "projectId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("beaconName", self._beacon_name);
if let Some(value) = self._project_id.as_ref() {
params.push("projectId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v1beta1/{+beaconName}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string());
}
for &(find_this, param_name) in [("{+beaconName}", "beaconName")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["beaconName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader =
{
let mut value = json::value::to_value(&self._request).expect("serde to work");
client::remove_json_null_values(&mut value);
let mut dst = io::Cursor::new(Vec::with_capacity(128));
json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::PUT)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let client::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(client::Error::HttpError(err))
}
Ok(mut res) => {
if !res.status().is_success() {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
let (parts, _) = res.into_parts();
let body = hyper::Body::from(res_body_string.clone());
let restored_response = hyper::Response::from_parts(parts, body);
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
continue;
}
dlg.finished(false);
return match server_response {
Some(error_value) => Err(client::Error::BadRequest(error_value)),
None => Err(client::Error::Failure(restored_response)),
}
}
let result_value = {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
match json::from_str(&res_body_string) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&res_body_string, &err);
return Err(client::Error::JsonDecodeError(res_body_string, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
pub fn request(mut self, new_value: Beacon) -> BeaconUpdateCall<'a, S> {
self._request = new_value;
self
}
pub fn beacon_name(mut self, new_value: &str) -> BeaconUpdateCall<'a, S> {
self._beacon_name = new_value.to_string();
self
}
pub fn project_id(mut self, new_value: &str) -> BeaconUpdateCall<'a, S> {
self._project_id = Some(new_value.to_string());
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> BeaconUpdateCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> BeaconUpdateCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> BeaconUpdateCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> BeaconUpdateCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> BeaconUpdateCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct NamespaceListCall<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
_project_id: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for NamespaceListCall<'a, S> {}
impl<'a, S> NamespaceListCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, ListNamespacesResponse)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "proximitybeacon.namespaces.list",
http_method: hyper::Method::GET });
for &field in ["alt", "projectId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
if let Some(value) = self._project_id.as_ref() {
params.push("projectId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v1beta1/namespaces";
if self._scopes.is_empty() {
self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string());
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.body(hyper::body::Body::empty());
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let client::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(client::Error::HttpError(err))
}
Ok(mut res) => {
if !res.status().is_success() {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
let (parts, _) = res.into_parts();
let body = hyper::Body::from(res_body_string.clone());
let restored_response = hyper::Response::from_parts(parts, body);
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
continue;
}
dlg.finished(false);
return match server_response {
Some(error_value) => Err(client::Error::BadRequest(error_value)),
None => Err(client::Error::Failure(restored_response)),
}
}
let result_value = {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
match json::from_str(&res_body_string) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&res_body_string, &err);
return Err(client::Error::JsonDecodeError(res_body_string, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
pub fn project_id(mut self, new_value: &str) -> NamespaceListCall<'a, S> {
self._project_id = Some(new_value.to_string());
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> NamespaceListCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> NamespaceListCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> NamespaceListCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> NamespaceListCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> NamespaceListCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct NamespaceUpdateCall<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
_request: Namespace,
_namespace_name: String,
_project_id: Option<String>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for NamespaceUpdateCall<'a, S> {}
impl<'a, S> NamespaceUpdateCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Namespace)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "proximitybeacon.namespaces.update",
http_method: hyper::Method::PUT });
for &field in ["alt", "namespaceName", "projectId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("namespaceName", self._namespace_name);
if let Some(value) = self._project_id.as_ref() {
params.push("projectId", value);
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v1beta1/{+namespaceName}";
if self._scopes.is_empty() {
self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string());
}
for &(find_this, param_name) in [("{+namespaceName}", "namespaceName")].iter() {
url = params.uri_replacement(url, param_name, find_this, true);
}
{
let to_remove = ["namespaceName"];
params.remove_params(&to_remove);
}
let url = params.parse_with_url(&url);
let mut json_mime_type = mime::APPLICATION_JSON;
let mut request_value_reader =
{
let mut value = json::value::to_value(&self._request).expect("serde to work");
client::remove_json_null_values(&mut value);
let mut dst = io::Cursor::new(Vec::with_capacity(128));
json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::PUT)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.header(CONTENT_TYPE, json_mime_type.to_string())
.header(CONTENT_LENGTH, request_size as u64)
.body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let client::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(client::Error::HttpError(err))
}
Ok(mut res) => {
if !res.status().is_success() {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
let (parts, _) = res.into_parts();
let body = hyper::Body::from(res_body_string.clone());
let restored_response = hyper::Response::from_parts(parts, body);
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
continue;
}
dlg.finished(false);
return match server_response {
Some(error_value) => Err(client::Error::BadRequest(error_value)),
None => Err(client::Error::Failure(restored_response)),
}
}
let result_value = {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
match json::from_str(&res_body_string) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&res_body_string, &err);
return Err(client::Error::JsonDecodeError(res_body_string, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
pub fn request(mut self, new_value: Namespace) -> NamespaceUpdateCall<'a, S> {
self._request = new_value;
self
}
pub fn namespace_name(mut self, new_value: &str) -> NamespaceUpdateCall<'a, S> {
self._namespace_name = new_value.to_string();
self
}
pub fn project_id(mut self, new_value: &str) -> NamespaceUpdateCall<'a, S> {
self._project_id = Some(new_value.to_string());
self
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> NamespaceUpdateCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> NamespaceUpdateCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> NamespaceUpdateCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> NamespaceUpdateCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> NamespaceUpdateCall<'a, S> {
self._scopes.clear();
self
}
}
pub struct MethodGetEidparamCall<'a, S>
where S: 'a {
hub: &'a Proximitybeacon<S>,
_delegate: Option<&'a mut dyn client::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>
}
impl<'a, S> client::CallBuilder for MethodGetEidparamCall<'a, S> {}
impl<'a, S> MethodGetEidparamCall<'a, S>
where
S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
{
pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, EphemeralIdRegistrationParams)> {
use std::io::{Read, Seek};
use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
use client::{ToParts, url::Params};
use std::borrow::Cow;
let mut dd = client::DefaultDelegate;
let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(client::MethodInfo { id: "proximitybeacon.getEidparams",
http_method: hyper::Method::GET });
for &field in ["alt"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(client::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(2 + self._additional_params.len());
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "v1beta1/eidparams";
if self._scopes.is_empty() {
self._scopes.insert(Scope::UserlocationBeaconRegistry.as_ref().to_string());
}
let url = params.parse_with_url(&url);
loop {
let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
Ok(token) => token,
Err(e) => {
match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(client::Error::MissingToken(e));
}
}
}
};
let mut req_result = {
let client = &self.hub.client;
dlg.pre_request();
let mut req_builder = hyper::Request::builder()
.method(hyper::Method::GET)
.uri(url.as_str())
.header(USER_AGENT, self.hub._user_agent.clone());
if let Some(token) = token.as_ref() {
req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
}
let request = req_builder
.body(hyper::body::Body::empty());
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let client::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(client::Error::HttpError(err))
}
Ok(mut res) => {
if !res.status().is_success() {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
let (parts, _) = res.into_parts();
let body = hyper::Body::from(res_body_string.clone());
let restored_response = hyper::Response::from_parts(parts, body);
let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
sleep(d).await;
continue;
}
dlg.finished(false);
return match server_response {
Some(error_value) => Err(client::Error::BadRequest(error_value)),
None => Err(client::Error::Failure(restored_response)),
}
}
let result_value = {
let res_body_string = client::get_body_as_string(res.body_mut()).await;
match json::from_str(&res_body_string) {
Ok(decoded) => (res, decoded),
Err(err) => {
dlg.response_json_decode_error(&res_body_string, &err);
return Err(client::Error::JsonDecodeError(res_body_string, err));
}
}
};
dlg.finished(true);
return Ok(result_value)
}
}
}
}
pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MethodGetEidparamCall<'a, S> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> MethodGetEidparamCall<'a, S>
where T: AsRef<str> {
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
pub fn add_scope<St>(mut self, scope: St) -> MethodGetEidparamCall<'a, S>
where St: AsRef<str> {
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> MethodGetEidparamCall<'a, S>
where I: IntoIterator<Item = St>,
St: AsRef<str> {
self._scopes
.extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
self
}
pub fn clear_scopes(mut self) -> MethodGetEidparamCall<'a, S> {
self._scopes.clear();
self
}
}