File: example_region.py

package info (click to toggle)
python-mypermobil 0.1.8-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 176 kB
  • sloc: python: 1,172; makefile: 3
file content (25 lines) | stat: -rw-r--r-- 681 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""Example of how to authenticate a MyPermobil instance"""

import asyncio
import mypermobil


async def main():
    """Example of how to authenticate a MyPermobil instance"""

    # Create a session
    # mypermobil uses aiohttp.ClientSession for the requests
    session = await mypermobil.create_session()
    p_api = mypermobil.MyPermobil(
        session=session,
        application="example-application",
    )
    try:
        regions = await p_api.request_regions(include_internal=True)
        print("\n".join([regions[region_id].get("url") for region_id in regions]))
    finally:
        await p_api.close_session()


if __name__ == "__main__":
    asyncio.run(main())