INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Gets an object which represents a range that s offset from the specified range. The dimension of the returned range will match this range. If the resulting range is forced outside the bounds of the worksheet grid an exception will be thrown.: param int row_offset: The number of rows ( positive negative or 0 ) by which ...
def get_offset_range(self, row_offset, column_offset): """ Gets an object which represents a range that's offset from the specified range. The dimension of the returned range will match this range. If the resulting range is forced outside the bounds of the worksheet grid, an ...
Clear range values format fill border etc.: param str apply_to: Optional. Determines the type of clear action. The possible values are: all formats contents.
def clear(self, apply_to='all'): """ Clear range values, format, fill, border, etc. :param str apply_to: Optional. Determines the type of clear action. The possible values are: all, formats, contents. """ url = self.build_url(self._endpoints.get('clear_range')) r...
Deletes the cells associated with the range.: param str shift: Optional. Specifies which way to shift the cells. The possible values are: up left.
def delete(self, shift='up'): """ Deletes the cells associated with the range. :param str shift: Optional. Specifies which way to shift the cells. The possible values are: up, left. """ url = self.build_url(self._endpoints.get('delete_range')) return bool(self.se...
Merge the range cells into one region in the worksheet.: param bool across: Optional. Set True to merge cells in each row of the specified range as separate merged cells.
def merge(self, across=False): """ Merge the range cells into one region in the worksheet. :param bool across: Optional. Set True to merge cells in each row of the specified range as separate merged cells. """ url = self.build_url(self._endpoints.get('merge_range')) ...
Update this range
def update(self): """ Update this range """ if not self._track_changes: return True # there's nothing to update data = self.to_api_data(restrict_keys=self._track_changes) response = self.session.patch(self.build_url(''), data=data) if not response: retu...
Returns a RangeFormat instance with the format of this range
def get_format(self): """ Returns a RangeFormat instance with the format of this range """ url = self.build_url(self._endpoints.get('get_format')) response = self.session.get(url) if not response: return None return self.range_format_constructor(parent=self, **{self._...
Updates this named range: param bool visible: Specifies whether the object is visible or not: param str comment: Represents the comment associated with this name: return: Success or Failure
def update(self, *, visible=None, comment=None): """ Updates this named range :param bool visible: Specifies whether the object is visible or not :param str comment: Represents the comment associated with this name :return: Success or Failure """ if visible is Non...
Updates this row
def update(self, values): """ Updates this row """ response = self.session.patch(self.build_url(''), data={'values': values}) if not response: return False data = response.json() self.values = data.get('values', self.values) return True
Apply the given filter criteria on the given column.: param str criteria: the criteria to apply criteria example: { color: string criterion1: string criterion2: string dynamicCriteria: string filterOn: string icon: {
def apply_filter(self, criteria): """ Apply the given filter criteria on the given column. :param str criteria: the criteria to apply criteria example: { "color": "string", "criterion1": "string", "criterion2": "string", "dynamicCriteria": ...
Returns the filter applie to this column
def get_filter(self): """ Returns the filter applie to this column """ q = self.q().select('name').expand('filter') response = self.session.get(self.build_url(''), params=q.as_params()) if not response: return None data = response.json() return data.get('crite...
Return the columns of this table: param int top: specify n columns to retrieve: param int skip: specify n columns to skip
def get_columns(self, *, top=None, skip=None): """ Return the columns of this table :param int top: specify n columns to retrieve :param int skip: specify n columns to skip """ url = self.build_url(self._endpoints.get('get_columns')) params = {} if top is...
Gets a column from this table by id or name: param id_or_name: the id or name of the column: return: WorkBookTableColumn
def get_column(self, id_or_name): """ Gets a column from this table by id or name :param id_or_name: the id or name of the column :return: WorkBookTableColumn """ url = self.build_url(self._endpoints.get('get_column').format(quote(id_or_name))) response = self.ses...
Returns a table column by it s index: param int index: the zero - indexed position of the column in the table
def get_column_at_index(self, index): """ Returns a table column by it's index :param int index: the zero-indexed position of the column in the table """ if index is None: return None url = self.build_url(self._endpoints.get('get_column_index')) respo...
Deletes a Column by its id or name: param id_or_name: the id or name of the column: return bool: Success or Failure
def delete_column(self, id_or_name): """ Deletes a Column by its id or name :param id_or_name: the id or name of the column :return bool: Success or Failure """ url = self.build_url(self._endpoints.get('delete_column').format(id=quote(id_or_name))) return bool(sel...
Adds a column to the table: param str name: the name of the column: param int index: the index at which the column should be added. Defaults to 0.: param list values: a two dimension array of values to add to the column
def add_column(self, name, *, index=0, values=None): """ Adds a column to the table :param str name: the name of the column :param int index: the index at which the column should be added. Defaults to 0. :param list values: a two dimension array of values to add to the column ...
Return the rows of this table: param int top: specify n rows to retrieve: param int skip: specify n rows to skip: rtype: TableRow
def get_rows(self, *, top=None, skip=None): """ Return the rows of this table :param int top: specify n rows to retrieve :param int skip: specify n rows to skip :rtype: TableRow """ url = self.build_url(self._endpoints.get('get_rows')) params = {} ...
Returns a Row instance at an index
def get_row(self, index): """ Returns a Row instance at an index """ url = self.build_url(self._endpoints.get('get_row').format(id=index)) response = self.session.get(url) if not response: return None return self.row_constructor(parent=self, **{self._cloud_data_key: r...
Returns a table row by it s index: param int index: the zero - indexed position of the row in the table
def get_row_at_index(self, index): """ Returns a table row by it's index :param int index: the zero-indexed position of the row in the table """ if index is None: return None url = self.build_url(self._endpoints.get('get_row_index')) response = self.s...
Deletes a Row by it s index: param int index: the index of the row. zero indexed: return bool: Success or Failure
def delete_row(self, index): """ Deletes a Row by it's index :param int index: the index of the row. zero indexed :return bool: Success or Failure """ url = self.build_url(self._endpoints.get('delete_row').format(id=index)) return bool(self.session.post(url))
Add rows to this table. Multiple rows can be added at once.
def add_rows(self, values=None, index=None): """ Add rows to this table. Multiple rows can be added at once. This request might occasionally receive a 504 HTTP error. The appropriate response to this error is to repeat the request. :param list values: Optional. a 1 or 2...
Updates this table: param str name: the name of the table: param bool show_headers: whether or not to show the headers: param bool show_totals: whether or not to show the totals: param str style: the style of the table: return: Success or Failure
def update(self, *, name=None, show_headers=None, show_totals=None, style=None): """ Updates this table :param str name: the name of the table :param bool show_headers: whether or not to show the headers :param bool show_totals: whether or not to show the totals :param st...
Returns a Range based on the endpoint name
def _get_range(self, endpoint_name): """ Returns a Range based on the endpoint name """ url = self.build_url(self._endpoints.get(endpoint_name)) response = self.session.get(url) if not response: return None data = response.json() return self.range_constructor...
Returns this table worksheet
def get_worksheet(self): """ Returns this table worksheet """ url = self.build_url('') q = self.q().select('name').expand('worksheet') response = self.session.get(url, params=q.as_params()) if not response: return None data = response.json() ws = data...
Changes the name position or visibility of this worksheet
def update(self, *, name=None, position=None, visibility=None): """ Changes the name, position or visibility of this worksheet """ if name is None and position is None and visibility is None: raise ValueError('Provide at least one parameter to update') data = {} if name: ...
Returns a collection of this worksheet tables
def get_tables(self): """ Returns a collection of this worksheet tables""" url = self.build_url(self._endpoints.get('get_tables')) response = self.session.get(url) if not response: return [] data = response.json() return [self.table_constructor(parent=self...
Retrieves a Table by id or name: param str id_or_name: The id or name of the column: return: a Table instance
def get_table(self, id_or_name): """ Retrieves a Table by id or name :param str id_or_name: The id or name of the column :return: a Table instance """ url = self.build_url(self._endpoints.get('get_table').format(id=id_or_name)) response = self.session.get(url) ...
Adds a table to this worksheet: param str address: a range address eg: A1: D4: param bool has_headers: if the range address includes headers or not: return: a Table instance
def add_table(self, address, has_headers): """ Adds a table to this worksheet :param str address: a range address eg: 'A1:D4' :param bool has_headers: if the range address includes headers or not :return: a Table instance """ if address is None: return...
Returns a Range instance from whitin this worksheet: param str address: Optional the range address you want: return: a Range instance
def get_range(self, address=None): """ Returns a Range instance from whitin this worksheet :param str address: Optional, the range address you want :return: a Range instance """ url = self.build_url(self._endpoints.get('get_range')) if address is not None: ...
Gets the range object containing the single cell based on row and column numbers.
def get_cell(self, row, column): """ Gets the range object containing the single cell based on row and column numbers. """ url = self.build_url(self._endpoints.get('get_cell').format(row=row, column=column)) response = self.session.get(url) if not response: return None ...
Adds a new name to the collection of the given scope using the user s locale for the formula: param str name: the name of this range: param str reference: the reference for this range or formula: param str comment: a comment to describe this named range: param bool is_formula: True if the reference is a formula: return...
def add_named_range(self, name, reference, comment='', is_formula=False): """ Adds a new name to the collection of the given scope using the user's locale for the formula :param str name: the name of this range :param str reference: the reference for this range or formula :param ...
Retrieves a Named range by it s name
def get_named_range(self, name): """ Retrieves a Named range by it's name """ url = self.build_url(self._endpoints.get('get_named_range').format(name=name)) response = self.session.get(url) if not response: return None return self.named_range_constructor(parent=self, ...
Returns a collection of this workbook worksheets
def get_worksheets(self): """ Returns a collection of this workbook worksheets""" url = self.build_url(self._endpoints.get('get_worksheets')) response = self.session.get(url) if not response: return [] data = response.json() return [self.worksheet_construc...
Gets a specific worksheet by id or name
def get_worksheet(self, id_or_name): """ Gets a specific worksheet by id or name """ url = self.build_url(self._endpoints.get('get_worksheet').format(id=quote(id_or_name))) response = self.session.get(url) if not response: return None return self.worksheet_constructor...
Adds a new worksheet
def add_worksheet(self, name=None): """ Adds a new worksheet """ url = self.build_url(self._endpoints.get('get_worksheets')) response = self.session.post(url, data={'name': name} if name else None) if not response: return None data = response.json() return sel...
Deletes a worksheet by it s id
def delete_worksheet(self, worksheet_id): """ Deletes a worksheet by it's id """ url = self.build_url(self._endpoints.get('get_worksheet').format(id=quote(worksheet_id))) return bool(self.session.delete(url))
Invokes an Excel Function
def invoke_function(self, function_name, **function_params): """ Invokes an Excel Function """ url = self.build_url(self._endpoints.get('function').format(function_name)) response = self.session.post(url, data=function_params) if not response: return None data = respo...
Returns the list of named ranges for this Workbook
def get_named_ranges(self): """ Returns the list of named ranges for this Workbook """ url = self.build_url(self._endpoints.get('get_names')) response = self.session.get(url) if not response: return [] data = response.json() return [self.named_range_construct...
Returns a dict to communicate with the server
def to_api_data(self): """ Returns a dict to communicate with the server :rtype: dict """ data = {} # recurrence pattern if self.__interval and isinstance(self.__interval, int): recurrence_pattern = data[self._cc('pattern')] = {} recurrence_patter...
Clears this event recurrence
def _clear_pattern(self): """ Clears this event recurrence """ # pattern group self.__interval = None self.__days_of_week = set() self.__first_day_of_week = None self.__day_of_month = None self.__month = None self.__index = 'first' # range group ...
Set the range of recurrence
def set_range(self, start=None, end=None, occurrences=None): """ Set the range of recurrence :param date start: Start date of repetition :param date end: End date of repetition :param int occurrences: no of occurrences """ if start is None: if self.__start_da...
Set to repeat every x no. of days
def set_daily(self, interval, **kwargs): """ Set to repeat every x no. of days :param int interval: no. of days to repeat at :keyword date start: Start date of repetition (kwargs) :keyword date end: End date of repetition (kwargs) :keyword int occurrences: no of occurrences (kwa...
Set to repeat every week on specified days for every x no. of days
def set_weekly(self, interval, *, days_of_week, first_day_of_week, **kwargs): """ Set to repeat every week on specified days for every x no. of days :param int interval: no. of days to repeat at :param str first_day_of_week: starting day for a week :param list[str] da...
Set to repeat every month on specified days for every x no. of days
def set_monthly(self, interval, *, day_of_month=None, days_of_week=None, index=None, **kwargs): """ Set to repeat every month on specified days for every x no. of days :param int interval: no. of days to repeat at :param int day_of_month: repeat day of a month :param...
Set to repeat every month on specified days for every x no. of days
def set_yearly(self, interval, month, *, day_of_month=None, days_of_week=None, index=None, **kwargs): """ Set to repeat every month on specified days for every x no. of days :param int interval: no. of days to repeat at :param int month: month to repeat :param int day...
Add attendees to the parent event
def add(self, attendees): """ Add attendees to the parent event :param attendees: list of attendees to add :type attendees: str or tuple(str, str) or Attendee or list[str] or list[tuple(str,str)] or list[Attendee] """ if attendees: if isinstance(attendees, s...
Remove the provided attendees from the event
def remove(self, attendees): """ Remove the provided attendees from the event :param attendees: list of attendees to add :type attendees: str or tuple(str, str) or Attendee or list[str] or list[tuple(str,str)] or list[Attendee] """ if isinstance(attendees, (list, tuple)...
Returns a dict to communicate with the server
def to_api_data(self): """ Returns a dict to communicate with the server :rtype: dict """ data = [] for attendee in self.__attendees: if attendee.address: att_data = { self._cc('emailAddress'): { self._cc('a...
Returns a dict to communicate with the server
def to_api_data(self, restrict_keys=None): """ Returns a dict to communicate with the server :param restrict_keys: a set of keys to restrict the returned data to :rtype: dict """ cc = self._cc # alias data = { cc('subject'): self.__subject, cc('b...
Returns all the occurrences of a seriesMaster event for a specified time range.: type start: datetime: param start: the start of the time range: type end: datetime: param end: the end of the time range: param int limit: ax no. of events to get. Over 999 uses batch.: type query: Query or str: param query: optional. extr...
def get_occurrences(self, start, end, *, limit=None, query=None, order_by=None, batch=None): """ Returns all the occurrences of a seriesMaster event for a specified time range. :type start: datetime :param start: the start of the time range :type end: datetime :param end:...
Create a new event or update an existing one by checking what values have changed and update them on the server
def save(self): """ Create a new event or update an existing one by checking what values have changed and update them on the server :return: Success / Failure :rtype: bool """ if self.object_id: # update event if not self._track_changes: ...
Decline the event
def decline_event(self, comment=None, *, send_response=True): """ Decline the event :param str comment: comment to add :param bool send_response: whether or not to send response back :return: Success / Failure :rtype: bool """ if not self.object_id: r...
Parse the body html and returns the body text using bs4
def get_body_text(self): """ Parse the body html and returns the body text using bs4 :return: body text :rtype: str """ if self.body_type != 'HTML': return self.body try: soup = bs(self.body, 'html.parser') except RuntimeError: ...
Updates this calendar. Only name and color can be changed.
def update(self): """ Updates this calendar. Only name and color can be changed. :return: Success / Failure :rtype: bool """ if not self.calendar_id: return False url = self.build_url(self._endpoints.get('calendar')) data = { self._cc('...
Get events from the this Calendar
def get_events(self, limit=25, *, query=None, order_by=None, batch=None, download_attachments=False, include_recurring=True): """ Get events from the this Calendar :param int limit: max no. of events to get. Over 999 uses batch. :param query: applies a OData filter to the req...
Returns a new ( unsaved ) Event object
def new_event(self, subject=None): """ Returns a new (unsaved) Event object :rtype: Event """ return self.event_constructor(parent=self, subject=subject, calendar_id=self.calendar_id)
Returns an Event instance by it s id
def get_event(self, param): """ Returns an Event instance by it's id :param param: an event_id or a Query instance :return: event for the specified info :rtype: Event """ if param is None: return None if isinstance(param, str): url = self...
Gets a list of calendars
def list_calendars(self, limit=None, *, query=None, order_by=None): """ Gets a list of calendars To use query an order_by check the OData specification here: http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/ part2-url-conventions/odata-v4.0-errata03-os-part2-url-conventi...
Creates a new calendar
def new_calendar(self, calendar_name): """ Creates a new calendar :param str calendar_name: name of the new calendar :return: a new Calendar instance :rtype: Calendar """ if not calendar_name: return None url = self.build_url(self._endpoints.get('roo...
Returns a calendar by it s id or name
def get_calendar(self, calendar_id=None, calendar_name=None): """ Returns a calendar by it's id or name :param str calendar_id: the calendar id to be retrieved. :param str calendar_name: the calendar name to be retrieved. :return: calendar for the given info :rtype: Calendar ...
Returns the default calendar for the current user
def get_default_calendar(self): """ Returns the default calendar for the current user :rtype: Calendar """ url = self.build_url(self._endpoints.get('default_calendar')) response = self.con.get(url) if not response: return None data = response.json(...
Get events from the default Calendar
def get_events(self, limit=25, *, query=None, order_by=None, batch=None, download_attachments=False, include_recurring=True): """ Get events from the default Calendar :param int limit: max no. of events to get. Over 999 uses batch. :param query: applies a OData filter to the ...
Returns the expiration datetime: return datetime: The datetime this token expires
def expiration_datetime(self): """ Returns the expiration datetime :return datetime: The datetime this token expires """ expires_at = self.get('expires_at') if expires_at is None: # consider it is expired return dt.datetime.now() - dt.timedelta(sec...
Setter to convert any token dict into Token instance
def token(self, value): """ Setter to convert any token dict into Token instance """ if value and not isinstance(value, Token): value = Token(value) self._token = value
Retrieves the token from the File System: return dict or None: The token if exists None otherwise
def get_token(self): """ Retrieves the token from the File System :return dict or None: The token if exists, None otherwise """ token = None if self.token_path.exists(): with self.token_path.open('r') as token_file: token = self.token_construct...
Saves the token dict in the specified file: return bool: Success/ Failure
def save_token(self): """ Saves the token dict in the specified file :return bool: Success / Failure """ if self.token is None: raise ValueError('You have to set the "token" first.') try: if not self.token_path.parent.exists(): sel...
Deletes the token file: return bool: Success/ Failure
def delete_token(self): """ Deletes the token file :return bool: Success / Failure """ if self.token_path.exists(): self.token_path.unlink() return True return False
Retrieves the token from the store: return dict or None: The token if exists None otherwise
def get_token(self): """ Retrieves the token from the store :return dict or None: The token if exists, None otherwise """ token = None try: doc = self.doc_ref.get() except Exception as e: log.error('Token (collection: {}, doc_id: {}) ' ...
Saves the token dict in the store: return bool: Success/ Failure
def save_token(self): """ Saves the token dict in the store :return bool: Success / Failure """ if self.token is None: raise ValueError('You have to set the "token" first.') try: # set token will overwrite previous data self.doc_ref.se...
Deletes the token from the store: return bool: Success/ Failure
def delete_token(self): """ Deletes the token from the store :return bool: Success / Failure """ try: self.doc_ref.delete() except Exception as e: log.error('Could not delete the token (key: {}): {}'.format(self.doc_id, str(e))) return ...
Checks if the token exists: return bool: True if it exists on the store
def check_token(self): """ Checks if the token exists :return bool: True if it exists on the store """ try: doc = self.doc_ref.get() except Exception as e: log.error('Token (collection: {}, doc_id: {}) ' 'could not be retrieve...
Checks whether the library has the authentication and that is not expired: return: True if authenticated False otherwise
def is_authenticated(self): """ Checks whether the library has the authentication and that is not expired :return: True if authenticated, False otherwise """ token = self.con.token_backend.token if not token: token = self.con.token_backend.get_token() ...
Performs the oauth authentication flow resulting in a stored token It uses the credentials passed on instantiation
def authenticate(self, *, scopes, **kwargs): """ Performs the oauth authentication flow resulting in a stored token It uses the credentials passed on instantiation :param list[str] scopes: list of protocol user scopes to be converted by the protocol or scope helpers :param kwar...
Creates a new message to be sent or stored
def new_message(self, resource=None): """ Creates a new message to be sent or stored :param str resource: Custom resource to be used in this message (Defaults to parent main_resource) :return: New empty message :rtype: Message """ return Message(parent=self, mai...
Get an instance to the specified address book for the specified account resource
def address_book(self, *, resource=None, address_book='personal'): """ Get an instance to the specified address book for the specified account resource :param str resource: Custom resource to be used in this address book (Defaults to parent main_resource) :param str address_boo...
Get an instance to handle file storage ( OneDrive/ Sharepoint ) for the specified account resource
def storage(self, *, resource=None): """ Get an instance to handle file storage (OneDrive / Sharepoint) for the specified account resource :param str resource: Custom resource to be used in this drive object (Defaults to parent main_resource) :return: a representation of OneDri...
Get an instance to read information from Sharepoint sites for the specified account resource
def sharepoint(self, *, resource=''): """ Get an instance to read information from Sharepoint sites for the specified account resource :param str resource: Custom resource to be used in this sharepoint object (Defaults to parent main_resource) :return: a representation of Share...
Get an instance to read information from Microsoft planner
def planner(self, *, resource=''): """ Get an instance to read information from Microsoft planner """ if not isinstance(self.protocol, MSGraphProtocol): # TODO: Custom protocol accessing OneDrive/Sharepoint Api fails here raise RuntimeError( 'planner api only wor...
Downloads this file to the local drive. Can download the file in chunks with multiple requests to the server.
def download(self, to_path=None, name=None, chunk_size='auto', convert_to_pdf=False): """ Downloads this file to the local drive. Can download the file in chunks with multiple requests to the server. :param to_path: a path to store the downloaded file :type to_path: str...
Checks the api endpoint to check if the async job progress
def _request_status(self): """ Checks the api endpoint to check if the async job progress """ if self.item_id: return True response = self.con.get(self.monitor_url) if not response: return False data = response.json() self.status = data.get('sta...
Checks the api endpoint in a loop
def check_status(self, delay=0): """ Checks the api endpoint in a loop :param delay: number of seconds to wait between api calls. Note Connection 'requests_delay' also apply. :return: tuple of status and percentage complete :rtype: tuple(str, float) """ if not s...
Restores this DriveItem Version. You can not restore the current version ( last one ).
def restore(self): """ Restores this DriveItem Version. You can not restore the current version (last one). :return: Success / Failure :rtype: bool """ url = self.build_url( self._endpoints.get('restore').format(id=self.object_id)) response = self.co...
Downloads this version. You can not download the current version ( last one ).
def download(self, to_path=None, name=None, chunk_size='auto', convert_to_pdf=False): """ Downloads this version. You can not download the current version (last one). :return: Success / Failure :rtype: bool """ return super().download(to_path=to_path, na...
Updates the roles of this permission
def update_roles(self, roles='view'): """ Updates the roles of this permission :return: Success / Failure :rtype: bool """ if not self.object_id: return False url = self.build_url(self._endpoints.get('permission').format( driveitem_id=self.drivei...
the parent of this DriveItem
def get_parent(self): """ the parent of this DriveItem :return: Parent of this item :rtype: Drive or drive.Folder """ if self._parent and self._parent.object_id == self.parent_id: return self._parent else: if self.parent_id: return...
Returns this Item Thumbnails. Thumbnails are not supported on SharePoint Server 2016.
def get_thumbnails(self, size=None): """ Returns this Item Thumbnails. Thumbnails are not supported on SharePoint Server 2016. :param size: request only the specified size: ej: "small", Custom 300x400 px: "c300x400", Crop: "c300x400_Crop" :return: Thumbnail Data :rtype:...
Updates this item
def update(self, **kwargs): """ Updates this item :param kwargs: all the properties to be updated. only name and description are allowed at the moment. :return: Success / Failure :rtype: bool """ if not self.object_id: return False url = sel...
Moves this item to the Recycle Bin
def delete(self): """ Moves this item to the Recycle Bin :return: Success / Failure :rtype: bool """ if not self.object_id: return False url = self.build_url( self._endpoints.get('item').format(id=self.object_id)) response = self.con.de...
Moves this DriveItem to another Folder. Can t move between different Drives.
def move(self, target): """ Moves this DriveItem to another Folder. Can't move between different Drives. :param target: a Folder, Drive item or Item Id string. If it's a drive the item will be moved to the root folder. :type target: drive.Folder or DriveItem or str :ret...
Asynchronously creates a copy of this DriveItem and all it s child elements.
def copy(self, target=None, name=None): """ Asynchronously creates a copy of this DriveItem and all it's child elements. :param target: target location to move to. If it's a drive the item will be moved to the root folder. :type target: drive.Folder or Drive :param name...
Returns a list of available versions for this item
def get_versions(self): """ Returns a list of available versions for this item :return: list of versions :rtype: list[DriveItemVersion] """ if not self.object_id: return [] url = self.build_url( self._endpoints.get('versions').format(id=self.obje...
Returns a version for specified id
def get_version(self, version_id): """ Returns a version for specified id :return: a version object of specified id :rtype: DriveItemVersion """ if not self.object_id: return None url = self.build_url( self._endpoints.get('version').format(id=sel...
Creates or returns a link you can share with others
def share_with_link(self, share_type='view', share_scope='anonymous'): """ Creates or returns a link you can share with others :param str share_type: 'view' to allow only view access, 'edit' to allow editions, and 'embed' to allow the DriveItem to be embedded :param str share_...
Sends an invitation to access or edit this DriveItem
def share_with_invite(self, recipients, require_sign_in=True, send_email=True, message=None, share_type='view'): """ Sends an invitation to access or edit this DriveItem :param recipients: a string or Contact or a list of the former representing recipients of this inv...
Returns a list of DriveItemPermissions with the permissions granted for this DriveItem.
def get_permissions(self): """ Returns a list of DriveItemPermissions with the permissions granted for this DriveItem. :return: List of Permissions :rtype: list[DriveItemPermission] """ if not self.object_id: return [] url = self.build_url( ...
Creates a Child Folder
def create_child_folder(self, name, description=None): """ Creates a Child Folder :param str name: the name of the new child folder :param str description: the description of the new child folder :return: newly created folder :rtype: drive.Folder """ if not self...
This will download each file and folder sequentially. Caution when downloading big folder structures
def download_contents(self, to_folder=None): """ This will download each file and folder sequentially. Caution when downloading big folder structures :param drive.Folder to_folder: folder where to store the contents """ to_folder = to_folder or Path() if not to_folder.ex...
Uploads a file
def upload_file(self, item, chunk_size=DEFAULT_UPLOAD_CHUNK_SIZE): """ Uploads a file :param item: path to the item you want to upload :type item: str or Path :param chunk_size: Only applies if file is bigger than 4MB. Chunk size for uploads. Must be a multiple of 327.680 bytes...
Returns a collection of drive items
def _base_get_list(self, url, limit=None, *, query=None, order_by=None, batch=None): """ Returns a collection of drive items """ if limit is None or limit > self.protocol.max_top_value: batch = self.protocol.max_top_value params = {'$top': batch if batch else...
Returns a collection of drive items from the root folder
def get_items(self, limit=None, *, query=None, order_by=None, batch=None): """ Returns a collection of drive items from the root folder :param int limit: max no. of items to get. Over 999 uses batch. :param query: applies a OData filter to the request :type query: Query or str :...
Returns a DriveItem by it s Id
def get_item(self, item_id): """ Returns a DriveItem by it's Id :return: one item :rtype: DriveItem """ if self.object_id: # reference the current drive_id url = self.build_url( self._endpoints.get('get_item').format(id=self.object_id, ...