diff --git a/.github/workflows/integrationtest.yml b/.github/workflows/integrationtest.yml index 39a2798..13edd18 100644 --- a/.github/workflows/integrationtest.yml +++ b/.github/workflows/integrationtest.yml @@ -28,10 +28,10 @@ jobs: cache: 'pip' - name: Install the requirements - run: pip install -r requirements.txt + run: pip install pdm && pdm install - name: Execute the integrationtests (http1.1) - run: python3 -m unittest discover tests/integrationtest + run: .venv/bin/python3 -m unittest discover tests/integrationtest env: GRAFANA_HOST: ${{ secrets.GRAFANA_HOST }} GRAFANA_TOKEN: ${{ secrets.GRAFANA_TOKEN }} @@ -45,7 +45,7 @@ jobs: run: sleep 20 - name: Execute the integrationtests (http2) - run: python3 -m unittest discover tests/integrationtest + run: .venv/bin/python3 -m unittest discover tests/integrationtest env: GRAFANA_HOST: ${{ secrets.GRAFANA_HOST }} GRAFANA_TOKEN: ${{ secrets.GRAFANA_TOKEN }} diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 946091a..bdbdd0b 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -24,22 +24,13 @@ jobs: cache: 'pip' - name: Install the requirements - run: pip install -r requirements.txt && pip install setuptools~=65.5.1 mkdocs mkdocs-material + run: pip install pdm && pdm install --no-self && pdm add setuptools~=65.5.1 mkdocs mkdocs-material build - - name: Install pypa/build - run: >- - python -m - pip install - build - --user + - name: Prepare the PyPi documentation + run: python3 .github/workflows/scripts/adjust-the-readme-file.py - name: Build a binary wheel and a source tarball - run: >- - python -m - build - --sdist - --wheel - --outdir dist/ + run: .venv/bin/python3 -m build --sdist --wheel --outdir dist/ - name: Setup the GitHub user run: | @@ -47,7 +38,7 @@ jobs: git config --local user.name "github-actions[bot]" - name: Update the GitHub pages documentation - run: cd docs && mkdocs gh-deploy --force && cd .. + run: cd docs && .venv/bin/mkdocs gh-deploy --force && cd .. - name: Publish distribution package to PyPI if: startsWith(github.ref, 'refs/tags') diff --git a/.github/workflows/pull-request-checks.yml b/.github/workflows/pull-request-checks.yml index ff77ba4..84dda89 100644 --- a/.github/workflows/pull-request-checks.yml +++ b/.github/workflows/pull-request-checks.yml @@ -23,10 +23,10 @@ jobs: cache: 'pip' - name: Install the requirements - run: pip install -r requirements.txt + run: pip install pdm && pdm install --no-self -d - name: Execute the unittests - run: python3 -m unittest discover tests/unittests + run: PYTHONPATH=$PWD/src .venv/bin/python3 -m unittest discover tests/unittests pr-lint: runs-on: ubuntu-latest @@ -73,10 +73,10 @@ jobs: cache: 'pip' - name: Install the requirements - run: pip install -r requirements.txt && pip install pytest-cov coverage-badge + run: pip install pdm && pdm install --no-self -d && pdm add pytest-cov coverage-badge - name: Generate the coverage report - run: export PYTHONPATH=$PWD && pytest --junitxml=pytest.xml --cov=. tests/unittests | tee pytest-coverage.txt + run: PYTHONPATH=$PWD/src .venv/bin/pytest --junitxml=pytest.xml --cov=. tests/unittests | tee pytest-coverage.txt - name: Execute the coverage checks uses: MishaKav/pytest-coverage-comment@v1.1.53 @@ -88,7 +88,7 @@ jobs: create-new-comment: true - name: Generate coverage badge - run: coverage-badge -f -o docs/coverage.svg + run: .venv/bin/coverage-badge -f -o docs/coverage.svg - name: Check changed files uses: tj-actions/verify-changed-files@v20 @@ -133,10 +133,10 @@ jobs: cache: 'pip' - name: Install the requirements - run: pip install pydoc-markdown==4.6.3 mkdocs mkdocs-material + run: pip install pdm && pdm add pydoc-markdown==4.6.3 pyyaml==5.3.1 mkdocs mkdocs-material - name: Generate documentation - run: pydoc-markdown --render-toc && rm -rf docs/content && mv build/docs/* docs + run: .venv/bin/pydoc-markdown --render-toc && rm -rf docs/content && mv build/docs/* docs - name: Check changed files uses: tj-actions/verify-changed-files@v20 diff --git a/.github/workflows/scripts/adjust-the-readme-file.py b/.github/workflows/scripts/adjust-the-readme-file.py new file mode 100644 index 0000000..4d85032 --- /dev/null +++ b/.github/workflows/scripts/adjust-the-readme-file.py @@ -0,0 +1,6 @@ +with open("README.md", "r", encoding="utf-8") as fh: + coverage_string: str = "![Coverage report](https://github.com/ZPascal/grafana_api_sdk/blob/main/docs/coverage.svg)" + long_description: str = fh.read() + +with open("README.md", "w", encoding="utf-8") as fh: + fh.write(long_description.replace(coverage_string, "")) diff --git a/README.md b/README.md index bf0dceb..787769f 100644 --- a/README.md +++ b/README.md @@ -373,7 +373,7 @@ In general, my focus on this project is to implement and deliver old and new fea Please be aware to not install the `grafana-api` and `grafana-api-sdk` packages in parallel and the same environment. This result in name clashes, and it's not possible to use the Grafana API SDK. -`pip install grafana-api-sdk` +`pdm install grafana-api-sdk` or `pip install grafana-api-sdk` ## Example @@ -434,7 +434,11 @@ model: APIModel = APIModel(host="test", token="test", ssl_context=ssl_ctx) If you want to template your JSON document based on a predefined folder structure you can check out one of my other [project](https://github.com/ZPascal/grafana_dashboard_templater) and integrate the functionality inside your code. ## Contribution -If you would like to contribute something, have an improvement request, or want to make a change inside the code, please open a pull request. +If you would like to contribute something, have an improvement request, or want to make a change inside the code, please open a pull request. +If you want to make a contribution and open a pull request, please write or adapt the necessary unit tests beforehand. +You can install the necessary development requirements for the unit tests by running `pdm install -d` or `pip install pytest-httpx pytest`. + +#TODO Document the unit test execution ## Support If you need support, or you encounter a bug, please don't hesitate to open an issue. diff --git a/docs/coverage.svg b/docs/coverage.svg index e5db27c..6bfc8fa 100644 --- a/docs/coverage.svg +++ b/docs/coverage.svg @@ -15,7 +15,7 @@ coverage coverage - 100% - 100% + 99% + 99% diff --git a/pdm.lock b/pdm.lock new file mode 100644 index 0000000..c015812 --- /dev/null +++ b/pdm.lock @@ -0,0 +1,252 @@ +# This file is @generated by PDM. +# It is not intended for manual editing. + +[metadata] +groups = ["default", "dev"] +strategy = ["inherit_metadata"] +lock_version = "4.5.0" +content_hash = "sha256:a368d55402933d7d20e702870b1901798be493454a1668bdf0d17d9edb940192" + +[[metadata.targets]] +requires_python = ">=3.9" + +[[package]] +name = "anyio" +version = "4.9.0" +requires_python = ">=3.9" +summary = "High level compatibility layer for multiple asynchronous event loop implementations" +groups = ["default", "dev"] +dependencies = [ + "exceptiongroup>=1.0.2; python_version < \"3.11\"", + "idna>=2.8", + "sniffio>=1.1", + "typing-extensions>=4.5; python_version < \"3.13\"", +] +files = [ + {file = "anyio-4.9.0-py3-none-any.whl", hash = "sha256:9f76d541cad6e36af7beb62e978876f3b41e3e04f2c1fbf0884604c0a9c4d93c"}, + {file = "anyio-4.9.0.tar.gz", hash = "sha256:673c0c244e15788651a4ff38710fea9675823028a6f08a5eda409e0c9840a028"}, +] + +[[package]] +name = "certifi" +version = "2025.1.31" +requires_python = ">=3.6" +summary = "Python package for providing Mozilla's CA Bundle." +groups = ["default", "dev"] +files = [ + {file = "certifi-2025.1.31-py3-none-any.whl", hash = "sha256:ca78db4565a652026a4db2bcdf68f2fb589ea80d0be70e03929ed730746b84fe"}, + {file = "certifi-2025.1.31.tar.gz", hash = "sha256:3d5da6925056f6f18f119200434a4780a94263f10d1c21d032a6f6b2baa20651"}, +] + +[[package]] +name = "colorama" +version = "0.4.6" +requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +summary = "Cross-platform colored terminal text." +groups = ["default", "dev"] +marker = "sys_platform == \"win32\"" +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] + +[[package]] +name = "exceptiongroup" +version = "1.2.2" +requires_python = ">=3.7" +summary = "Backport of PEP 654 (exception groups)" +groups = ["default", "dev"] +marker = "python_version < \"3.11\"" +files = [ + {file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"}, + {file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"}, +] + +[[package]] +name = "h11" +version = "0.14.0" +requires_python = ">=3.7" +summary = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1" +groups = ["default", "dev"] +dependencies = [ + "typing-extensions; python_version < \"3.8\"", +] +files = [ + {file = "h11-0.14.0-py3-none-any.whl", hash = "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761"}, + {file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, +] + +[[package]] +name = "httpcore" +version = "1.0.7" +requires_python = ">=3.8" +summary = "A minimal low-level HTTP client." +groups = ["default", "dev"] +dependencies = [ + "certifi", + "h11<0.15,>=0.13", +] +files = [ + {file = "httpcore-1.0.7-py3-none-any.whl", hash = "sha256:a3fff8f43dc260d5bd363d9f9cf1830fa3a458b332856f34282de498ed420edd"}, + {file = "httpcore-1.0.7.tar.gz", hash = "sha256:8551cb62a169ec7162ac7be8d4817d561f60e08eaa485234898414bb5a8a0b4c"}, +] + +[[package]] +name = "httpx" +version = "0.28.1" +requires_python = ">=3.8" +summary = "The next generation HTTP client." +groups = ["default", "dev"] +dependencies = [ + "anyio", + "certifi", + "httpcore==1.*", + "idna", +] +files = [ + {file = "httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad"}, + {file = "httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc"}, +] + +[[package]] +name = "idna" +version = "3.10" +requires_python = ">=3.6" +summary = "Internationalized Domain Names in Applications (IDNA)" +groups = ["default", "dev"] +files = [ + {file = "idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3"}, + {file = "idna-3.10.tar.gz", hash = "sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9"}, +] + +[[package]] +name = "iniconfig" +version = "2.1.0" +requires_python = ">=3.8" +summary = "brain-dead simple config-ini parsing" +groups = ["default", "dev"] +files = [ + {file = "iniconfig-2.1.0-py3-none-any.whl", hash = "sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760"}, + {file = "iniconfig-2.1.0.tar.gz", hash = "sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7"}, +] + +[[package]] +name = "packaging" +version = "24.2" +requires_python = ">=3.8" +summary = "Core utilities for Python packages" +groups = ["default", "dev"] +files = [ + {file = "packaging-24.2-py3-none-any.whl", hash = "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759"}, + {file = "packaging-24.2.tar.gz", hash = "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f"}, +] + +[[package]] +name = "pluggy" +version = "1.5.0" +requires_python = ">=3.8" +summary = "plugin and hook calling mechanisms for python" +groups = ["default", "dev"] +files = [ + {file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"}, + {file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"}, +] + +[[package]] +name = "pytest" +version = "8.3.5" +requires_python = ">=3.8" +summary = "pytest: simple powerful testing with Python" +groups = ["default", "dev"] +dependencies = [ + "colorama; sys_platform == \"win32\"", + "exceptiongroup>=1.0.0rc8; python_version < \"3.11\"", + "iniconfig", + "packaging", + "pluggy<2,>=1.5", + "tomli>=1; python_version < \"3.11\"", +] +files = [ + {file = "pytest-8.3.5-py3-none-any.whl", hash = "sha256:c69214aa47deac29fad6c2a4f590b9c4a9fdb16a403176fe154b79c0b4d4d820"}, + {file = "pytest-8.3.5.tar.gz", hash = "sha256:f4efe70cc14e511565ac476b57c279e12a855b11f48f212af1080ef2263d3845"}, +] + +[[package]] +name = "pytest-httpx" +version = "0.35.0" +requires_python = ">=3.9" +summary = "Send responses to httpx." +groups = ["dev"] +dependencies = [ + "httpx==0.28.*", + "pytest==8.*", +] +files = [ + {file = "pytest_httpx-0.35.0-py3-none-any.whl", hash = "sha256:ee11a00ffcea94a5cbff47af2114d34c5b231c326902458deed73f9c459fd744"}, + {file = "pytest_httpx-0.35.0.tar.gz", hash = "sha256:d619ad5d2e67734abfbb224c3d9025d64795d4b8711116b1a13f72a251ae511f"}, +] + +[[package]] +name = "sniffio" +version = "1.3.1" +requires_python = ">=3.7" +summary = "Sniff out which async library your code is running under" +groups = ["default", "dev"] +files = [ + {file = "sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2"}, + {file = "sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc"}, +] + +[[package]] +name = "tomli" +version = "2.2.1" +requires_python = ">=3.8" +summary = "A lil' TOML parser" +groups = ["default", "dev"] +marker = "python_version < \"3.11\"" +files = [ + {file = "tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249"}, + {file = "tomli-2.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6"}, + {file = "tomli-2.2.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ece47d672db52ac607a3d9599a9d48dcb2f2f735c6c2d1f34130085bb12b112a"}, + {file = "tomli-2.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6972ca9c9cc9f0acaa56a8ca1ff51e7af152a9f87fb64623e31d5c83700080ee"}, + {file = "tomli-2.2.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c954d2250168d28797dd4e3ac5cf812a406cd5a92674ee4c8f123c889786aa8e"}, + {file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8dd28b3e155b80f4d54beb40a441d366adcfe740969820caf156c019fb5c7ec4"}, + {file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:e59e304978767a54663af13c07b3d1af22ddee3bb2fb0618ca1593e4f593a106"}, + {file = "tomli-2.2.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:33580bccab0338d00994d7f16f4c4ec25b776af3ffaac1ed74e0b3fc95e885a8"}, + {file = "tomli-2.2.1-cp311-cp311-win32.whl", hash = "sha256:465af0e0875402f1d226519c9904f37254b3045fc5084697cefb9bdde1ff99ff"}, + {file = "tomli-2.2.1-cp311-cp311-win_amd64.whl", hash = "sha256:2d0f2fdd22b02c6d81637a3c95f8cd77f995846af7414c5c4b8d0545afa1bc4b"}, + {file = "tomli-2.2.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:4a8f6e44de52d5e6c657c9fe83b562f5f4256d8ebbfe4ff922c495620a7f6cea"}, + {file = "tomli-2.2.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8d57ca8095a641b8237d5b079147646153d22552f1c637fd3ba7f4b0b29167a8"}, + {file = "tomli-2.2.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4e340144ad7ae1533cb897d406382b4b6fede8890a03738ff1683af800d54192"}, + {file = "tomli-2.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:db2b95f9de79181805df90bedc5a5ab4c165e6ec3fe99f970d0e302f384ad222"}, + {file = "tomli-2.2.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:40741994320b232529c802f8bc86da4e1aa9f413db394617b9a256ae0f9a7f77"}, + {file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:400e720fe168c0f8521520190686ef8ef033fb19fc493da09779e592861b78c6"}, + {file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:02abe224de6ae62c19f090f68da4e27b10af2b93213d36cf44e6e1c5abd19fdd"}, + {file = "tomli-2.2.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:b82ebccc8c8a36f2094e969560a1b836758481f3dc360ce9a3277c65f374285e"}, + {file = "tomli-2.2.1-cp312-cp312-win32.whl", hash = "sha256:889f80ef92701b9dbb224e49ec87c645ce5df3fa2cc548664eb8a25e03127a98"}, + {file = "tomli-2.2.1-cp312-cp312-win_amd64.whl", hash = "sha256:7fc04e92e1d624a4a63c76474610238576942d6b8950a2d7f908a340494e67e4"}, + {file = "tomli-2.2.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f4039b9cbc3048b2416cc57ab3bda989a6fcf9b36cf8937f01a6e731b64f80d7"}, + {file = "tomli-2.2.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:286f0ca2ffeeb5b9bd4fcc8d6c330534323ec51b2f52da063b11c502da16f30c"}, + {file = "tomli-2.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a92ef1a44547e894e2a17d24e7557a5e85a9e1d0048b0b5e7541f76c5032cb13"}, + {file = "tomli-2.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9316dc65bed1684c9a98ee68759ceaed29d229e985297003e494aa825ebb0281"}, + {file = "tomli-2.2.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e85e99945e688e32d5a35c1ff38ed0b3f41f43fad8df0bdf79f72b2ba7bc5272"}, + {file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:ac065718db92ca818f8d6141b5f66369833d4a80a9d74435a268c52bdfa73140"}, + {file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:d920f33822747519673ee656a4b6ac33e382eca9d331c87770faa3eef562aeb2"}, + {file = "tomli-2.2.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:a198f10c4d1b1375d7687bc25294306e551bf1abfa4eace6650070a5c1ae2744"}, + {file = "tomli-2.2.1-cp313-cp313-win32.whl", hash = "sha256:d3f5614314d758649ab2ab3a62d4f2004c825922f9e370b29416484086b264ec"}, + {file = "tomli-2.2.1-cp313-cp313-win_amd64.whl", hash = "sha256:a38aa0308e754b0e3c67e344754dff64999ff9b513e691d0e786265c93583c69"}, + {file = "tomli-2.2.1-py3-none-any.whl", hash = "sha256:cb55c73c5f4408779d0cf3eef9f762b9c9f147a77de7b258bef0a5628adc85cc"}, + {file = "tomli-2.2.1.tar.gz", hash = "sha256:cd45e1dc79c835ce60f7404ec8119f2eb06d38b1deba146f07ced3bbc44505ff"}, +] + +[[package]] +name = "typing-extensions" +version = "4.12.2" +requires_python = ">=3.8" +summary = "Backported and Experimental Type Hints for Python 3.8+" +groups = ["default", "dev"] +marker = "python_version < \"3.13\"" +files = [ + {file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"}, + {file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"}, +] diff --git a/pydoc-markdown.yml b/pydoc-markdown.yml index c006016..7a87fb2 100644 --- a/pydoc-markdown.yml +++ b/pydoc-markdown.yml @@ -1,6 +1,6 @@ loaders: - type: python - search_path: [grafana_api] + search_path: [src/grafana_api] processors: - type: filter - type: smart diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..049b5ae --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,42 @@ +[project] +name = "grafana-api-sdk" +version = "0.9.0" +description = "A Grafana API SDK" +authors = [ + {name = "Pascal Zimmermann", email = "info@theiotstudio.com"}, +] +dependencies = [ + "httpx", + "pytest>=8.3.5", +] +requires-python = ">=3.9" +readme = "README.md" +license = "Apache-2.0" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Topic :: Software Development :: Libraries :: Grafana API SDK", +] +keywords = ["grafana", "api", "sdk"] + +[project.urls] +Homepage = "https://github.com/ZPascal/grafana_api_sdk" +Source = "https://github.com/ZPascal/grafana_api_sdk" +"Bug Tracker" = "https://github.com/ZPascal/grafana_api_sdk/issues" +Documentation = "https://zpascal.github.io/grafana_api_sdk/" + +[project.optional-dependencies] +http2 = [ + "httpx[http2]", +] +[build-system] +requires = ["pdm-backend"] +build-backend = "pdm.backend" + +[tool.pdm] +distribution = true + +[dependency-groups] +dev = ["pytest-httpx", "pytest"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 5289064..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -httpx[http2] -pytest -pytest-httpx \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index cf91b42..0000000 --- a/setup.py +++ /dev/null @@ -1,36 +0,0 @@ -import setuptools - -with open("README.md", "r", encoding="utf-8") as fh: - coverage_string: str = "![Coverage report](https://github.com/ZPascal/grafana_api_sdk/blob/main/docs/coverage.svg)" - long_description: str = fh.read() - -long_description = long_description.replace(coverage_string, "") - -setuptools.setup( - name="grafana-api-sdk", - version="0.8.0", - author="Pascal Zimmermann", - author_email="info@theiotstudio.com", - description="A Grafana API SDK", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/ZPascal/grafana_api_sdk", - project_urls={ - "Source": "https://github.com/ZPascal/grafana_api_sdk", - "Bug Tracker": "https://github.com/ZPascal/grafana_api_sdk/issues", - "Documentation": "https://zpascal.github.io/grafana_api_sdk/", - }, - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved", - "Operating System :: OS Independent", - ], - license="Apache-2.0 License", - packages=["grafana_api"], - install_requires=["httpx"], - extras_require={ - "http2": ["httpx[http2]"], - }, - tests_require=["pytest-httpx", "pytest"], - python_requires=">=3.8", -) diff --git a/grafana_api/__init__.py b/src/grafana_api/__init__.py similarity index 100% rename from grafana_api/__init__.py rename to src/grafana_api/__init__.py diff --git a/grafana_api/admin.py b/src/grafana_api/admin.py similarity index 100% rename from grafana_api/admin.py rename to src/grafana_api/admin.py diff --git a/grafana_api/alerting.py b/src/grafana_api/alerting.py similarity index 100% rename from grafana_api/alerting.py rename to src/grafana_api/alerting.py diff --git a/grafana_api/alerting_notifications.py b/src/grafana_api/alerting_notifications.py similarity index 100% rename from grafana_api/alerting_notifications.py rename to src/grafana_api/alerting_notifications.py diff --git a/grafana_api/alerting_provisioning.py b/src/grafana_api/alerting_provisioning.py similarity index 100% rename from grafana_api/alerting_provisioning.py rename to src/grafana_api/alerting_provisioning.py diff --git a/grafana_api/annotations.py b/src/grafana_api/annotations.py similarity index 100% rename from grafana_api/annotations.py rename to src/grafana_api/annotations.py diff --git a/grafana_api/api.py b/src/grafana_api/api.py similarity index 100% rename from grafana_api/api.py rename to src/grafana_api/api.py diff --git a/grafana_api/authentication.py b/src/grafana_api/authentication.py similarity index 100% rename from grafana_api/authentication.py rename to src/grafana_api/authentication.py diff --git a/grafana_api/correlations.py b/src/grafana_api/correlations.py similarity index 100% rename from grafana_api/correlations.py rename to src/grafana_api/correlations.py diff --git a/grafana_api/dashboard.py b/src/grafana_api/dashboard.py similarity index 100% rename from grafana_api/dashboard.py rename to src/grafana_api/dashboard.py diff --git a/grafana_api/datasource.py b/src/grafana_api/datasource.py similarity index 100% rename from grafana_api/datasource.py rename to src/grafana_api/datasource.py diff --git a/grafana_api/external_group.py b/src/grafana_api/external_group.py similarity index 100% rename from grafana_api/external_group.py rename to src/grafana_api/external_group.py diff --git a/grafana_api/folder.py b/src/grafana_api/folder.py similarity index 100% rename from grafana_api/folder.py rename to src/grafana_api/folder.py diff --git a/grafana_api/legacy_alerting.py b/src/grafana_api/legacy_alerting.py similarity index 100% rename from grafana_api/legacy_alerting.py rename to src/grafana_api/legacy_alerting.py diff --git a/grafana_api/legacy_playlist.py b/src/grafana_api/legacy_playlist.py similarity index 100% rename from grafana_api/legacy_playlist.py rename to src/grafana_api/legacy_playlist.py diff --git a/grafana_api/library.py b/src/grafana_api/library.py similarity index 100% rename from grafana_api/library.py rename to src/grafana_api/library.py diff --git a/grafana_api/licensing.py b/src/grafana_api/licensing.py similarity index 100% rename from grafana_api/licensing.py rename to src/grafana_api/licensing.py diff --git a/grafana_api/model.py b/src/grafana_api/model.py similarity index 100% rename from grafana_api/model.py rename to src/grafana_api/model.py diff --git a/grafana_api/organisation.py b/src/grafana_api/organisation.py similarity index 100% rename from grafana_api/organisation.py rename to src/grafana_api/organisation.py diff --git a/grafana_api/other_http.py b/src/grafana_api/other_http.py similarity index 100% rename from grafana_api/other_http.py rename to src/grafana_api/other_http.py diff --git a/grafana_api/playlist.py b/src/grafana_api/playlist.py similarity index 100% rename from grafana_api/playlist.py rename to src/grafana_api/playlist.py diff --git a/grafana_api/preferences.py b/src/grafana_api/preferences.py similarity index 100% rename from grafana_api/preferences.py rename to src/grafana_api/preferences.py diff --git a/grafana_api/query_history.py b/src/grafana_api/query_history.py similarity index 100% rename from grafana_api/query_history.py rename to src/grafana_api/query_history.py diff --git a/grafana_api/rbac.py b/src/grafana_api/rbac.py similarity index 100% rename from grafana_api/rbac.py rename to src/grafana_api/rbac.py diff --git a/grafana_api/reporting.py b/src/grafana_api/reporting.py similarity index 100% rename from grafana_api/reporting.py rename to src/grafana_api/reporting.py diff --git a/grafana_api/search.py b/src/grafana_api/search.py similarity index 100% rename from grafana_api/search.py rename to src/grafana_api/search.py diff --git a/grafana_api/service_account.py b/src/grafana_api/service_account.py similarity index 100% rename from grafana_api/service_account.py rename to src/grafana_api/service_account.py diff --git a/grafana_api/short_url.py b/src/grafana_api/short_url.py similarity index 100% rename from grafana_api/short_url.py rename to src/grafana_api/short_url.py diff --git a/grafana_api/snapshot.py b/src/grafana_api/snapshot.py similarity index 100% rename from grafana_api/snapshot.py rename to src/grafana_api/snapshot.py diff --git a/grafana_api/sso_settings.py b/src/grafana_api/sso_settings.py similarity index 100% rename from grafana_api/sso_settings.py rename to src/grafana_api/sso_settings.py diff --git a/grafana_api/team.py b/src/grafana_api/team.py similarity index 100% rename from grafana_api/team.py rename to src/grafana_api/team.py diff --git a/grafana_api/user.py b/src/grafana_api/user.py similarity index 100% rename from grafana_api/user.py rename to src/grafana_api/user.py diff --git a/tests/integrationtest/test_folder.py b/tests/integrationtest/test_folder.py index e899dfb..faa4151 100644 --- a/tests/integrationtest/test_folder.py +++ b/tests/integrationtest/test_folder.py @@ -106,10 +106,10 @@ def test_e_delete_folder(self): self.assertEqual(1, len(self.folder.get_folders())) def test_get_folder_permissions(self): - self.assertEqual( - 1, - self.folder.get_folder_permissions("6U_QdWJnz")[0]["permission"], - ) + folder_permission: dict = self.folder.get_folder_permissions("6U_QdWJnz")[0] + + self.assertEqual("View", folder_permission["permissionName"]) + self.assertEqual(1, folder_permission["permission"]) def test_f_update_folder_permissions(self): permission_dict: dict = dict({"items": [{"role": "Viewer", "permission": 2}]})