pub struct Permissions { /* private fields */ }Expand description
Permissions for a file.
A permission grants a user, group, domain, or the world access to a file or a folder hierarchy.
Some resource methods (such as permissions.update)
require a permission_id. Use the permissions.list
method to retrieve the ID for a file, folder, or shared drive.
§Examples:
List the permission in a file
let file_id = "some-file-id";
let permission_list = drive.permissions.list(&file_id).execute()?;
if let Some(permissions) = permission_list.permissions {
for permission in permissions {
println!("{}", permission);
}
}Implementations§
Source§impl Permissions
impl Permissions
Sourcepub fn new(credentials: &Credentials) -> Self
pub fn new(credentials: &Credentials) -> Self
Creates a new Permissions resource with the given Credentials.
Sourcepub fn create<T: AsRef<str>>(&self, file_id: T) -> CreateRequest
pub fn create<T: AsRef<str>>(&self, file_id: T) -> CreateRequest
Creates a permission for a file or shared drive.
See Google’s documentation for more information.
§Warning
Concurrent permissions operations on the same file are not supported; only the last update is applied.
§Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/drivehttps://www.googleapis.com/auth/drive.file
§Examples:
use drive_v3::objects::Permission;
let permission = Permission {
permission_type: Some( "anyone".to_string() ),
role: Some( "reader".to_string() ),
..Default::default()
};
let file_id = "some-file-id";
let created_permission = drive.permissions.create(&file_id)
.permission(&permission)
.execute()?;
assert_eq!(created_permission.permission_type, permission.permission_type);
assert_eq!(created_permission.role, permission.role);Sourcepub fn delete<T, U>(&self, file_id: T, permission_id: U) -> DeleteRequest
pub fn delete<T, U>(&self, file_id: T, permission_id: U) -> DeleteRequest
Deletes a permission.
See Google’s documentation for more information.
§Warning
Concurrent permissions operations on the same file are not supported; only the last update is applied.
§Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/drivehttps://www.googleapis.com/auth/drive.file
§Examples:
let file_id = "some-file-id";
let permission_id = "some-permission-id";
let response = drive.permissions.delete(&file_id, &permission_id).execute();
assert!( response.is_ok() );Sourcepub fn get<T, U>(&self, file_id: T, permission_id: U) -> GetRequest
pub fn get<T, U>(&self, file_id: T, permission_id: U) -> GetRequest
Gets a permission by ID.
See Google’s documentation for more information.
§Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/drivehttps://www.googleapis.com/auth/drive.filehttps://www.googleapis.com/auth/drive.metadatahttps://www.googleapis.com/auth/drive.metadata.readonlyhttps://www.googleapis.com/auth/drive.photos.readonlyhttps://www.googleapis.com/auth/drive.readonly
§Examples:
let file_id = "some-file-id";
let permission_id = "some-permission-id";
let permission = drive.permissions.get(&file_id, &permission_id).execute()?;
println!("This is the file's permission:\n{}", permission);Sourcepub fn list<T: AsRef<str>>(&self, file_id: T) -> ListRequest
pub fn list<T: AsRef<str>>(&self, file_id: T) -> ListRequest
Lists a file’s or shared drive’s permissions.
See Google’s documentation for more information.
§Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/drivehttps://www.googleapis.com/auth/drive.filehttps://www.googleapis.com/auth/drive.metadatahttps://www.googleapis.com/auth/drive.metadata.readonlyhttps://www.googleapis.com/auth/drive.photos.readonlyhttps://www.googleapis.com/auth/drive.readonly
§Examples:
let file_id = "some-file-id";
let permission_list = drive.permissions.list(&file_id).execute()?;
if let Some(permissions) = permission_list.permissions {
for permission in permissions {
println!("{}", permission);
}
}Sourcepub fn update<T, U>(&self, file_id: T, permission_id: U) -> UpdateRequest
pub fn update<T, U>(&self, file_id: T, permission_id: U) -> UpdateRequest
Updates a permission with patch semantics.
See Google’s documentation for more information.
§Warning
Concurrent permissions operations on the same file are not supported; only the last update is applied.
§Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/drivehttps://www.googleapis.com/auth/drive.file
§Examples:
use drive_v3::objects::Permission;
let updated_permission = Permission {
permission_type: Some( "anyone".to_string() ),
role: Some( "commenter".to_string() ),
..Default::default()
};
let file_id = "some-file-id";
let permission_id = "some-permission-id";
let permission = drive.permissions.update(&file_id, &permission_id)
.permission(&updated_permission)
.execute()?;
assert_eq!(permission.permission_type, updated_permission.permission_type);
assert_eq!(permission.role, updated_permission.role);Trait Implementations§
Source§impl Clone for Permissions
impl Clone for Permissions
Source§fn clone(&self) -> Permissions
fn clone(&self) -> Permissions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Permissions
impl Debug for Permissions
Source§impl PartialEq for Permissions
impl PartialEq for Permissions
impl Eq for Permissions
impl StructuralPartialEq for Permissions
Auto Trait Implementations§
impl Freeze for Permissions
impl RefUnwindSafe for Permissions
impl Send for Permissions
impl Sync for Permissions
impl Unpin for Permissions
impl UnwindSafe for Permissions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.