Skip to main content

No project description provided

Project description

Pinnacle Python Client

This is the official Python client for the Pinnacle Serverless Backend API.

Pre-requisites

  • Python 3.12 or higher

Usage

  1. Install the package using pip:
pip install pinnacle-python
  1. Create a directory called pinnacle and create a file called main.py in the directory. This directory will contain all your endpoint definitions.
  2. To define an endpoint, use the @endpoint decorator:
from pinnacle_python import endpoint

@endpoint()
def hello_world():
    return "Hello, World!"

This will create a POST endpoint at /hello_world with no parameters.

  1. To define a scheduled script, use the @scheduled decorator:
from pinnacle_python import schedule, Period
@schedule(
    for_time=datetime.datetime.today() + timedelta(minutes=1), 
    repeats=Period(seconds=2)
)
def test_job():
    print("Hello, world!")

This will run the test_job function every 2 seconds starting 1 minute from the time the script is deployed. See the schedule documentation for more information on how to configure the schedule.

  1. Install the Pinnacle CLI:
pip install pinnacle-cli
  1. Deploy the endpoint using the CLI:
pinnacle dev
  1. You can now access the endpoint at http://localhost:8000/hello_world. Calling the endpoint
curl -X POST http://localhost:8000/hello_world \
     -H "Content-Type: application/json" \
     -d '{}'

will return a JSON in the following format:

{
    "data": "Hello, World!"
}

Defining response models

If you want to define a response model for your endpoint, provide the return type for the endpoint function:

from pinnacle_python import endpoint
@endpoint()
def hello_world() -> int:
    return 1

Or, if you want to return a more complex object use Pydantic's BaseModel class:

from pydantic import BaseModel
from pinnacle_python import endpoint

class Person(BaseModel):
    name: str
    message: str


@endpoint()
def hello_world() -> Person:
    return Person(name="John", message="Hello, World!")

Environment Variables

See the Pinnacle CLI README for a list of environment variables that can be used to configure the Pinnacle CLI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pinnacle_python-0.0.3.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

pinnacle_python-0.0.3-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file pinnacle_python-0.0.3.tar.gz.

File metadata

  • Download URL: pinnacle_python-0.0.3.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/23.5.0

File hashes

Hashes for pinnacle_python-0.0.3.tar.gz
Algorithm Hash digest
SHA256 4c76f6c0aa70249591ccbfc7a638e46518caa58e5561efcecc58c6b34b4a58ce
MD5 7d033596d0b124a9c8c950d88bb1fdbd
BLAKE2b-256 ab55184b32bf6b3793e7cd91f7254fd18edf056b822c8f94378e232b5883ced9

See more details on using hashes here.

File details

Details for the file pinnacle_python-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pinnacle_python-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/23.5.0

File hashes

Hashes for pinnacle_python-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7871249aac0e9dedb89853aae5cc3354798c0e68ff5a4532920ef2f2854100cf
MD5 dd208dd05815b37b0f8ea6bcf7a6d30f
BLAKE2b-256 9404b64d8619203b8fdfc020080a8506341f219ddbaf3ac9c10e1ac6b854c008

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page