[−][src]Struct onedrive_api::OneDrive
The authorized client to access OneDrive resources in a specified Drive.
Implementations
impl OneDrive
[src]
pub fn new(access_token: String, drive: impl Into<DriveLocation>) -> Self
[src]
Create a new OneDrive instance with access token given to perform operations in a Drive.
pub fn new_with_client(
client: Client,
access_token: String,
drive: impl Into<DriveLocation>
) -> Self
[src]
client: Client,
access_token: String,
drive: impl Into<DriveLocation>
) -> Self
Same as OneDrive::new
but with custom reqwest::Client
.
Note
The given client
should have redirection disabled to
make get_item_download_url[_with_option]
work properly.
See also the docs of get_item_download_url[_with_option]
.
pub fn access_token(&self) -> &str
[src]
Get the access token used to create the OneDrive instance.
pub async fn get_drive_with_option(
&self,
option: ObjectOption<DriveField>
) -> Result<Drive>
[src]
&self,
option: ObjectOption<DriveField>
) -> Result<Drive>
Get current Drive
.
Retrieve the properties and relationships of a resource::Drive
resource.
See also
pub async fn get_drive(&self) -> Result<Drive>
[src]
pub async fn list_children_with_option<'a>(
&self,
item: impl Into<ItemLocation<'a>>,
option: CollectionOption<DriveItemField>
) -> Result<Option<ListChildrenFetcher>>
[src]
&self,
item: impl Into<ItemLocation<'a>>,
option: CollectionOption<DriveItemField>
) -> Result<Option<ListChildrenFetcher>>
List children of a DriveItem
.
Retrieve a collection of resource::DriveItem
s in the children relationship
of the given one.
Response
If successful, respond a fetcher for fetching changes from initial state (empty) to the snapshot of
current states. See ListChildrenFetcher
for more details.
If if_none_match
is set and it matches the item tag, return an None
.
See also
pub async fn list_children<'a>(
&self,
item: impl Into<ItemLocation<'a>>
) -> Result<Vec<DriveItem>>
[src]
&self,
item: impl Into<ItemLocation<'a>>
) -> Result<Vec<DriveItem>>
Shortcut to list_children_with_option
with default params,
and fetch and collect all children.
See also
pub async fn get_item_with_option<'a>(
&self,
item: impl Into<ItemLocation<'a>>,
option: ObjectOption<DriveItemField>
) -> Result<Option<DriveItem>>
[src]
&self,
item: impl Into<ItemLocation<'a>>,
option: ObjectOption<DriveItemField>
) -> Result<Option<DriveItem>>
Get a DriveItem
resource.
Retrieve the metadata for a resource::DriveItem
by file system path or ID.
Errors
Will return Ok(None)
if if_none_match
is set and it matches the item tag.
See also
pub async fn get_item<'a>(
&self,
item: impl Into<ItemLocation<'a>>
) -> Result<DriveItem>
[src]
&self,
item: impl Into<ItemLocation<'a>>
) -> Result<DriveItem>
pub async fn get_item_download_url_with_option<'a>(
&self,
item: impl Into<ItemLocation<'a>>,
option: ObjectOption<DriveItemField>
) -> Result<String>
[src]
&self,
item: impl Into<ItemLocation<'a>>,
option: ObjectOption<DriveItemField>
) -> Result<String>
Get a pre-authorized download URL for a file.
The URL returned is only valid for a short period of time (a few minutes).
Note
This API only works with reqwest redirection disabled, which is the default option set by
OneDrive::new()
.
If the OneDrive
instance is created by new_with_client()
,
be sure the reqwest::Client
has redirection disabled.
Only If-None-Match
is supported in option
.
See also
pub async fn get_item_download_url<'a>(
&self,
item: impl Into<ItemLocation<'a>>
) -> Result<String>
[src]
&self,
item: impl Into<ItemLocation<'a>>
) -> Result<String>
Shortcut to get_item_download_url_with_option
with default options.
See also
pub async fn create_folder_with_option<'a>(
&self,
parent_item: impl Into<ItemLocation<'a>>,
name: &FileName,
option: DriveItemPutOption
) -> Result<DriveItem>
[src]
&self,
parent_item: impl Into<ItemLocation<'a>>,
name: &FileName,
option: DriveItemPutOption
) -> Result<DriveItem>
Create a new folder under an DriveItem
Create a new folder DriveItem
with a specified parent item or path.
Errors
Will result in Err
with HTTP 409 CONFLICT if conflict_behavior
is set to Fail
and the target already exists.
See also
pub async fn create_folder<'a>(
&self,
parent_item: impl Into<ItemLocation<'a>>,
name: &FileName
) -> Result<DriveItem>
[src]
&self,
parent_item: impl Into<ItemLocation<'a>>,
name: &FileName
) -> Result<DriveItem>
pub async fn update_item_with_option<'a>(
&self,
item: impl Into<ItemLocation<'a>>,
patch: &DriveItem,
option: ObjectOption<DriveItemField>
) -> Result<DriveItem>
[src]
&self,
item: impl Into<ItemLocation<'a>>,
patch: &DriveItem,
option: ObjectOption<DriveItemField>
) -> Result<DriveItem>
Update DriveItem properties
Update the metadata for a DriveItem
.
If you want to rename or move an DriveItem
to another place,
you should use move_
(or move_with_option
) instead of this, which is a wrapper
to this API endpoint to make things easier.
See also
pub async fn update_item<'a>(
&self,
item: impl Into<ItemLocation<'a>>,
patch: &DriveItem
) -> Result<DriveItem>
[src]
&self,
item: impl Into<ItemLocation<'a>>,
patch: &DriveItem
) -> Result<DriveItem>
pub async fn upload_small<'a>(
&self,
item: impl Into<ItemLocation<'a>>,
data: impl Into<Bytes>
) -> Result<DriveItem>
[src]
&self,
item: impl Into<ItemLocation<'a>>,
data: impl Into<Bytes>
) -> Result<DriveItem>
Upload or replace the contents of a DriveItem
file.
The simple upload API allows you to provide the contents of a new file or update the contents of an existing file in a single API call. This method only supports files up to 4MB in size.
Panic
Panic if data
is larger than 4 MB (4,000,000 bytes).
See also
pub async fn new_upload_session_with_option<'a>(
&self,
item: impl Into<ItemLocation<'a>>,
option: DriveItemPutOption,
file_size: u64
) -> Result<UploadSession>
[src]
&self,
item: impl Into<ItemLocation<'a>>,
option: DriveItemPutOption,
file_size: u64
) -> Result<UploadSession>
Create an upload session.
Create an upload session to allow your app to upload files up to the maximum file size. An upload session allows your app to upload ranges of the file in sequential API requests, which allows the transfer to be resumed if a connection is dropped while the upload is in progress.
Errors
Will return Err
with HTTP 412 PRECONDITION_FAILED if if_match
is set
but does not match the item.
Note
conflict_behavior
is supported.
file_size
is actually NOT a part of this request, but is used to be stored
in UploadSession
and will be sent in upload_part()
requests.
See also
pub async fn new_upload_session<'a>(
&self,
item: impl Into<ItemLocation<'a>>,
file_size: u64
) -> Result<UploadSession>
[src]
&self,
item: impl Into<ItemLocation<'a>>,
file_size: u64
) -> Result<UploadSession>
Shortcut to new_upload_session_with_option
with ConflictBehavior::Fail
.
See also
pub async fn get_upload_session(
&self,
upload_url: String,
file_size: u64
) -> Result<UploadSession>
[src]
&self,
upload_url: String,
file_size: u64
) -> Result<UploadSession>
Resuming an in-progress upload
Query the status of the upload to find out which byte ranges have been received previously.
Note
file_size
is not saved by server but is required by UploadSession::upload_part()
.
You need to store it somewhere to make it possible to resume the session.
See also
pub async fn copy<'a, 'b>(
&self,
source_item: impl Into<ItemLocation<'a>>,
dest_folder: impl Into<ItemLocation<'b>>,
dest_name: &FileName
) -> Result<CopyProgressMonitor>
[src]
&self,
source_item: impl Into<ItemLocation<'a>>,
dest_folder: impl Into<ItemLocation<'b>>,
dest_name: &FileName
) -> Result<CopyProgressMonitor>
Copy a DriveItem.
Asynchronously creates a copy of an driveItem (including any children), under a new parent item or with a new name.
Note
The conflict behavior is not mentioned in Microsoft Docs, and cannot be specified.
But it seems to behave as Rename
if the destination folder is just the current
parent folder, and Fail
overwise.
See also
pub async fn move_with_option<'a, 'b>(
&self,
source_item: impl Into<ItemLocation<'a>>,
dest_folder: impl Into<ItemLocation<'b>>,
dest_name: Option<&FileName>,
option: DriveItemPutOption
) -> Result<DriveItem>
[src]
&self,
source_item: impl Into<ItemLocation<'a>>,
dest_folder: impl Into<ItemLocation<'b>>,
dest_name: Option<&FileName>,
option: DriveItemPutOption
) -> Result<DriveItem>
Move a DriveItem to a new folder.
This is a special case of the Update method. Your app can combine moving an item to a new container and updating other properties of the item into a single request.
Note: Items cannot be moved between Drives using this request.
Note
conflict_behavior
is supported.
Errors
Will return Err
with HTTP 412 PRECONDITION_FAILED if if_match
is set
but it does not match the item.
See also
pub async fn move_<'a, 'b>(
&self,
source_item: impl Into<ItemLocation<'a>>,
dest_folder: impl Into<ItemLocation<'b>>,
dest_name: Option<&FileName>
) -> Result<DriveItem>
[src]
&self,
source_item: impl Into<ItemLocation<'a>>,
dest_folder: impl Into<ItemLocation<'b>>,
dest_name: Option<&FileName>
) -> Result<DriveItem>
pub async fn delete_with_option<'a>(
&self,
item: impl Into<ItemLocation<'a>>,
option: DriveItemPutOption
) -> Result<()>
[src]
&self,
item: impl Into<ItemLocation<'a>>,
option: DriveItemPutOption
) -> Result<()>
Delete a DriveItem
.
Delete a DriveItem
by using its ID or path. Note that deleting items using
this method will move the items to the recycle bin instead of permanently
deleting the item.
Error
Will result in error with HTTP 412 PRECONDITION_FAILED if if_match
is set but
does not match the item.
Panic
conflict_behavior
is NOT supported. Set it will cause a panic.
See also
pub async fn delete<'a>(&self, item: impl Into<ItemLocation<'a>>) -> Result<()>
[src]
pub async fn track_root_changes_from_initial_with_option<'a>(
&self,
option: CollectionOption<DriveItemField>
) -> Result<TrackChangeFetcher>
[src]
&self,
option: CollectionOption<DriveItemField>
) -> Result<TrackChangeFetcher>
Track changes for root folder from initial state (empty state) to snapshot of current states.
This method allows your app to track changes to a drive and its children over time. Deleted items are returned with the deleted facet. Items with this property set should be removed from your local state.
Note: you should only delete a folder locally if it is empty after syncing all the changes.
Panic
Track Changes API does not support $count=true
query parameter.
If CollectionOption::get_count
is set in option, it will panic.
Response
Respond a fetcher for fetching changes from initial state (empty) to the snapshot of
current states. See TrackChangeFetcher
for more details.
See also
pub async fn track_root_changes_from_initial<'a>(
&self
) -> Result<TrackChangeFetcher>
[src]
&self
) -> Result<TrackChangeFetcher>
Shortcut to track_root_changes_from_initial_with_option
with default parameters.
See also
pub async fn track_root_changes_from_delta_url(
&self,
delta_url: &str
) -> Result<TrackChangeFetcher>
[src]
&self,
delta_url: &str
) -> Result<TrackChangeFetcher>
Track changes for root folder from snapshot (delta url) to snapshot of current states.
Note
There is no with_option
version of this function. Since delta URL already carries
query parameters when you get it. The initial parameters will be automatically used
in all following requests through delta URL.
pub async fn get_root_latest_delta_url_with_option<'a>(
&self,
option: CollectionOption<DriveItemField>
) -> Result<String>
[src]
&self,
option: CollectionOption<DriveItemField>
) -> Result<String>
Get a delta url representing the snapshot of current states of root folder.
The delta url can be used in track_root_changes_from_delta_url
later
to get diffs between two snapshots of states.
Note that options (query parameters) are saved in delta url, so they are applied to all later
requests by track_changes_from_delta_url
without need for specifying them every time.
Panic
Track Changes API does not support $count=true
query parameter.
If CollectionOption::get_count
is set in option, it will panic.
See also
pub async fn get_root_latest_delta_url<'a>(&self) -> Result<String>
[src]
Shortcut to get_root_latest_delta_url_with_option
with default parameters.
See also
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for OneDrive
[src]
impl Send for OneDrive
[src]
impl Sync for OneDrive
[src]
impl Unpin for OneDrive
[src]
impl !UnwindSafe for OneDrive
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,