def call_google_api()

in libs/google/controller.py [0:0]


  def call_google_api(self, service, api_resource, api_method, response_field, **kwargs):
    """
    Performs a call to Google's API Services.
    :args:
      api_resource, the Google Resource object to create.
      api_method, the method to perform.
    :return:
      resource, the resulting resource json object field.
    """
    try:
      api_resources = api_resource.split(".")
      google_resource = getattr(service, api_resources[0])()
      for res in api_resources[1:]:
        google_resource = getattr(google_resource, res)()
      resource_method = getattr(google_resource, api_method)(**kwargs)
      results = resource_method.execute()
      if response_field is not None:
        results = results.get(response_field)
    except discovery.HttpError:
      print("Error talking to Google API")
      results = None
    return json.dumps(results)