scheduler-py | A python3 job scheduler with cron expression | Cron Utils library
kandi X-RAY | scheduler-py Summary
kandi X-RAY | scheduler-py Summary
A python3 job scheduler with cron expression
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Main loop
- Run the cron expression
- Refresh scheduled jobs
- Get the next run
- Return True if there is enough time to run
- Process cron expression
- Read a file
scheduler-py Key Features
scheduler-py Examples and Code Snippets
Community Discussions
Trending Discussions on scheduler-py
QUESTION
I'm extending off of this question: How to create a job with Google Cloud scheduler Python api
I'm wondering how I can insert a body object to be passed along with the function, I can do it via gcloud
, and I know according to the v1 docs that the body needs to be passed in a HttpTarget
any time I try to pass it that way it errors and says:
TypeError: No positional arguments allowed
Honestly I haven't been able to get from google.cloud.scheduler_v1.types import HttpTarget as Target
to work at all.
Can someone give me an example where they successfully used the API to create a job in the Cloud Scheduler with a body (JSON object) sent with it (POST method of course)?
...ANSWER
Answered 2020-May-26 at 18:01import json
from google.cloud import scheduler_v1
client = scheduler_v1.CloudSchedulerClient()
project = "..." # TODO
location = "..." # TODO
parent = client.location_path(project, location)
uri = "..." # TODO
body = {"Hello": "World"}
job = {
"http_target": {
"http_method": "POST",
"uri": uri,
"headers": {"Content-Type": "application/json"},
"body": json.dumps(body).encode("utf-8"),
},
"schedule": "* * * * *",
}
response = client.create_job(parent, job)
print(response)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install scheduler-py
You can use scheduler-py like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page