Skip to main content

Add your description here

Project description

IntelliOpsOpenFgaSDK-Python

An efficient, asynchronous Python SDK for communicating with the IntelliOps FGA API.

Features

  • Async API calls using aiohttp
  • Fast and efficient client
  • Easy integration with asyncio-based applications
  • Example methods for permission checking and listing

Installation

Install via pip (after publishing):

pip install intelliopsopenfgasdk-python

Or install dependencies for development:

pip install -r requirements.txt

Usage Examples

1. Initialize the SDK (Recommended)

from intelliopsopenfgasdk_python.intelliops_openfga_sdk import IntelliOpsOpenFgaSDK
from intelliopsopenfgasdk_python.models import CreateFgaModel

sdk = IntelliOpsOpenFgaSDK()
fga_model = CreateFgaModel(
    intelliopsUserUId="your-user-id",
    intelliopsTenantUId="your-tenant-id",
    intelliopsConnectorUId="your-connector-id",
    intelliopsConnectorType="Confluence",
    datasourceTenantUId="your-datasource-tenant-id",
    accessToken="your-access-token",
    refreshToken="your-refresh-token"
)
sdk.initialize(fga_model)  # This will call both datasource and FGA initialization

2. Initialize FGA Data Source (Manual)

from intelliopsopenfgasdk_python.intelliops_openfga_sdk import IntelliOpsOpenFgaSDK
from intelliopsopenfgasdk_python.models import CreateDataSourceModel

sdk = IntelliOpsOpenFgaSDK()
datasource_model = CreateDataSourceModel(
    intelliopsTenantUId="your-tenant-id",
    intelliopsConnectorType="Confluence",
    datasourceTenantUId="your-datasource-tenant-id"
)
sdk._IntelliOpsOpenFgaSDK__init_datasource(datasource_model)  # Not recommended, use initialize() if possible

3. Initialize FGA (Manual)

from intelliopsopenfgasdk_python.intelliops_openfga_sdk import IntelliOpsOpenFgaSDK
from intelliopsopenfgasdk_python.models import CreateFgaModel

sdk = IntelliOpsOpenFgaSDK()
fga_model = CreateFgaModel(
    intelliopsUserUId="your-user-id",
    intelliopsTenantUId="your-tenant-id",
    intelliopsConnectorUId="your-connector-id",
    intelliopsConnectorType="Confluence",
    datasourceTenantUId="your-datasource-tenant-id",
    accessToken="your-access-token",
    refreshToken="your-refresh-token"
)
sdk._IntelliOpsOpenFgaSDK__init_fga(fga_model)  # Not recommended, use initialize() if possible

4. Check Access (Sync)

from intelliopsopenfgasdk_python.intelliops_openfga_sdk import IntelliOpsOpenFgaSDK
from intelliopsopenfgasdk_python.models import CheckAccessModel, FgaObjectModel

sdk = IntelliOpsOpenFgaSDK()
model = CheckAccessModel(
    intelliopsUserUId="your-user-id",
    fgaObject=FgaObjectModel(
        intelliopsConnectorUId="your-connector-id",
        objectId="your-object-id"
    )
)
has_access = sdk.check_access(model)
print("User has access?", has_access)

5. Check Access (Async)

import asyncio
from intelliopsopenfgasdk_python.intelliops_openfga_sdk import IntelliOpsOpenFgaSDK
from intelliopsopenfgasdk_python.models import CheckAccessModel, FgaObjectModel

sdk = IntelliOpsOpenFgaSDK()
async def main():
    model = CheckAccessModel(
        intelliopsUserUId="your-user-id",
        fgaObject=FgaObjectModel(
            intelliopsConnectorUId="your-connector-id",
            objectId="your-object-id"
        )
    )
    has_access = await sdk.async_check_access(model)
    print("User has access?", has_access)

asyncio.run(main())

6. Check Multiple Access (Sync)

from intelliopsopenfgasdk_python.intelliops_openfga_sdk import IntelliOpsOpenFgaSDK
from intelliopsopenfgasdk_python.models import CheckMultipleAccessModel, FgaObjectModel

sdk = IntelliOpsOpenFgaSDK()
model = CheckMultipleAccessModel(
    intelliopsUserUId="your-user-id",
    fgaObjects=[
        FgaObjectModel(intelliopsConnectorUId="your-connector-id", objectId="object-id-1"),
        FgaObjectModel(intelliopsConnectorUId="your-connector-id", objectId="object-id-2"),
    ]
)
result = sdk.check_multi_access(model)
print(result)  # {"object-id-1": True, "object-id-2": False}

7. Check Multiple Access (Async)

import asyncio
from intelliopsopenfgasdk_python.intelliops_openfga_sdk import IntelliOpsOpenFgaSDK
from intelliopsopenfgasdk_python.models import CheckMultipleAccessModel, FgaObjectModel

sdk = IntelliOpsOpenFgaSDK()
async def main():
    model = CheckMultipleAccessModel(
        intelliopsUserUId="your-user-id",
        fgaObjects=[
            FgaObjectModel(intelliopsConnectorUId="your-connector-id", objectId="object-id-1"),
            FgaObjectModel(intelliopsConnectorUId="your-connector-id", objectId="object-id-2"),
        ]
    )
    result = await sdk.async_check_multi_access(model)
    print(result)

asyncio.run(main())

Testing

Run tests using pytest:

pytest

License

MIT

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

intelliopsopenfgasdk_python-0.2.8.tar.gz (41.9 kB view details)

Uploaded Source

Built Distribution

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

intelliopsopenfgasdk_python-0.2.8-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file intelliopsopenfgasdk_python-0.2.8.tar.gz.

File metadata

File hashes

Hashes for intelliopsopenfgasdk_python-0.2.8.tar.gz
Algorithm Hash digest
SHA256 22df652d0470bbcd30b770f272b30d959cae52bad9f56fac5e707aaece476925
MD5 25588714b7eafc39f6ac116a60aea47c
BLAKE2b-256 0e05ad365afaf713296d4013b5c7a80f470f77dc4c4edd000f92adc10a11a648

See more details on using hashes here.

File details

Details for the file intelliopsopenfgasdk_python-0.2.8-py3-none-any.whl.

File metadata

File hashes

Hashes for intelliopsopenfgasdk_python-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 ec966e6e99e17df677c978a7e07863ef1b0a70c6817227d7a819cc5cb1c34b7a
MD5 adc339ea74db46896b2ebe36256b12d7
BLAKE2b-256 dee6edc6b31efcdd14fd4e3d6767661df9cbf1734b5acfcb75e0ebb4cfec4ebf

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