When using the Python client API for the Google Cloud Scheduler I always get the above error message for some reason. I also tried to start the parent path without the slash but got the same result. Any hint is much appreciated!

import os
from google.cloud import scheduler_v1

def gcloudscheduler(data, context):
    current_folder = os.path.dirname(os.path.abspath(__file__))
    abs_auth_path = os.path.join(current_folder, 'auth.json')
    os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = abs_auth_path


    response = scheduler_v1.CloudSchedulerClient().create_job(data["parent"], data["job"])
    print(response)

I used following parameter:

{"job": {
        "pubsub_target": {
            "topic_name": "trade-tests",
            "attributes": {
                "attrKey": "attrValue"
            }
        },
        "schedule": "* * * * *"
    },
 "parent": "/projects/my-project-id/locations/europe-west1"
}

1 Answers

2
Sandro On Best Solutions

The problem was actually not the parent parameter but the incorrect format of the topic-name. It should have been projects/my-project-id/topics/trade-tests. Even though the error message says it should with a slash. But it is in line with the API doc here and here.

The problem was just that the error message didn't say which resource name the error was about.