.. 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
Raw data
{
"_id": null,
"home_page": "",
"name": "confluent-cloud-sdk",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "kafka,confluent,sdk",
"author": "John Preston",
"author_email": "john@ews-network.net",
"download_url": "https://files.pythonhosted.org/packages/8f/ed/22b6876833271b46fc999cfe91b86e28808292b253a0bc4a83d55b8093c0/confluent_cloud_sdk-0.2.3.tar.gz",
"platform": null,
"description": "\n.. meta::\n :description: Confluent Cloud SDK\n :keywords: kafka, confluent, cloud, sdk\n\n=======================\nConfluent Cloud SDK\n=======================\n\nSDK to interact with Confluent Cloud API\n\nInstallation\n=============\n\n.. code-block:: bash\n\n pip install confluent-cloud-sdk\n\nImports\n---------\n\nTo use Confluent Admin API SDK in a project\n\n\n.. code-block:: python\n\n from confluent_cloud_sdk.client_factory import ConfluentClient\n from confluent_cloud_sdk.confluent_iam_v2 import ApiKey\n from confluent_cloud_sdk.confluent_iam_v2 import ServiceAccount\n\n\nInitialize connection\n----------------------\n\n\n.. code-block:: python\n\n client = ConfluentClient(\n \"cloud_key_key\",\n \"cloud_key_secret\",\n )\n\nExample with secret in AWS And list all assets\n------------------------------------------------\n\n.. code-block:: python\n\n import json\n from os import environ\n\n from boto3.session import Session\n from confluent_cloud_sdk.client_factory import ConfluentClient\n from confluent_cloud_sdk.confluent_iam_v2 import ServiceAccount\n from confluent_cloud_sdk.confluent_org_v2 import ConfluentEnvironment\n from confluent_cloud_sdk.confluent_cluster_v2 import KafkaClusterV2\n\n from compose_x_common.aws import get_session\n\n\n def get_confluent_admin_secret(\n secret_arn: str,\n session: Session = None,\n key_id: str = \"ApiKey\",\n secret_id: str = \"ApiSecret\",\n ) -> ConfluentClient:\n session = get_session(session)\n client = session.client(\"secretsmanager\")\n value = json.loads(client.get_secret_value(SecretId=secret_arn)[\"SecretString\"])\n return ConfluentClient(value[key_id], value[secret_id])\n\n\n cclient = get_confluent_admin_secret(environ.get(\"SECRET_ARN\"))\n\n envs = cclient.list_all(ConfluentEnvironment)\n\n for env in envs:\n print(env.obj_id)\n clusters = cclient.list_all(KafkaClusterV2, url_args=f\"?environment={env.obj_id}\")\n for cluster in clusters:\n print(cluster.obj_id)\n\n svc_accounts = cclient.list_all(ServiceAccount)\n for svc_account in svc_accounts:\n print(svc_account.obj_id)\n svc_account.import_api_keys()\n print([key.obj_id for key in svc_account.api_keys.values()])\n\nUsage examples\n==================\n\nFor more details, see docs/usage.rst\n",
"bugtrack_url": null,
"license": "GPL-2-only",
"summary": "Confluent Cloud API SDK",
"version": "0.2.3",
"project_urls": {
"Bug Tracker": "https://codeberg.org/compose-x/confluent-cloud-sdk/issues",
"Confluent API Documentation": "https://docs.confluent.io/cloud/current/api.html"
},
"split_keywords": [
"kafka",
"confluent",
"sdk"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7bfad1b7254d13426936be4e763eed6c2a5dc0f8aa678f765de9bbac0dedb920",
"md5": "19f23913f8eaa0704f2d8308cd1aa7e5",
"sha256": "c11e10d28e956742c1b4138e9220befdd47d1e5a34e8c3be56155f95ebe95ece"
},
"downloads": -1,
"filename": "confluent_cloud_sdk-0.2.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "19f23913f8eaa0704f2d8308cd1aa7e5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 18386,
"upload_time": "2023-10-06T04:07:14",
"upload_time_iso_8601": "2023-10-06T04:07:14.509821Z",
"url": "https://files.pythonhosted.org/packages/7b/fa/d1b7254d13426936be4e763eed6c2a5dc0f8aa678f765de9bbac0dedb920/confluent_cloud_sdk-0.2.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8fed22b6876833271b46fc999cfe91b86e28808292b253a0bc4a83d55b8093c0",
"md5": "51dbdae2738f90aa76e15c485fc0a934",
"sha256": "a8280ae04019c73a6769bf7170096b722b82a7875b8a33c049db01f1ba6abc6e"
},
"downloads": -1,
"filename": "confluent_cloud_sdk-0.2.3.tar.gz",
"has_sig": false,
"md5_digest": "51dbdae2738f90aa76e15c485fc0a934",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 14582,
"upload_time": "2023-10-06T04:07:16",
"upload_time_iso_8601": "2023-10-06T04:07:16.480896Z",
"url": "https://files.pythonhosted.org/packages/8f/ed/22b6876833271b46fc999cfe91b86e28808292b253a0bc4a83d55b8093c0/confluent_cloud_sdk-0.2.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-06 04:07:16",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": true,
"codeberg_user": "compose-x",
"codeberg_project": "confluent-cloud-sdk",
"lcname": "confluent-cloud-sdk"
}