developer-platform-cli 0.2.0__tar.gz → 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. developer_platform_cli-1.0.0/.github/workflows/ci.yaml +69 -0
  2. {developer_platform_cli-0.2.0 → developer_platform_cli-1.0.0}/.gitignore +3 -0
  3. developer_platform_cli-1.0.0/PKG-INFO +73 -0
  4. developer_platform_cli-1.0.0/README.md +56 -0
  5. {developer_platform_cli-0.2.0 → developer_platform_cli-1.0.0}/pyproject.toml +6 -1
  6. developer_platform_cli-1.0.0/scripts/cli-release.py +34 -0
  7. developer_platform_cli-1.0.0/scripts/generate-cli-contract.py +28 -0
  8. {developer_platform_cli-0.2.0 → developer_platform_cli-1.0.0}/src/platform_cli/__init__.py +1 -1
  9. developer_platform_cli-1.0.0/src/platform_cli/__main__.py +624 -0
  10. developer_platform_cli-1.0.0/src/platform_cli/api_contract.json +20071 -0
  11. {developer_platform_cli-0.2.0 → developer_platform_cli-1.0.0}/src/platform_cli/authentication.py +100 -28
  12. {developer_platform_cli-0.2.0 → developer_platform_cli-1.0.0}/src/platform_cli/client.py +131 -35
  13. developer_platform_cli-1.0.0/src/platform_cli/commands.py +833 -0
  14. {developer_platform_cli-0.2.0 → developer_platform_cli-1.0.0}/src/platform_cli/config.py +37 -11
  15. {developer_platform_cli-0.2.0 → developer_platform_cli-1.0.0}/src/platform_cli/errors.py +3 -1
  16. {developer_platform_cli-0.2.0 → developer_platform_cli-1.0.0}/src/platform_cli/models.py +23 -5
  17. {developer_platform_cli-0.2.0 → developer_platform_cli-1.0.0}/src/platform_cli/profiles.py +67 -21
  18. developer_platform_cli-1.0.0/src/platform_cli/registry.py +762 -0
  19. developer_platform_cli-1.0.0/src/platform_cli/tunnel.py +127 -0
  20. developer_platform_cli-1.0.0/tests/test_administration.py +716 -0
  21. developer_platform_cli-1.0.0/tests/test_client.py +152 -0
  22. developer_platform_cli-1.0.0/tests/test_commands.py +250 -0
  23. developer_platform_cli-1.0.0/tests/test_config.py +45 -0
  24. {developer_platform_cli-0.2.0 → developer_platform_cli-1.0.0}/tests/test_profiles_authentication.py +49 -14
  25. developer_platform_cli-1.0.0/tests/test_release.py +29 -0
  26. developer_platform_cli-0.2.0/PKG-INFO +0 -49
  27. developer_platform_cli-0.2.0/README.md +0 -33
  28. developer_platform_cli-0.2.0/src/platform_cli/__main__.py +0 -407
  29. developer_platform_cli-0.2.0/src/platform_cli/api_contract.json +0 -5790
  30. developer_platform_cli-0.2.0/src/platform_cli/commands.py +0 -458
  31. developer_platform_cli-0.2.0/src/platform_cli/registry.py +0 -137
  32. developer_platform_cli-0.2.0/tests/test_administration.py +0 -184
  33. developer_platform_cli-0.2.0/tests/test_client.py +0 -54
  34. developer_platform_cli-0.2.0/tests/test_commands.py +0 -46
  35. developer_platform_cli-0.2.0/tests/test_config.py +0 -32
@@ -0,0 +1,69 @@
1
+ ---
2
+ name: CLI CI
3
+ "on":
4
+ pull_request:
5
+ push:
6
+ branches: [main]
7
+ tags: ["v*"]
8
+ workflow_dispatch:
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ defaults:
14
+ run:
15
+ shell: bash
16
+
17
+ jobs:
18
+ test:
19
+ runs-on: ubuntu-latest
20
+ timeout-minutes: 10
21
+ steps:
22
+ - uses: actions/checkout@v7.0.1
23
+ - uses: actions/setup-python@v7.0.0
24
+ with:
25
+ python-version: "3.14"
26
+ - run: python3 -m pip install uv
27
+ - run: uv venv --python 3.14
28
+ - run: uv pip install -e '.[dev]' twine ruff
29
+ - run: uv run --no-sync ruff check src tests scripts
30
+ - run: uv run --no-sync ruff format --check src tests scripts
31
+ - name: Validate release version
32
+ if: startsWith(github.ref, 'refs/tags/v')
33
+ run: uv run --no-sync python scripts/cli-release.py
34
+ - run: uv run --no-sync devplat contract check --output json
35
+ - run: uv run --no-sync pytest tests
36
+ - run: uv build --out-dir dist .
37
+ - run: uv run --no-sync twine check dist/*
38
+ - name: Test installed wheel
39
+ run: |
40
+ uv pip uninstall developer-platform-cli
41
+ uv pip install dist/*.whl
42
+ uv run --no-sync pytest tests
43
+ uv run --no-sync devplat contract check --output json
44
+ - uses: actions/upload-artifact@v4
45
+ with:
46
+ name: cli-distributions
47
+ path: dist/
48
+ retention-days: 7
49
+ if-no-files-found: error
50
+
51
+ publish:
52
+ needs: test
53
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
54
+ runs-on: ubuntu-latest
55
+ timeout-minutes: 10
56
+ environment: pypi
57
+ permissions:
58
+ contents: read
59
+ steps:
60
+ - uses: actions/download-artifact@v4
61
+ with:
62
+ name: cli-distributions
63
+ path: dist
64
+ - name: Publish tested distributions to PyPI
65
+ uses: pypa/gh-action-pypi-publish@release/v1
66
+ with:
67
+ user: __token__
68
+ password: ${{ secrets.PYPI_API_TOKEN }}
69
+ packages-dir: dist/
@@ -1,3 +1,6 @@
1
1
  .pytest_cache/
2
2
  __pycache__/
3
3
  *.py[cod]
4
+ .venv/
5
+ dist/
6
+ *.egg-info/
@@ -0,0 +1,73 @@
1
+ Metadata-Version: 2.4
2
+ Name: developer-platform-cli
3
+ Version: 1.0.0
4
+ Summary: Command-line client for the Developer Platform API
5
+ Requires-Python: >=3.12
6
+ Requires-Dist: httpx<1,>=0.28
7
+ Requires-Dist: jsonschema<5,>=4.23
8
+ Requires-Dist: keyring<26,>=25
9
+ Requires-Dist: platformdirs<5,>=4
10
+ Requires-Dist: pydantic<3,>=2.10
11
+ Requires-Dist: rich<14,>=13.9
12
+ Requires-Dist: typer<1,>=0.15
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest<9,>=8.3; extra == 'dev'
15
+ Requires-Dist: respx<1,>=0.22; extra == 'dev'
16
+ Description-Content-Type: text/markdown
17
+
18
+ # Developer Platform CLI
19
+
20
+ This repository builds and releases the `devplat` command-line client for the
21
+ Developer Platform API. The [CLI guide](https://github.com/eseidinger/developer-platform/blob/main/docs/developers/cli.md)
22
+ documents commands and authentication.
23
+
24
+ `devplat` is the command-line client for the Developer Platform API. It supports
25
+ CI deployments and project administration, including hosted application access.
26
+ Use `devplat --help` and `devplat access --help` to inspect commands.
27
+
28
+ Install an editable development copy and run the checks:
29
+
30
+ ```bash
31
+ uv venv
32
+ uv pip install -e '.[dev]'
33
+ uv run --no-sync pytest tests
34
+ uv run --no-sync devplat contract check --output json
35
+ uv build
36
+ ```
37
+
38
+ Set the values returned when the deployment credential was created. Keep the
39
+ secret in the CI system's protected environment and disable shell tracing around
40
+ this step:
41
+
42
+ ```bash
43
+ export PLATFORM_API_URL=https://platform.example
44
+ export PLATFORM_TOKEN_ENDPOINT=\
45
+ https://identity.example/realms/platform/protocol/openid-connect/token
46
+ export PLATFORM_CLIENT_ID='...'
47
+ export PLATFORM_CLIENT_SECRET='...'
48
+ devplat deploy apply --project hello --file application.json --wait
49
+ ```
50
+
51
+ `PLATFORM_ACCESS_TOKEN` may be used instead of the deployment-credential
52
+ variables for a short-lived, externally obtained token. The CLI never persists
53
+ either form of authentication material. Deployment credentials authorize
54
+ deployment and observation only; access administration requires a human
55
+ project-administrator login or an externally supplied administrator token. See
56
+ the [CLI guide](https://github.com/eseidinger/developer-platform/blob/main/docs/developers/cli.md)
57
+ for profiles, login, access commands, and versioned updates.
58
+
59
+ ## Update the API contract
60
+
61
+ The checked-in `src/platform_cli/api_contract.json` is extracted from the API's
62
+ OpenAPI export in the [developer-platform repository](https://github.com/eseidinger/developer-platform).
63
+ After an API contract change, check out both repositories side by side and run:
64
+
65
+ ```bash
66
+ uv run --no-sync python scripts/generate-cli-contract.py --source ../developer-platform/docs/api/openapi.json
67
+ uv run --no-sync devplat contract check --output json
68
+ uv run --no-sync pytest tests
69
+ ```
70
+
71
+ Review and commit the resulting contract change here with any CLI command
72
+ updates. A tag `vMAJOR.MINOR.PATCH` must match `pyproject.toml`; the CLI
73
+ repository builds, tests, and publishes that version from its own CI workflow.
@@ -0,0 +1,56 @@
1
+ # Developer Platform CLI
2
+
3
+ This repository builds and releases the `devplat` command-line client for the
4
+ Developer Platform API. The [CLI guide](https://github.com/eseidinger/developer-platform/blob/main/docs/developers/cli.md)
5
+ documents commands and authentication.
6
+
7
+ `devplat` is the command-line client for the Developer Platform API. It supports
8
+ CI deployments and project administration, including hosted application access.
9
+ Use `devplat --help` and `devplat access --help` to inspect commands.
10
+
11
+ Install an editable development copy and run the checks:
12
+
13
+ ```bash
14
+ uv venv
15
+ uv pip install -e '.[dev]'
16
+ uv run --no-sync pytest tests
17
+ uv run --no-sync devplat contract check --output json
18
+ uv build
19
+ ```
20
+
21
+ Set the values returned when the deployment credential was created. Keep the
22
+ secret in the CI system's protected environment and disable shell tracing around
23
+ this step:
24
+
25
+ ```bash
26
+ export PLATFORM_API_URL=https://platform.example
27
+ export PLATFORM_TOKEN_ENDPOINT=\
28
+ https://identity.example/realms/platform/protocol/openid-connect/token
29
+ export PLATFORM_CLIENT_ID='...'
30
+ export PLATFORM_CLIENT_SECRET='...'
31
+ devplat deploy apply --project hello --file application.json --wait
32
+ ```
33
+
34
+ `PLATFORM_ACCESS_TOKEN` may be used instead of the deployment-credential
35
+ variables for a short-lived, externally obtained token. The CLI never persists
36
+ either form of authentication material. Deployment credentials authorize
37
+ deployment and observation only; access administration requires a human
38
+ project-administrator login or an externally supplied administrator token. See
39
+ the [CLI guide](https://github.com/eseidinger/developer-platform/blob/main/docs/developers/cli.md)
40
+ for profiles, login, access commands, and versioned updates.
41
+
42
+ ## Update the API contract
43
+
44
+ The checked-in `src/platform_cli/api_contract.json` is extracted from the API's
45
+ OpenAPI export in the [developer-platform repository](https://github.com/eseidinger/developer-platform).
46
+ After an API contract change, check out both repositories side by side and run:
47
+
48
+ ```bash
49
+ uv run --no-sync python scripts/generate-cli-contract.py --source ../developer-platform/docs/api/openapi.json
50
+ uv run --no-sync devplat contract check --output json
51
+ uv run --no-sync pytest tests
52
+ ```
53
+
54
+ Review and commit the resulting contract change here with any CLI command
55
+ updates. A tag `vMAJOR.MINOR.PATCH` must match `pyproject.toml`; the CLI
56
+ repository builds, tests, and publishes that version from its own CI workflow.
@@ -4,12 +4,13 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "developer-platform-cli"
7
- version = "0.2.0"
7
+ version = "1.0.0"
8
8
  description = "Command-line client for the Developer Platform API"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
11
11
  dependencies = [
12
12
  "httpx>=0.28,<1",
13
+ "jsonschema>=4.23,<5",
13
14
  "pydantic>=2.10,<3",
14
15
  "rich>=13.9,<14",
15
16
  "typer>=0.15,<1",
@@ -28,6 +29,10 @@ devplat = "platform_cli.__main__:main"
28
29
 
29
30
  [tool.hatch.build.targets.wheel]
30
31
  packages = ["src/platform_cli"]
32
+ core-metadata-version = "2.4"
33
+
34
+ [tool.hatch.build.targets.sdist]
35
+ core-metadata-version = "2.4"
31
36
 
32
37
  [tool.pytest.ini_options]
33
38
  testpaths = ["tests"]
@@ -0,0 +1,34 @@
1
+ """Reject release tags that differ from the CLI distribution version."""
2
+
3
+ import os
4
+ import re
5
+ import tomllib
6
+ from pathlib import Path
7
+
8
+ ROOT = Path(__file__).resolve().parents[1]
9
+ TAG = re.compile(r"v((?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*))")
10
+
11
+
12
+ def validate(reference_type: str | None, tag: str, package_version: str) -> str:
13
+ match = TAG.fullmatch(tag)
14
+ if reference_type != "tag" or match is None:
15
+ raise ValueError("CLI releases require a vMAJOR.MINOR.PATCH tag")
16
+ if match[1] != package_version:
17
+ raise ValueError(
18
+ f"Release tag {tag} does not match package version {package_version}"
19
+ )
20
+ return package_version
21
+
22
+
23
+ def main() -> None:
24
+ version = tomllib.loads((ROOT / "pyproject.toml").read_text())["project"]["version"]
25
+ validate(
26
+ os.environ.get("GITHUB_REF_TYPE"),
27
+ os.environ.get("GITHUB_REF_NAME", ""),
28
+ version,
29
+ )
30
+ print(f"Validated CLI release {version}")
31
+
32
+
33
+ if __name__ == "__main__":
34
+ main()
@@ -0,0 +1,28 @@
1
+ """Extract the packaged public API contract from a platform OpenAPI export."""
2
+
3
+ import argparse
4
+ import json
5
+ from pathlib import Path
6
+
7
+
8
+ def main() -> None:
9
+ parser = argparse.ArgumentParser(description=__doc__)
10
+ parser.add_argument("--source", required=True, type=Path)
11
+ parser.add_argument("--check", action="store_true")
12
+ args = parser.parse_args()
13
+
14
+ source = json.loads(args.source.read_text())
15
+ contract = {key: source[key] for key in ("paths", "components", "openapi")}
16
+ target = Path(__file__).resolve().parents[1] / "src/platform_cli/api_contract.json"
17
+ rendered = json.dumps(contract, indent=2, sort_keys=True) + "\n"
18
+ if args.check:
19
+ if not target.exists() or target.read_text() != rendered:
20
+ parser.exit(
21
+ 1, "CLI API contract is stale; regenerate it from the API export.\n"
22
+ )
23
+ else:
24
+ target.write_text(rendered)
25
+
26
+
27
+ if __name__ == "__main__":
28
+ main()
@@ -1,3 +1,3 @@
1
1
  """Developer Platform command-line client."""
2
2
 
3
- __version__ = "0.1.0"
3
+ __version__ = "1.0.0"