Source code for utils.google_api

from googleapiclient.discovery import build
from googleapiclient.discovery_cache.base import Cache

from thaliawebsite import settings


[docs]class MemoryCache(Cache): _CACHE = {}
[docs] def get(self, url): return MemoryCache._CACHE.get(url)
[docs] def set(self, url, content): MemoryCache._CACHE[url] = content
memory_cache = MemoryCache()
[docs]def get_directory_api(): return build( "admin", "directory_v1", credentials=settings.GSUITE_ADMIN_CREDENTIALS, cache=memory_cache, )
[docs]def get_groups_settings_api(): return build( "groupssettings", "v1", credentials=settings.GSUITE_ADMIN_CREDENTIALS, cache=memory_cache, )