// 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;
/// Updates a file's metadata and/or content. When calling this method, only populate fields in the request that you want to modify. When updating fields, some fields might be changed automatically, such as `modifiedDate`. This method supports patch semantics. This method supports an */upload* URI and accepts uploaded media with the following characteristics: - *Maximum file size:* 5,120 GB - *Accepted Media MIME types:*`*/*` Note: Specify a valid MIME type, rather than the literal `*/*` value. The literal `*/*` is only used to indicate that any valid MIME type can be uploaded. For more information on uploading files, see \[Upload file data\](/workspace/drive/api/guides/manage-uploads).
#[derive(Deserialize, Serialize, Builder)]
#[builder(name = DriveFilesUpdateCallBuilder)]
#[builder(derive(::derive_more::Debug))]
#[derive(::derive_more::Debug)]
#[builder(setter(strip_option))]
#[builder(pattern = "owned")]
pub struct DriveFilesUpdateCall<'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(skip)]
#[debug(skip)]
#[builder(setter(custom))]
#[builder(pattern = "owned")]
#[builder(default)]
_media: ::core::option::Option<
::gapirs_common::api::MediaUpload<
dyn crate::gapirs_common::api::MediaUploadStream,
>,
>,
#[serde(skip)]
#[debug(skip)]
#[builder(setter(custom))]
#[builder(pattern = "owned")]
#[builder(default)]
_resumable_media: ::core::option::Option<::gapirs_common::api::ResumableBody>,
#[serde(rename = "addParents")]
#[builder(setter(into))]
#[serde(default)]
#[builder(default)]
///A comma-separated list of parent IDs to add.
pub add_parents: ::core::option::Option<::alloc::string::String>,
#[serde(rename = "enforceSingleParent")]
#[builder(setter(into))]
#[serde(default = "::gapirs_common::defaults::bool_false")]
#[builder(default = "false")]
///Deprecated: Adding files to multiple folders is no longer supported. Use shortcuts instead.
#[deprecated(note = "This field is deprecated and might be removed at any point")]
pub enforce_single_parent: ::core::primitive::bool,
#[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 = "fileId")]
#[builder(setter(into))]
///The ID of the file.
pub file_id: ::alloc::string::String,
#[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 = "keepRevisionForever")]
#[builder(setter(into))]
#[serde(default = "::gapirs_common::defaults::bool_false")]
#[builder(default = "false")]
///Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Google Drive. Only 200 revisions for the file can be kept forever. If the limit is reached, try deleting pinned revisions.
pub keep_revision_forever: ::core::primitive::bool,
#[serde(rename = "ocrLanguage")]
#[builder(setter(into))]
#[serde(default)]
#[builder(default)]
///A language hint for OCR processing during image import (ISO 639-1 code).
pub ocr_language: ::core::option::Option<::alloc::string::String>,
#[serde(rename = "removeParents")]
#[builder(setter(into))]
#[serde(default)]
#[builder(default)]
///A comma-separated list of parent IDs to remove.
pub remove_parents: ::core::option::Option<::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 = "useContentAsIndexableText")]
#[builder(setter(into))]
#[serde(default = "::gapirs_common::defaults::bool_false")]
#[builder(default = "false")]
///Whether to use the uploaded content as indexable text.
pub use_content_as_indexable_text: ::core::primitive::bool,
}
impl<
'a,
H: crate::gapirs_common::Hub,
> crate::gapirs_common::ApiCallBase<
'a,
H,
::alloc::boxed::Box<crate::discovery::schemas::file::FilePartial>,
> for DriveFilesUpdateCall<'a, H> {
fn get_method_path(&self) -> &::core::primitive::str {
"files/{fileId}"
}
fn get_media_upload_path_simple(
&self,
) -> ::core::option::Option<&::core::primitive::str> {
::core::option::Option::Some("/upload/drive/v3/files/{fileId}")
}
fn get_media_upload_path_resumable(
&self,
) -> ::core::option::Option<&::core::primitive::str> {
Some("/resumable/upload/drive/v3/files/{fileId}")
}
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.add_parents {
params.push(("addParents", v.to_google_param_str()));
}
#[allow(deprecated)]
let v = self.enforce_single_parent.to_google_param_str();
if v != "false" {
params.push(("enforceSingleParent", v));
}
if let ::core::option::Option::Some(v) = &self.fields {
params.push(("fields", v.to_google_param_str()));
}
let v = self.file_id.to_google_param_str();
{
params.push(("fileId", 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.keep_revision_forever.to_google_param_str();
if v != "false" {
params.push(("keepRevisionForever", v));
}
if let ::core::option::Option::Some(v) = &self.ocr_language {
params.push(("ocrLanguage", v.to_google_param_str()));
}
if let ::core::option::Option::Some(v) = &self.remove_parents {
params.push(("removeParents", v.to_google_param_str()));
}
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));
}
let v = self.use_content_as_indexable_text.to_google_param_str();
if v != "false" {
params.push(("useContentAsIndexableText", v));
}
params.push(("prettyPrint", "false".to_string()));
params
}
fn get_query_param_order(&self) -> ::alloc::vec::Vec<&::core::primitive::str> {
::alloc::vec!["fileId"]
}
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.metadata")
.expect("Invalid scope in generated code"), crate
::Scopes::from_str("https://www.googleapis.com/auth/drive.scripts")
.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 {
self._media.is_some()
}
fn take_media_upload(
&mut self,
) -> ::core::option::Option<
::gapirs_common::api::MediaUpload<
dyn crate::gapirs_common::api::MediaUploadStream,
>,
> {
self._media.take()
}
fn has_resumable_media_upload(&self) -> bool {
self._resumable_media.is_some()
}
fn take_resumable_media_upload(
&mut self,
) -> ::core::option::Option<::gapirs_common::api::ResumableBody> {
self._resumable_media.take()
}
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::PATCH
}
}
impl<'a, H: crate::gapirs_common::Hub> crate::gapirs_common::ApiCallBuilder<'a, H>
for DriveFilesUpdateCallBuilder<'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> DriveFilesUpdateCallBuilder<'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::file::FilePartial>,
>,
) -> ::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)
}
pub fn with_media(
mut self,
media: crate::gapirs_common::api::MediaUpload<
dyn crate::gapirs_common::api::MediaUploadStream,
>,
) -> Self {
self._media = Some(Some(media));
self
}
pub fn with_resumable_media(
mut self,
resumable_media: crate::gapirs_common::api::ResumableBody,
) -> Self {
self._resumable_media = Some(Some(resumable_media));
self
}
}