internetdata 1.0.0__py3-none-any.whl

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 (46) hide show
  1. internetdata/__init__.py +49 -0
  2. internetdata/_core.py +287 -0
  3. internetdata/_generated/__init__.py +8 -0
  4. internetdata/_generated/api/__init__.py +1 -0
  5. internetdata/_generated/api/database_v_2/__init__.py +1 -0
  6. internetdata/_generated/api/database_v_2/database_checksum_v2.py +203 -0
  7. internetdata/_generated/api/database_v_2/database_metadata_v2.py +205 -0
  8. internetdata/_generated/api/database_v_2/download_database_v2.py +213 -0
  9. internetdata/_generated/api/database_v_2/list_databases.py +162 -0
  10. internetdata/_generated/api/database_v_2/list_downloads.py +178 -0
  11. internetdata/_generated/client.py +272 -0
  12. internetdata/_generated/errors.py +16 -0
  13. internetdata/_generated/models/__init__.py +53 -0
  14. internetdata/_generated/models/database.py +233 -0
  15. internetdata/_generated/models/database_checksum_v2_format.py +9 -0
  16. internetdata/_generated/models/database_checksum_v2_response_200.py +85 -0
  17. internetdata/_generated/models/database_checksum_v2_response_200_format.py +9 -0
  18. internetdata/_generated/models/database_metadata.py +132 -0
  19. internetdata/_generated/models/database_metadata_column.py +80 -0
  20. internetdata/_generated/models/database_metadata_sample.py +78 -0
  21. internetdata/_generated/models/database_metadata_sample_additional_property_item.py +45 -0
  22. internetdata/_generated/models/database_metadata_schema.py +72 -0
  23. internetdata/_generated/models/database_metadata_size.py +47 -0
  24. internetdata/_generated/models/database_redistribution_type_1.py +10 -0
  25. internetdata/_generated/models/database_redistribution_type_2_type_1.py +10 -0
  26. internetdata/_generated/models/database_redistribution_type_3_type_1.py +10 -0
  27. internetdata/_generated/models/database_standing.py +10 -0
  28. internetdata/_generated/models/database_version.py +97 -0
  29. internetdata/_generated/models/database_version_formats_item.py +9 -0
  30. internetdata/_generated/models/db_checksums.py +85 -0
  31. internetdata/_generated/models/download.py +161 -0
  32. internetdata/_generated/models/download_database_v2_format.py +9 -0
  33. internetdata/_generated/models/download_outcome.py +13 -0
  34. internetdata/_generated/models/error.py +62 -0
  35. internetdata/_generated/models/list_databases_response_200.py +75 -0
  36. internetdata/_generated/models/list_downloads_response_200.py +75 -0
  37. internetdata/_generated/types.py +54 -0
  38. internetdata/aio.py +268 -0
  39. internetdata/client.py +278 -0
  40. internetdata/errors.py +128 -0
  41. internetdata/models.py +197 -0
  42. internetdata/py.typed +0 -0
  43. internetdata-1.0.0.dist-info/METADATA +184 -0
  44. internetdata-1.0.0.dist-info/RECORD +46 -0
  45. internetdata-1.0.0.dist-info/WHEEL +4 -0
  46. internetdata-1.0.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,205 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.database_metadata import DatabaseMetadata
9
+ from ...models.error import Error
10
+ from ...types import UNSET, Response
11
+
12
+
13
+ def _get_kwargs(
14
+ *,
15
+ id: str,
16
+ ) -> dict[str, Any]:
17
+
18
+ params: dict[str, Any] = {}
19
+
20
+ params["id"] = id
21
+
22
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
23
+
24
+ _kwargs: dict[str, Any] = {
25
+ "method": "get",
26
+ "url": "/api/v2/database/metadata",
27
+ "params": params,
28
+ }
29
+
30
+ return _kwargs
31
+
32
+
33
+ def _parse_response(
34
+ *, client: AuthenticatedClient | Client, response: httpx.Response
35
+ ) -> DatabaseMetadata | Error | None:
36
+ if response.status_code == 200:
37
+ response_200 = DatabaseMetadata.from_dict(response.json())
38
+
39
+ return response_200
40
+
41
+ if response.status_code == 401:
42
+ response_401 = Error.from_dict(response.json())
43
+
44
+ return response_401
45
+
46
+ if response.status_code == 403:
47
+ response_403 = Error.from_dict(response.json())
48
+
49
+ return response_403
50
+
51
+ if response.status_code == 404:
52
+ response_404 = Error.from_dict(response.json())
53
+
54
+ return response_404
55
+
56
+ if response.status_code == 503:
57
+ response_503 = Error.from_dict(response.json())
58
+
59
+ return response_503
60
+
61
+ if client.raise_on_unexpected_status:
62
+ raise errors.UnexpectedStatus(response.status_code, response.content)
63
+ else:
64
+ return None
65
+
66
+
67
+ def _build_response(
68
+ *, client: AuthenticatedClient | Client, response: httpx.Response
69
+ ) -> Response[DatabaseMetadata | Error]:
70
+ return Response(
71
+ status_code=HTTPStatus(response.status_code),
72
+ content=response.content,
73
+ headers=response.headers,
74
+ parsed=_parse_response(client=client, response=response),
75
+ )
76
+
77
+
78
+ def sync_detailed(
79
+ *,
80
+ client: AuthenticatedClient,
81
+ id: str,
82
+ ) -> Response[DatabaseMetadata | Error]:
83
+ """What is inside one database - schema, sample rows, row count, sizes
84
+
85
+ Poll this to decide whether today's build is worth fetching: it carries
86
+ `updated` and `entries` without downloading anything.
87
+
88
+ No `format` parameter - one document describes every format the database
89
+ is built in.
90
+
91
+ Args:
92
+ id (str): Example: vpn_ip_v1.
93
+
94
+ Raises:
95
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
96
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
97
+
98
+ Returns:
99
+ Response[DatabaseMetadata | Error]
100
+ """
101
+
102
+ kwargs = _get_kwargs(
103
+ id=id,
104
+ )
105
+
106
+ response = client.get_httpx_client().request(
107
+ **kwargs,
108
+ )
109
+
110
+ return _build_response(client=client, response=response)
111
+
112
+
113
+ def sync(
114
+ *,
115
+ client: AuthenticatedClient,
116
+ id: str,
117
+ ) -> DatabaseMetadata | Error | None:
118
+ """What is inside one database - schema, sample rows, row count, sizes
119
+
120
+ Poll this to decide whether today's build is worth fetching: it carries
121
+ `updated` and `entries` without downloading anything.
122
+
123
+ No `format` parameter - one document describes every format the database
124
+ is built in.
125
+
126
+ Args:
127
+ id (str): Example: vpn_ip_v1.
128
+
129
+ Raises:
130
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
131
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
132
+
133
+ Returns:
134
+ DatabaseMetadata | Error
135
+ """
136
+
137
+ return sync_detailed(
138
+ client=client,
139
+ id=id,
140
+ ).parsed
141
+
142
+
143
+ async def asyncio_detailed(
144
+ *,
145
+ client: AuthenticatedClient,
146
+ id: str,
147
+ ) -> Response[DatabaseMetadata | Error]:
148
+ """What is inside one database - schema, sample rows, row count, sizes
149
+
150
+ Poll this to decide whether today's build is worth fetching: it carries
151
+ `updated` and `entries` without downloading anything.
152
+
153
+ No `format` parameter - one document describes every format the database
154
+ is built in.
155
+
156
+ Args:
157
+ id (str): Example: vpn_ip_v1.
158
+
159
+ Raises:
160
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
161
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
162
+
163
+ Returns:
164
+ Response[DatabaseMetadata | Error]
165
+ """
166
+
167
+ kwargs = _get_kwargs(
168
+ id=id,
169
+ )
170
+
171
+ response = await client.get_async_httpx_client().request(**kwargs)
172
+
173
+ return _build_response(client=client, response=response)
174
+
175
+
176
+ async def asyncio(
177
+ *,
178
+ client: AuthenticatedClient,
179
+ id: str,
180
+ ) -> DatabaseMetadata | Error | None:
181
+ """What is inside one database - schema, sample rows, row count, sizes
182
+
183
+ Poll this to decide whether today's build is worth fetching: it carries
184
+ `updated` and `entries` without downloading anything.
185
+
186
+ No `format` parameter - one document describes every format the database
187
+ is built in.
188
+
189
+ Args:
190
+ id (str): Example: vpn_ip_v1.
191
+
192
+ Raises:
193
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
194
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
195
+
196
+ Returns:
197
+ DatabaseMetadata | Error
198
+ """
199
+
200
+ return (
201
+ await asyncio_detailed(
202
+ client=client,
203
+ id=id,
204
+ )
205
+ ).parsed
@@ -0,0 +1,213 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, cast
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.download_database_v2_format import DownloadDatabaseV2Format
9
+ from ...models.error import Error
10
+ from ...types import UNSET, Response
11
+
12
+
13
+ def _get_kwargs(
14
+ *,
15
+ id: str,
16
+ format_: DownloadDatabaseV2Format,
17
+ ) -> dict[str, Any]:
18
+
19
+ params: dict[str, Any] = {}
20
+
21
+ params["id"] = id
22
+
23
+ json_format_ = format_.value
24
+ params["format"] = json_format_
25
+
26
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
27
+
28
+ _kwargs: dict[str, Any] = {
29
+ "method": "get",
30
+ "url": "/api/v2/database/download",
31
+ "params": params,
32
+ }
33
+
34
+ return _kwargs
35
+
36
+
37
+ def _parse_response(
38
+ *, client: AuthenticatedClient | Client, response: httpx.Response
39
+ ) -> Any | Error | None:
40
+ if response.status_code == 302:
41
+ response_302 = cast(Any, None)
42
+ return response_302
43
+
44
+ if response.status_code == 400:
45
+ response_400 = Error.from_dict(response.json())
46
+
47
+ return response_400
48
+
49
+ if response.status_code == 401:
50
+ response_401 = Error.from_dict(response.json())
51
+
52
+ return response_401
53
+
54
+ if response.status_code == 403:
55
+ response_403 = Error.from_dict(response.json())
56
+
57
+ return response_403
58
+
59
+ if response.status_code == 404:
60
+ response_404 = Error.from_dict(response.json())
61
+
62
+ return response_404
63
+
64
+ if response.status_code == 503:
65
+ response_503 = Error.from_dict(response.json())
66
+
67
+ return response_503
68
+
69
+ if client.raise_on_unexpected_status:
70
+ raise errors.UnexpectedStatus(response.status_code, response.content)
71
+ else:
72
+ return None
73
+
74
+
75
+ def _build_response(
76
+ *, client: AuthenticatedClient | Client, response: httpx.Response
77
+ ) -> Response[Any | Error]:
78
+ return Response(
79
+ status_code=HTTPStatus(response.status_code),
80
+ content=response.content,
81
+ headers=response.headers,
82
+ parsed=_parse_response(client=client, response=response),
83
+ )
84
+
85
+
86
+ def sync_detailed(
87
+ *,
88
+ client: AuthenticatedClient,
89
+ id: str,
90
+ format_: DownloadDatabaseV2Format,
91
+ ) -> Response[Any | Error]:
92
+ """Redirect to a time-limited download URL for one database
93
+
94
+ Answers `302`; the bytes come straight from object storage rather than
95
+ through this API. Follow the redirect.
96
+
97
+ Args:
98
+ id (str): Example: vpn_ip_v1.
99
+ format_ (DownloadDatabaseV2Format): Example: mmdb.
100
+
101
+ Raises:
102
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
103
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
104
+
105
+ Returns:
106
+ Response[Any | Error]
107
+ """
108
+
109
+ kwargs = _get_kwargs(
110
+ id=id,
111
+ format_=format_,
112
+ )
113
+
114
+ response = client.get_httpx_client().request(
115
+ **kwargs,
116
+ )
117
+
118
+ return _build_response(client=client, response=response)
119
+
120
+
121
+ def sync(
122
+ *,
123
+ client: AuthenticatedClient,
124
+ id: str,
125
+ format_: DownloadDatabaseV2Format,
126
+ ) -> Any | Error | None:
127
+ """Redirect to a time-limited download URL for one database
128
+
129
+ Answers `302`; the bytes come straight from object storage rather than
130
+ through this API. Follow the redirect.
131
+
132
+ Args:
133
+ id (str): Example: vpn_ip_v1.
134
+ format_ (DownloadDatabaseV2Format): Example: mmdb.
135
+
136
+ Raises:
137
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
138
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
139
+
140
+ Returns:
141
+ Any | Error
142
+ """
143
+
144
+ return sync_detailed(
145
+ client=client,
146
+ id=id,
147
+ format_=format_,
148
+ ).parsed
149
+
150
+
151
+ async def asyncio_detailed(
152
+ *,
153
+ client: AuthenticatedClient,
154
+ id: str,
155
+ format_: DownloadDatabaseV2Format,
156
+ ) -> Response[Any | Error]:
157
+ """Redirect to a time-limited download URL for one database
158
+
159
+ Answers `302`; the bytes come straight from object storage rather than
160
+ through this API. Follow the redirect.
161
+
162
+ Args:
163
+ id (str): Example: vpn_ip_v1.
164
+ format_ (DownloadDatabaseV2Format): Example: mmdb.
165
+
166
+ Raises:
167
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
168
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
169
+
170
+ Returns:
171
+ Response[Any | Error]
172
+ """
173
+
174
+ kwargs = _get_kwargs(
175
+ id=id,
176
+ format_=format_,
177
+ )
178
+
179
+ response = await client.get_async_httpx_client().request(**kwargs)
180
+
181
+ return _build_response(client=client, response=response)
182
+
183
+
184
+ async def asyncio(
185
+ *,
186
+ client: AuthenticatedClient,
187
+ id: str,
188
+ format_: DownloadDatabaseV2Format,
189
+ ) -> Any | Error | None:
190
+ """Redirect to a time-limited download URL for one database
191
+
192
+ Answers `302`; the bytes come straight from object storage rather than
193
+ through this API. Follow the redirect.
194
+
195
+ Args:
196
+ id (str): Example: vpn_ip_v1.
197
+ format_ (DownloadDatabaseV2Format): Example: mmdb.
198
+
199
+ Raises:
200
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
201
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
202
+
203
+ Returns:
204
+ Any | Error
205
+ """
206
+
207
+ return (
208
+ await asyncio_detailed(
209
+ client=client,
210
+ id=id,
211
+ format_=format_,
212
+ )
213
+ ).parsed
@@ -0,0 +1,162 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.error import Error
9
+ from ...models.list_databases_response_200 import ListDatabasesResponse200
10
+ from ...types import Response
11
+
12
+
13
+ def _get_kwargs() -> dict[str, Any]:
14
+
15
+ _kwargs: dict[str, Any] = {
16
+ "method": "get",
17
+ "url": "/api/v2/database/list",
18
+ }
19
+
20
+ return _kwargs
21
+
22
+
23
+ def _parse_response(
24
+ *, client: AuthenticatedClient | Client, response: httpx.Response
25
+ ) -> Error | ListDatabasesResponse200 | None:
26
+ if response.status_code == 200:
27
+ response_200 = ListDatabasesResponse200.from_dict(response.json())
28
+
29
+ return response_200
30
+
31
+ if response.status_code == 401:
32
+ response_401 = Error.from_dict(response.json())
33
+
34
+ return response_401
35
+
36
+ if client.raise_on_unexpected_status:
37
+ raise errors.UnexpectedStatus(response.status_code, response.content)
38
+ else:
39
+ return None
40
+
41
+
42
+ def _build_response(
43
+ *, client: AuthenticatedClient | Client, response: httpx.Response
44
+ ) -> Response[Error | ListDatabasesResponse200]:
45
+ return Response(
46
+ status_code=HTTPStatus(response.status_code),
47
+ content=response.content,
48
+ headers=response.headers,
49
+ parsed=_parse_response(client=client, response=response),
50
+ )
51
+
52
+
53
+ def sync_detailed(
54
+ *,
55
+ client: AuthenticatedClient,
56
+ ) -> Response[Error | ListDatabasesResponse200]:
57
+ """Every database your organization may see, and where each one stands
58
+
59
+ The whole published catalog, with your organization's licence beside
60
+ each entry, so `standing` says whether a database is yours today
61
+ (`licensed`), was (`expired`), or has never been bought (`unlicensed`).
62
+
63
+ Databases commissioned for a single customer are not listed to anyone
64
+ else.
65
+
66
+ Raises:
67
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
68
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
69
+
70
+ Returns:
71
+ Response[Error | ListDatabasesResponse200]
72
+ """
73
+
74
+ kwargs = _get_kwargs()
75
+
76
+ response = client.get_httpx_client().request(
77
+ **kwargs,
78
+ )
79
+
80
+ return _build_response(client=client, response=response)
81
+
82
+
83
+ def sync(
84
+ *,
85
+ client: AuthenticatedClient,
86
+ ) -> Error | ListDatabasesResponse200 | None:
87
+ """Every database your organization may see, and where each one stands
88
+
89
+ The whole published catalog, with your organization's licence beside
90
+ each entry, so `standing` says whether a database is yours today
91
+ (`licensed`), was (`expired`), or has never been bought (`unlicensed`).
92
+
93
+ Databases commissioned for a single customer are not listed to anyone
94
+ else.
95
+
96
+ Raises:
97
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
98
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
99
+
100
+ Returns:
101
+ Error | ListDatabasesResponse200
102
+ """
103
+
104
+ return sync_detailed(
105
+ client=client,
106
+ ).parsed
107
+
108
+
109
+ async def asyncio_detailed(
110
+ *,
111
+ client: AuthenticatedClient,
112
+ ) -> Response[Error | ListDatabasesResponse200]:
113
+ """Every database your organization may see, and where each one stands
114
+
115
+ The whole published catalog, with your organization's licence beside
116
+ each entry, so `standing` says whether a database is yours today
117
+ (`licensed`), was (`expired`), or has never been bought (`unlicensed`).
118
+
119
+ Databases commissioned for a single customer are not listed to anyone
120
+ else.
121
+
122
+ Raises:
123
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
124
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
125
+
126
+ Returns:
127
+ Response[Error | ListDatabasesResponse200]
128
+ """
129
+
130
+ kwargs = _get_kwargs()
131
+
132
+ response = await client.get_async_httpx_client().request(**kwargs)
133
+
134
+ return _build_response(client=client, response=response)
135
+
136
+
137
+ async def asyncio(
138
+ *,
139
+ client: AuthenticatedClient,
140
+ ) -> Error | ListDatabasesResponse200 | None:
141
+ """Every database your organization may see, and where each one stands
142
+
143
+ The whole published catalog, with your organization's licence beside
144
+ each entry, so `standing` says whether a database is yours today
145
+ (`licensed`), was (`expired`), or has never been bought (`unlicensed`).
146
+
147
+ Databases commissioned for a single customer are not listed to anyone
148
+ else.
149
+
150
+ Raises:
151
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
152
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
153
+
154
+ Returns:
155
+ Error | ListDatabasesResponse200
156
+ """
157
+
158
+ return (
159
+ await asyncio_detailed(
160
+ client=client,
161
+ )
162
+ ).parsed