Metadata-Version: 2.5
Name: pyatlassdk
Version: 0.1.0
Summary: Python SDKs for the MongoDB Atlas Administration, App Services Admin, and Status APIs.
Project-URL: Homepage, https://github.com/zhangyaoxing/pyatlassdk
Project-URL: Repository, https://github.com/zhangyaoxing/pyatlassdk
Project-URL: Issues, https://github.com/zhangyaoxing/pyatlassdk/issues
Author: Yaoxing
License-Expression: MIT
License-File: LICENSE
Keywords: api,atlas,mongodb,sdk
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: httpx>=0.28.1
Requires-Dist: pydantic>=2.14.1
Description-Content-Type: text/markdown

# pyatlassdk

Python SDKs for MongoDB Atlas APIs, generated automatically:

- **Atlas Administration API v2**
- **Atlas App Services Admin API v3**
- **Atlas Status API v2**

> `src/pyatlassdk/admin/`, `src/pyatlassdk/app/`, and `src/pyatlassdk/status/` are generated by [mongo-atlas-sdk](https://github.com/zhangyaoxing/mongo-atlas-sdk). Do not edit them by hand.

## Installation

```bash
pip install pyatlassdk
```

## Packages and clients

| API | Package | Client | Authentication |
| --- | --- | --- | --- |
| Atlas Administration API v2 | `pyatlassdk.admin` | `AtlasAdminClient` | Digest API keys or OAuth 2.0 service accounts |
| App Services Admin API v3 | `pyatlassdk.app` | `AtlasAppAdminClient` | Bearer access token, or API-key login |
| Atlas Status API v2 | `pyatlassdk.status` | `AtlasStatusClient` | None (public API) |

```python
from pyatlassdk import AtlasAdminClient, AtlasAppAdminClient, AtlasStatusClient
```

## Atlas Administration API

```python
from pyatlassdk import AtlasAdminClient
from pyatlassdk.admin.models.cluster_description20240805 import ClusterDescription20240805

# Digest authentication with Atlas API keys
with AtlasAdminClient(public_key="...", private_key="...") as client:
    cluster = client.clusters.create_group_cluster(
        group_id="...",
        body=ClusterDescription20240805(name="demo", cluster_type="REPLICASET"),
    )

# OAuth 2.0 client credentials with Atlas service account credentials
with AtlasAdminClient(client_id="...", client_secret="...") as client:
    cluster = client.clusters.create_group_cluster(
        group_id="...",
        body=ClusterDescription20240805(name="demo", cluster_type="REPLICASET"),
    )
```

## App Services Admin API

```python
from pyatlassdk import AtlasAppAdminClient

# Exchange API-key credentials for an access token
client = AtlasAppAdminClient.login(username="...", api_key="...")
apps = client.apps.admin_list_applications(group_id="...")

# Or reuse an existing access token
with AtlasAppAdminClient(access_token="...") as client:
    apps = client.apps.admin_list_applications(group_id="...")
```

- `base_url` defaults to `https://services.cloud.mongodb.com/api/admin/v3.0`.
- `AtlasAppAdminClient.login` posts to `/auth/providers/mongodb-cloud/login` and returns a client holding the `access_token`.

## Atlas Status API

```python
from pyatlassdk import AtlasStatusClient

with AtlasStatusClient() as client:
    summary = client.status.get_status_summary()
    print(summary.status.indicator)  # none | minor | major | critical
```

The Status API is public and requires no authentication. `base_url` defaults to
`https://status.mongodb.com/api/v2`.

## Shared behavior

- Models are pydantic v2 with snake_case fields; serialization uses the original Atlas field names (aliases).
- `datetime` / `date` values are serialized to ISO 8601 strings, so they can be passed directly in request bodies.
- Enum values are case-insensitive for uppercase code enums (`"secondary"` becomes `"SECONDARY"`).
- Map-like fields (for example `connectionStrings.awsPrivateLink`) are typed as `dict[str, str]`.
- Admin methods send the versioned `Accept` header declared by each endpoint; App Services and Status methods use `application/json`.
- `AtlasClient` is an alias for `AtlasAdminClient` for backwards compatibility.
- Each generated package exports its own `AtlasApiError`.

## Regenerating

Run these commands from the `mongo-atlas-sdk` repository:

```bash
make pipeline          # all APIs
# or one at a time:
make pipeline-admin    # Admin API
make pipeline-app      # App Services API
make pipeline-status   # Status API

# equivalent CLI commands
uv run mongo-atlas crawl --api admin && uv run mongo-atlas normalize --api admin && uv run mongo-atlas pygen --api admin
uv run mongo-atlas crawl --api app && uv run mongo-atlas normalize --api app && uv run mongo-atlas pygen --api app
uv run mongo-atlas crawl --api status && uv run mongo-atlas normalize --api status && uv run mongo-atlas pygen --api status
```

Normalized documents live in `.data/api_docs*.json` and `.data/normalized_api_docs*.json`.

## Releasing

1. Bump `version` in `pyproject.toml`.
2. Commit, tag, and push:

```bash
git tag v0.1.0
git push origin main --tags
```

3. Create a GitHub Release from the tag. Publishing it triggers `.github/workflows/release.yml`, which builds the sdist and wheel, validates the metadata, and publishes to PyPI.

The workflow uses PyPI trusted publishing (OIDC), so no API token is stored. Configure a trusted publisher at <https://pypi.org/manage/account/publishing/> with:

- owner: `zhangyaoxing`
- repository: `pyatlassdk`
- workflow: `release.yml`
- environment: `pypi`

The release tag must be `v` plus the version in `pyproject.toml`; the workflow fails if they differ.

## Development

```bash
uv sync
uv run pytest
```
