#![allow(clippy::ptr_arg)]
use std::collections::{BTreeSet, HashMap};
use tokio::time::sleep;
#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
pub enum Scope {
AppLicensing,
}
impl AsRef<str> for Scope {
fn as_ref(&self) -> &str {
match *self {
Scope::AppLicensing => "https://www.googleapis.com/auth/apps.licensing",
}
}
}
#[allow(clippy::derivable_impls)]
impl Default for Scope {
fn default() -> Scope {
Scope::AppLicensing
}
}
#[derive(Clone)]
pub struct Licensing<C> {
pub client: common::Client<C>,
pub auth: Box<dyn common::GetToken>,
_user_agent: String,
_base_url: String,
_root_url: String,
}
impl<C> common::Hub for Licensing<C> {}
impl<'a, C> Licensing<C> {
pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Licensing<C> {
Licensing {
client,
auth: Box::new(auth),
_user_agent: "google-api-rust-client/7.0.0".to_string(),
_base_url: "https://licensing.googleapis.com/".to_string(),
_root_url: "https://licensing.googleapis.com/".to_string(),
}
}
pub fn license_assignments(&'a self) -> LicenseAssignmentMethods<'a, C> {
LicenseAssignmentMethods { hub: self }
}
pub fn user_agent(&mut self, agent_name: String) -> String {
std::mem::replace(&mut self._user_agent, agent_name)
}
pub fn base_url(&mut self, new_base_url: String) -> String {
std::mem::replace(&mut self._base_url, new_base_url)
}
pub fn root_url(&mut self, new_root_url: String) -> String {
std::mem::replace(&mut self._root_url, new_root_url)
}
}
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Empty {
_never_set: Option<bool>,
}
impl common::ResponseResult for Empty {}
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LicenseAssignment {
pub etags: Option<String>,
pub kind: Option<String>,
#[serde(rename = "productId")]
pub product_id: Option<String>,
#[serde(rename = "productName")]
pub product_name: Option<String>,
#[serde(rename = "selfLink")]
pub self_link: Option<String>,
#[serde(rename = "skuId")]
pub sku_id: Option<String>,
#[serde(rename = "skuName")]
pub sku_name: Option<String>,
#[serde(rename = "userId")]
pub user_id: Option<String>,
}
impl common::RequestValue for LicenseAssignment {}
impl common::Resource for LicenseAssignment {}
impl common::ResponseResult for LicenseAssignment {}
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LicenseAssignmentInsert {
#[serde(rename = "userId")]
pub user_id: Option<String>,
}
impl common::RequestValue for LicenseAssignmentInsert {}
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LicenseAssignmentList {
pub etag: Option<String>,
pub items: Option<Vec<LicenseAssignment>>,
pub kind: Option<String>,
#[serde(rename = "nextPageToken")]
pub next_page_token: Option<String>,
}
impl common::ResponseResult for LicenseAssignmentList {}
pub struct LicenseAssignmentMethods<'a, C>
where
C: 'a,
{
hub: &'a Licensing<C>,
}
impl<'a, C> common::MethodsBuilder for LicenseAssignmentMethods<'a, C> {}
impl<'a, C> LicenseAssignmentMethods<'a, C> {
pub fn delete(
&self,
product_id: &str,
sku_id: &str,
user_id: &str,
) -> LicenseAssignmentDeleteCall<'a, C> {
LicenseAssignmentDeleteCall {
hub: self.hub,
_product_id: product_id.to_string(),
_sku_id: sku_id.to_string(),
_user_id: user_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn get(
&self,
product_id: &str,
sku_id: &str,
user_id: &str,
) -> LicenseAssignmentGetCall<'a, C> {
LicenseAssignmentGetCall {
hub: self.hub,
_product_id: product_id.to_string(),
_sku_id: sku_id.to_string(),
_user_id: user_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn insert(
&self,
request: LicenseAssignmentInsert,
product_id: &str,
sku_id: &str,
) -> LicenseAssignmentInsertCall<'a, C> {
LicenseAssignmentInsertCall {
hub: self.hub,
_request: request,
_product_id: product_id.to_string(),
_sku_id: sku_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn list_for_product(
&self,
product_id: &str,
customer_id: &str,
) -> LicenseAssignmentListForProductCall<'a, C> {
LicenseAssignmentListForProductCall {
hub: self.hub,
_product_id: product_id.to_string(),
_customer_id: customer_id.to_string(),
_page_token: Default::default(),
_max_results: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn list_for_product_and_sku(
&self,
product_id: &str,
sku_id: &str,
customer_id: &str,
) -> LicenseAssignmentListForProductAndSkuCall<'a, C> {
LicenseAssignmentListForProductAndSkuCall {
hub: self.hub,
_product_id: product_id.to_string(),
_sku_id: sku_id.to_string(),
_customer_id: customer_id.to_string(),
_page_token: Default::default(),
_max_results: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn patch(
&self,
request: LicenseAssignment,
product_id: &str,
sku_id: &str,
user_id: &str,
) -> LicenseAssignmentPatchCall<'a, C> {
LicenseAssignmentPatchCall {
hub: self.hub,
_request: request,
_product_id: product_id.to_string(),
_sku_id: sku_id.to_string(),
_user_id: user_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
pub fn update(
&self,
request: LicenseAssignment,
product_id: &str,
sku_id: &str,
user_id: &str,
) -> LicenseAssignmentUpdateCall<'a, C> {
LicenseAssignmentUpdateCall {
hub: self.hub,
_request: request,
_product_id: product_id.to_string(),
_sku_id: sku_id.to_string(),
_user_id: user_id.to_string(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
}
pub struct LicenseAssignmentDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a Licensing<C>,
_product_id: String,
_sku_id: String,
_user_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LicenseAssignmentDeleteCall<'a, C> {}
impl<'a, C> LicenseAssignmentDeleteCall<'a, C>
where
C: common::Connector,
{
pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "licensing.licenseAssignments.delete",
http_method: hyper::Method::DELETE,
});
for &field in ["alt", "productId", "skuId", "userId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("productId", self._product_id);
params.push("skuId", self._sku_id);
params.push("userId", self._user_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "apps/licensing/v1/product/{productId}/sku/{skuId}/user/{userId}";
if self._scopes.is_empty() {
self._scopes
.insert(Scope::AppLicensing.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{productId}", "productId"),
("{skuId}", "skuId"),
("{userId}", "userId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["userId", "skuId", "productId"];
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(common::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
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
pub fn product_id(mut self, new_value: &str) -> LicenseAssignmentDeleteCall<'a, C> {
self._product_id = new_value.to_string();
self
}
pub fn sku_id(mut self, new_value: &str) -> LicenseAssignmentDeleteCall<'a, C> {
self._sku_id = new_value.to_string();
self
}
pub fn user_id(mut self, new_value: &str) -> LicenseAssignmentDeleteCall<'a, C> {
self._user_id = new_value.to_string();
self
}
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> LicenseAssignmentDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> LicenseAssignmentDeleteCall<'a, C>
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) -> LicenseAssignmentDeleteCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> LicenseAssignmentDeleteCall<'a, C>
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) -> LicenseAssignmentDeleteCall<'a, C> {
self._scopes.clear();
self
}
}
pub struct LicenseAssignmentGetCall<'a, C>
where
C: 'a,
{
hub: &'a Licensing<C>,
_product_id: String,
_sku_id: String,
_user_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LicenseAssignmentGetCall<'a, C> {}
impl<'a, C> LicenseAssignmentGetCall<'a, C>
where
C: common::Connector,
{
pub async fn doit(mut self) -> common::Result<(common::Response, LicenseAssignment)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "licensing.licenseAssignments.get",
http_method: hyper::Method::GET,
});
for &field in ["alt", "productId", "skuId", "userId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("productId", self._product_id);
params.push("skuId", self._sku_id);
params.push("userId", self._user_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "apps/licensing/v1/product/{productId}/sku/{skuId}/user/{userId}";
if self._scopes.is_empty() {
self._scopes
.insert(Scope::AppLicensing.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{productId}", "productId"),
("{skuId}", "skuId"),
("{userId}", "userId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["userId", "skuId", "productId"];
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(common::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
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
pub fn product_id(mut self, new_value: &str) -> LicenseAssignmentGetCall<'a, C> {
self._product_id = new_value.to_string();
self
}
pub fn sku_id(mut self, new_value: &str) -> LicenseAssignmentGetCall<'a, C> {
self._sku_id = new_value.to_string();
self
}
pub fn user_id(mut self, new_value: &str) -> LicenseAssignmentGetCall<'a, C> {
self._user_id = new_value.to_string();
self
}
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> LicenseAssignmentGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> LicenseAssignmentGetCall<'a, C>
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) -> LicenseAssignmentGetCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> LicenseAssignmentGetCall<'a, C>
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) -> LicenseAssignmentGetCall<'a, C> {
self._scopes.clear();
self
}
}
pub struct LicenseAssignmentInsertCall<'a, C>
where
C: 'a,
{
hub: &'a Licensing<C>,
_request: LicenseAssignmentInsert,
_product_id: String,
_sku_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LicenseAssignmentInsertCall<'a, C> {}
impl<'a, C> LicenseAssignmentInsertCall<'a, C>
where
C: common::Connector,
{
pub async fn doit(mut self) -> common::Result<(common::Response, LicenseAssignment)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "licensing.licenseAssignments.insert",
http_method: hyper::Method::POST,
});
for &field in ["alt", "productId", "skuId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
params.push("productId", self._product_id);
params.push("skuId", self._sku_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url =
self.hub._base_url.clone() + "apps/licensing/v1/product/{productId}/sku/{skuId}/user";
if self._scopes.is_empty() {
self._scopes
.insert(Scope::AppLicensing.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{productId}", "productId"), ("{skuId}", "skuId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["skuId", "productId"];
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::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(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
pub fn request(
mut self,
new_value: LicenseAssignmentInsert,
) -> LicenseAssignmentInsertCall<'a, C> {
self._request = new_value;
self
}
pub fn product_id(mut self, new_value: &str) -> LicenseAssignmentInsertCall<'a, C> {
self._product_id = new_value.to_string();
self
}
pub fn sku_id(mut self, new_value: &str) -> LicenseAssignmentInsertCall<'a, C> {
self._sku_id = new_value.to_string();
self
}
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> LicenseAssignmentInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> LicenseAssignmentInsertCall<'a, C>
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) -> LicenseAssignmentInsertCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> LicenseAssignmentInsertCall<'a, C>
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) -> LicenseAssignmentInsertCall<'a, C> {
self._scopes.clear();
self
}
}
pub struct LicenseAssignmentListForProductCall<'a, C>
where
C: 'a,
{
hub: &'a Licensing<C>,
_product_id: String,
_customer_id: String,
_page_token: Option<String>,
_max_results: Option<u32>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LicenseAssignmentListForProductCall<'a, C> {}
impl<'a, C> LicenseAssignmentListForProductCall<'a, C>
where
C: common::Connector,
{
pub async fn doit(mut self) -> common::Result<(common::Response, LicenseAssignmentList)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "licensing.licenseAssignments.listForProduct",
http_method: hyper::Method::GET,
});
for &field in ["alt", "productId", "customerId", "pageToken", "maxResults"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("productId", self._product_id);
params.push("customerId", self._customer_id);
if let Some(value) = self._page_token.as_ref() {
params.push("pageToken", value);
}
if let Some(value) = self._max_results.as_ref() {
params.push("maxResults", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone() + "apps/licensing/v1/product/{productId}/users";
if self._scopes.is_empty() {
self._scopes
.insert(Scope::AppLicensing.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{productId}", "productId")].iter() {
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["productId"];
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(common::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
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
pub fn product_id(mut self, new_value: &str) -> LicenseAssignmentListForProductCall<'a, C> {
self._product_id = new_value.to_string();
self
}
pub fn customer_id(mut self, new_value: &str) -> LicenseAssignmentListForProductCall<'a, C> {
self._customer_id = new_value.to_string();
self
}
pub fn page_token(mut self, new_value: &str) -> LicenseAssignmentListForProductCall<'a, C> {
self._page_token = Some(new_value.to_string());
self
}
pub fn max_results(mut self, new_value: u32) -> LicenseAssignmentListForProductCall<'a, C> {
self._max_results = Some(new_value);
self
}
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> LicenseAssignmentListForProductCall<'a, C> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> LicenseAssignmentListForProductCall<'a, C>
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) -> LicenseAssignmentListForProductCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> LicenseAssignmentListForProductCall<'a, C>
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) -> LicenseAssignmentListForProductCall<'a, C> {
self._scopes.clear();
self
}
}
pub struct LicenseAssignmentListForProductAndSkuCall<'a, C>
where
C: 'a,
{
hub: &'a Licensing<C>,
_product_id: String,
_sku_id: String,
_customer_id: String,
_page_token: Option<String>,
_max_results: Option<u32>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LicenseAssignmentListForProductAndSkuCall<'a, C> {}
impl<'a, C> LicenseAssignmentListForProductAndSkuCall<'a, C>
where
C: common::Connector,
{
pub async fn doit(mut self) -> common::Result<(common::Response, LicenseAssignmentList)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "licensing.licenseAssignments.listForProductAndSku",
http_method: hyper::Method::GET,
});
for &field in [
"alt",
"productId",
"skuId",
"customerId",
"pageToken",
"maxResults",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(7 + self._additional_params.len());
params.push("productId", self._product_id);
params.push("skuId", self._sku_id);
params.push("customerId", self._customer_id);
if let Some(value) = self._page_token.as_ref() {
params.push("pageToken", value);
}
if let Some(value) = self._max_results.as_ref() {
params.push("maxResults", value.to_string());
}
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url =
self.hub._base_url.clone() + "apps/licensing/v1/product/{productId}/sku/{skuId}/users";
if self._scopes.is_empty() {
self._scopes
.insert(Scope::AppLicensing.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [("{productId}", "productId"), ("{skuId}", "skuId")].iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["skuId", "productId"];
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(common::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
.header(CONTENT_LENGTH, 0_u64)
.body(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
pub fn product_id(
mut self,
new_value: &str,
) -> LicenseAssignmentListForProductAndSkuCall<'a, C> {
self._product_id = new_value.to_string();
self
}
pub fn sku_id(mut self, new_value: &str) -> LicenseAssignmentListForProductAndSkuCall<'a, C> {
self._sku_id = new_value.to_string();
self
}
pub fn customer_id(
mut self,
new_value: &str,
) -> LicenseAssignmentListForProductAndSkuCall<'a, C> {
self._customer_id = new_value.to_string();
self
}
pub fn page_token(
mut self,
new_value: &str,
) -> LicenseAssignmentListForProductAndSkuCall<'a, C> {
self._page_token = Some(new_value.to_string());
self
}
pub fn max_results(
mut self,
new_value: u32,
) -> LicenseAssignmentListForProductAndSkuCall<'a, C> {
self._max_results = Some(new_value);
self
}
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> LicenseAssignmentListForProductAndSkuCall<'a, C> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> LicenseAssignmentListForProductAndSkuCall<'a, C>
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) -> LicenseAssignmentListForProductAndSkuCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(
mut self,
scopes: I,
) -> LicenseAssignmentListForProductAndSkuCall<'a, C>
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) -> LicenseAssignmentListForProductAndSkuCall<'a, C> {
self._scopes.clear();
self
}
}
pub struct LicenseAssignmentPatchCall<'a, C>
where
C: 'a,
{
hub: &'a Licensing<C>,
_request: LicenseAssignment,
_product_id: String,
_sku_id: String,
_user_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LicenseAssignmentPatchCall<'a, C> {}
impl<'a, C> LicenseAssignmentPatchCall<'a, C>
where
C: common::Connector,
{
pub async fn doit(mut self) -> common::Result<(common::Response, LicenseAssignment)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "licensing.licenseAssignments.patch",
http_method: hyper::Method::PATCH,
});
for &field in ["alt", "productId", "skuId", "userId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("productId", self._product_id);
params.push("skuId", self._sku_id);
params.push("userId", self._user_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "apps/licensing/v1/product/{productId}/sku/{skuId}/user/{userId}";
if self._scopes.is_empty() {
self._scopes
.insert(Scope::AppLicensing.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{productId}", "productId"),
("{skuId}", "skuId"),
("{userId}", "userId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["userId", "skuId", "productId"];
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::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(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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::PATCH)
.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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
pub fn request(mut self, new_value: LicenseAssignment) -> LicenseAssignmentPatchCall<'a, C> {
self._request = new_value;
self
}
pub fn product_id(mut self, new_value: &str) -> LicenseAssignmentPatchCall<'a, C> {
self._product_id = new_value.to_string();
self
}
pub fn sku_id(mut self, new_value: &str) -> LicenseAssignmentPatchCall<'a, C> {
self._sku_id = new_value.to_string();
self
}
pub fn user_id(mut self, new_value: &str) -> LicenseAssignmentPatchCall<'a, C> {
self._user_id = new_value.to_string();
self
}
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> LicenseAssignmentPatchCall<'a, C> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> LicenseAssignmentPatchCall<'a, C>
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) -> LicenseAssignmentPatchCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> LicenseAssignmentPatchCall<'a, C>
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) -> LicenseAssignmentPatchCall<'a, C> {
self._scopes.clear();
self
}
}
pub struct LicenseAssignmentUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a Licensing<C>,
_request: LicenseAssignment,
_product_id: String,
_sku_id: String,
_user_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LicenseAssignmentUpdateCall<'a, C> {}
impl<'a, C> LicenseAssignmentUpdateCall<'a, C>
where
C: common::Connector,
{
pub async fn doit(mut self) -> common::Result<(common::Response, LicenseAssignment)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "licensing.licenseAssignments.update",
http_method: hyper::Method::PUT,
});
for &field in ["alt", "productId", "skuId", "userId"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("productId", self._product_id);
params.push("skuId", self._sku_id);
params.push("userId", self._user_id);
params.extend(self._additional_params.iter());
params.push("alt", "json");
let mut url = self.hub._base_url.clone()
+ "apps/licensing/v1/product/{productId}/sku/{skuId}/user/{userId}";
if self._scopes.is_empty() {
self._scopes
.insert(Scope::AppLicensing.as_ref().to_string());
}
#[allow(clippy::single_element_loop)]
for &(find_this, param_name) in [
("{productId}", "productId"),
("{skuId}", "skuId"),
("{userId}", "userId"),
]
.iter()
{
url = params.uri_replacement(url, param_name, find_this, false);
}
{
let to_remove = ["userId", "skuId", "productId"];
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::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(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
pub fn request(mut self, new_value: LicenseAssignment) -> LicenseAssignmentUpdateCall<'a, C> {
self._request = new_value;
self
}
pub fn product_id(mut self, new_value: &str) -> LicenseAssignmentUpdateCall<'a, C> {
self._product_id = new_value.to_string();
self
}
pub fn sku_id(mut self, new_value: &str) -> LicenseAssignmentUpdateCall<'a, C> {
self._sku_id = new_value.to_string();
self
}
pub fn user_id(mut self, new_value: &str) -> LicenseAssignmentUpdateCall<'a, C> {
self._user_id = new_value.to_string();
self
}
pub fn delegate(
mut self,
new_value: &'a mut dyn common::Delegate,
) -> LicenseAssignmentUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
pub fn param<T>(mut self, name: T, value: T) -> LicenseAssignmentUpdateCall<'a, C>
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) -> LicenseAssignmentUpdateCall<'a, C>
where
St: AsRef<str>,
{
self._scopes.insert(String::from(scope.as_ref()));
self
}
pub fn add_scopes<I, St>(mut self, scopes: I) -> LicenseAssignmentUpdateCall<'a, C>
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) -> LicenseAssignmentUpdateCall<'a, C> {
self._scopes.clear();
self
}
}