mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49:49 +01:00
Publish latest versions of all APIs
This commit is contained in:
753
gen/playcustomapp1/src/cmn.rs
Normal file
753
gen/playcustomapp1/src/cmn.rs
Normal file
@@ -0,0 +1,753 @@
|
||||
// COPY OF 'src/rust/api/cmn.rs'
|
||||
// DO NOT EDIT
|
||||
use std::io::{self, Read, Seek, Cursor, Write, SeekFrom};
|
||||
use std;
|
||||
use std::fmt::{self, Display};
|
||||
use std::str::FromStr;
|
||||
use std::error;
|
||||
use std::thread::sleep;
|
||||
use std::time::Duration;
|
||||
|
||||
use mime::{Mime, TopLevel, SubLevel, Attr, Value};
|
||||
use oauth2::{TokenType, Retry, self};
|
||||
use hyper;
|
||||
use hyper::header::{ContentType, ContentLength, Headers, UserAgent, Authorization, Header,
|
||||
HeaderFormat, Bearer};
|
||||
use hyper::http::h1::LINE_ENDING;
|
||||
use hyper::method::Method;
|
||||
use hyper::status::StatusCode;
|
||||
|
||||
use serde_json as json;
|
||||
|
||||
/// Identifies the Hub. There is only one per library, this trait is supposed
|
||||
/// to make intended use more explicit.
|
||||
/// The hub allows to access all resource methods more easily.
|
||||
pub trait Hub {}
|
||||
|
||||
/// Identifies types for building methods of a particular resource type
|
||||
pub trait MethodsBuilder {}
|
||||
|
||||
/// Identifies types which represent builders for a particular resource method
|
||||
pub trait CallBuilder {}
|
||||
|
||||
/// Identifies types which can be inserted and deleted.
|
||||
/// Types with this trait are most commonly used by clients of this API.
|
||||
pub trait Resource {}
|
||||
|
||||
/// Identifies types which are used in API responses.
|
||||
pub trait ResponseResult {}
|
||||
|
||||
/// Identifies types which are used in API requests.
|
||||
pub trait RequestValue {}
|
||||
|
||||
/// Identifies types which are not actually used by the API
|
||||
/// This might be a bug within the google API schema.
|
||||
pub trait UnusedType {}
|
||||
|
||||
/// Identifies types which are only used as part of other types, which
|
||||
/// usually are carrying the `Resource` trait.
|
||||
pub trait Part {}
|
||||
|
||||
/// Identifies types which are only used by other types internally.
|
||||
/// They have no special meaning, this trait just marks them for completeness.
|
||||
pub trait NestedType {}
|
||||
|
||||
/// A utility to specify reader types which provide seeking capabilities too
|
||||
pub trait ReadSeek: Seek + Read {}
|
||||
impl<T: Seek + Read> ReadSeek for T {}
|
||||
|
||||
/// A trait for all types that can convert themselves into a *parts* string
|
||||
pub trait ToParts {
|
||||
fn to_parts(&self) -> String;
|
||||
}
|
||||
|
||||
/// A utility type which can decode a server response that indicates error
|
||||
#[derive(Deserialize)]
|
||||
pub struct JsonServerError {
|
||||
pub error: String,
|
||||
pub error_description: Option<String>
|
||||
}
|
||||
|
||||
/// A utility to represent detailed errors we might see in case there are BadRequests.
|
||||
/// The latter happen if the sent parameters or request structures are unsound
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub struct ErrorResponse {
|
||||
error: ServerError,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub struct ServerError {
|
||||
errors: Vec<ServerMessage>,
|
||||
code: u16,
|
||||
message: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub struct ServerMessage {
|
||||
domain: String,
|
||||
reason: String,
|
||||
message: String,
|
||||
#[serde(rename="locationType")]
|
||||
location_type: Option<String>,
|
||||
location: Option<String>
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct DummyNetworkStream;
|
||||
|
||||
impl Read for DummyNetworkStream {
|
||||
fn read(&mut self, _: &mut [u8]) -> io::Result<usize> {
|
||||
Ok(0)
|
||||
}
|
||||
}
|
||||
|
||||
impl Write for DummyNetworkStream {
|
||||
fn write(&mut self, _: &[u8]) -> io::Result<usize> {
|
||||
Ok(0)
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl hyper::net::NetworkStream for DummyNetworkStream {
|
||||
fn peer_addr(&mut self) -> io::Result<std::net::SocketAddr> {
|
||||
Ok("127.0.0.1:1337".parse().unwrap())
|
||||
}
|
||||
|
||||
fn set_read_timeout(&self, _dur: Option<Duration>) -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_write_timeout(&self, _dur: Option<Duration>) -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// A trait specifying functionality to help controlling any request performed by the API.
|
||||
/// The trait has a conservative default implementation.
|
||||
///
|
||||
/// It contains methods to deal with all common issues, as well with the ones related to
|
||||
/// uploading media
|
||||
pub trait Delegate {
|
||||
|
||||
/// Called at the beginning of any API request. The delegate should store the method
|
||||
/// information if he is interesting in knowing more context when further calls to it
|
||||
/// are made.
|
||||
/// The matching `finished()` call will always be made, no matter whether or not the API
|
||||
/// request was successful. That way, the delegate may easily maintain a clean state
|
||||
/// between various API calls.
|
||||
fn begin(&mut self, MethodInfo) {}
|
||||
|
||||
/// Called whenever there is an [HttpError](http://hyperium.github.io/hyper/hyper/error/enum.HttpError.html), usually if there are network problems.
|
||||
///
|
||||
/// If you choose to retry after a duration, the duration should be chosen using the
|
||||
/// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff).
|
||||
///
|
||||
/// Return retry information.
|
||||
fn http_error(&mut self, &hyper::Error) -> Retry {
|
||||
Retry::Abort
|
||||
}
|
||||
|
||||
/// Called whenever there is the need for your applications API key after
|
||||
/// the official authenticator implementation didn't provide one, for some reason.
|
||||
/// If this method returns None as well, the underlying operation will fail
|
||||
fn api_key(&mut self) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Called whenever the Authenticator didn't yield a token. The delegate
|
||||
/// may attempt to provide one, or just take it as a general information about the
|
||||
/// impending failure.
|
||||
/// The given Error provides information about why the token couldn't be acquired in the
|
||||
/// first place
|
||||
fn token(&mut self, err: &error::Error) -> Option<oauth2::Token> {
|
||||
let _ = err;
|
||||
None
|
||||
}
|
||||
|
||||
/// Called during resumable uploads to provide a URL for the impending upload.
|
||||
/// It was saved after a previous call to `store_upload_url(...)`, and if not None,
|
||||
/// will be used instead of asking the server for a new upload URL.
|
||||
/// This is useful in case a previous resumable upload was aborted/canceled, but should now
|
||||
/// be resumed.
|
||||
/// The returned URL will be used exactly once - if it fails again and the delegate allows
|
||||
/// to retry, we will ask the server for a new upload URL.
|
||||
fn upload_url(&mut self) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Called after we have retrieved a new upload URL for a resumable upload to store it
|
||||
/// in case we fail or cancel. That way, we can attempt to resume the upload later,
|
||||
/// see `upload_url()`.
|
||||
/// It will also be called with None after a successful upload, which allows the delegate
|
||||
/// to forget the URL. That way, we will not attempt to resume an upload that has already
|
||||
/// finished.
|
||||
fn store_upload_url(&mut self, url: Option<&str>) {
|
||||
let _ = url;
|
||||
}
|
||||
|
||||
/// Called whenever a server response could not be decoded from json.
|
||||
/// It's for informational purposes only, the caller will return with an error
|
||||
/// accordingly.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `json_encoded_value` - The json-encoded value which failed to decode.
|
||||
/// * `json_decode_error` - The decoder error
|
||||
fn response_json_decode_error(&mut self, json_encoded_value: &str, json_decode_error: &json::Error) {
|
||||
let _ = json_encoded_value;
|
||||
let _ = json_decode_error;
|
||||
}
|
||||
|
||||
/// Called whenever the http request returns with a non-success status code.
|
||||
/// This can involve authentication issues, or anything else that very much
|
||||
/// depends on the used API method.
|
||||
/// The delegate should check the status, header and decoded json error to decide
|
||||
/// whether to retry or not. In the latter case, the underlying call will fail.
|
||||
///
|
||||
/// If you choose to retry after a duration, the duration should be chosen using the
|
||||
/// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff).
|
||||
fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry {
|
||||
Retry::Abort
|
||||
}
|
||||
|
||||
/// Called prior to sending the main request of the given method. It can be used to time
|
||||
/// the call or to print progress information.
|
||||
/// It's also useful as you can be sure that a request will definitely be made.
|
||||
fn pre_request(&mut self) { }
|
||||
|
||||
/// Return the size of each chunk of a resumable upload.
|
||||
/// Must be a power of two, with 1<<18 being the smallest allowed chunk size.
|
||||
/// Will be called once before starting any resumable upload.
|
||||
fn chunk_size(&mut self) -> u64 {
|
||||
1 << 23
|
||||
}
|
||||
|
||||
/// Called before the given chunk is uploaded to the server.
|
||||
/// If true is returned, the upload will be interrupted.
|
||||
/// However, it may be resumable if you stored the upload URL in a previous call
|
||||
/// to `store_upload_url()`
|
||||
fn cancel_chunk_upload(&mut self, chunk: &ContentRange) -> bool {
|
||||
let _ = chunk;
|
||||
false
|
||||
}
|
||||
|
||||
/// Called before the API request method returns, in every case. It can be used to clean up
|
||||
/// internal state between calls to the API.
|
||||
/// This call always has a matching call to `begin(...)`.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `is_success` - a true value indicates the operation was successful. If false, you should
|
||||
/// discard all values stored during `store_upload_url`.
|
||||
fn finished(&mut self, is_success: bool) {
|
||||
let _ = is_success;
|
||||
}
|
||||
}
|
||||
|
||||
/// A delegate with a conservative default implementation, which is used if no other delegate is
|
||||
/// set.
|
||||
#[derive(Default)]
|
||||
pub struct DefaultDelegate;
|
||||
|
||||
impl Delegate for DefaultDelegate {}
|
||||
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
/// The http connection failed
|
||||
HttpError(hyper::Error),
|
||||
|
||||
/// An attempt was made to upload a resource with size stored in field `.0`
|
||||
/// even though the maximum upload size is what is stored in field `.1`.
|
||||
UploadSizeLimitExceeded(u64, u64),
|
||||
|
||||
/// Represents information about a request that was not understood by the server.
|
||||
/// Details are included.
|
||||
BadRequest(ErrorResponse),
|
||||
|
||||
/// We needed an API key for authentication, but didn't obtain one.
|
||||
/// Neither through the authenticator, nor through the Delegate.
|
||||
MissingAPIKey,
|
||||
|
||||
/// We required a Token, but didn't get one from the Authenticator
|
||||
MissingToken(Box<error::Error>),
|
||||
|
||||
/// The delgate instructed to cancel the operation
|
||||
Cancelled,
|
||||
|
||||
/// An additional, free form field clashed with one of the built-in optional ones
|
||||
FieldClash(&'static str),
|
||||
|
||||
/// Shows that we failed to decode the server response.
|
||||
/// This can happen if the protocol changes in conjunction with strict json decoding.
|
||||
JsonDecodeError(String, json::Error),
|
||||
|
||||
/// Indicates an HTTP repsonse with a non-success status code
|
||||
Failure(hyper::client::Response),
|
||||
}
|
||||
|
||||
|
||||
impl Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
Error::HttpError(ref err) => err.fmt(f),
|
||||
Error::UploadSizeLimitExceeded(ref resource_size, ref max_size) =>
|
||||
writeln!(f, "The media size {} exceeds the maximum allowed upload size of {}"
|
||||
, resource_size, max_size),
|
||||
Error::MissingAPIKey => {
|
||||
(writeln!(f, "The application's API key was not found in the configuration")).ok();
|
||||
writeln!(f, "It is used as there are no Scopes defined for this method.")
|
||||
},
|
||||
Error::BadRequest(ref err) => {
|
||||
try!(writeln!(f, "Bad Request ({}): {}", err.error.code, err.error.message));
|
||||
for err in err.error.errors.iter() {
|
||||
try!(writeln!(f, " {}: {}, {}{}",
|
||||
err.domain,
|
||||
err.message,
|
||||
err.reason,
|
||||
match &err.location {
|
||||
&Some(ref loc) => format!("@{}", loc),
|
||||
&None => String::new(),
|
||||
}));
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
Error::MissingToken(ref err) =>
|
||||
writeln!(f, "Token retrieval failed with error: {}", err),
|
||||
Error::Cancelled =>
|
||||
writeln!(f, "Operation cancelled by delegate"),
|
||||
Error::FieldClash(field) =>
|
||||
writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field),
|
||||
Error::JsonDecodeError(ref json_str, ref err)
|
||||
=> writeln!(f, "{}: {}", err, json_str),
|
||||
Error::Failure(ref response) =>
|
||||
writeln!(f, "Http status indicates failure: {:?}", response),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl error::Error for Error {
|
||||
fn description(&self) -> &str {
|
||||
match *self {
|
||||
Error::HttpError(ref err) => err.description(),
|
||||
Error::JsonDecodeError(_, ref err) => err.description(),
|
||||
_ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead"
|
||||
}
|
||||
}
|
||||
|
||||
fn cause(&self) -> Option<&error::Error> {
|
||||
match *self {
|
||||
Error::HttpError(ref err) => err.cause(),
|
||||
Error::JsonDecodeError(_, ref err) => err.cause(),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A universal result type used as return for all calls.
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
/// Contains information about an API request.
|
||||
pub struct MethodInfo {
|
||||
pub id: &'static str,
|
||||
pub http_method: Method,
|
||||
}
|
||||
|
||||
const BOUNDARY: &'static str = "MDuXWGyeE33QFXGchb2VFWc4Z7945d";
|
||||
|
||||
/// Provides a `Read` interface that converts multiple parts into the protocol
|
||||
/// identified by [RFC2387](https://tools.ietf.org/html/rfc2387).
|
||||
/// **Note**: This implementation is just as rich as it needs to be to perform uploads
|
||||
/// to google APIs, and might not be a fully-featured implementation.
|
||||
#[derive(Default)]
|
||||
pub struct MultiPartReader<'a> {
|
||||
raw_parts: Vec<(Headers, &'a mut Read)>,
|
||||
current_part: Option<(Cursor<Vec<u8>>, &'a mut Read)>,
|
||||
last_part_boundary: Option<Cursor<Vec<u8>>>,
|
||||
}
|
||||
|
||||
impl<'a> MultiPartReader<'a> {
|
||||
|
||||
/// Reserve memory for exactly the given amount of parts
|
||||
pub fn reserve_exact(&mut self, cap: usize) {
|
||||
self.raw_parts.reserve_exact(cap);
|
||||
}
|
||||
|
||||
/// Add a new part to the queue of parts to be read on the first `read` call.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// `headers` - identifying the body of the part. It's similar to the header
|
||||
/// in an ordinary single-part call, and should thus contain the
|
||||
/// same information.
|
||||
/// `reader` - a reader providing the part's body
|
||||
/// `size` - the amount of bytes provided by the reader. It will be put onto the header as
|
||||
/// content-size.
|
||||
/// `mime` - It will be put onto the content type
|
||||
pub fn add_part(&mut self, reader: &'a mut Read, size: u64, mime_type: Mime) -> &mut MultiPartReader<'a> {
|
||||
let mut headers = Headers::new();
|
||||
headers.set(ContentType(mime_type));
|
||||
headers.set(ContentLength(size));
|
||||
self.raw_parts.push((headers, reader));
|
||||
self
|
||||
}
|
||||
|
||||
/// Returns the mime-type representing our multi-part message.
|
||||
/// Use it with the ContentType header.
|
||||
pub fn mime_type(&self) -> Mime {
|
||||
Mime(
|
||||
TopLevel::Multipart,
|
||||
SubLevel::Ext("Related".to_string()),
|
||||
vec![(Attr::Ext("boundary".to_string()), Value::Ext(BOUNDARY.to_string()))],
|
||||
)
|
||||
}
|
||||
|
||||
/// Returns true if we are totally used
|
||||
fn is_depleted(&self) -> bool {
|
||||
self.raw_parts.len() == 0 && self.current_part.is_none() && self.last_part_boundary.is_none()
|
||||
}
|
||||
|
||||
/// Returns true if we are handling our last part
|
||||
fn is_last_part(&self) -> bool {
|
||||
self.raw_parts.len() == 0 && self.current_part.is_some()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Read for MultiPartReader<'a> {
|
||||
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
|
||||
match (self.raw_parts.len(),
|
||||
self.current_part.is_none(),
|
||||
self.last_part_boundary.is_none()) {
|
||||
(_, _, false) => {
|
||||
let br = self.last_part_boundary.as_mut().unwrap().read(buf).unwrap_or(0);
|
||||
if br < buf.len() {
|
||||
self.last_part_boundary = None;
|
||||
}
|
||||
return Ok(br)
|
||||
},
|
||||
(0, true, true) => return Ok(0),
|
||||
(n, true, _) if n > 0 => {
|
||||
let (headers, reader) = self.raw_parts.remove(0);
|
||||
let mut c = Cursor::new(Vec::<u8>::new());
|
||||
(write!(&mut c, "{}--{}{}{}{}", LINE_ENDING, BOUNDARY, LINE_ENDING,
|
||||
headers, LINE_ENDING)).unwrap();
|
||||
c.seek(SeekFrom::Start(0)).unwrap();
|
||||
self.current_part = Some((c, reader));
|
||||
}
|
||||
_ => {},
|
||||
}
|
||||
|
||||
// read headers as long as possible
|
||||
let (hb, rr) = {
|
||||
let &mut (ref mut c, ref mut reader) = self.current_part.as_mut().unwrap();
|
||||
let b = c.read(buf).unwrap_or(0);
|
||||
(b, reader.read(&mut buf[b..]))
|
||||
};
|
||||
|
||||
match rr {
|
||||
Ok(bytes_read) => {
|
||||
if hb < buf.len() && bytes_read == 0 {
|
||||
if self.is_last_part() {
|
||||
// before clearing the last part, we will add the boundary that
|
||||
// will be written last
|
||||
self.last_part_boundary = Some(Cursor::new(
|
||||
format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes()))
|
||||
}
|
||||
// We are depleted - this can trigger the next part to come in
|
||||
self.current_part = None;
|
||||
}
|
||||
let mut total_bytes_read = hb + bytes_read;
|
||||
while total_bytes_read < buf.len() && !self.is_depleted() {
|
||||
match self.read(&mut buf[total_bytes_read ..]) {
|
||||
Ok(br) => total_bytes_read += br,
|
||||
Err(err) => return Err(err),
|
||||
}
|
||||
}
|
||||
Ok(total_bytes_read)
|
||||
}
|
||||
Err(err) => {
|
||||
// fail permanently
|
||||
self.current_part = None;
|
||||
self.last_part_boundary = None;
|
||||
self.raw_parts.clear();
|
||||
Err(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The `X-Upload-Content-Type` header.
|
||||
///
|
||||
/// Generated via rustc --pretty expanded -Z unstable-options, and manually
|
||||
/// processed to be more readable.
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
pub struct XUploadContentType(pub Mime);
|
||||
|
||||
impl ::std::ops::Deref for XUploadContentType {
|
||||
type Target = Mime;
|
||||
fn deref<'a>(&'a self) -> &'a Mime { &self.0 }
|
||||
}
|
||||
impl ::std::ops::DerefMut for XUploadContentType {
|
||||
fn deref_mut<'a>(&'a mut self) -> &'a mut Mime { &mut self.0 }
|
||||
}
|
||||
impl Header for XUploadContentType {
|
||||
fn header_name() -> &'static str { "X-Upload-Content-Type" }
|
||||
fn parse_header(raw: &[Vec<u8>]) -> hyper::error::Result<Self> {
|
||||
hyper::header::parsing::from_one_raw_str(raw).map(XUploadContentType)
|
||||
}
|
||||
}
|
||||
impl HeaderFormat for XUploadContentType {
|
||||
fn fmt_header(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
Display::fmt(&**self, f)
|
||||
}
|
||||
}
|
||||
impl Display for XUploadContentType {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::Display::fmt(&**self, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct Chunk {
|
||||
pub first: u64,
|
||||
pub last: u64
|
||||
}
|
||||
|
||||
impl fmt::Display for Chunk {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
(write!(fmt, "{}-{}", self.first, self.last)).ok();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for Chunk {
|
||||
type Err = &'static str;
|
||||
|
||||
/// NOTE: only implements `%i-%i`, not `*`
|
||||
fn from_str(s: &str) -> std::result::Result<Chunk, &'static str> {
|
||||
let parts: Vec<&str> = s.split('-').collect();
|
||||
if parts.len() != 2 {
|
||||
return Err("Expected two parts: %i-%i")
|
||||
}
|
||||
Ok(
|
||||
Chunk {
|
||||
first: match FromStr::from_str(parts[0]) {
|
||||
Ok(d) => d,
|
||||
_ => return Err("Couldn't parse 'first' as digit")
|
||||
},
|
||||
last: match FromStr::from_str(parts[1]) {
|
||||
Ok(d) => d,
|
||||
_ => return Err("Couldn't parse 'last' as digit")
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Implements the Content-Range header, for serialization only
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct ContentRange {
|
||||
pub range: Option<Chunk>,
|
||||
pub total_length: u64,
|
||||
}
|
||||
|
||||
impl Header for ContentRange {
|
||||
fn header_name() -> &'static str {
|
||||
"Content-Range"
|
||||
}
|
||||
|
||||
/// We are not parsable, as parsing is done by the `Range` header
|
||||
fn parse_header(_: &[Vec<u8>]) -> hyper::error::Result<Self> {
|
||||
Err(hyper::error::Error::Method)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl HeaderFormat for ContentRange {
|
||||
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
try!(fmt.write_str("bytes "));
|
||||
match self.range {
|
||||
Some(ref c) => try!(c.fmt(fmt)),
|
||||
None => try!(fmt.write_str("*"))
|
||||
}
|
||||
(write!(fmt, "/{}", self.total_length)).ok();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct RangeResponseHeader(pub Chunk);
|
||||
|
||||
impl Header for RangeResponseHeader {
|
||||
fn header_name() -> &'static str {
|
||||
"Range"
|
||||
}
|
||||
|
||||
fn parse_header(raw: &[Vec<u8>]) -> hyper::error::Result<Self> {
|
||||
if raw.len() > 0 {
|
||||
let v = &raw[0];
|
||||
if let Ok(s) = std::str::from_utf8(v) {
|
||||
const PREFIX: &'static str = "bytes ";
|
||||
if s.starts_with(PREFIX) {
|
||||
if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) {
|
||||
return Ok(RangeResponseHeader(c))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(hyper::error::Error::Method)
|
||||
}
|
||||
}
|
||||
|
||||
impl HeaderFormat for RangeResponseHeader {
|
||||
/// No implmentation necessary, we just need to parse
|
||||
fn fmt_header(&self, _: &mut fmt::Formatter) -> fmt::Result {
|
||||
Err(fmt::Error)
|
||||
}
|
||||
}
|
||||
|
||||
/// A utility type to perform a resumable upload from start to end.
|
||||
pub struct ResumableUploadHelper<'a, A: 'a> {
|
||||
pub client: &'a mut hyper::client::Client,
|
||||
pub delegate: &'a mut Delegate,
|
||||
pub start_at: Option<u64>,
|
||||
pub auth: &'a mut A,
|
||||
pub user_agent: &'a str,
|
||||
pub auth_header: Authorization<Bearer>,
|
||||
pub url: &'a str,
|
||||
pub reader: &'a mut ReadSeek,
|
||||
pub media_type: Mime,
|
||||
pub content_length: u64
|
||||
}
|
||||
|
||||
impl<'a, A> ResumableUploadHelper<'a, A>
|
||||
where A: oauth2::GetToken {
|
||||
|
||||
fn query_transfer_status(&mut self) -> std::result::Result<u64, hyper::Result<hyper::client::Response>> {
|
||||
loop {
|
||||
match self.client.post(self.url)
|
||||
.header(UserAgent(self.user_agent.to_string()))
|
||||
.header(ContentRange { range: None, total_length: self.content_length })
|
||||
.header(self.auth_header.clone())
|
||||
.send() {
|
||||
Ok(r) => {
|
||||
// 308 = resume-incomplete == PermanentRedirect
|
||||
let headers = r.headers.clone();
|
||||
let h: &RangeResponseHeader = match headers.get() {
|
||||
Some(hh) if r.status == StatusCode::PermanentRedirect => hh,
|
||||
None|Some(_) => {
|
||||
if let Retry::After(d) = self.delegate.http_failure(&r, None, None) {
|
||||
sleep(d);
|
||||
continue;
|
||||
}
|
||||
return Err(Ok(r))
|
||||
}
|
||||
};
|
||||
return Ok(h.0.last)
|
||||
}
|
||||
Err(err) => {
|
||||
if let Retry::After(d) = self.delegate.http_error(&err) {
|
||||
sleep(d);
|
||||
continue;
|
||||
}
|
||||
return Err(Err(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// returns None if operation was cancelled by delegate, or the HttpResult.
|
||||
/// It can be that we return the result just because we didn't understand the status code -
|
||||
/// caller should check for status himself before assuming it's OK to use
|
||||
pub fn upload(&mut self) -> Option<hyper::Result<hyper::client::Response>> {
|
||||
let mut start = match self.start_at {
|
||||
Some(s) => s,
|
||||
None => match self.query_transfer_status() {
|
||||
Ok(s) => s,
|
||||
Err(result) => return Some(result)
|
||||
}
|
||||
};
|
||||
|
||||
const MIN_CHUNK_SIZE: u64 = 1 << 18;
|
||||
let chunk_size = match self.delegate.chunk_size() {
|
||||
cs if cs > MIN_CHUNK_SIZE => cs,
|
||||
_ => MIN_CHUNK_SIZE
|
||||
};
|
||||
|
||||
self.reader.seek(SeekFrom::Start(start)).unwrap();
|
||||
loop {
|
||||
let request_size = match self.content_length - start {
|
||||
rs if rs > chunk_size => chunk_size,
|
||||
rs => rs
|
||||
};
|
||||
|
||||
let mut section_reader = self.reader.take(request_size);
|
||||
let range_header = ContentRange {
|
||||
range: Some(Chunk {first: start, last: start + request_size - 1}),
|
||||
total_length: self.content_length
|
||||
};
|
||||
start += request_size;
|
||||
if self.delegate.cancel_chunk_upload(&range_header) {
|
||||
return None
|
||||
}
|
||||
let res = self.client.post(self.url)
|
||||
.header(range_header)
|
||||
.header(ContentType(self.media_type.clone()))
|
||||
.header(UserAgent(self.user_agent.to_string()))
|
||||
.body(&mut section_reader)
|
||||
.send();
|
||||
match res {
|
||||
Ok(mut res) => {
|
||||
if res.status == StatusCode::PermanentRedirect {
|
||||
continue
|
||||
}
|
||||
if !res.status.is_success() {
|
||||
let mut json_err = String::new();
|
||||
res.read_to_string(&mut json_err).unwrap();
|
||||
if let Retry::After(d) = self.delegate.http_failure(&res,
|
||||
json::from_str(&json_err).ok(),
|
||||
json::from_str(&json_err).ok()) {
|
||||
sleep(d);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return Some(Ok(res))
|
||||
},
|
||||
Err(err) => {
|
||||
if let Retry::After(d) = self.delegate.http_error(&err) {
|
||||
sleep(d);
|
||||
continue;
|
||||
}
|
||||
return Some(Err(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Copy of src/rust/cli/cmn.rs
|
||||
// TODO(ST): Allow sharing common code between program types
|
||||
pub fn remove_json_null_values(value: &mut json::value::Value) {
|
||||
match *value {
|
||||
json::value::Value::Object(ref mut map) => {
|
||||
let mut for_removal = Vec::new();
|
||||
|
||||
for (key, mut value) in map.iter_mut() {
|
||||
if value.is_null() {
|
||||
for_removal.push(key.clone());
|
||||
} else {
|
||||
remove_json_null_values(&mut value);
|
||||
}
|
||||
}
|
||||
|
||||
for key in &for_removal {
|
||||
map.remove(key);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
852
gen/playcustomapp1/src/lib.rs
Normal file
852
gen/playcustomapp1/src/lib.rs
Normal file
@@ -0,0 +1,852 @@
|
||||
// DO NOT EDIT !
|
||||
// This file was generated automatically from 'src/mako/api/lib.rs.mako'
|
||||
// DO NOT EDIT !
|
||||
|
||||
//! This documentation was generated from *playcustomapp* crate version *1.0.6+20170622*, where *20170622* is the exact revision of the *playcustomapp:v1* schema built by the [mako](http://www.makotemplates.org/) code generator *v1.0.6*.
|
||||
//!
|
||||
//! Everything else about the *playcustomapp* *v1* API can be found at the
|
||||
//! [official documentation site](https://developers.google.com/android/work/play/custom-app-api).
|
||||
//! The original source code is [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/playcustomapp1).
|
||||
//! # Features
|
||||
//!
|
||||
//! Handle the following *Resources* with ease from the central [hub](struct.Playcustomapp.html) ...
|
||||
//!
|
||||
//! * accounts
|
||||
//! * [*custom apps create*](struct.AccountCustomAppCreateCall.html)
|
||||
//!
|
||||
//!
|
||||
//! Upload supported by ...
|
||||
//!
|
||||
//! * [*custom apps create accounts*](struct.AccountCustomAppCreateCall.html)
|
||||
//!
|
||||
//!
|
||||
//!
|
||||
//! Not what you are looking for ? Find all other Google APIs in their Rust [documentation index](http://byron.github.io/google-apis-rs).
|
||||
//!
|
||||
//! # Structure of this Library
|
||||
//!
|
||||
//! The API is structured into the following primary items:
|
||||
//!
|
||||
//! * **[Hub](struct.Playcustomapp.html)**
|
||||
//! * a central object to maintain state and allow accessing all *Activities*
|
||||
//! * creates [*Method Builders*](trait.MethodsBuilder.html) which in turn
|
||||
//! allow access to individual [*Call Builders*](trait.CallBuilder.html)
|
||||
//! * **[Resources](trait.Resource.html)**
|
||||
//! * primary types that you can apply *Activities* to
|
||||
//! * a collection of properties and *Parts*
|
||||
//! * **[Parts](trait.Part.html)**
|
||||
//! * a collection of properties
|
||||
//! * never directly used in *Activities*
|
||||
//! * **[Activities](trait.CallBuilder.html)**
|
||||
//! * operations to apply to *Resources*
|
||||
//!
|
||||
//! All *structures* are marked with applicable traits to further categorize them and ease browsing.
|
||||
//!
|
||||
//! Generally speaking, you can invoke *Activities* like this:
|
||||
//!
|
||||
//! ```Rust,ignore
|
||||
//! let r = hub.resource().activity(...).doit()
|
||||
//! ```
|
||||
//!
|
||||
//! Or specifically ...
|
||||
//!
|
||||
//! ```ignore
|
||||
//! let r = hub.accounts().custom_apps_create(...).doit()
|
||||
//! ```
|
||||
//!
|
||||
//! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities`
|
||||
//! supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be
|
||||
//! specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired.
|
||||
//! The `doit()` method performs the actual communication with the server and returns the respective result.
|
||||
//!
|
||||
//! # Usage
|
||||
//!
|
||||
//! ## Setting up your Project
|
||||
//!
|
||||
//! To use this library, you would put the following lines into your `Cargo.toml` file:
|
||||
//!
|
||||
//! ```toml
|
||||
//! [dependencies]
|
||||
//! google-playcustomapp1 = "*"
|
||||
//! ```
|
||||
//!
|
||||
//! ## A complete example
|
||||
//!
|
||||
//! ```test_harness,no_run
|
||||
//! extern crate hyper;
|
||||
//! extern crate hyper_rustls;
|
||||
//! extern crate yup_oauth2 as oauth2;
|
||||
//! extern crate google_playcustomapp1 as playcustomapp1;
|
||||
//! use playcustomapp1::CustomApp;
|
||||
//! use playcustomapp1::{Result, Error};
|
||||
//! use std::fs;
|
||||
//! # #[test] fn egal() {
|
||||
//! use std::default::Default;
|
||||
//! use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||||
//! use playcustomapp1::Playcustomapp;
|
||||
//!
|
||||
//! // Get an ApplicationSecret instance by some means. It contains the `client_id` and
|
||||
//! // `client_secret`, among other things.
|
||||
//! let secret: ApplicationSecret = Default::default();
|
||||
//! // Instantiate the authenticator. It will choose a suitable authentication flow for you,
|
||||
//! // unless you replace `None` with the desired Flow.
|
||||
//! // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
|
||||
//! // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
|
||||
//! // retrieve them from storage.
|
||||
//! let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||||
//! hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||||
//! <MemoryStorage as Default>::default(), None);
|
||||
//! let mut hub = Playcustomapp::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
||||
//! // As the method needs a request, you would usually fill it with the desired information
|
||||
//! // into the respective structure. Some of the parts shown here might not be applicable !
|
||||
//! // Values shown here are possibly random and not representative !
|
||||
//! let mut req = CustomApp::default();
|
||||
//!
|
||||
//! // You can configure optional parameters by calling the respective setters at will, and
|
||||
//! // execute the final call using `upload_resumable(...)`.
|
||||
//! // Values shown here are possibly random and not representative !
|
||||
//! let result = hub.accounts().custom_apps_create(req, "account")
|
||||
//! .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap());
|
||||
//!
|
||||
//! match result {
|
||||
//! Err(e) => match e {
|
||||
//! // The Error enum provides details about what exactly happened.
|
||||
//! // You can also just use its `Debug`, `Display` or `Error` traits
|
||||
//! Error::HttpError(_)
|
||||
//! |Error::MissingAPIKey
|
||||
//! |Error::MissingToken(_)
|
||||
//! |Error::Cancelled
|
||||
//! |Error::UploadSizeLimitExceeded(_, _)
|
||||
//! |Error::Failure(_)
|
||||
//! |Error::BadRequest(_)
|
||||
//! |Error::FieldClash(_)
|
||||
//! |Error::JsonDecodeError(_, _) => println!("{}", e),
|
||||
//! },
|
||||
//! Ok(res) => println!("Success: {:?}", res),
|
||||
//! }
|
||||
//! # }
|
||||
//! ```
|
||||
//! ## Handling Errors
|
||||
//!
|
||||
//! All errors produced by the system are provided either as [Result](enum.Result.html) enumeration as return value of
|
||||
//! the doit() methods, or handed as possibly intermediate results to either the
|
||||
//! [Hub Delegate](trait.Delegate.html), or the [Authenticator Delegate](https://docs.rs/yup-oauth2/*/yup_oauth2/trait.AuthenticatorDelegate.html).
|
||||
//!
|
||||
//! When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This
|
||||
//! makes the system potentially resilient to all kinds of errors.
|
||||
//!
|
||||
//! ## Uploads and Downloads
|
||||
//! If a method supports downloads, the response body, which is part of the [Result](enum.Result.html), should be
|
||||
//! read by you to obtain the media.
|
||||
//! If such a method also supports a [Response Result](trait.ResponseResult.html), it will return that by default.
|
||||
//! You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making
|
||||
//! this call: `.param("alt", "media")`.
|
||||
//!
|
||||
//! Methods supporting uploads can do so using up to 2 different protocols:
|
||||
//! *simple* and *resumable*. The distinctiveness of each is represented by customized
|
||||
//! `doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively.
|
||||
//!
|
||||
//! ## Customization and Callbacks
|
||||
//!
|
||||
//! You may alter the way an `doit()` method is called by providing a [delegate](trait.Delegate.html) to the
|
||||
//! [Method Builder](trait.CallBuilder.html) before making the final `doit()` call.
|
||||
//! Respective methods will be called to provide progress information, as well as determine whether the system should
|
||||
//! retry on failure.
|
||||
//!
|
||||
//! The [delegate trait](trait.Delegate.html) is default-implemented, allowing you to customize it with minimal effort.
|
||||
//!
|
||||
//! ## Optional Parts in Server-Requests
|
||||
//!
|
||||
//! All structures provided by this library are made to be [enocodable](trait.RequestValue.html) and
|
||||
//! [decodable](trait.ResponseResult.html) via *json*. Optionals are used to indicate that partial requests are responses
|
||||
//! are valid.
|
||||
//! Most optionals are are considered [Parts](trait.Part.html) which are identifiable by name, which will be sent to
|
||||
//! the server to indicate either the set parts of the request or the desired parts in the response.
|
||||
//!
|
||||
//! ## Builder Arguments
|
||||
//!
|
||||
//! Using [method builders](trait.CallBuilder.html), you are able to prepare an action call by repeatedly calling it's methods.
|
||||
//! These will always take a single argument, for which the following statements are true.
|
||||
//!
|
||||
//! * [PODs][wiki-pod] are handed by copy
|
||||
//! * strings are passed as `&str`
|
||||
//! * [request values](trait.RequestValue.html) are moved
|
||||
//!
|
||||
//! Arguments will always be copied or cloned into the builder, to make them independent of their original life times.
|
||||
//!
|
||||
//! [wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure
|
||||
//! [builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern
|
||||
//! [google-go-api]: https://github.com/google/google-api-go-client
|
||||
//!
|
||||
//!
|
||||
|
||||
// Unused attributes happen thanks to defined, but unused structures
|
||||
// We don't warn about this, as depending on the API, some data structures or facilities are never used.
|
||||
// Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any
|
||||
// unused imports in fully featured APIs. Same with unused_mut ... .
|
||||
#![allow(unused_imports, unused_mut, dead_code)]
|
||||
|
||||
// DO NOT EDIT !
|
||||
// This file was generated automatically from 'src/mako/api/lib.rs.mako'
|
||||
// DO NOT EDIT !
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
extern crate hyper;
|
||||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
extern crate yup_oauth2 as oauth2;
|
||||
extern crate mime;
|
||||
extern crate url;
|
||||
|
||||
mod cmn;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::cell::RefCell;
|
||||
use std::borrow::BorrowMut;
|
||||
use std::default::Default;
|
||||
use std::collections::BTreeMap;
|
||||
use serde_json as json;
|
||||
use std::io;
|
||||
use std::fs;
|
||||
use std::mem;
|
||||
use std::thread::sleep;
|
||||
use std::time::Duration;
|
||||
|
||||
pub use cmn::{MultiPartReader, ToParts, MethodInfo, Result, Error, CallBuilder, Hub, ReadSeek, Part,
|
||||
ResponseResult, RequestValue, NestedType, Delegate, DefaultDelegate, MethodsBuilder,
|
||||
Resource, ErrorResponse, remove_json_null_values};
|
||||
|
||||
|
||||
// ##############
|
||||
// UTILITIES ###
|
||||
// ############
|
||||
|
||||
/// Identifies the an OAuth2 authorization scope.
|
||||
/// A scope is needed when requesting an
|
||||
/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
|
||||
#[derive(PartialEq, Eq, Hash)]
|
||||
pub enum Scope {
|
||||
/// View and manage your Google Play Developer account
|
||||
Androidpublisher,
|
||||
}
|
||||
|
||||
impl AsRef<str> for Scope {
|
||||
fn as_ref(&self) -> &str {
|
||||
match *self {
|
||||
Scope::Androidpublisher => "https://www.googleapis.com/auth/androidpublisher",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Scope {
|
||||
fn default() -> Scope {
|
||||
Scope::Androidpublisher
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ########
|
||||
// HUB ###
|
||||
// ######
|
||||
|
||||
/// Central instance to access all Playcustomapp related resource activities
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Instantiate a new hub
|
||||
///
|
||||
/// ```test_harness,no_run
|
||||
/// extern crate hyper;
|
||||
/// extern crate hyper_rustls;
|
||||
/// extern crate yup_oauth2 as oauth2;
|
||||
/// extern crate google_playcustomapp1 as playcustomapp1;
|
||||
/// use playcustomapp1::CustomApp;
|
||||
/// use playcustomapp1::{Result, Error};
|
||||
/// use std::fs;
|
||||
/// # #[test] fn egal() {
|
||||
/// use std::default::Default;
|
||||
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||||
/// use playcustomapp1::Playcustomapp;
|
||||
///
|
||||
/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
|
||||
/// // `client_secret`, among other things.
|
||||
/// let secret: ApplicationSecret = Default::default();
|
||||
/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
|
||||
/// // unless you replace `None` with the desired Flow.
|
||||
/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
|
||||
/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
|
||||
/// // retrieve them from storage.
|
||||
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||||
/// hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||||
/// <MemoryStorage as Default>::default(), None);
|
||||
/// let mut hub = Playcustomapp::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
||||
/// // As the method needs a request, you would usually fill it with the desired information
|
||||
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
||||
/// // Values shown here are possibly random and not representative !
|
||||
/// let mut req = CustomApp::default();
|
||||
///
|
||||
/// // You can configure optional parameters by calling the respective setters at will, and
|
||||
/// // execute the final call using `upload_resumable(...)`.
|
||||
/// // Values shown here are possibly random and not representative !
|
||||
/// let result = hub.accounts().custom_apps_create(req, "account")
|
||||
/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap());
|
||||
///
|
||||
/// match result {
|
||||
/// Err(e) => match e {
|
||||
/// // The Error enum provides details about what exactly happened.
|
||||
/// // You can also just use its `Debug`, `Display` or `Error` traits
|
||||
/// Error::HttpError(_)
|
||||
/// |Error::MissingAPIKey
|
||||
/// |Error::MissingToken(_)
|
||||
/// |Error::Cancelled
|
||||
/// |Error::UploadSizeLimitExceeded(_, _)
|
||||
/// |Error::Failure(_)
|
||||
/// |Error::BadRequest(_)
|
||||
/// |Error::FieldClash(_)
|
||||
/// |Error::JsonDecodeError(_, _) => println!("{}", e),
|
||||
/// },
|
||||
/// Ok(res) => println!("Success: {:?}", res),
|
||||
/// }
|
||||
/// # }
|
||||
/// ```
|
||||
pub struct Playcustomapp<C, A> {
|
||||
client: RefCell<C>,
|
||||
auth: RefCell<A>,
|
||||
_user_agent: String,
|
||||
_base_url: String,
|
||||
_root_url: String,
|
||||
}
|
||||
|
||||
impl<'a, C, A> Hub for Playcustomapp<C, A> {}
|
||||
|
||||
impl<'a, C, A> Playcustomapp<C, A>
|
||||
where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||||
|
||||
pub fn new(client: C, authenticator: A) -> Playcustomapp<C, A> {
|
||||
Playcustomapp {
|
||||
client: RefCell::new(client),
|
||||
auth: RefCell::new(authenticator),
|
||||
_user_agent: "google-api-rust-client/1.0.6".to_string(),
|
||||
_base_url: "https://www.googleapis.com/playcustomapp/v1/accounts/".to_string(),
|
||||
_root_url: "https://www.googleapis.com/".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn accounts(&'a self) -> AccountMethods<'a, C, A> {
|
||||
AccountMethods { hub: &self }
|
||||
}
|
||||
|
||||
/// Set the user-agent header field to use in all requests to the server.
|
||||
/// It defaults to `google-api-rust-client/1.0.6`.
|
||||
///
|
||||
/// Returns the previously set user-agent.
|
||||
pub fn user_agent(&mut self, agent_name: String) -> String {
|
||||
mem::replace(&mut self._user_agent, agent_name)
|
||||
}
|
||||
|
||||
/// Set the base url to use in all requests to the server.
|
||||
/// It defaults to `https://www.googleapis.com/playcustomapp/v1/accounts/`.
|
||||
///
|
||||
/// Returns the previously set base url.
|
||||
pub fn base_url(&mut self, new_base_url: String) -> String {
|
||||
mem::replace(&mut self._base_url, new_base_url)
|
||||
}
|
||||
|
||||
/// Set the root url to use in all requests to the server.
|
||||
/// It defaults to `https://www.googleapis.com/`.
|
||||
///
|
||||
/// Returns the previously set root url.
|
||||
pub fn root_url(&mut self, new_root_url: String) -> String {
|
||||
mem::replace(&mut self._root_url, new_root_url)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ############
|
||||
// SCHEMAS ###
|
||||
// ##########
|
||||
/// This resource represents a custom app.
|
||||
///
|
||||
/// # Activities
|
||||
///
|
||||
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
|
||||
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
|
||||
///
|
||||
/// * [custom apps create accounts](struct.AccountCustomAppCreateCall.html) (request|response)
|
||||
///
|
||||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct CustomApp {
|
||||
/// Default listing language in BCP 47 format.
|
||||
#[serde(rename="languageCode")]
|
||||
pub language_code: Option<String>,
|
||||
/// Title for the Android app.
|
||||
pub title: Option<String>,
|
||||
}
|
||||
|
||||
impl RequestValue for CustomApp {}
|
||||
impl ResponseResult for CustomApp {}
|
||||
|
||||
|
||||
|
||||
// ###################
|
||||
// MethodBuilders ###
|
||||
// #################
|
||||
|
||||
/// A builder providing access to all methods supported on *account* resources.
|
||||
/// It is not used directly, but through the `Playcustomapp` hub.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// Instantiate a resource builder
|
||||
///
|
||||
/// ```test_harness,no_run
|
||||
/// extern crate hyper;
|
||||
/// extern crate hyper_rustls;
|
||||
/// extern crate yup_oauth2 as oauth2;
|
||||
/// extern crate google_playcustomapp1 as playcustomapp1;
|
||||
///
|
||||
/// # #[test] fn egal() {
|
||||
/// use std::default::Default;
|
||||
/// use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||||
/// use playcustomapp1::Playcustomapp;
|
||||
///
|
||||
/// let secret: ApplicationSecret = Default::default();
|
||||
/// let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||||
/// hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||||
/// <MemoryStorage as Default>::default(), None);
|
||||
/// let mut hub = Playcustomapp::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
||||
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
|
||||
/// // like `custom_apps_create(...)`
|
||||
/// // to build up your call.
|
||||
/// let rb = hub.accounts();
|
||||
/// # }
|
||||
/// ```
|
||||
pub struct AccountMethods<'a, C, A>
|
||||
where C: 'a, A: 'a {
|
||||
|
||||
hub: &'a Playcustomapp<C, A>,
|
||||
}
|
||||
|
||||
impl<'a, C, A> MethodsBuilder for AccountMethods<'a, C, A> {}
|
||||
|
||||
impl<'a, C, A> AccountMethods<'a, C, A> {
|
||||
|
||||
/// Create a builder to help you perform the following task:
|
||||
///
|
||||
/// Create and publish a new custom app.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `request` - No description provided.
|
||||
/// * `account` - Developer account ID.
|
||||
pub fn custom_apps_create(&self, request: CustomApp, account: &str) -> AccountCustomAppCreateCall<'a, C, A> {
|
||||
AccountCustomAppCreateCall {
|
||||
hub: self.hub,
|
||||
_request: request,
|
||||
_account: account.to_string(),
|
||||
_delegate: Default::default(),
|
||||
_scopes: Default::default(),
|
||||
_additional_params: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ###################
|
||||
// CallBuilders ###
|
||||
// #################
|
||||
|
||||
/// Create and publish a new custom app.
|
||||
///
|
||||
/// A builder for the *customApps.create* method supported by a *account* resource.
|
||||
/// It is not used directly, but through a `AccountMethods` instance.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// Instantiate a resource method builder
|
||||
///
|
||||
/// ```test_harness,no_run
|
||||
/// # extern crate hyper;
|
||||
/// # extern crate hyper_rustls;
|
||||
/// # extern crate yup_oauth2 as oauth2;
|
||||
/// # extern crate google_playcustomapp1 as playcustomapp1;
|
||||
/// use playcustomapp1::CustomApp;
|
||||
/// use std::fs;
|
||||
/// # #[test] fn egal() {
|
||||
/// # use std::default::Default;
|
||||
/// # use oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, MemoryStorage};
|
||||
/// # use playcustomapp1::Playcustomapp;
|
||||
///
|
||||
/// # let secret: ApplicationSecret = Default::default();
|
||||
/// # let auth = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
|
||||
/// # hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())),
|
||||
/// # <MemoryStorage as Default>::default(), None);
|
||||
/// # let mut hub = Playcustomapp::new(hyper::Client::with_connector(hyper::net::HttpsConnector::new(hyper_rustls::TlsClient::new())), auth);
|
||||
/// // As the method needs a request, you would usually fill it with the desired information
|
||||
/// // into the respective structure. Some of the parts shown here might not be applicable !
|
||||
/// // Values shown here are possibly random and not representative !
|
||||
/// let mut req = CustomApp::default();
|
||||
///
|
||||
/// // You can configure optional parameters by calling the respective setters at will, and
|
||||
/// // execute the final call using `upload_resumable(...)`.
|
||||
/// // Values shown here are possibly random and not representative !
|
||||
/// let result = hub.accounts().custom_apps_create(req, "account")
|
||||
/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap());
|
||||
/// # }
|
||||
/// ```
|
||||
pub struct AccountCustomAppCreateCall<'a, C, A>
|
||||
where C: 'a, A: 'a {
|
||||
|
||||
hub: &'a Playcustomapp<C, A>,
|
||||
_request: CustomApp,
|
||||
_account: String,
|
||||
_delegate: Option<&'a mut Delegate>,
|
||||
_additional_params: HashMap<String, String>,
|
||||
_scopes: BTreeMap<String, ()>
|
||||
}
|
||||
|
||||
impl<'a, C, A> CallBuilder for AccountCustomAppCreateCall<'a, C, A> {}
|
||||
|
||||
impl<'a, C, A> AccountCustomAppCreateCall<'a, C, A> where C: BorrowMut<hyper::Client>, A: oauth2::GetToken {
|
||||
|
||||
|
||||
/// Perform the operation you have build so far.
|
||||
fn doit<RS>(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: &'static str) -> Result<(hyper::client::Response, CustomApp)>
|
||||
where RS: ReadSeek {
|
||||
use std::io::{Read, Seek};
|
||||
use hyper::header::{ContentType, ContentLength, Authorization, Bearer, UserAgent, Location};
|
||||
let mut dd = DefaultDelegate;
|
||||
let mut dlg: &mut Delegate = match self._delegate {
|
||||
Some(d) => d,
|
||||
None => &mut dd
|
||||
};
|
||||
dlg.begin(MethodInfo { id: "playcustomapp.accounts.customApps.create",
|
||||
http_method: hyper::method::Method::Post });
|
||||
let mut params: Vec<(&str, String)> = Vec::with_capacity((4 + self._additional_params.len()));
|
||||
params.push(("account", self._account.to_string()));
|
||||
for &field in ["alt", "account"].iter() {
|
||||
if self._additional_params.contains_key(field) {
|
||||
dlg.finished(false);
|
||||
return Err(Error::FieldClash(field));
|
||||
}
|
||||
}
|
||||
for (name, value) in self._additional_params.iter() {
|
||||
params.push((&name, value.clone()));
|
||||
}
|
||||
|
||||
params.push(("alt", "json".to_string()));
|
||||
|
||||
let (mut url, upload_type) =
|
||||
if protocol == "simple" {
|
||||
(self.hub._root_url.clone() + "upload/playcustomapp/v1/accounts/{account}/customApps", "multipart")
|
||||
} else if protocol == "resumable" {
|
||||
(self.hub._root_url.clone() + "resumable/upload/playcustomapp/v1/accounts/{account}/customApps", "resumable")
|
||||
} else {
|
||||
unreachable!()
|
||||
};
|
||||
params.push(("uploadType", upload_type.to_string()));
|
||||
if self._scopes.len() == 0 {
|
||||
self._scopes.insert(Scope::Androidpublisher.as_ref().to_string(), ());
|
||||
}
|
||||
|
||||
for &(find_this, param_name) in [("{account}", "account")].iter() {
|
||||
let mut replace_with: Option<&str> = None;
|
||||
for &(name, ref value) in params.iter() {
|
||||
if name == param_name {
|
||||
replace_with = Some(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
url = url.replace(find_this, replace_with.expect("to find substitution value in params"));
|
||||
}
|
||||
{
|
||||
let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
|
||||
for param_name in ["account"].iter() {
|
||||
if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
|
||||
indices_for_removal.push(index);
|
||||
}
|
||||
}
|
||||
for &index in indices_for_removal.iter() {
|
||||
params.remove(index);
|
||||
}
|
||||
}
|
||||
|
||||
if params.len() > 0 {
|
||||
url.push('?');
|
||||
url.push_str(&url::form_urlencoded::serialize(params));
|
||||
}
|
||||
|
||||
let mut json_mime_type = mime::Mime(mime::TopLevel::Application, mime::SubLevel::Json, Default::default());
|
||||
let mut request_value_reader =
|
||||
{
|
||||
let mut value = json::value::to_value(&self._request).expect("serde to work");
|
||||
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();
|
||||
|
||||
let mut should_ask_dlg_for_url = false;
|
||||
let mut upload_url_from_server;
|
||||
let mut upload_url: Option<String> = None;
|
||||
|
||||
loop {
|
||||
let token = match self.hub.auth.borrow_mut().token(self._scopes.keys()) {
|
||||
Ok(token) => token,
|
||||
Err(err) => {
|
||||
match dlg.token(&*err) {
|
||||
Some(token) => token,
|
||||
None => {
|
||||
dlg.finished(false);
|
||||
return Err(Error::MissingToken(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
let auth_header = Authorization(Bearer { token: token.access_token });
|
||||
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||||
let mut req_result = {
|
||||
if should_ask_dlg_for_url && (upload_url = dlg.upload_url()) == () && upload_url.is_some() {
|
||||
should_ask_dlg_for_url = false;
|
||||
upload_url_from_server = false;
|
||||
let url = upload_url.as_ref().and_then(|s| Some(hyper::Url::parse(s).unwrap())).unwrap();
|
||||
hyper::client::Response::new(url, Box::new(cmn::DummyNetworkStream)).and_then(|mut res| {
|
||||
res.status = hyper::status::StatusCode::Ok;
|
||||
res.headers.set(Location(upload_url.as_ref().unwrap().clone()));
|
||||
Ok(res)
|
||||
})
|
||||
} else {
|
||||
let mut mp_reader: MultiPartReader = Default::default();
|
||||
let (mut body_reader, content_type) = match protocol {
|
||||
"simple" => {
|
||||
mp_reader.reserve_exact(2);
|
||||
let size = reader.seek(io::SeekFrom::End(0)).unwrap();
|
||||
reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||||
if size > 104857600 {
|
||||
return Err(Error::UploadSizeLimitExceeded(size, 104857600))
|
||||
}
|
||||
mp_reader.add_part(&mut request_value_reader, request_size, json_mime_type.clone())
|
||||
.add_part(&mut reader, size, reader_mime_type.clone());
|
||||
let mime_type = mp_reader.mime_type();
|
||||
(&mut mp_reader as &mut io::Read, ContentType(mime_type))
|
||||
},
|
||||
_ => (&mut request_value_reader as &mut io::Read, ContentType(json_mime_type.clone())),
|
||||
};
|
||||
let mut client = &mut *self.hub.client.borrow_mut();
|
||||
let mut req = client.borrow_mut().request(hyper::method::Method::Post, &url)
|
||||
.header(UserAgent(self.hub._user_agent.clone()))
|
||||
.header(auth_header.clone())
|
||||
.header(content_type)
|
||||
.body(&mut body_reader);
|
||||
upload_url_from_server = true;
|
||||
if protocol == "resumable" {
|
||||
req = req.header(cmn::XUploadContentType(reader_mime_type.clone()));
|
||||
}
|
||||
|
||||
dlg.pre_request();
|
||||
req.send()
|
||||
}
|
||||
};
|
||||
|
||||
match req_result {
|
||||
Err(err) => {
|
||||
if let oauth2::Retry::After(d) = dlg.http_error(&err) {
|
||||
sleep(d);
|
||||
continue;
|
||||
}
|
||||
dlg.finished(false);
|
||||
return Err(Error::HttpError(err))
|
||||
}
|
||||
Ok(mut res) => {
|
||||
if !res.status.is_success() {
|
||||
let mut json_err = String::new();
|
||||
res.read_to_string(&mut json_err).unwrap();
|
||||
if let oauth2::Retry::After(d) = dlg.http_failure(&res,
|
||||
json::from_str(&json_err).ok(),
|
||||
json::from_str(&json_err).ok()) {
|
||||
sleep(d);
|
||||
continue;
|
||||
}
|
||||
dlg.finished(false);
|
||||
return match json::from_str::<ErrorResponse>(&json_err){
|
||||
Err(_) => Err(Error::Failure(res)),
|
||||
Ok(serr) => Err(Error::BadRequest(serr))
|
||||
}
|
||||
}
|
||||
if protocol == "resumable" {
|
||||
let size = reader.seek(io::SeekFrom::End(0)).unwrap();
|
||||
reader.seek(io::SeekFrom::Start(0)).unwrap();
|
||||
if size > 104857600 {
|
||||
return Err(Error::UploadSizeLimitExceeded(size, 104857600))
|
||||
}
|
||||
let mut client = &mut *self.hub.client.borrow_mut();
|
||||
let upload_result = {
|
||||
let url_str = &res.headers.get::<Location>().expect("Location header is part of protocol").0;
|
||||
if upload_url_from_server {
|
||||
dlg.store_upload_url(Some(url_str));
|
||||
}
|
||||
|
||||
cmn::ResumableUploadHelper {
|
||||
client: &mut client.borrow_mut(),
|
||||
delegate: dlg,
|
||||
start_at: if upload_url_from_server { Some(0) } else { None },
|
||||
auth: &mut *self.hub.auth.borrow_mut(),
|
||||
user_agent: &self.hub._user_agent,
|
||||
auth_header: auth_header.clone(),
|
||||
url: url_str,
|
||||
reader: &mut reader,
|
||||
media_type: reader_mime_type.clone(),
|
||||
content_length: size
|
||||
}.upload()
|
||||
};
|
||||
match upload_result {
|
||||
None => {
|
||||
dlg.finished(false);
|
||||
return Err(Error::Cancelled)
|
||||
}
|
||||
Some(Err(err)) => {
|
||||
dlg.finished(false);
|
||||
return Err(Error::HttpError(err))
|
||||
}
|
||||
Some(Ok(upload_result)) => {
|
||||
res = upload_result;
|
||||
if !res.status.is_success() {
|
||||
dlg.store_upload_url(None);
|
||||
dlg.finished(false);
|
||||
return Err(Error::Failure(res))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let result_value = {
|
||||
let mut json_response = String::new();
|
||||
res.read_to_string(&mut json_response).unwrap();
|
||||
match json::from_str(&json_response) {
|
||||
Ok(decoded) => (res, decoded),
|
||||
Err(err) => {
|
||||
dlg.response_json_decode_error(&json_response, &err);
|
||||
return Err(Error::JsonDecodeError(json_response, err));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
dlg.finished(true);
|
||||
return Ok(result_value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Upload media all at once.
|
||||
/// If the upload fails for whichever reason, all progress is lost.
|
||||
///
|
||||
/// * *max size*: 100MB
|
||||
/// * *multipart*: yes
|
||||
/// * *valid mime types*: '*/*'
|
||||
pub fn upload<RS>(self, stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, CustomApp)>
|
||||
where RS: ReadSeek {
|
||||
self.doit(stream, mime_type, "simple")
|
||||
}
|
||||
/// Upload media in a resumable fashion.
|
||||
/// Even if the upload fails or is interrupted, it can be resumed for a
|
||||
/// certain amount of time as the server maintains state temporarily.
|
||||
///
|
||||
/// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
|
||||
/// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
|
||||
/// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
|
||||
/// `cancel_chunk_upload(...)`.
|
||||
///
|
||||
/// * *max size*: 100MB
|
||||
/// * *multipart*: yes
|
||||
/// * *valid mime types*: '*/*'
|
||||
pub fn upload_resumable<RS>(self, resumeable_stream: RS, mime_type: mime::Mime) -> Result<(hyper::client::Response, CustomApp)>
|
||||
where RS: ReadSeek {
|
||||
self.doit(resumeable_stream, mime_type, "resumable")
|
||||
}
|
||||
|
||||
///
|
||||
/// Sets the *request* property to the given value.
|
||||
///
|
||||
/// Even though the property as already been set when instantiating this call,
|
||||
/// we provide this method for API completeness.
|
||||
pub fn request(mut self, new_value: CustomApp) -> AccountCustomAppCreateCall<'a, C, A> {
|
||||
self._request = new_value;
|
||||
self
|
||||
}
|
||||
/// Developer account ID.
|
||||
///
|
||||
/// Sets the *account* path property to the given value.
|
||||
///
|
||||
/// Even though the property as already been set when instantiating this call,
|
||||
/// we provide this method for API completeness.
|
||||
pub fn account(mut self, new_value: &str) -> AccountCustomAppCreateCall<'a, C, A> {
|
||||
self._account = new_value.to_string();
|
||||
self
|
||||
}
|
||||
/// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
|
||||
/// while executing the actual API request.
|
||||
///
|
||||
/// It should be used to handle progress information, and to implement a certain level of resilience.
|
||||
///
|
||||
/// Sets the *delegate* property to the given value.
|
||||
pub fn delegate(mut self, new_value: &'a mut Delegate) -> AccountCustomAppCreateCall<'a, C, A> {
|
||||
self._delegate = Some(new_value);
|
||||
self
|
||||
}
|
||||
|
||||
/// Set any additional parameter of the query string used in the request.
|
||||
/// It should be used to set parameters which are not yet available through their own
|
||||
/// setters.
|
||||
///
|
||||
/// Please note that this method must not be used to set any of the known paramters
|
||||
/// which have their own setter method. If done anyway, the request will fail.
|
||||
///
|
||||
/// # Additional Parameters
|
||||
///
|
||||
/// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
|
||||
/// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
|
||||
/// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
|
||||
/// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
|
||||
/// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
|
||||
/// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
|
||||
/// * *alt* (query-string) - Data format for the response.
|
||||
pub fn param<T>(mut self, name: T, value: T) -> AccountCustomAppCreateCall<'a, C, A>
|
||||
where T: AsRef<str> {
|
||||
self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
|
||||
self
|
||||
}
|
||||
|
||||
/// Identifies the authorization scope for the method you are building.
|
||||
///
|
||||
/// Use this method to actively specify which scope should be used, instead the default `Scope` variant
|
||||
/// `Scope::Androidpublisher`.
|
||||
///
|
||||
/// The `scope` will be added to a set of scopes. This is important as one can maintain access
|
||||
/// tokens for more than one scope.
|
||||
/// If `None` is specified, then all scopes will be removed and no default scope will be used either.
|
||||
/// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
|
||||
/// function for details).
|
||||
///
|
||||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||||
/// sufficient, a read-write scope will do as well.
|
||||
pub fn add_scope<T, S>(mut self, scope: T) -> AccountCustomAppCreateCall<'a, C, A>
|
||||
where T: Into<Option<S>>,
|
||||
S: AsRef<str> {
|
||||
match scope.into() {
|
||||
Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
|
||||
None => None,
|
||||
};
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user