{"id":13689927,"url":"https://github.com/goblet/goblet","last_synced_at":"2025-05-02T06:31:40.621Z","repository":{"id":37582890,"uuid":"242865500","full_name":"goblet/goblet","owner":"goblet","description":"Goblet is an easy-to-use framework that enables developers to quickly spin up fully featured REST APIs with python on GCP","archived":false,"fork":false,"pushed_at":"2024-06-18T20:50:05.000Z","size":9004,"stargazers_count":122,"open_issues_count":43,"forks_count":29,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-23T21:02:14.422Z","etag":null,"topics":["api-gateway","cloudfunctions","gcp","goblet","python"],"latest_commit_sha":null,"homepage":"https://goblet.github.io/goblet","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/goblet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-24T23:23:56.000Z","updated_at":"2025-04-17T11:55:37.000Z","dependencies_parsed_at":"2023-02-17T09:30:50.490Z","dependency_job_id":"88033ee8-44f7-4d16-8457-da0c859f4475","html_url":"https://github.com/goblet/goblet","commit_stats":{"total_commits":196,"total_committers":18,"mean_commits":10.88888888888889,"dds":0.173469387755102,"last_synced_commit":"affc76a96bbc4a44396e99e0fc33d7168ac6a336"},"previous_names":["anovis/goblet"],"tags_count":68,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goblet%2Fgoblet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goblet%2Fgoblet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goblet%2Fgoblet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goblet%2Fgoblet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goblet","download_url":"https://codeload.github.com/goblet/goblet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251651226,"owners_count":21621713,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-gateway","cloudfunctions","gcp","goblet","python"],"created_at":"2024-08-02T16:00:34.582Z","updated_at":"2025-05-02T06:31:40.079Z","avatar_url":"https://github.com/goblet.png","language":"Python","readme":"# GOBLET\n\n![PyPI](https://img.shields.io/pypi/v/goblet-gcp?color=blue\u0026style=plastic)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/goblet-gcp?style=plastic)\n![Tests](https://github.com/goblet/goblet/actions/workflows/main.yml/badge.svg)\n[![codecov](https://codecov.io/gh/goblet/goblet/branch/main/graph/badge.svg?token=g8TL6Sc0P5)](https://codecov.io/gh/goblet/goblet)\n\nGoblet is a framework for writing serverless rest apis in python in google cloud. It allows you to quickly create and deploy python apis backed by [Cloud Functions](https://cloud.google.com/functions) and [Cloud Run](https://cloud.google.com/run) as well as other GCP serverless services.\n\nIt provides:\n\n* A command line tool for creating, deploying, and managing your api\n* A decorator based API for integrating with GCP API Gateway, Storage, Cloudfunctions, PubSub, Scheduler, Cloudrun Jobs, BQ remote functions, Redis, Monitoring alerts and other GCP services.\n* Local environment for testing and running your api endpoints\n* Dynamically generated openapispec\n* Support for multiple stages\n\nYou can create Rest APIs:\n\n```python\nfrom goblet import Goblet, jsonify, goblet_entrypoint\n\napp = Goblet(function_name=\"goblet_example\")\ngoblet_entrypoint(app)\n\n@app.route('/home')\ndef home():\n    return {\"hello\": \"world\"}\n\n@app.route('/home/{id}', methods=[\"POST\"])\ndef post_example(id: int) -\u003e List[int]:\n    return jsonify([id])\n```\n\nYou can also create other GCP resources that are related to your REST api:\n\n```python\nfrom goblet import Goblet, jsonify, goblet_entrypoint\n\napp = Goblet(function_name=\"goblet_example\")\ngoblet_entrypoint(app)\n\n# Scheduled job\n@app.schedule(\"5 * * * *\")\ndef scheduled_job():\n    return jsonify(\"success\")\n\n# Pubsub subscription\n@app.pubsub_subscription(\"test\")\ndef pubsub_subscription(data):\n    app.log.info(data)\n    return\n\n# Example Redis Instance\napp.redis(\"redis-test\")\n\n# Example Metric Alert for the cloudfunction metric execution_count with a threshold of 10\napp.alert(\"metric\",conditions=[MetricCondition(\"test\", metric=\"cloudfunctions.googleapis.com/function/execution_count\", value=10)])\n```\n\nOnce you've written your code, you just run goblet deploy and Goblet takes care of deploying your app.\n\n```sh\n$ goblet deploy -l us-central1\n...\nhttps://api.uc.gateway.dev\n\n$ curl https://api.uc.gateway.dev/home\n{\"hello\": \"world\"}\n```\n\n\u003e Note: Due to breaking changes in Cloudfunctions you will need to wrap your goblet class in a function. See [issue #88](https://github.com/goblet/goblet/issues/88). In the latest goblet version (0.5.0) there is a helper function `goblet_entrypoint` that can be used as well. \n\n\u003e `goblet_entrypoint(app)`\n\n## Resources Supported\n\n#### Infrastructure\n* vpc connector\n* redis\n* api gateway\n* cloudtaskqueue\n* pubsub topics\n* bq spark stored procedures\n\n#### Backends\n* cloudfunction\n* cloudfunction V2\n* cloudrun\n\n#### Routing\n* api gateway\n* http\n\n#### Handlers\n* pubsub\n* scheduler\n* storage\n* eventarc\n* cloudrun jobs\n* bq remote functions\n* cloudtask target\n* uptime checks\n\n#### Alerts\n* Backend Alerts\n* Uptime Alerts\n* PubSub DLQ Alerts\n\n## Data Typing Frameworks Supported\n\n* pydantic\n* marshmallow\n\n## Installation\n\nTo install goblet, open an interactive shell and run:\n\n```pip install goblet-gcp```\n\nMake sure to have the correct services enabled in your gcp project depending on what you want to deploy\n\n`api-gateway`, `cloudfunctions`, `storage`, `pubsub`, `scheduler`\n\nYou will also need to install [gcloud cli](https://cloud.google.com/sdk/docs/install) for authentication\n\n## QuickStart\n\nIn this tutorial, you'll use the goblet command line utility to create and deploy a basic REST API. This quickstart uses Python 3.10. You can find the latest versions of python on the Python download page.\n\nTo install Goblet, we'll first create and activate a virtual environment in python3.10:\n\n```sh\n$ python3 --version\nPython 3.10.10\n$ python3 -m venv venv310\n$ . venv37/bin/activate\n```\n\nNext we'll install Goblet using pip:\n\n```sh\npython3 -m pip install goblet-gcp\n```\n\nYou can verify you have goblet installed by running:\n\n```sh\n$ goblet --help\nUsage: goblet [OPTIONS] COMMAND [ARGS]...\n...\n```\n\n### Credentials\n\nBefore you can deploy an application, be sure you have credentials configured. You should run `gcloud auth application-default login` and sign in to the desired project.\n\n### Creating Your Project\n\ncreate your project directory, which should include an main.py and a requirements.txt. Make sure requirements.txt includes `goblet-gcp`\n\n```sh\n$ ls -la\ndrwxr-xr-x   .goblet\n-rw-r--r--   main.py\n-rw-r--r--   requirements.txt\n```\n\nYou can ignore the .goblet directory for now, the two main files we'll focus on is app.py and requirements.txt.\n\nLet's take a look at the main.py file:\n\n```python\nfrom goblet import Goblet, goblet_entrypoint\n\napp = Goblet(function_name=\"goblet_example\")\ngoblet_entrypoint(app)\n\n@app.route('/home')\ndef home():\n    return {\"hello\": \"world\"}\n```\n\nThis app will deploy an api with endpoint `/home`.\n\n### Running Locally\n\nRunning your functions locally for testing and debugging is easy to do with goblet.\n\n```python\nfrom goblet import Goblet\n\napp = Goblet(function_name=\"goblet_example\")\ngoblet_entrypoint(app)\n\n@app.route('/home')\ndef home():\n    return {\"hello\": \"world\"}\n```\n\nThen run `goblet local`\nNow you can hit your functions endpoint at `localhost:8080` with your routes. For example `localhost:8080/home`\n\n### Building and Running locally using Docker\n\nMake sure Docker Desktop and Docker CLI is installed, more information located here: \u003chttps://docs.docker.com/desktop/\u003e\n\nRefresh local credentials by running: `gcloud auth application-default login`\n\nSet the GOOGLE_APPLICATION_CREDENTIALS variable by running: `export GOOGLE_APPLICATION_CREDENTIALS=~/.config/gcloud/application_default_credentials.json`\n\nTo build container run: `docker build . -t \u003ctag\u003e`\n\nTo start container run:\n\n```zsh\n    docker run -p 8080:8080 \\\n        -v ~/.config/gcloud/application_default_credentials.json:/tmp/application_default_credentials.json:ro \\\n        -e GOOGLE_APPLICATION_CREDENTIALS=/tmp/application_default_credentials.json \\\n        -e GCLOUD_PROJECT=\u003cgcp-project\u003e \u003ctag\u003e:latest\n```\n\n#### Installing private packages during Docker Build\n\nTo install a private package located with GCP Artifact Registry, credentials will need to be mounted during the build process. Add this line to Dockerfile before requirements install:\n\n```Dockerfile\nRUN --mount=type=secret,id=gcloud_creds,target=/app/google_adc.json export GOOGLE_APPLICATION_CREDENTIALS=/app/google_adc.json \\  \n    \u0026\u0026 pip install -r requirements.txt\n```\n\nTo build container run: `docker build . --secret id=gcloud_creds,src=\"$GOOGLE_APPLICATION_CREDENTIALS\" -t \u003ctag\u003e`\n\n### Deploying\n\nLet's deploy this app. Make sure you're in the app directory and run goblet deploy making sure to specify the desired location:\n\n```sh\n$ goblet deploy -l us-central1\nINFO:goblet.deployer:zipping function......\nINFO:goblet.deployer:uploading function zip to gs......\nINFO:goblet.deployer:function code uploaded\nINFO:goblet.deployer:creating cloudfunction......\nINFO:goblet.deployer:deploying api......\nINFO:goblet.deployer:api successfully deployed...\nINFO:goblet.deployer:api endpoint is goblet-example-yol8sbt.uc.gateway.dev\n```\n\nYou now have an API up and running using API Gateway and cloudfunctions:\n\n```sh\n$ curl https://goblet-example-yol8sbt.uc.gateway.dev/home\n{\"hello\": \"world\"}\n```\n\nTry making a change to the returned dictionary from the home() function. You can then redeploy your changes by running `golet deploy`.\n\n### Next Steps\n\nYou've now created your first app using goblet. You can make modifications to your main.py file and rerun goblet deploy to redeploy your changes.\n\nAt this point, there are several next steps you can take.\n\nDocs - [Goblet Documentation](https://goblet.github.io/goblet/build/html/index.html)\n\nIf you're done experimenting with Goblet and you'd like to cleanup, you can use the `goblet destroy` command making sure to specify the desired location, and Goblet will delete all the resources it created when running the goblet deploy command.\n\n```sh\n$ goblet destroy -l us-central1\nINFO:goblet.deployer:destroying api gateway......\nINFO:goblet.deployer:api configs destroying....\nINFO:goblet.deployer:apis successfully destroyed......\nINFO:goblet.deployer:deleting google cloudfunction......\nINFO:goblet.deployer:deleting storage bucket......\n```\n\n## Docs\n\n[Goblet Documentation](https://goblet.github.io/goblet/build/html/index.html)\n\n## Blog Posts\n\n[Building Python Serverless Applications on GCP](https://austennovis.medium.com/building-python-serverless-applications-on-gcp-141a806eb7a5)\n\n[Serverless APIs made simple on GCP with Goblet backed by Cloud Functions and Cloud Run](https://engineering.premise.com/serverless-apis-made-simple-on-gcp-with-goblet-backed-by-cloud-functions-and-cloud-run-730db2da04ba)\n\n[Tutorial: Publishing GitHub Findings to Security Command Center](https://engineering.premise.com/tutorial-publishing-github-findings-to-security-command-center-2d1749f530bc)\n\n[Tutorial: Cost Spike Alerting](https://engineering.premise.com/tutorial-cost-spike-alerting-for-google-cloud-platform-gcp-46fd26ae3f6a)\n\n[Tutorial: Setting Up Approval Processes with Slack Apps](https://engineering.premise.com/tutorial-setting-up-approval-processes-with-slack-apps-d325aee31763)\n\n[Tutorial: API Deployments with Traffic Revisions and Centralized Artifact Registries in Google Cloud Run](https://engineering.premise.com/traffic-revisions-and-artifact-registries-in-google-cloud-run-made-easy-with-goblet-1a3fa86de25c)\n\n[Tutorial: Deploying Cloud Run Jobs](https://engineering.premise.com/tutorial-deploying-cloud-run-jobs-9435466b26f5)\n\n[Tutorial: Connecting Cloudrun and Cloudfunctions to Redis and other Private Services using Goblet](https://engineering.premise.com/tutorial-connecting-cloudrun-and-cloudfunctions-to-redis-and-other-private-services-using-goblet-5782f80da6a0)\n\n[Tutorial: Deploying BigQuery Remote Functions](https://engineering.premise.com/tutorial-deploying-bigquery-remote-functions-9040316d9d3e)\n\n[GCP Alerts the Easy Way: Alerting for Cloudfunctions and Cloudrun using Goblet](https://engineering.premise.com/gcp-alerts-the-easy-way-alerting-for-cloudfunctions-and-cloudrun-using-goblet-62bdf2126ef6)\n\n[Tutorial: Deploy CloudTaskQueues, enqueue CloudTasks and handle CloudTasks](https://engineering.premise.com/deploy-and-handle-gcp-cloudtasks-with-goblet-in-minutes-ee138e9dd2c5)\n\n[Tutorial: Low Usage Alerting On Slack for Google Cloud Platform](https://engineering.premise.com/tutorial-low-usage-alerting-on-slack-for-google-cloud-platform-gcp-cc68ac8ca4d)\n\n[Easily Manage IAM Policies for Serverless REST Applications in GCP with Goblet](https://engineering.premise.com/easily-manage-iam-policies-for-serverless-rest-applications-in-gcp-with-goblet-f1580a97b74)\n\n[Serverless Data Pipelines in GCP using Dataform and BigQuery Remote Functions](https://engineering.premise.com/serverless-data-pipelines-in-gcp-using-dataform-and-bigquery-remote-functions-9ee235d0cb18)\n\n## Examples\n\n[Goblet Examples](https://github.com/goblet/goblet/blob/main/examples/main.py)\n\n## Issues\n\nPlease file any issues, bugs or feature requests as an issue on our [GitHub](https://github.com/goblet/goblet/issues) page.\n\n## Github Action\n\n[Goblet Github Action](https://github.com/marketplace/actions/goblet-deploy)\n\n## Roadmap\n\n \u0026#9745; Integration Tests \\\n \u0026#9745; [Api Gateway Auth](https://cloud.google.com/api-gateway/docs/authenticate-service-account) \\\n \u0026#9745; Configuration Options (function names, ...) \\\n \u0026#9745; Use checksum for updates \\\n \u0026#9745; Cloudrun Backend \\\n \u0026#9745; [Scheduler](https://cloud.google.com/scheduler) trigger \\\n \u0026#9745; [Pub Sub](https://cloud.google.com/pubsub/docs/overview) trigger \\\n \u0026#9745; [Cloud Storage](https://cloud.google.com/functions/docs/calling/storage) trigger \\\n \u0026#9745; [Cloudrun Jobs](https://cloud.google.com/run/docs/quickstarts/jobs/create-execute) trigger \\\n \u0026#9744; [Firestore]( https://cloud.google.com/functions/docs/calling/cloud-firestore) trigger \\\n \u0026#9744; [Firebase](https://cloud.google.com/functions/docs/calling/realtime-database) trigger \\\n \u0026#9745; [CloudTask and CloudTask Queues](https://cloud.google.com/tasks/docs/dual-overview) \\\n \u0026#9744; [Cloud Endpoints](https://cloud.google.com/endpoints/docs/openapi/get-started-cloud-functions) trigger \\\n \u0026#9745; [EventArc](https://cloud.google.com/eventarc/docs) trigger \\\n \u0026#9745; [Redis](https://cloud.google.com/memorystore) infrastructure \\\n \u0026#9745; [BQ Remote Functions](https://cloud.google.com/bigquery/docs/reference/standard-sql/remote-functions) \\\n \u0026#9745; Deploy API Gateway from existing openapi spec \\\n \u0026#9745; Deploy arbitrary Dockerfile to Cloudrun \\\n \u0026#9745; [Multi Container Deployments](https://cloud.google.com/blog/products/serverless/cloud-run-now-supports-multi-container-deployments) \\\n \u0026#9745; Create Deployment Service Accounts \\\n \u0026#9745; Automatically add IAM invoker bindings on the backend based on deployed handlers \\\n \u0026#9745; [Uptime Checks](https://cloud.google.com/monitoring/uptime-checks)\n\n\n## Want to Contribute\n\nIf you would like to contribute to the library (e.g. by improving the documentation, solving a bug or adding a cool new feature) please follow the [contribution guide](CONTRIBUTING.md) and submit a [pull request](https://github.com/goblet/goblet/pulls).\n\n## Want to Support\n\n\u003c!-- markdownlint-disable MD033 --\u003e\n\u003ca href=\"https://www.buymeacoffee.com/austennovis\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/default-blue.png\" alt=\"Buy Me A Coffee\" height=\"41\" width=\"174\"\u003e\u003c/a\u003e\n\u003c!-- markdownlint-disable MD033 --\u003e\n\n___\n\nBased on [chalice](https://github.com/aws/chalice)\n","funding_links":["https://www.buymeacoffee.com/austennovis"],"categories":["Compute"],"sub_categories":["Cloud Functions"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoblet%2Fgoblet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoblet%2Fgoblet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoblet%2Fgoblet/lists"}