Skip to main content

Formal Admin Python SDK

This is the Python SDK for the Formal Admin API.

Installing

pip install formal-sdk

Example Use

Create and Get a Native Role

import os
import formal_sdk

if __name__ == '__main__':
    # Import data types for the requests
    # example: from formal_sdk.gen.admin.v1.client_name_pb2 import methodNameRequest
    # for NativeUserClient it will be native_user_pb2
    # the client_name_pb2 contains the request and response class
    # for example: CreateNativeUserRequest for CreateNativeUser method
    from formal_sdk.gen.admin.v1.native_user_pb2 import CreateNativeUserRequest

    # Initialize formal client
    api_key = os.environ.get('API_KEY')
    formal_client = formal_sdk.Client(api_key)

    # Create Native Role
    data_store_id = ""
    native_user_id = ""
    native_user_secret = ""
    use_as_default = False

    createdRole = formal_client.NativeUserClient.CreateNativeUser(CreateNativeUserRequest(
            data_store_id=data_store_id,
            native_user_id=native_user_id,
            native_user_secret=native_user_secret,
            use_as_default=use_as_default)
        )

    # Get Native Role
    from formal_sdk.gen.admin.v1.native_user_pb2 import GetNativeUserRequest
    # NOTE: inline import intended for examples to see the import pattern, follow PEP 8 recommendation to import on your code

    previousRole = formal_client.NativeUserClient.GetNativeUser(
        GetNativeUserRequest(data_store_id=data_store_id, native_user_id=native_user_id)
        )

    print(f'data_store_id: {previousRole.native_user.datastore_id}')
    print(f'native_role_id: {previousRole.native_user.native_user_id}')
    print(f'native_role_secret: {previousRole.native_user.native_user_secret}')
    print(f'use_as_default: {previousRole.native_user.use_as_default}')

    # Get sidecar tls certificate and private key
    from formal_sdk.gen.admin.v1.sidecar_pb2 import GetSidecarTlsCertificateByIdRequest 
    # NOTE: inline import intended for examples to see the import pattern, follow PEP 8 recommendation to import on your code

    sidecar_id = ""
    secret = formal_client.SidecarClient.GetSidecarTlsCertificateById(GetSidecarTlsCertificateByIdRequest(id=sidecar_id))
    print(f'secret: {secret.secret}')

    # Empty request parameter example
    from formal_sdk.gen.admin.v1.identities_pb2 import GetUsersRequest
    # NOTE: inline import intended for examples to see the import pattern, follow PEP 8 recommendation to import on your code

    user_client = formal_client.UserClient
    print(user_client.GetUsers(GetUsersRequest())) # empty param need to pass the request object without any param
    print(user_client.GetUsers(GetUsersRequest()).users[0].id)
    
import os
import formal_sdk

from formal_sdk.gen.admin.v1 import inventory_pb2 as inventory

if __name__ == '__main__':
    api_key = os.environ.get('API_KEY')
    new_client = formal_sdk.Client(api_key).InventoryClient

    data_store_id = ""
    path = ""
    column_dict = {
        "path": path,
        "name": "column",
        "data_type": "string"
    }

    # Create Inventory Object
    create_inventory_object_request = inventory.CreateInventoryObjectRequest(
            datastore_id=data_store_id,
            object_type="column",
            column=column_dict,
        )
    new_client.CreateInventoryObject(create_inventory_object_request)

    # Get Inventory Object
    get_inventory_object_request = inventory.GetInventoryObjectRequest(
        datastore_id=data_store_id,
        path=path
        )
    inventory_column = new_client.GetInventoryObject(get_inventory_object_request)

    print(f'datastore_id: {inventory_column.column.datastore_id}')
    print(f'path: {inventory_column.column.path}')
    print(f'name: {inventory_column.column.name}')
    print(f'data_type: {inventory_column.column.data_type}')

    # Create and Get Inventory Tag
    create_inventory_tag_request = inventory.CreateInventoryTagRequest(name="tag_name")
    create_inventory_tag_response = new_client.CreateInventoryTag(create_inventory_tag_request)
    print(f'tag_id: {create_inventory_tag_response.tag.id}')

    # Get all Inventory Tags
    inventory_tags = new_client.GetInventoryTags(inventory.GetInventoryTagsRequest()) # empty param
    for tag in inventory_tags.tags:
        print(f'tag_id: {tag.id}')
        print(f'tag_name: {tag.name}')
        print(f'created_at: {tag.created_at}')
        # Delete Inventory Tag
        new_client.DeleteInventoryTag(inventory.DeleteInventoryTagRequest(id=tag.id))

Data References

https://buf.build/formal/admin/

Download files

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

Source Distribution

formal_sdk-1.0.48.tar.gz (138.4 kB view details)

Uploaded Source

Built Distribution

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

formal_sdk-1.0.48-py3-none-any.whl (246.1 kB view details)

Uploaded Python 3

File details

Details for the file formal_sdk-1.0.48.tar.gz.

File metadata

  • Download URL: formal_sdk-1.0.48.tar.gz
  • Upload date:
  • Size: 138.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for formal_sdk-1.0.48.tar.gz
Algorithm Hash digest
SHA256 14c18667b92575fbca7a7efaaf82bb2b09f026f3a307fba703c9e83432b8823e
MD5 f4799c9a36267550a31dabb44b9f6558
BLAKE2b-256 f9023ba392f674b8f6c91309b4725b9b7550b9fb940f949c5800013952e6ae0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for formal_sdk-1.0.48.tar.gz:

Publisher: sdk-python-pypi-deploy.yml on formalco/monorepo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file formal_sdk-1.0.48-py3-none-any.whl.

File metadata

  • Download URL: formal_sdk-1.0.48-py3-none-any.whl
  • Upload date:
  • Size: 246.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for formal_sdk-1.0.48-py3-none-any.whl
Algorithm Hash digest
SHA256 5fbb93065ab36cb468f37cfb3f51b725df20bbf5ff2ab2659fbb4beeb159748e
MD5 9c077abc82d3106b8c69695aa03ff4ac
BLAKE2b-256 7c4e8ccf495388955334e2f22de1799c09da2c126d18b1fde711502284a3fd15

See more details on using hashes here.

Provenance

The following attestation bundles were made for formal_sdk-1.0.48-py3-none-any.whl:

Publisher: sdk-python-pypi-deploy.yml on formalco/monorepo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.48 This release

2 files

1.0.47

2 files

1.0.46

2 files

1.0.45

2 files

1.0.44

2 files

1.0.43

2 files

1.0.42

2 files

1.0.41

2 files

1.0.40

2 files

1.0.39

2 files

1.0.38

2 files

1.0.29

2 files

1.0.28

2 files

1.0.27

2 files

1.0.26

2 files

1.0.25

2 files

1.0.24

2 files

1.0.23

2 files

1.0.22

2 files

1.0.21

2 files

1.0.20

2 files

1.0.18

2 files

1.0.17

2 files

1.0.16

2 files

1.0.15

2 files

1.0.14

2 files

1.0.13

2 files

1.0.12

2 files

1.0.11

2 files

1.0.10

2 files

1.0.9

2 files

1.0.8

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.13.0

2 files

0.12.0

2 files

0.11.0

2 files

0.10.0

2 files

0.9.0

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.2.0

2 files

0.0.9

2 files

0.0.8

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

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