dapla-toolbelt-datafangst 0.0.1__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 (47) hide show
  1. dapla_toolbelt_datafangst-0.0.1/LICENSE +21 -0
  2. dapla_toolbelt_datafangst-0.0.1/PKG-INFO +103 -0
  3. dapla_toolbelt_datafangst-0.0.1/README.md +76 -0
  4. dapla_toolbelt_datafangst-0.0.1/pyproject.toml +187 -0
  5. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/__init__.py +40 -0
  6. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/__main__.py +13 -0
  7. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_client.py +53 -0
  8. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_config.py +67 -0
  9. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_exceptions.py +99 -0
  10. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/__init__.py +0 -0
  11. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/__init__.py +96 -0
  12. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/api/__init__.py +5 -0
  13. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/api/default_api.py +4692 -0
  14. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/api_client.py +804 -0
  15. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/api_response.py +21 -0
  16. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/configuration.py +622 -0
  17. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/exceptions.py +218 -0
  18. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/__init__.py +40 -0
  19. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/altinn_form.py +101 -0
  20. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/assignment_type.py +37 -0
  21. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/collection_instrument.py +164 -0
  22. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/contact.py +99 -0
  23. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/feedback_request.py +93 -0
  24. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/feedback_type.py +40 -0
  25. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/instrument_contact.py +100 -0
  26. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/owner.py +90 -0
  27. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/period_plan.py +132 -0
  28. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/relevant_doc.py +91 -0
  29. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/relevant_doc_type.py +42 -0
  30. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/request_collection.py +183 -0
  31. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/response_collection.py +211 -0
  32. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/sample_plan.py +101 -0
  33. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/statistic.py +118 -0
  34. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/status.py +38 -0
  35. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/team.py +97 -0
  36. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/team_member.py +90 -0
  37. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/tool_altinn.py +98 -0
  38. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/tool_api.py +223 -0
  39. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/tool_blaise.py +138 -0
  40. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/tool_config.py +137 -0
  41. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/user_response.py +90 -0
  42. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/models/version_information.py +118 -0
  43. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/py.typed +0 -0
  44. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/_generated/kudoc_client/rest.py +263 -0
  45. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/collections.py +65 -0
  46. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/drafts.py +112 -0
  47. dapla_toolbelt_datafangst-0.0.1/src/dapla_toolbelt_datafangst/py.typed +0 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright © 2026 Statistics Norway
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,103 @@
1
+ Metadata-Version: 2.4
2
+ Name: dapla-toolbelt-datafangst
3
+ Version: 0.0.1
4
+ Summary: Dapla Toolbelt Datafangst
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Author: Contact Person
8
+ Author-email: rupinder.kaur@ssb.no
9
+ Maintainer: Statistics Norway, Data collection platform Department (722)
10
+ Requires-Python: >=3.12
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Requires-Dist: click (>=8.0.1)
17
+ Requires-Dist: dapla-auth-client (>=1.2.1)
18
+ Requires-Dist: pydantic (>=2.11)
19
+ Requires-Dist: python-dateutil (>=2.8.2)
20
+ Requires-Dist: urllib3 (>=2.1.0,<3.0.0)
21
+ Project-URL: Changelog, https://github.com/statisticsnorway/dapla-toolbelt-datafangst/releases
22
+ Project-URL: Documentation, https://statisticsnorway.github.io/dapla-toolbelt-datafangst
23
+ Project-URL: Homepage, https://github.com/statisticsnorway/dapla-toolbelt-datafangst
24
+ Project-URL: Repository, https://github.com/statisticsnorway/dapla-toolbelt-datafangst
25
+ Description-Content-Type: text/markdown
26
+
27
+ # Dapla Toolbelt Datafangst
28
+
29
+ [![PyPI](https://img.shields.io/pypi/v/dapla-toolbelt-datafangst.svg)][pypi status]
30
+ [![Status](https://img.shields.io/pypi/status/dapla-toolbelt-datafangst.svg)][pypi status]
31
+ [![Python Version](https://img.shields.io/pypi/pyversions/dapla-toolbelt-datafangst)][pypi status]
32
+ [![License](https://img.shields.io/pypi/l/dapla-toolbelt-datafangst)][license]
33
+
34
+ [![Documentation](https://github.com/statisticsnorway/dapla-toolbelt-datafangst/actions/workflows/docs.yml/badge.svg)][documentation]
35
+ [![Tests](https://github.com/statisticsnorway/dapla-toolbelt-datafangst/actions/workflows/tests.yml/badge.svg)][tests]
36
+ [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=statisticsnorway_dapla-toolbelt-datafangst&metric=coverage)][sonarcov]
37
+ [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=statisticsnorway_dapla-toolbelt-datafangst&metric=alert_status)][sonarquality]
38
+
39
+ [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)][pre-commit]
40
+ [![Black](https://img.shields.io/badge/code%20style-black-000000.svg)][black]
41
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
42
+ [![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)][poetry]
43
+
44
+ [pypi status]: https://pypi.org/project/dapla-toolbelt-datafangst/
45
+ [documentation]: https://statisticsnorway.github.io/dapla-toolbelt-datafangst
46
+ [tests]: https://github.com/statisticsnorway/dapla-toolbelt-datafangst/actions?workflow=Tests
47
+ [sonarcov]: https://sonarcloud.io/summary/overall?id=statisticsnorway_dapla-toolbelt-datafangst
48
+ [sonarquality]: https://sonarcloud.io/summary/overall?id=statisticsnorway_dapla-toolbelt-datafangst
49
+ [pre-commit]: https://github.com/pre-commit/pre-commit
50
+ [black]: https://github.com/psf/black
51
+ [poetry]: https://python-poetry.org/
52
+
53
+ ## Features
54
+
55
+ - TODO
56
+
57
+ ## Requirements
58
+
59
+ - TODO
60
+
61
+ ## Installation
62
+
63
+ You can install _Dapla Toolbelt Datafangst_ via [pip] from [PyPI]:
64
+
65
+ ```console
66
+ pip install dapla-toolbelt-datafangst
67
+ ```
68
+
69
+ ## Usage
70
+
71
+ Please see the [Reference Guide] for details.
72
+
73
+ ## Contributing
74
+
75
+ Contributions are very welcome.
76
+ To learn more, see the [Contributor Guide].
77
+
78
+ ## License
79
+
80
+ Distributed under the terms of the [MIT license][license],
81
+ _Dapla Toolbelt Datafangst_ is free and open source software.
82
+
83
+ ## Issues
84
+
85
+ If you encounter any problems,
86
+ please [file an issue] along with a detailed description.
87
+
88
+ ## Credits
89
+
90
+ This project was generated from [Statistics Norway]'s [SSB PyPI Template].
91
+
92
+ [statistics norway]: https://www.ssb.no/en
93
+ [pypi]: https://pypi.org/
94
+ [ssb pypi template]: https://github.com/statisticsnorway/ssb-pypitemplate
95
+ [file an issue]: https://github.com/statisticsnorway/dapla-toolbelt-datafangst/issues
96
+ [pip]: https://pip.pypa.io/
97
+
98
+ <!-- github-only -->
99
+
100
+ [license]: https://github.com/statisticsnorway/dapla-toolbelt-datafangst/blob/main/LICENSE
101
+ [contributor guide]: https://github.com/statisticsnorway/dapla-toolbelt-datafangst/blob/main/CONTRIBUTING.md
102
+ [reference guide]: https://statisticsnorway.github.io/dapla-toolbelt-datafangst/reference.html
103
+
@@ -0,0 +1,76 @@
1
+ # Dapla Toolbelt Datafangst
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/dapla-toolbelt-datafangst.svg)][pypi status]
4
+ [![Status](https://img.shields.io/pypi/status/dapla-toolbelt-datafangst.svg)][pypi status]
5
+ [![Python Version](https://img.shields.io/pypi/pyversions/dapla-toolbelt-datafangst)][pypi status]
6
+ [![License](https://img.shields.io/pypi/l/dapla-toolbelt-datafangst)][license]
7
+
8
+ [![Documentation](https://github.com/statisticsnorway/dapla-toolbelt-datafangst/actions/workflows/docs.yml/badge.svg)][documentation]
9
+ [![Tests](https://github.com/statisticsnorway/dapla-toolbelt-datafangst/actions/workflows/tests.yml/badge.svg)][tests]
10
+ [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=statisticsnorway_dapla-toolbelt-datafangst&metric=coverage)][sonarcov]
11
+ [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=statisticsnorway_dapla-toolbelt-datafangst&metric=alert_status)][sonarquality]
12
+
13
+ [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)][pre-commit]
14
+ [![Black](https://img.shields.io/badge/code%20style-black-000000.svg)][black]
15
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
16
+ [![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)][poetry]
17
+
18
+ [pypi status]: https://pypi.org/project/dapla-toolbelt-datafangst/
19
+ [documentation]: https://statisticsnorway.github.io/dapla-toolbelt-datafangst
20
+ [tests]: https://github.com/statisticsnorway/dapla-toolbelt-datafangst/actions?workflow=Tests
21
+ [sonarcov]: https://sonarcloud.io/summary/overall?id=statisticsnorway_dapla-toolbelt-datafangst
22
+ [sonarquality]: https://sonarcloud.io/summary/overall?id=statisticsnorway_dapla-toolbelt-datafangst
23
+ [pre-commit]: https://github.com/pre-commit/pre-commit
24
+ [black]: https://github.com/psf/black
25
+ [poetry]: https://python-poetry.org/
26
+
27
+ ## Features
28
+
29
+ - TODO
30
+
31
+ ## Requirements
32
+
33
+ - TODO
34
+
35
+ ## Installation
36
+
37
+ You can install _Dapla Toolbelt Datafangst_ via [pip] from [PyPI]:
38
+
39
+ ```console
40
+ pip install dapla-toolbelt-datafangst
41
+ ```
42
+
43
+ ## Usage
44
+
45
+ Please see the [Reference Guide] for details.
46
+
47
+ ## Contributing
48
+
49
+ Contributions are very welcome.
50
+ To learn more, see the [Contributor Guide].
51
+
52
+ ## License
53
+
54
+ Distributed under the terms of the [MIT license][license],
55
+ _Dapla Toolbelt Datafangst_ is free and open source software.
56
+
57
+ ## Issues
58
+
59
+ If you encounter any problems,
60
+ please [file an issue] along with a detailed description.
61
+
62
+ ## Credits
63
+
64
+ This project was generated from [Statistics Norway]'s [SSB PyPI Template].
65
+
66
+ [statistics norway]: https://www.ssb.no/en
67
+ [pypi]: https://pypi.org/
68
+ [ssb pypi template]: https://github.com/statisticsnorway/ssb-pypitemplate
69
+ [file an issue]: https://github.com/statisticsnorway/dapla-toolbelt-datafangst/issues
70
+ [pip]: https://pip.pypa.io/
71
+
72
+ <!-- github-only -->
73
+
74
+ [license]: https://github.com/statisticsnorway/dapla-toolbelt-datafangst/blob/main/LICENSE
75
+ [contributor guide]: https://github.com/statisticsnorway/dapla-toolbelt-datafangst/blob/main/CONTRIBUTING.md
76
+ [reference guide]: https://statisticsnorway.github.io/dapla-toolbelt-datafangst/reference.html
@@ -0,0 +1,187 @@
1
+ [project]
2
+ name = "dapla-toolbelt-datafangst"
3
+ version = "0.0.1"
4
+ description = "Dapla Toolbelt Datafangst"
5
+ authors = [{ name = "Contact Person", email = "rupinder.kaur@ssb.no" }]
6
+ maintainers = [{ name = "Statistics Norway, Data collection platform Department (722)" }]
7
+ license = "MIT"
8
+ readme = "README.md"
9
+ requires-python = ">=3.12"
10
+ dynamic = ["classifiers"]
11
+ dependencies = [
12
+ "click>=8.0.1",
13
+ "dapla-auth-client>=1.2.1",
14
+ "pydantic>=2.11",
15
+ "python-dateutil>=2.8.2",
16
+ "urllib3>=2.1.0,<3.0.0",
17
+ ]
18
+
19
+ [project.urls]
20
+ homepage = "https://github.com/statisticsnorway/dapla-toolbelt-datafangst"
21
+ repository = "https://github.com/statisticsnorway/dapla-toolbelt-datafangst"
22
+ documentation = "https://statisticsnorway.github.io/dapla-toolbelt-datafangst"
23
+ Changelog = "https://github.com/statisticsnorway/dapla-toolbelt-datafangst/releases"
24
+
25
+ [project.scripts]
26
+ dapla-toolbelt-datafangst = "dapla_toolbelt_datafangst.__main__:main"
27
+
28
+ [dependency-groups]
29
+ lint = [
30
+ "black[jupyter]>=25.11.0",
31
+ "pre-commit>=4.4.0",
32
+ "pre-commit-hooks>=6.0.0",
33
+ "pydoclint>=0.8.3",
34
+ "ruff>=0.14.5",
35
+ ]
36
+ doc = [
37
+ "furo>=2025.9.25",
38
+ "myst-parser>=4.0.1",
39
+ "sphinx>=8.2.3",
40
+ "sphinx-autobuild>=2025.8.25",
41
+ "sphinx-autodoc-typehints>=3.5.2",
42
+ "sphinx-click>=6.1.0",
43
+ ]
44
+
45
+ # Type hint stubs should be placed in the dev dependency group
46
+ dev = [
47
+ {include-group = "lint"},
48
+ {include-group = "doc"},
49
+ "coverage[toml]>=7.11.3",
50
+ "deptry>=0.24.0; python_version < '4.0'",
51
+ "mypy>=1.18.2",
52
+ "pygments>=2.19.0",
53
+ "pytest>=9.0.0",
54
+ "typeguard>=2.13.3",
55
+ "xdoctest[colors]>=1.3.0",
56
+ ]
57
+
58
+ [tool.poetry]
59
+ classifiers = ["Development Status :: 5 - Production/Stable"]
60
+ requires-poetry = ">=2.3"
61
+
62
+ [tool.poetry.requires-plugins]
63
+ poetry-plugin-export = ">=1.9"
64
+
65
+ [tool.pytest.ini_options]
66
+ pythonpath = ["src"]
67
+ norecursedirs = ["kudoc-client"]
68
+
69
+ [tool.coverage.paths]
70
+ source = ["src", "*/site-packages"]
71
+ tests = ["tests", "*/tests"]
72
+
73
+ [tool.coverage.run]
74
+ branch = true
75
+ source = ["dapla_toolbelt_datafangst", "tests"]
76
+ relative_files = true
77
+ omit = ["*/dapla_toolbelt_datafangst/_generated/*"]
78
+
79
+ [tool.coverage.report]
80
+ show_missing = true
81
+ fail_under = 50
82
+
83
+ [tool.deptry.per_rule_ignores]
84
+ DEP001 = ["nox", "nox_poetry"] # packages available by default
85
+
86
+ [tool.mypy]
87
+ strict = true
88
+ warn_unreachable = true
89
+ pretty = true
90
+ show_column_numbers = true
91
+ show_error_context = true
92
+
93
+ [[tool.mypy.overrides]]
94
+ module = ["dapla_toolbelt_datafangst._generated.*"]
95
+ ignore_errors = true
96
+
97
+ [[tool.mypy.overrides]]
98
+ module = ["tests.*"]
99
+ disallow_untyped_defs = false
100
+ disallow_incomplete_defs = false
101
+
102
+ [tool.pydoclint]
103
+ style = "google"
104
+ exclude = '\.git|\.nox|kudoc-client|_generated'
105
+ arg-type-hints-in-docstring = false
106
+ check-return-types = false
107
+ check-yield-types = false
108
+ allow-init-docstring = true
109
+ quiet = true
110
+
111
+ [tool.ruff]
112
+ force-exclude = true # Apply excludes to pre-commit
113
+ show-fixes = true
114
+ src = ["src", "tests"]
115
+ target-version = "py313" # Minimum Python version supported
116
+ include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"]
117
+ extend-exclude = [
118
+ "__pycache__",
119
+ "old",
120
+ ".ipynb_checkpoints",
121
+ "noxfile.py",
122
+ "docs/conf.py",
123
+ "kudoc-client",
124
+ "_generated",
125
+ ]
126
+
127
+ # Ruff rules may be customized as desired: https://docs.astral.sh/ruff/rules/
128
+ [tool.ruff.lint]
129
+ select = [
130
+ "A", # prevent using keywords that clobber python builtins
131
+ "ANN", # check type annotations
132
+ "B", # bugbear: security warnings
133
+ "D", # documentation
134
+ "E", # pycodestyle
135
+ "F", # pyflakes
136
+ "ISC", # implicit string concatenation
137
+ "I", # sort imports
138
+ "UP", # alert you when better syntax is available in your python version
139
+ "RUF", # the ruff developer's own rules
140
+ ]
141
+ ignore = [
142
+ "ANN202", # Don't require return type annotation for private functions.
143
+ "ANN401", # Allow type annotation with type Any.
144
+ "D100", # Supress undocumented-public-module. Only doc of public api required.
145
+ "FBT001", # Allow boolean positional arguments in a function.
146
+ "FBT002", # Allow boolean default positional arguments in a function.
147
+ "E402", # Supress module-import-not-at-top-of-file, needed in jupyter notebooks.
148
+ "E501", # Supress line-too-long warnings: trust black's judgement on this one.
149
+ "PLR2004", # Allow to compare with unnamed numerical constants.
150
+ ]
151
+ external = ["DOC"] # Avoiding removing any codes starting with `DOC` from any `# noqa` directives.
152
+
153
+ [tool.ruff.lint.isort]
154
+ force-single-line = true
155
+
156
+ [tool.ruff.lint.mccabe]
157
+ max-complexity = 15
158
+
159
+ [tool.ruff.lint.pydocstyle]
160
+ convention = "google" # You can also use "numpy".
161
+
162
+ [tool.ruff.lint.pylint]
163
+ max-args = 8
164
+
165
+ [tool.ruff.lint.pep8-naming]
166
+ classmethod-decorators = ["classmethod", "validator", "root_validator", "pydantic.validator"]
167
+
168
+ [tool.ruff.lint.per-file-ignores]
169
+ "*/__init__.py" = ["F401"]
170
+ "**/tests/*" = [
171
+ "ANN001", # type annotations don't add value for test functions
172
+ "ANN002", # type annotations don't add value for test functions
173
+ "ANN003", # type annotations don't add value for test functions
174
+ "ANN201", # type annotations don't add value for test functions
175
+ "ANN204", # type annotations don't add value for test functions
176
+ "ANN205", # type annotations don't add value for test functions
177
+ "ANN206", # type annotations don't add value for test functions
178
+ "D100", # docstrings are overkill for test functions
179
+ "D101",
180
+ "D102",
181
+ "D103",
182
+ "S101", # asserts are encouraged in pytest
183
+ ]
184
+
185
+ [build-system]
186
+ requires = ["poetry-core>=2.0.0,<3.0.0"]
187
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,40 @@
1
+ """Dapla Toolbelt Datafangst."""
2
+
3
+ from dapla_toolbelt_datafangst._client import KudocClient
4
+ from dapla_toolbelt_datafangst._exceptions import KudocClientError
5
+ from dapla_toolbelt_datafangst._generated.kudoc_client.models.assignment_type import (
6
+ AssignmentType,
7
+ )
8
+ from dapla_toolbelt_datafangst._generated.kudoc_client.models.collection_instrument import (
9
+ CollectionInstrument,
10
+ )
11
+ from dapla_toolbelt_datafangst._generated.kudoc_client.models.contact import Contact
12
+ from dapla_toolbelt_datafangst._generated.kudoc_client.models.instrument_contact import (
13
+ InstrumentContact,
14
+ )
15
+ from dapla_toolbelt_datafangst._generated.kudoc_client.models.owner import Owner
16
+ from dapla_toolbelt_datafangst._generated.kudoc_client.models.period_plan import (
17
+ PeriodPlan,
18
+ )
19
+ from dapla_toolbelt_datafangst._generated.kudoc_client.models.request_collection import (
20
+ RequestCollection,
21
+ )
22
+ from dapla_toolbelt_datafangst._generated.kudoc_client.models.response_collection import (
23
+ ResponseCollection,
24
+ )
25
+ from dapla_toolbelt_datafangst._generated.kudoc_client.models.sample_plan import (
26
+ SamplePlan,
27
+ )
28
+ from dapla_toolbelt_datafangst._generated.kudoc_client.models.status import Status
29
+ from dapla_toolbelt_datafangst._generated.kudoc_client.models.tool_altinn import (
30
+ ToolAltinn,
31
+ )
32
+ from dapla_toolbelt_datafangst._generated.kudoc_client.models.tool_api import ToolAPI
33
+ from dapla_toolbelt_datafangst._generated.kudoc_client.models.tool_blaise import (
34
+ ToolBlaise,
35
+ )
36
+ from dapla_toolbelt_datafangst._generated.kudoc_client.models.tool_config import (
37
+ ToolConfig,
38
+ )
39
+ from dapla_toolbelt_datafangst.collections import Collections
40
+ from dapla_toolbelt_datafangst.drafts import Drafts
@@ -0,0 +1,13 @@
1
+ """Command-line interface."""
2
+
3
+ import click
4
+
5
+
6
+ @click.command()
7
+ @click.version_option()
8
+ def main() -> None:
9
+ """Dapla Toolbelt Datafangst."""
10
+
11
+
12
+ if __name__ == "__main__":
13
+ main(prog_name="dapla-toolbelt-datafangst") # pragma: no cover
@@ -0,0 +1,53 @@
1
+ """KudocClient singleton for managing the API client."""
2
+
3
+ from importlib import metadata
4
+
5
+ from dapla_toolbelt_datafangst._config import get_kudoc_client_configuration
6
+ from dapla_toolbelt_datafangst._config import refresh_access_token
7
+ from dapla_toolbelt_datafangst._generated.kudoc_client.api_client import ApiClient
8
+ from dapla_toolbelt_datafangst._generated.kudoc_client.configuration import (
9
+ Configuration,
10
+ )
11
+
12
+ PACKAGE_NAME = "dapla-toolbelt-datafangst"
13
+
14
+
15
+ def _get_user_agent() -> str:
16
+ """Get the User-Agent header value."""
17
+ version = metadata.distribution(PACKAGE_NAME).version
18
+ return f"{PACKAGE_NAME}/{version}"
19
+
20
+
21
+ class KudocClient:
22
+ """Configure an ApiClient and make it available to facade classes."""
23
+
24
+ _client: ApiClient | None = None
25
+ _config: Configuration | None = None
26
+
27
+ @classmethod
28
+ def get_client(cls) -> ApiClient:
29
+ """Return a configured ApiClient with a fresh access token.
30
+
31
+ Retrieves a fresh access token for each request so that we
32
+ don't attempt to use an expired token.
33
+
34
+ Returns:
35
+ ApiClient: The configured client.
36
+ """
37
+ if not cls._client:
38
+ if not cls._config:
39
+ cls._config = get_kudoc_client_configuration()
40
+ cls._client = ApiClient(cls._config)
41
+ cls._client.user_agent = _get_user_agent()
42
+ cls._client.configuration.access_token = refresh_access_token()
43
+ return cls._client
44
+
45
+ @classmethod
46
+ def set_config(cls, config: Configuration) -> None:
47
+ """Override config, e.g. for testing.
48
+
49
+ Args:
50
+ config: The configuration to use.
51
+ """
52
+ cls._config = config
53
+ cls._client = None
@@ -0,0 +1,67 @@
1
+ """Configuration for kudoc API host and authentication."""
2
+
3
+ import os
4
+ from enum import StrEnum
5
+
6
+ from dapla_auth_client import AuthClient
7
+
8
+ from dapla_toolbelt_datafangst._generated.kudoc_client.configuration import (
9
+ Configuration,
10
+ )
11
+
12
+
13
+ class DaplaEnvironment(StrEnum):
14
+ """Dapla lifecycle environment."""
15
+
16
+ PROD = "PROD"
17
+ TEST = "TEST"
18
+ DEV = "DEV"
19
+ QA = "QA"
20
+
21
+
22
+ KUDOC_HOSTS: dict[DaplaEnvironment, str] = {
23
+ DaplaEnvironment.DEV: "https://dev-collection-gateway.intern.test.ssb.no/kudoc",
24
+ DaplaEnvironment.QA: "https://qa-collection-gateway.intern.test.ssb.no/kudoc",
25
+ DaplaEnvironment.TEST: "https://test-collection-gateway.intern.test.ssb.no/kudoc",
26
+ }
27
+
28
+
29
+ def get_dapla_environment() -> DaplaEnvironment | None:
30
+ """Get the Dapla environment from the DAPLA_ENVIRONMENT env var."""
31
+ if env := os.environ.get("DAPLA_ENVIRONMENT"):
32
+ return DaplaEnvironment(env)
33
+ return None
34
+
35
+
36
+ def get_kudoc_host() -> str:
37
+ """Get the kudoc API host URL based on environment.
38
+
39
+ Returns:
40
+ The host URL string.
41
+
42
+ Raises:
43
+ NotImplementedError: When PROD environment is not yet available.
44
+ """
45
+ env = get_dapla_environment()
46
+ if env == DaplaEnvironment.PROD:
47
+ msg = "PROD environment is not yet available for Kudoc."
48
+ raise NotImplementedError(msg)
49
+ if env is not None:
50
+ return KUDOC_HOSTS[env]
51
+ return os.environ.get("KUDOC_HOST", "http://localhost:8080")
52
+
53
+
54
+ def refresh_access_token() -> str:
55
+ """Fetch a fresh personal token for the kudoc API."""
56
+ return AuthClient.fetch_personal_token(
57
+ scopes=["all_groups", "current_group"],
58
+ audiences=["kudoc"],
59
+ )
60
+
61
+
62
+ def get_kudoc_client_configuration() -> Configuration:
63
+ """Build a Configuration for the kudoc ApiClient."""
64
+ return Configuration(
65
+ host=get_kudoc_host(),
66
+ access_token=refresh_access_token(),
67
+ )
@@ -0,0 +1,99 @@
1
+ """Kudoc client exceptions and error handling."""
2
+
3
+ import json
4
+ from collections.abc import Callable
5
+ from functools import wraps
6
+ from http import HTTPStatus
7
+ from types import MappingProxyType
8
+ from typing import Any
9
+
10
+ import urllib3
11
+
12
+ from dapla_toolbelt_datafangst._generated.kudoc_client.exceptions import ApiException
13
+ from dapla_toolbelt_datafangst._generated.kudoc_client.exceptions import (
14
+ UnauthorizedException,
15
+ )
16
+
17
+ STATUS_EXPLANATIONS: MappingProxyType[HTTPStatus | None, str] = MappingProxyType(
18
+ {
19
+ HTTPStatus.BAD_REQUEST: "There was a problem with the supplied data. Please review the details below.",
20
+ HTTPStatus.UNAUTHORIZED: "Authentication problem. Your token may have expired. Try logging out, logging in and trying again.",
21
+ HTTPStatus.FORBIDDEN: "Forbidden. You don't have access to this resource.",
22
+ HTTPStatus.NOT_FOUND: "Not found. Check that the ID is correct and the resource exists.",
23
+ HTTPStatus.METHOD_NOT_ALLOWED: "This operation is not allowed for the current resource state.",
24
+ HTTPStatus.CONFLICT: "There was a conflict with existing data. Please change your data and try again.",
25
+ None: "",
26
+ },
27
+ )
28
+
29
+
30
+ class KudocClientError(Exception):
31
+ """Wraps API errors into user-friendly messages."""
32
+
33
+ def __init__(self, response_body: str) -> None:
34
+ """Initialize from a JSON-formatted response body.
35
+
36
+ Args:
37
+ response_body: The JSON string from the API error response.
38
+ """
39
+ self.status: int | None = None
40
+ self.detail: str = ""
41
+ try:
42
+ data: dict[str, Any] = json.loads(response_body)
43
+ self.status = data.get("status")
44
+ if data.get("title") == "Constraint Violation":
45
+ violations: list[dict[str, str]] = data.get("violations", [])
46
+ self.detail = "\n" + "\n".join(
47
+ f"{v.get('field', 'Unknown field')}: {v.get('message', 'No message provided')}"
48
+ for v in violations
49
+ )
50
+ else:
51
+ self.detail = data.get("detail", "")
52
+
53
+ if self.detail:
54
+ self.detail = f"\nDetail: {self.detail}"
55
+ except (json.JSONDecodeError, TypeError):
56
+ self.detail = f"Could not decode error response. Body: {response_body}"
57
+
58
+ super().__init__(
59
+ f"{self._get_status_explanation(self.status)}{self.detail or ''}",
60
+ )
61
+
62
+ @staticmethod
63
+ def _get_status_explanation(status: int | None) -> str:
64
+ if not status:
65
+ return ""
66
+ return STATUS_EXPLANATIONS.get(HTTPStatus(status)) or f"Status {status}:"
67
+
68
+
69
+ def kudoc_exception_handler[**P, R](method: Callable[P, R]) -> Callable[P, R]:
70
+ """Decorator for handling exceptions in kudoc facade methods."""
71
+
72
+ @wraps(method)
73
+ def _impl(*method_args: P.args, **method_kwargs: P.kwargs) -> R:
74
+ try:
75
+ return method(*method_args, **method_kwargs)
76
+ except urllib3.exceptions.HTTPError as e:
77
+ raise KudocClientError(
78
+ json.dumps(
79
+ {
80
+ "status": None,
81
+ "title": "Network problems",
82
+ "detail": f"There was a network problem when sending the request. Try again shortly.\nOriginal exception: {getattr(e, 'message', repr(e))}",
83
+ },
84
+ ),
85
+ ) from e
86
+ except UnauthorizedException as e:
87
+ raise KudocClientError(
88
+ json.dumps(
89
+ {
90
+ "status": e.status,
91
+ "title": "Unauthorized",
92
+ "detail": "Unauthorized",
93
+ },
94
+ ),
95
+ ) from e
96
+ except ApiException as e:
97
+ raise KudocClientError(e.body or "No body in error response") from e
98
+
99
+ return _impl