mirror of
https://github.com/GAM-team/GAM.git
synced 2026-06-28 18:01:36 +00:00
gapi_drive
This commit is contained in:
8
src/gam/gapi/drive/__init__.py
Normal file
8
src/gam/gapi/drive/__init__.py
Normal file
@@ -0,0 +1,8 @@
|
||||
import gam
|
||||
|
||||
|
||||
def build(user=None):
|
||||
if not user:
|
||||
user = gam._get_admin_email()
|
||||
userEmail = gam.convertUIDtoEmailAddress(user)
|
||||
return (userEmail, gam.buildGAPIServiceObject('drive3', userEmail))
|
||||
26
src/gam/gapi/drive/drives.py
Normal file
26
src/gam/gapi/drive/drives.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""Methods related to Drive API Shared Drives"""
|
||||
import sys
|
||||
|
||||
|
||||
import gam
|
||||
from gam.var import GC_CUSTOMER_ID, GC_Values, MY_CUSTOMER, SORTORDER_CHOICES_MAP
|
||||
from gam import controlflow
|
||||
from gam import display
|
||||
from gam import gapi
|
||||
from gam.gapi import errors as gapi_errors
|
||||
from gam.gapi import drive as gapi_drive
|
||||
|
||||
def drive_name_to_id(name, drive=None):
|
||||
if not drive:
|
||||
_, drive = gapi_drive.build()
|
||||
q = f"name = '{name}'"
|
||||
sds = gapi.get_all_pages(drive.drives(),
|
||||
'list',
|
||||
'drives',
|
||||
q=q,
|
||||
useDomainAdminAccess=True)
|
||||
if len(sds) == 0:
|
||||
controlflow.system_error_exit(f'Could not find shared drive named "{name}"')
|
||||
elif len(sds) > 1:
|
||||
controlflow.system_error_exit(f'Got more than one shared drive named "{name}"')
|
||||
return sds[0]['id']
|
||||
Reference in New Issue
Block a user