datagovgr-datamodels


Namedatagovgr-datamodels JSON
Version 0.1.0a1 PyPI version JSON
download
home_pagehttps://github.com/KAUTH/govgr-opendata-api-schema/blob/main/datamodels/python
SummaryDatamodels generated from the data.gov.gr OpenAPI documentation
upload_time2024-06-22 18:20:42
maintainerNone
docs_urlNone
authorKonstantinos Papadopoulos
requires_python<4.0,>=3.7
licenseMIT
keywords gov-gr datamodels open-data
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # datagovgr-datamodels
Datamodels created for handling the data from the https://data.gov.gr API.

The models are automatically generated from the [unofficial API documentation](https://github.com/KAUTH/govgr-opendata-api-schema/blob/main/docs/openapi-data-gov-gr.yaml),
using the [`datamodel-code-generator`](https://github.com/koxudaxi/datamodel-code-generator).

For more information regarding the related project, see https://github.com/KAUTH/govgr-opendata-api-schema.

## Supported datamodels
- [pydantic_v1](https://docs.pydantic.dev/1.10/).BaseModel
- [pydantic_v2](https://docs.pydantic.dev/2.0/).BaseModel

_Note: At this moment, the package focuses on the datamodels of the responses._

## Quick Installation
To install `datagovgr-datamodels`:

- For `pydantic` models:
```bash
$ pip install datagovgr-datamodels[pydantic]
```

## Example Usage

### Pydantic models
- To test querying the API and using the `pydantic` data models, provide a valid token and run:  
`$ python3 examples/pydantic_v1_models.py`

- Example directly using `pydantic` v1 models:
```python
from datagovgr_datamodels.pydantic_v1 import VaccinationData


data = {
    'area': 'ΑΝΑΤΟΛΙΚΗΣ ΑΤΤΙΚΗΣ',
    'areaid': 901,
    'dailydose1': 45,
    'dailydose2': 0,
    'dailydose3': 0,
    'daydiff': 0,
    'daytotal': 45,
    'referencedate': '2021-01-01T00:00:00',
    'totaldistinctpersons': 276,
    'totaldose1': 276,
    'totaldose2': 0,
    'totaldose3': 0,
    'totalvaccinations': 276
}

vaccination = VaccinationData.parse_obj(data)
print(
    f"Total vaccinations in '{vaccination.area}' "
    f"for {vaccination.referencedate.date()}: "
    f"{vaccination.totalvaccinations}."
)
```

- Example directly using `pydantic` v2 models:
```python
from datagovgr_datamodels.pydantic_v2 import VaccinationData


data = {
    'area': 'ΑΝΑΤΟΛΙΚΗΣ ΑΤΤΙΚΗΣ',
    'areaid': 901,
    'dailydose1': 45,
    'dailydose2': 0,
    'dailydose3': 0,
    'daydiff': 0,
    'daytotal': 45,
    'referencedate': '2021-01-01T00:00:00',
    'totaldistinctpersons': 276,
    'totaldose1': 276,
    'totaldose2': 0,
    'totaldose3': 0,
    'totalvaccinations': 276
}

vaccination = VaccinationData.model_validate(data)
print(
    f"Total vaccinations in '{vaccination.area}' "
    f"for {vaccination.referencedate.date()}: "
    f"{vaccination.totalvaccinations}."
)
```

## Changelog
Changes to the datamodels are accompanied by a version update, documented in
https://github.com/KAUTH/govgr-opendata-api-schema/blob/main/datamodels/python/CHANGELOG.md.

## License
[MIT License](https://github.com/KAUTH/govgr-opendata-api-schema/blob/main/datamodels/python/LICENSE)


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/KAUTH/govgr-opendata-api-schema/blob/main/datamodels/python",
    "name": "datagovgr-datamodels",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.7",
    "maintainer_email": null,
    "keywords": "gov-gr, datamodels, open-data",
    "author": "Konstantinos Papadopoulos",
    "author_email": "konpap1996@yahoo.com",
    "download_url": "https://files.pythonhosted.org/packages/c6/17/92e0a789c71763229b10d542dc20ab827d8c20f846011725b94423724da8/datagovgr_datamodels-0.1.0a1.tar.gz",
    "platform": null,
    "description": "# datagovgr-datamodels\nDatamodels created for handling the data from the https://data.gov.gr API.\n\nThe models are automatically generated from the [unofficial API documentation](https://github.com/KAUTH/govgr-opendata-api-schema/blob/main/docs/openapi-data-gov-gr.yaml),\nusing the [`datamodel-code-generator`](https://github.com/koxudaxi/datamodel-code-generator).\n\nFor more information regarding the related project, see https://github.com/KAUTH/govgr-opendata-api-schema.\n\n## Supported datamodels\n- [pydantic_v1](https://docs.pydantic.dev/1.10/).BaseModel\n- [pydantic_v2](https://docs.pydantic.dev/2.0/).BaseModel\n\n_Note: At this moment, the package focuses on the datamodels of the responses._\n\n## Quick Installation\nTo install `datagovgr-datamodels`:\n\n- For `pydantic` models:\n```bash\n$ pip install datagovgr-datamodels[pydantic]\n```\n\n## Example Usage\n\n### Pydantic models\n- To test querying the API and using the `pydantic` data models, provide a valid token and run:  \n`$ python3 examples/pydantic_v1_models.py`\n\n- Example directly using `pydantic` v1 models:\n```python\nfrom datagovgr_datamodels.pydantic_v1 import VaccinationData\n\n\ndata = {\n    'area': '\u0391\u039d\u0391\u03a4\u039f\u039b\u0399\u039a\u0397\u03a3 \u0391\u03a4\u03a4\u0399\u039a\u0397\u03a3',\n    'areaid': 901,\n    'dailydose1': 45,\n    'dailydose2': 0,\n    'dailydose3': 0,\n    'daydiff': 0,\n    'daytotal': 45,\n    'referencedate': '2021-01-01T00:00:00',\n    'totaldistinctpersons': 276,\n    'totaldose1': 276,\n    'totaldose2': 0,\n    'totaldose3': 0,\n    'totalvaccinations': 276\n}\n\nvaccination = VaccinationData.parse_obj(data)\nprint(\n    f\"Total vaccinations in '{vaccination.area}' \"\n    f\"for {vaccination.referencedate.date()}: \"\n    f\"{vaccination.totalvaccinations}.\"\n)\n```\n\n- Example directly using `pydantic` v2 models:\n```python\nfrom datagovgr_datamodels.pydantic_v2 import VaccinationData\n\n\ndata = {\n    'area': '\u0391\u039d\u0391\u03a4\u039f\u039b\u0399\u039a\u0397\u03a3 \u0391\u03a4\u03a4\u0399\u039a\u0397\u03a3',\n    'areaid': 901,\n    'dailydose1': 45,\n    'dailydose2': 0,\n    'dailydose3': 0,\n    'daydiff': 0,\n    'daytotal': 45,\n    'referencedate': '2021-01-01T00:00:00',\n    'totaldistinctpersons': 276,\n    'totaldose1': 276,\n    'totaldose2': 0,\n    'totaldose3': 0,\n    'totalvaccinations': 276\n}\n\nvaccination = VaccinationData.model_validate(data)\nprint(\n    f\"Total vaccinations in '{vaccination.area}' \"\n    f\"for {vaccination.referencedate.date()}: \"\n    f\"{vaccination.totalvaccinations}.\"\n)\n```\n\n## Changelog\nChanges to the datamodels are accompanied by a version update, documented in\nhttps://github.com/KAUTH/govgr-opendata-api-schema/blob/main/datamodels/python/CHANGELOG.md.\n\n## License\n[MIT License](https://github.com/KAUTH/govgr-opendata-api-schema/blob/main/datamodels/python/LICENSE)\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Datamodels generated from the data.gov.gr OpenAPI documentation",
    "version": "0.1.0a1",
    "project_urls": {
        "Documentation": "https://github.com/KAUTH/govgr-opendata-api-schema/blob/main/datamodels/python/README.md",
        "Homepage": "https://github.com/KAUTH/govgr-opendata-api-schema/blob/main/datamodels/python",
        "Repository": "https://github.com/KAUTH/govgr-opendata-api-schema"
    },
    "split_keywords": [
        "gov-gr",
        " datamodels",
        " open-data"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a6645fc88a4a0060811b85a96f99cf9fcd12c6dc87e9a41e4994d0c4985b2456",
                "md5": "a3e7bc348c313d072021a247f71c3b63",
                "sha256": "ebb83f9930b819cd226b8123c58114a77d5547a9534097319df9def108f86bed"
            },
            "downloads": -1,
            "filename": "datagovgr_datamodels-0.1.0a1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a3e7bc348c313d072021a247f71c3b63",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.7",
            "size": 17550,
            "upload_time": "2024-06-22T18:20:41",
            "upload_time_iso_8601": "2024-06-22T18:20:41.550247Z",
            "url": "https://files.pythonhosted.org/packages/a6/64/5fc88a4a0060811b85a96f99cf9fcd12c6dc87e9a41e4994d0c4985b2456/datagovgr_datamodels-0.1.0a1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c61792e0a789c71763229b10d542dc20ab827d8c20f846011725b94423724da8",
                "md5": "cf553dae0f4992d2221689257036fefa",
                "sha256": "29f7f5d9257ab9dbc60e73445bb11295386cc28d23a8297b355db67cfa158326"
            },
            "downloads": -1,
            "filename": "datagovgr_datamodels-0.1.0a1.tar.gz",
            "has_sig": false,
            "md5_digest": "cf553dae0f4992d2221689257036fefa",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.7",
            "size": 16223,
            "upload_time": "2024-06-22T18:20:42",
            "upload_time_iso_8601": "2024-06-22T18:20:42.740651Z",
            "url": "https://files.pythonhosted.org/packages/c6/17/92e0a789c71763229b10d542dc20ab827d8c20f846011725b94423724da8/datagovgr_datamodels-0.1.0a1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-22 18:20:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "KAUTH",
    "github_project": "govgr-opendata-api-schema",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "datagovgr-datamodels"
}
        
Elapsed time: 0.26844s