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;
///Subscribes to changes for a user. For more information, see \[Notifications for resource changes\](https://developers.google.com/workspace/drive/api/guides/push).
#[derive(Deserialize, Serialize, Builder)]
#[builder(name = DriveChangesWatchCallBuilder)]
#[builder(derive(::derive_more::Debug))]
#[derive(::derive_more::Debug)]
#[builder(setter(strip_option))]
#[builder(pattern = "owned")]
pub struct DriveChangesWatchCall<'a, H: Hub> {
    #[serde(skip)]
    #[debug(skip)]
    #[builder(setter(custom))]
    #[builder(default)]
    _hub: ::core::option::Option<&'a H>,
    #[serde(skip)]
    #[debug(skip)]
    #[builder(setter(custom))]
    #[builder(pattern = "owned")]
    _body: ::core::option::Option<::alloc::string::String>,
    #[serde(rename = "driveId")]
    #[builder(setter(into))]
    #[serde(default)]
    #[builder(default)]
    ///The shared drive from which changes will be returned. If specified the change IDs will be reflective of the shared drive; use the combined drive ID and change ID as an identifier.
    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 = "includeCorpusRemovals")]
    #[builder(setter(into))]
    #[serde(default = "::gapirs_common::defaults::bool_false")]
    #[builder(default = "false")]
    ///Whether changes should include the file resource if the file is still accessible by the user at the time of the request, even when a file was removed from the list of changes and there will be no further change entries for this file.
    pub include_corpus_removals: ::core::primitive::bool,
    #[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 = "includeRemoved")]
    #[builder(setter(into))]
    #[serde(default = "::gapirs_common::defaults::bool_true")]
    #[builder(default = "true")]
    ///Whether to include changes indicating that items have been removed from the list of changes, for example by deletion or loss of access.
    pub include_removed: ::core::primitive::bool,
    #[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 = "pageSize")]
    #[builder(setter(into))]
    #[serde(default = "_serde_default_setter_0")]
    #[builder(default = "100")]
    ///The maximum number of changes to return per page.
    pub page_size: ::core::primitive::i32,
    #[serde(rename = "pageToken")]
    #[builder(setter(into))]
    ///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 or to the response from the getStartPageToken method.
    pub page_token: ::alloc::string::String,
    #[serde(rename = "restrictToMyDrive")]
    #[builder(setter(into))]
    #[serde(default = "::gapirs_common::defaults::bool_false")]
    #[builder(default = "false")]
    ///Whether to restrict the results to changes inside the My Drive hierarchy. This omits changes to files such as those in the Application Data folder or shared files which have not been added to My Drive.
    pub restrict_to_my_drive: ::core::primitive::bool,
    #[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::channel::ChannelPartial>,
> for DriveChangesWatchCall<'a, H> {
    fn get_method_path(&self) -> &::core::primitive::str {
        "changes/watch"
    }
    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.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_corpus_removals.to_google_param_str();
        if v != "false" {
            params.push(("includeCorpusRemovals", v));
        }
        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()));
        }
        let v = self.include_removed.to_google_param_str();
        if v != "true" {
            params.push(("includeRemoved", v));
        }
        #[allow(deprecated)]
        let v = self.include_team_drive_items.to_google_param_str();
        if v != "false" {
            params.push(("includeTeamDriveItems", v));
        }
        let v = self.page_size.to_google_param_str();
        if v != "100" {
            params.push(("pageSize", v));
        }
        let v = self.page_token.to_google_param_str();
        {
            params.push(("pageToken", v));
        }
        let v = self.restrict_to_my_drive.to_google_param_str();
        if v != "false" {
            params.push(("restrictToMyDrive", v));
        }
        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!["pageToken"]
    }
    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 {
        self._body.is_some()
    }
    fn take_body(&mut self) -> ::core::option::Option<::alloc::string::String> {
        self._body.take()
    }
    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::POST
    }
}
impl<'a, H: crate::gapirs_common::Hub> crate::gapirs_common::ApiCallBuilder<'a, H>
for DriveChangesWatchCallBuilder<'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> DriveChangesWatchCallBuilder<'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
    }
    pub fn with_body(
        mut self,
        body: impl ::core::convert::Into<
            ::alloc::boxed::Box<crate::discovery::schemas::channel::ChannelPartial>,
        >,
    ) -> ::core::result::Result<Self, crate::gapirs_common::errors::ApiCallError> {
        self._body = Some(
            Some(::gapirs_common::deps::serde_json::to_string(&body.into())?),
        );
        ::core::result::Result::Ok(self)
    }
}