https://github.com/compose-x/confluent-cloud-sdk
Confluent Cloud Admin API SDK
https://github.com/compose-x/confluent-cloud-sdk
confluent-api confluent-cloud confluent-kafka
Last synced: 12 months ago
JSON representation
Confluent Cloud Admin API SDK
- Host: GitHub
- URL: https://github.com/compose-x/confluent-cloud-sdk
- Owner: compose-x
- License: gpl-2.0
- Created: 2022-02-13T13:15:28.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-10-06T03:55:38.000Z (over 2 years ago)
- Last Synced: 2025-06-05T00:45:53.326Z (12 months ago)
- Topics: confluent-api, confluent-cloud, confluent-kafka
- Language: Python
- Homepage:
- Size: 336 KB
- Stars: 1
- Watchers: 1
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: HISTORY.rst
- Contributing: docs/contributing.rst
- License: LICENSE
Awesome Lists containing this project
README
.. meta::
:description: Confluent Cloud SDK
:keywords: kafka, confluent, cloud, sdk
=======================
Confluent Cloud SDK
=======================
SDK to interact with Confluent Cloud API
Installation
=============
.. code-block:: bash
pip install confluent-cloud-sdk
Imports
---------
To use Confluent Admin API SDK in a project
.. code-block:: python
from confluent_cloud_sdk.client_factory import ConfluentClient
from confluent_cloud_sdk.confluent_iam_v2 import ApiKey
from confluent_cloud_sdk.confluent_iam_v2 import ServiceAccount
Initialize connection
----------------------
.. code-block:: python
client = ConfluentClient(
"cloud_key_key",
"cloud_key_secret",
)
Example with secret in AWS And list all assets
------------------------------------------------
.. code-block:: python
import json
from os import environ
from boto3.session import Session
from confluent_cloud_sdk.client_factory import ConfluentClient
from confluent_cloud_sdk.confluent_iam_v2 import ServiceAccount
from confluent_cloud_sdk.confluent_org_v2 import ConfluentEnvironment
from confluent_cloud_sdk.confluent_cluster_v2 import KafkaClusterV2
from compose_x_common.aws import get_session
def get_confluent_admin_secret(
secret_arn: str,
session: Session = None,
key_id: str = "ApiKey",
secret_id: str = "ApiSecret",
) -> ConfluentClient:
session = get_session(session)
client = session.client("secretsmanager")
value = json.loads(client.get_secret_value(SecretId=secret_arn)["SecretString"])
return ConfluentClient(value[key_id], value[secret_id])
cclient = get_confluent_admin_secret(environ.get("SECRET_ARN"))
envs = cclient.list_all(ConfluentEnvironment)
for env in envs:
print(env.obj_id)
clusters = cclient.list_all(KafkaClusterV2, url_args=f"?environment={env.obj_id}")
for cluster in clusters:
print(cluster.obj_id)
svc_accounts = cclient.list_all(ServiceAccount)
for svc_account in svc_accounts:
print(svc_account.obj_id)
svc_account.import_api_keys()
print([key.obj_id for key in svc_account.api_keys.values()])
Usage examples
==================
For more details, see docs/usage.rst