gapirs-drive-v3 0.0.1

Rust library for Google API drive v0.0.1
Documentation
// This file was generated by code-gen. DO NOT EDIT MANUALLY! 

extern crate derive_more;
extern crate std;
use ::serde::{Deserialize, Serialize};
use crate::gapirs_common::errors::*;
use crate::gapirs_common::utils::converters::ConvertToQueryParams;
use crate::gapirs_common::Hub;
///This usage is to have a reference to the return type of the call
use crate::discovery::schemas::*;
use ::derive_builder::Builder;
use ::core::str::FromStr;
use ::std::write;
use ::std::error;
use ::core::option::Option::Some;
use ::core::option::Option::None;
use ::core::result::Result::Ok;
use ::core::result::Result::Err;
use ::core::default::Default;
use ::core::convert::AsRef;
use ::core::convert::From;
use std::string::ToString;
/// Lists the user's files. This method accepts the `q` parameter, which is a search query combining one or more search terms. For more information, see the \[Search for files & folders\](/workspace/drive/api/guides/search-files) guide. *Note:* This method returns *all* files by default, including trashed files. If you don't want trashed files to appear in the list, use the `trashed=false` query parameter to remove trashed files from the results.
#[derive(Deserialize, Serialize, Builder)]
#[builder(name = DriveFilesListCallBuilder)]
#[builder(derive(::derive_more::Debug))]
#[derive(::derive_more::Debug)]
#[builder(setter(strip_option))]
#[builder(pattern = "owned")]
pub struct DriveFilesListCall<'a, H: Hub> {
    #[serde(skip)]
    #[debug(skip)]
    #[builder(setter(custom))]
    #[builder(default)]
    _hub: ::core::option::Option<&'a H>,
    #[serde(rename = "corpora")]
    #[builder(setter(into))]
    #[serde(default)]
    #[builder(default)]
    ///Bodies of items (files/documents) to which the query applies. Supported bodies are 'user', 'domain', 'drive', and 'allDrives'. Prefer 'user' or 'drive' to 'allDrives' for efficiency. By default, corpora is set to 'user'. However, this can change depending on the filter set through the 'q' parameter.
    pub corpora: ::core::option::Option<::alloc::string::String>,
    #[serde(rename = "corpus")]
    #[builder(setter(into))]
    #[serde(default)]
    #[builder(default)]
    ///Deprecated: The source of files to list. Use 'corpora' instead.
    #[deprecated(note = "This field is deprecated and might be removed at any point")]
    pub corpus: ::core::option::Option<Corpus>,
    #[serde(rename = "driveId")]
    #[builder(setter(into))]
    #[serde(default)]
    #[builder(default)]
    ///ID of the shared drive to search.
    pub drive_id: ::core::option::Option<::alloc::string::String>,
    #[serde(rename = "fields")]
    #[builder(setter(into))]
    #[serde(default)]
    #[builder(default)]
    ///Field mask used for response filtering
    pub fields: ::core::option::Option<::alloc::string::String>,
    #[serde(rename = "includeItemsFromAllDrives")]
    #[builder(setter(into))]
    #[serde(default = "::gapirs_common::defaults::bool_false")]
    #[builder(default = "false")]
    ///Whether both My Drive and shared drive items should be included in results.
    pub include_items_from_all_drives: ::core::primitive::bool,
    #[serde(rename = "includeLabels")]
    #[builder(setter(into))]
    #[serde(default)]
    #[builder(default)]
    ///A comma-separated list of IDs of labels to include in the `labelInfo` part of the response.
    pub include_labels: ::core::option::Option<::alloc::string::String>,
    #[serde(rename = "includePermissionsForView")]
    #[builder(setter(into))]
    #[serde(default)]
    #[builder(default)]
    ///Specifies which additional view's permissions to include in the response. Only 'published' is supported.
    pub include_permissions_for_view: ::core::option::Option<::alloc::string::String>,
    #[serde(rename = "includeTeamDriveItems")]
    #[builder(setter(into))]
    #[serde(default = "::gapirs_common::defaults::bool_false")]
    #[builder(default = "false")]
    ///Deprecated: Use `includeItemsFromAllDrives` instead.
    #[deprecated(note = "This field is deprecated and might be removed at any point")]
    pub include_team_drive_items: ::core::primitive::bool,
    #[serde(rename = "orderBy")]
    #[builder(setter(into))]
    #[serde(default)]
    #[builder(default)]
    ///A comma-separated list of sort keys. Valid keys are: * `createdTime`: When the file was created. * `folder`: The folder ID. This field is sorted using alphabetical ordering. * `modifiedByMeTime`: The last time the file was modified by the user. * `modifiedTime`: The last time the file was modified by anyone. * `name`: The name of the file. This field is sorted using alphabetical ordering, so 1, 12, 2, 22. * `name_natural`: The name of the file. This field is sorted using natural sort ordering, so 1, 2, 12, 22. * `quotaBytesUsed`: The number of storage quota bytes used by the file. * `recency`: The most recent timestamp from the file's date-time fields. * `sharedWithMeTime`: When the file was shared with the user, if applicable. * `starred`: Whether the user has starred the file. * `viewedByMeTime`: The last time the file was viewed by the user. Each key sorts ascending by default, but can be reversed with the 'desc' modifier. Example usage: `?orderBy=folder,modifiedTime desc,name`.
    pub order_by: ::core::option::Option<::alloc::string::String>,
    #[serde(rename = "pageSize")]
    #[builder(setter(into))]
    #[serde(default = "_serde_default_setter_0")]
    #[builder(default = "100")]
    ///The maximum number of files to return per page. Partial or empty result pages are possible even before the end of the files list has been reached.
    pub page_size: ::core::primitive::i32,
    #[serde(rename = "pageToken")]
    #[builder(setter(into))]
    #[serde(default)]
    #[builder(default)]
    ///The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.
    pub page_token: ::core::option::Option<::alloc::string::String>,
    #[serde(rename = "q")]
    #[builder(setter(into))]
    #[serde(default)]
    #[builder(default)]
    ///A query for filtering the file results. See the "Search for files & folders" guide for supported syntax.
    pub q: ::core::option::Option<::alloc::string::String>,
    #[serde(rename = "spaces")]
    #[builder(setter(into))]
    #[serde(default = "_serde_default_setter_1")]
    #[builder(default = "\"drive\".to_string()")]
    ///A comma-separated list of spaces to query within the corpora. Supported values are 'drive' and 'appDataFolder'.
    pub spaces: ::alloc::string::String,
    #[serde(rename = "supportsAllDrives")]
    #[builder(setter(into))]
    #[serde(default = "::gapirs_common::defaults::bool_false")]
    #[builder(default = "false")]
    ///Whether the requesting application supports both My Drives and shared drives.
    pub supports_all_drives: ::core::primitive::bool,
    #[serde(rename = "supportsTeamDrives")]
    #[builder(setter(into))]
    #[serde(default = "::gapirs_common::defaults::bool_false")]
    #[builder(default = "false")]
    ///Deprecated: Use `supportsAllDrives` instead.
    #[deprecated(note = "This field is deprecated and might be removed at any point")]
    pub supports_team_drives: ::core::primitive::bool,
    #[serde(rename = "teamDriveId")]
    #[builder(setter(into))]
    #[serde(default)]
    #[builder(default)]
    ///Deprecated: Use `driveId` instead.
    #[deprecated(note = "This field is deprecated and might be removed at any point")]
    pub team_drive_id: ::core::option::Option<::alloc::string::String>,
}
fn _serde_default_setter_0() -> ::core::primitive::i32 {
    "100".parse().unwrap()
}
fn _serde_default_setter_1() -> ::alloc::string::String {
    "drive".to_string()
}
impl<
    'a,
    H: crate::gapirs_common::Hub,
> crate::gapirs_common::ApiCallBase<
    'a,
    H,
    ::alloc::boxed::Box<crate::discovery::schemas::file_list::FileListPartial>,
> for DriveFilesListCall<'a, H> {
    fn get_method_path(&self) -> &::core::primitive::str {
        "files"
    }
    fn get_media_upload_path_simple(
        &self,
    ) -> ::core::option::Option<&::core::primitive::str> {
        ::core::option::Option::None
    }
    fn get_media_upload_path_resumable(
        &self,
    ) -> ::core::option::Option<&::core::primitive::str> {
        ::core::option::Option::None
    }
    fn get_query_params(
        &self,
    ) -> ::alloc::vec::Vec<(&::core::primitive::str, ::alloc::string::String)> {
        let mut params: ::alloc::vec::Vec<
            (&::core::primitive::str, ::alloc::string::String),
        > = ::alloc::vec![];
        if let ::core::option::Option::Some(v) = &self.corpora {
            params.push(("corpora", v.to_google_param_str()));
        }
        #[allow(deprecated)]
        if let ::core::option::Option::Some(v) = &self.corpus {
            params.push(("corpus", v.to_google_param_str()));
        }
        if let ::core::option::Option::Some(v) = &self.drive_id {
            params.push(("driveId", v.to_google_param_str()));
        }
        if let ::core::option::Option::Some(v) = &self.fields {
            params.push(("fields", v.to_google_param_str()));
        }
        let v = self.include_items_from_all_drives.to_google_param_str();
        if v != "false" {
            params.push(("includeItemsFromAllDrives", v));
        }
        if let ::core::option::Option::Some(v) = &self.include_labels {
            params.push(("includeLabels", v.to_google_param_str()));
        }
        if let ::core::option::Option::Some(v) = &self.include_permissions_for_view {
            params.push(("includePermissionsForView", v.to_google_param_str()));
        }
        #[allow(deprecated)]
        let v = self.include_team_drive_items.to_google_param_str();
        if v != "false" {
            params.push(("includeTeamDriveItems", v));
        }
        if let ::core::option::Option::Some(v) = &self.order_by {
            params.push(("orderBy", v.to_google_param_str()));
        }
        let v = self.page_size.to_google_param_str();
        if v != "100" {
            params.push(("pageSize", v));
        }
        if let ::core::option::Option::Some(v) = &self.page_token {
            params.push(("pageToken", v.to_google_param_str()));
        }
        if let ::core::option::Option::Some(v) = &self.q {
            params.push(("q", v.to_google_param_str()));
        }
        let v = self.spaces.to_google_param_str();
        if v != "drive" {
            params.push(("spaces", v));
        }
        let v = self.supports_all_drives.to_google_param_str();
        if v != "false" {
            params.push(("supportsAllDrives", v));
        }
        #[allow(deprecated)]
        let v = self.supports_team_drives.to_google_param_str();
        if v != "false" {
            params.push(("supportsTeamDrives", v));
        }
        #[allow(deprecated)]
        if let ::core::option::Option::Some(v) = &self.team_drive_id {
            params.push(("teamDriveId", v.to_google_param_str()));
        }
        params.push(("prettyPrint", "false".to_string()));
        params
    }
    fn get_query_param_order(&self) -> ::alloc::vec::Vec<&::core::primitive::str> {
        ::alloc::vec![]
    }
    fn get_scopes() -> ::alloc::vec::Vec<impl crate::Scope> {
        let scopes: ::alloc::vec::Vec<crate::Scopes> = ::alloc::vec![
            crate ::Scopes::from_str("https://www.googleapis.com/auth/drive")
            .expect("Invalid scope in generated code"), crate
            ::Scopes::from_str("https://www.googleapis.com/auth/drive.appdata")
            .expect("Invalid scope in generated code"), crate
            ::Scopes::from_str("https://www.googleapis.com/auth/drive.file")
            .expect("Invalid scope in generated code"), crate
            ::Scopes::from_str("https://www.googleapis.com/auth/drive.meet.readonly")
            .expect("Invalid scope in generated code"), crate
            ::Scopes::from_str("https://www.googleapis.com/auth/drive.metadata")
            .expect("Invalid scope in generated code"), crate
            ::Scopes::from_str("https://www.googleapis.com/auth/drive.metadata.readonly")
            .expect("Invalid scope in generated code"), crate
            ::Scopes::from_str("https://www.googleapis.com/auth/drive.photos.readonly")
            .expect("Invalid scope in generated code"), crate
            ::Scopes::from_str("https://www.googleapis.com/auth/drive.readonly")
            .expect("Invalid scope in generated code")
        ];
        scopes
    }
    fn get_hub(
        &self,
    ) -> ::core::result::Result<&impl crate::gapirs_common::Hub, ApiCallError> {
        let hub: &H = self._hub.as_ref().ok_or(ApiCallError::NoHub)?;
        ::core::result::Result::Ok(hub)
    }
    fn set_hub<'b>(&mut self, hub: &'b H)
    where
        'b: 'a,
    {
        self._hub = ::core::option::Option::Some(hub);
    }
    fn has_body(&self) -> ::core::primitive::bool {
        false
    }
    fn take_body(&mut self) -> ::core::option::Option<::alloc::string::String> {
        ::core::option::Option::None
    }
    fn has_media_upload(&self) -> ::core::primitive::bool {
        false
    }
    fn take_media_upload(
        &mut self,
    ) -> ::core::option::Option<
        ::gapirs_common::api::MediaUpload<
            dyn crate::gapirs_common::api::MediaUploadStream,
        >,
    > {
        ::core::option::Option::None
    }
    fn has_resumable_media_upload(&self) -> bool {
        false
    }
    fn take_resumable_media_upload(
        &mut self,
    ) -> ::core::option::Option<::gapirs_common::api::ResumableBody> {
        ::core::option::Option::None
    }
    fn take_media_download(
        &mut self,
    ) -> ::core::option::Option<
        ::gapirs_common::api::MediaDownload<
            dyn crate::gapirs_common::api::MediaDownloadStream,
        >,
    > {
        ::core::option::Option::None
    }
    fn get_media_download(
        &mut self,
    ) -> ::core::option::Option<
        &::gapirs_common::api::MediaDownload<
            dyn crate::gapirs_common::api::MediaDownloadStream,
        >,
    > {
        ::core::option::Option::None
    }
    fn is_media_download(&self) -> ::core::primitive::bool {
        false
    }
    fn get_request_method() -> crate::gapirs_common::deps::hyper::Method {
        ::gapirs_common::deps::hyper::Method::GET
    }
}
impl<'a, H: crate::gapirs_common::Hub> crate::gapirs_common::ApiCallBuilder<'a, H>
for DriveFilesListCallBuilder<'a, H> {
    fn new(hub: &'a H) -> Self {
        Self {
            _hub: ::core::option::Option::Some(::core::option::Option::Some(hub)),
            ..::core::default::Default::default()
        }
    }
}
impl<'a, H: crate::gapirs_common::Hub> DriveFilesListCallBuilder<'a, H> {
    pub fn with_hub(&mut self, hub: &'a H) -> &mut Self {
        self._hub = ::core::option::Option::Some(::core::option::Option::Some(hub));
        self
    }
}
#[derive(
    ::core::fmt::Debug,
    ::serde::Deserialize,
    ::serde::Serialize,
    Copy,
    Clone,
    PartialEq
)]
pub enum Corpus {
    ///Files shared to the user's domain.
    #[serde(rename = "domain")]
    Domain,
    ///Files owned by or shared to the user.
    #[serde(rename = "user")]
    User,
}
pub type CorpusPartial = Corpus;
impl ::core::str::FromStr for Corpus {
    type Err = &'static ::core::primitive::str;
    fn from_str(s: &::core::primitive::str) -> ::core::result::Result<Self, Self::Err> {
        match s {
            "domain" => crate::StdResult::Ok(Corpus::Domain),
            "user" => crate::StdResult::Ok(Corpus::User),
            _ => ::core::result::Result::Err("Invalid variant"),
        }
    }
}
impl ::core::convert::AsRef<::core::primitive::str> for Corpus {
    fn as_ref(&self) -> &::core::primitive::str {
        match self {
            Corpus::Domain => "domain",
            Corpus::User => "user",
        }
    }
}
impl crate::gapirs_common::utils::converters::ConvertToQueryParams for Corpus {
    fn to_google_param_str(&self) -> ::alloc::string::String {
        ::std::string::ToString::to_string(
            ::core::convert::AsRef::<::core::primitive::str>::as_ref(self),
        )
    }
}
impl crate::gapirs_common::utils::converters::ConvertToQueryParams for &Corpus {
    fn to_google_param_str(&self) -> ::alloc::string::String {
        ::std::string::ToString::to_string(
            ::core::convert::AsRef::<::core::primitive::str>::as_ref(self),
        )
    }
}