Skip to main content

API client & CLI for https://github.com/realerikrani/project

Project description

projectclient

API client and CLI for https://github.com/realerikrani/project.

CLI

Pip-install projectclient.

Set export PROJECT_CLI_CONFIG_PATH=/path/to/config.ini

which contains the URL of your project API

[DEFAULT]
url = http://localhost:5000

Then can call the

cli_project -h
usage: cli_project [-h] {create,read,delete,key-create,keys-read,key-delete} ...

CLI for managing projects and keys.

positional arguments:
  {create,read,delete,key-create,keys-read,key-delete}
    create              Create a project with a key.
    read                Read a project.
    delete              Delete a project.
    key-create          Create a new key for a project.
    keys-read           Read public keys of a project.
    key-delete          Delete a key.

options:
  -h, --help            show this help message and exit

After creating a project, the ini-file shall be updated by the code. For example, it could be similar to

[DEFAULT]
url = http://localhost:5000
current_key_id = 01744bc7-45e5-4a49-837b-3677e6cc65f7
current_project_id = 3c6955c4-2ag9-4f31-ba75-9e96afca5ee4

[01744bc7-45e5-4a49-837b-3677e6cc65f7@3c6955c4-2ag9-4f31-ba75-9e96afca5ee4]
public = /Users/john/Documents/demo/pubkey.pem
private = /Users/john/Documents/demo/key.pem.enc

API Client

from realerikrani.projectclient import JWTAuth, ProjectClient
from realerikrani.baseclient import BaseAdapter, BaseClient


def create_project_client() -> ProjectClient:
    adapter = BaseAdapter()
    with requests.Session() as session:
        jwt_auth = None
        with suppress(KeyError):
            jwt_auth = JWTAuth(
                YOUR_CONF[YOUR_PROJECT_ID], 
                YOUR_CONF[YOUR_KEY_ID], 
                YOUR_CONF[YOUR_PRIVATE_KEY_ENCRYPTED_PEM_STRING], 
                YOUR_CONF[YOUR_PRIVATE_KEY_ENCRYPTED_PEM_PASSPHRASE]
            )
            # If you don't have encrypted key, then don't provide the passphrase
            # jwt_auth = JWTAuth(YOUR_CONF[YOUR_PROJECT_ID], YOUR_CONF[YOUR_KEY_ID], YOUR_CONF[YOUR_PRIVATE_KEY_PEM_STR])
        baseclient = BaseClient(
            session=session, adapter=adapter, url=read_url(config), auth=jwt_auth
        )
        return ProjectClient(baseclient)

Direct Dependencies:

  • requests - licensed under the Apache License 2.0
  • realerikrani-baseclient - licensed under the Apache License 2.0
  • pyjwt[crypto] - licensed under the MIT License

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

realerikrani_projectclient-1.1.0.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

realerikrani_projectclient-1.1.0-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file realerikrani_projectclient-1.1.0.tar.gz.

File metadata

File hashes

Hashes for realerikrani_projectclient-1.1.0.tar.gz
Algorithm Hash digest
SHA256 eb5f42837aeace0652d09e84009c054924d68c54a01def9617fd57ee4879f549
MD5 14b18f5bf6a227dc2529490d6e42ad0d
BLAKE2b-256 0e3dbcb9a9bd021d90a24a71d69a7c26a4119e0c9b6856dfb59226727a7f71f1

See more details on using hashes here.

File details

Details for the file realerikrani_projectclient-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for realerikrani_projectclient-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9536366cbf2bb5132c4f6a0423413e2d49fdadaa22daecb31eca0ea4e7464800
MD5 de905329d7af999b72ffda847fb32528
BLAKE2b-256 d072880e72cae67e10b02a9e262d7e2d506beefb62132dc23a3d3d9dff1627f5

See more details on using hashes here.

Supported by

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