Search code examples
pythongoogle-apigcloud

Applying filters on google apl


I am trying to get the job ids, args, state and other fields from the API ml.googleapis.com. I want to filter the API to list the jobids for a start date and end date. I have to create this as a job that will run for multiple projects every day. So this cannot be done from the gshell. I tried the following code and it is giving errors.

  from googleapiclient import discovery
    from googleapiclient import errors
    project_id = 'projects/a'.format('gcp-scj3-host-scj-core-01')
    ml = discovery.build('ml', 'v1')
    request = ml.projects().jobs().list(parent=project_id,filter="createTime>=2021-10-21T12:00:00" and "createTime<=2021-10-22T12:00:00")
    response = request.execute()
    print(response)

The error I'm getting is "Invalid syntax or TypeError: unhashable type: ‘list'". It will be great to know how to apply the filter for dates when making a request to the API. Thanks.


Solution

  • It seems filtering on createTime is not currently supported.