internetdata 2.9.6__tar.gz → 2.10.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.
- {internetdata-2.9.6 → internetdata-2.10.1}/PKG-INFO +9 -1
- {internetdata-2.9.6 → internetdata-2.10.1}/README.md +8 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/spec/openapi.yaml +6 -6
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/__init__.py +1 -1
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_core.py +11 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/authorization/oauth_revoke.py +12 -16
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/authorization/oauth_token.py +8 -4
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/aio.py +31 -7
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/client.py +29 -7
- {internetdata-2.9.6 → internetdata-2.10.1}/tests/test_download.py +50 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/.gitignore +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/LICENSE +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/pyproject.toml +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/scripts/download-spec.sh +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/scripts/generate.sh +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/scripts/publish.sh +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/scripts/v2_subset.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/__init__.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/__init__.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/account/__init__.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/account/account_identity.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/api_keys/__init__.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/api_keys/account_create_apikey.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/api_keys/account_list_apikeys.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/api_keys/account_reveal_apikey.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/api_keys/account_revoke_apikey.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/api_keys/account_rotate_apikey.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/authorization/__init__.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/authorization/oauth_authorize.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/authorization/oauth_device_authorization.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/authorization/oauth_metadata.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/authorization/oauth_register.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/database_v_2/__init__.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/database_v_2/database_checksum_v2.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/database_v_2/database_metadata_v2.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/database_v_2/download_database_v2.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/database_v_2/list_databases.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/database_v_2/list_downloads.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/organization/__init__.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/organization/account_org.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/organization/account_org_members.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/client.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/errors.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/__init__.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/account_create_apikey_request.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/account_created_apikey.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/account_org.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/account_org_ref.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/account_org_wrap.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/account_rc.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/account_revealed_apikey.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/account_user.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/apikey_detail.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/apikey_list.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/client_registration.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/client_registration_request.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/database.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/database_checksum_v2_response_200.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/database_format.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/database_license_type_type_1.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/database_license_type_type_2_type_1.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/database_license_type_type_3_type_1.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/database_metadata.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/database_metadata_column.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/database_metadata_sample.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/database_metadata_sample_additional_property_item.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/database_metadata_sample_size.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/database_metadata_schema.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/database_metadata_size.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/database_version.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/db_checksums.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/device_authorization.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/device_authorization_request.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/download.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/download_outcome.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/error.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/identity.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/list_databases_response_200.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/list_downloads_response_200.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/oauth_authorize_code_challenge_method.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/oauth_authorize_response_type.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/oauth_error.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/oauth_metadata.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/oauth_revoke_response_200.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/revoke_request.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/standing.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/token_request.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/token_response.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/types.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/errors.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/models.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/py.typed +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/testdata/testdata.json +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/tests/conftest.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/tests/helpers.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/tests/test_client.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/tests/test_conformance.py +0 -0
- {internetdata-2.9.6 → internetdata-2.10.1}/tests/test_oauth.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: internetdata
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.10.1
|
|
4
4
|
Summary: Official Python client library for the InternetData API. Download and verify licensed IP datasets.
|
|
5
5
|
Project-URL: Homepage, https://internetdata.io
|
|
6
6
|
Project-URL: Documentation, https://docs.internetdata.io
|
|
@@ -117,6 +117,14 @@ written = client.database.download("bogon_ip_v1", "mmdb", "./bogon_ip_v1.mmdb")
|
|
|
117
117
|
|
|
118
118
|
Either way a short transfer fails rather than handing you a truncated file, and the key is never sent to object storage.
|
|
119
119
|
|
|
120
|
+
Each of the three downloads the build that is live unless you name one. A `database.updated` webhook names the build it announces and carries its `sha256`, so a receiver that downloads after the next publish asks for that build to get the file the hash is of:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
client.database.download("vpn_ip_v1", "mmdb", "./vpn_ip_v1.mmdb", build=event["data"]["build"])
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
A build is kept 7 days. Past that the call raises `bad_request` with the message `BUILD_GONE`, and downloading without `build` fetches the live one.
|
|
127
|
+
|
|
120
128
|
Verify what you fetched against the published digests:
|
|
121
129
|
|
|
122
130
|
```python
|
|
@@ -83,6 +83,14 @@ written = client.database.download("bogon_ip_v1", "mmdb", "./bogon_ip_v1.mmdb")
|
|
|
83
83
|
|
|
84
84
|
Either way a short transfer fails rather than handing you a truncated file, and the key is never sent to object storage.
|
|
85
85
|
|
|
86
|
+
Each of the three downloads the build that is live unless you name one. A `database.updated` webhook names the build it announces and carries its `sha256`, so a receiver that downloads after the next publish asks for that build to get the file the hash is of:
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
client.database.download("vpn_ip_v1", "mmdb", "./vpn_ip_v1.mmdb", build=event["data"]["build"])
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
A build is kept 7 days. Past that the call raises `bad_request` with the message `BUILD_GONE`, and downloading without `build` fetches the live one.
|
|
93
|
+
|
|
86
94
|
Verify what you fetched against the published digests:
|
|
87
95
|
|
|
88
96
|
```python
|
|
@@ -12,7 +12,7 @@ info:
|
|
|
12
12
|
email: support@internetdata.io
|
|
13
13
|
url: https://internetdata.io
|
|
14
14
|
termsOfService: https://internetdata.io/terms
|
|
15
|
-
version: 2026.11.
|
|
15
|
+
version: 2026.11.08
|
|
16
16
|
servers:
|
|
17
17
|
- url: https://internetdata.io
|
|
18
18
|
tags:
|
|
@@ -815,7 +815,8 @@ paths:
|
|
|
815
815
|
- Authorization
|
|
816
816
|
summary: Token
|
|
817
817
|
description: |
|
|
818
|
-
|
|
818
|
+
Issues tokens for three grant types: a device code, an authorization
|
|
819
|
+
code and a refresh token.
|
|
819
820
|
|
|
820
821
|
`urn:ietf:params:oauth:grant-type:device_code` polls a device
|
|
821
822
|
authorization. Until the person approves it answers
|
|
@@ -873,11 +874,10 @@ paths:
|
|
|
873
874
|
- Authorization
|
|
874
875
|
summary: Revoke
|
|
875
876
|
description: |
|
|
876
|
-
RFC 7009. Always answers 200,
|
|
877
|
-
|
|
878
|
-
whether a stolen string is a live credential.
|
|
877
|
+
RFC 7009. Always answers 200, even for a token that was never valid, so
|
|
878
|
+
it can't be used to test whether a token is live.
|
|
879
879
|
|
|
880
|
-
Revoking a
|
|
880
|
+
Revoking a refresh token ends the whole authorization and takes its
|
|
881
881
|
access tokens with it. Revoking an access token affects only that token.
|
|
882
882
|
security: []
|
|
883
883
|
requestBody:
|
|
@@ -23,6 +23,7 @@ from urllib.parse import quote
|
|
|
23
23
|
import httpx
|
|
24
24
|
|
|
25
25
|
from ._generated.client import AuthenticatedClient, Client
|
|
26
|
+
from ._generated.types import UNSET, Unset
|
|
26
27
|
from .errors import InternetDataError, error_from_response, oauth_error_from
|
|
27
28
|
from .models import Database, Download, Pkce, to_database, to_download
|
|
28
29
|
|
|
@@ -158,6 +159,16 @@ def check_api_key(api_key: str | None) -> str | None:
|
|
|
158
159
|
return key or None
|
|
159
160
|
|
|
160
161
|
|
|
162
|
+
def check_build(build: str | None) -> str | Unset:
|
|
163
|
+
"""`build` as the download takes it: unset for None or an empty name, so a value read
|
|
164
|
+
from an unset setting downloads the live build."""
|
|
165
|
+
if build is None or build == "":
|
|
166
|
+
return UNSET
|
|
167
|
+
if not isinstance(build, str):
|
|
168
|
+
raise TypeError(f"build must be a build's name, a string, not {build!r}")
|
|
169
|
+
return build
|
|
170
|
+
|
|
171
|
+
|
|
161
172
|
def check_timeout(timeout: float | None) -> float | None:
|
|
162
173
|
"""`timeout`, once it is a bound an attempt can meet.
|
|
163
174
|
|
|
@@ -60,11 +60,10 @@ def sync_detailed(
|
|
|
60
60
|
) -> Response[OauthRevokeResponse200]:
|
|
61
61
|
"""Revoke
|
|
62
62
|
|
|
63
|
-
RFC 7009. Always answers 200,
|
|
64
|
-
|
|
65
|
-
whether a stolen string is a live credential.
|
|
63
|
+
RFC 7009. Always answers 200, even for a token that was never valid, so
|
|
64
|
+
it can't be used to test whether a token is live.
|
|
66
65
|
|
|
67
|
-
Revoking a
|
|
66
|
+
Revoking a refresh token ends the whole authorization and takes its
|
|
68
67
|
access tokens with it. Revoking an access token affects only that token.
|
|
69
68
|
|
|
70
69
|
Args:
|
|
@@ -96,11 +95,10 @@ def sync(
|
|
|
96
95
|
) -> OauthRevokeResponse200 | None:
|
|
97
96
|
"""Revoke
|
|
98
97
|
|
|
99
|
-
RFC 7009. Always answers 200,
|
|
100
|
-
|
|
101
|
-
whether a stolen string is a live credential.
|
|
98
|
+
RFC 7009. Always answers 200, even for a token that was never valid, so
|
|
99
|
+
it can't be used to test whether a token is live.
|
|
102
100
|
|
|
103
|
-
Revoking a
|
|
101
|
+
Revoking a refresh token ends the whole authorization and takes its
|
|
104
102
|
access tokens with it. Revoking an access token affects only that token.
|
|
105
103
|
|
|
106
104
|
Args:
|
|
@@ -127,11 +125,10 @@ async def asyncio_detailed(
|
|
|
127
125
|
) -> Response[OauthRevokeResponse200]:
|
|
128
126
|
"""Revoke
|
|
129
127
|
|
|
130
|
-
RFC 7009. Always answers 200,
|
|
131
|
-
|
|
132
|
-
whether a stolen string is a live credential.
|
|
128
|
+
RFC 7009. Always answers 200, even for a token that was never valid, so
|
|
129
|
+
it can't be used to test whether a token is live.
|
|
133
130
|
|
|
134
|
-
Revoking a
|
|
131
|
+
Revoking a refresh token ends the whole authorization and takes its
|
|
135
132
|
access tokens with it. Revoking an access token affects only that token.
|
|
136
133
|
|
|
137
134
|
Args:
|
|
@@ -161,11 +158,10 @@ async def asyncio(
|
|
|
161
158
|
) -> OauthRevokeResponse200 | None:
|
|
162
159
|
"""Revoke
|
|
163
160
|
|
|
164
|
-
RFC 7009. Always answers 200,
|
|
165
|
-
|
|
166
|
-
whether a stolen string is a live credential.
|
|
161
|
+
RFC 7009. Always answers 200, even for a token that was never valid, so
|
|
162
|
+
it can't be used to test whether a token is live.
|
|
167
163
|
|
|
168
|
-
Revoking a
|
|
164
|
+
Revoking a refresh token ends the whole authorization and takes its
|
|
169
165
|
access tokens with it. Revoking an access token affects only that token.
|
|
170
166
|
|
|
171
167
|
Args:
|
|
@@ -71,7 +71,8 @@ def sync_detailed(
|
|
|
71
71
|
) -> Response[OauthError | TokenResponse]:
|
|
72
72
|
"""Token
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
Issues tokens for three grant types: a device code, an authorization
|
|
75
|
+
code and a refresh token.
|
|
75
76
|
|
|
76
77
|
`urn:ietf:params:oauth:grant-type:device_code` polls a device
|
|
77
78
|
authorization. Until the person approves it answers
|
|
@@ -117,7 +118,8 @@ def sync(
|
|
|
117
118
|
) -> OauthError | TokenResponse | None:
|
|
118
119
|
"""Token
|
|
119
120
|
|
|
120
|
-
|
|
121
|
+
Issues tokens for three grant types: a device code, an authorization
|
|
122
|
+
code and a refresh token.
|
|
121
123
|
|
|
122
124
|
`urn:ietf:params:oauth:grant-type:device_code` polls a device
|
|
123
125
|
authorization. Until the person approves it answers
|
|
@@ -158,7 +160,8 @@ async def asyncio_detailed(
|
|
|
158
160
|
) -> Response[OauthError | TokenResponse]:
|
|
159
161
|
"""Token
|
|
160
162
|
|
|
161
|
-
|
|
163
|
+
Issues tokens for three grant types: a device code, an authorization
|
|
164
|
+
code and a refresh token.
|
|
162
165
|
|
|
163
166
|
`urn:ietf:params:oauth:grant-type:device_code` polls a device
|
|
164
167
|
authorization. Until the person approves it answers
|
|
@@ -202,7 +205,8 @@ async def asyncio(
|
|
|
202
205
|
) -> OauthError | TokenResponse | None:
|
|
203
206
|
"""Token
|
|
204
207
|
|
|
205
|
-
|
|
208
|
+
Issues tokens for three grant types: a device code, an authorization
|
|
209
|
+
code and a refresh token.
|
|
206
210
|
|
|
207
211
|
`urn:ietf:params:oauth:grant-type:device_code` polls a device
|
|
208
212
|
authorization. Until the person approves it answers
|
|
@@ -35,6 +35,7 @@ from ._core import (
|
|
|
35
35
|
authorization_url,
|
|
36
36
|
build_async_transfer_client,
|
|
37
37
|
build_client,
|
|
38
|
+
check_build,
|
|
38
39
|
check_retries,
|
|
39
40
|
check_timeout,
|
|
40
41
|
checksums_of,
|
|
@@ -231,7 +232,12 @@ class AsyncDatabaseApi:
|
|
|
231
232
|
return await self._retrying(call)
|
|
232
233
|
|
|
233
234
|
async def download_url(
|
|
234
|
-
self,
|
|
235
|
+
self,
|
|
236
|
+
database_id: str,
|
|
237
|
+
format: Format,
|
|
238
|
+
*,
|
|
239
|
+
build: str | None = None,
|
|
240
|
+
timeout: float | None = None,
|
|
235
241
|
) -> str:
|
|
236
242
|
"""The time-limited URL for one database file.
|
|
237
243
|
|
|
@@ -241,9 +247,15 @@ class AsyncDatabaseApi:
|
|
|
241
247
|
gigabytes; the link authorizes the START of a transfer, so one already running is
|
|
242
248
|
not interrupted when it lapses.
|
|
243
249
|
|
|
250
|
+
`build` names one build of the database, as a `database.updated` webhook gives it
|
|
251
|
+
(`20261105.0t53s5`), so the file is the one whose `sha256` the webhook carries.
|
|
252
|
+
None, the default, is the build that is live. A build is kept 7 days; past that
|
|
253
|
+
the call raises `bad_request` with the message `BUILD_GONE`.
|
|
254
|
+
|
|
244
255
|
`timeout` bounds each attempt at MINTING the link, which is an ordinary API
|
|
245
256
|
request, and says nothing about the transfer you then run with it.
|
|
246
257
|
"""
|
|
258
|
+
build_ = check_build(build)
|
|
247
259
|
|
|
248
260
|
async def call() -> str:
|
|
249
261
|
res = await request_async(
|
|
@@ -252,12 +264,20 @@ class AsyncDatabaseApi:
|
|
|
252
264
|
self._bound(timeout),
|
|
253
265
|
id=database_id,
|
|
254
266
|
format_=DatabaseFormat(format),
|
|
267
|
+
build=build_,
|
|
255
268
|
)
|
|
256
269
|
return redirect_location(res)
|
|
257
270
|
|
|
258
271
|
return await self._retrying(call)
|
|
259
272
|
|
|
260
|
-
async def download(
|
|
273
|
+
async def download(
|
|
274
|
+
self,
|
|
275
|
+
database_id: str,
|
|
276
|
+
format: Format,
|
|
277
|
+
path: str | os.PathLike[str],
|
|
278
|
+
*,
|
|
279
|
+
build: str | None = None,
|
|
280
|
+
) -> int:
|
|
261
281
|
"""Download one database file to `path`, and return the bytes written.
|
|
262
282
|
|
|
263
283
|
The bytes are streamed straight to disk, so nothing larger than a chunk is ever
|
|
@@ -274,7 +294,7 @@ class AsyncDatabaseApi:
|
|
|
274
294
|
event loop would stall every other task in the process for the length of the
|
|
275
295
|
transfer, which is the one thing an async caller cannot afford.
|
|
276
296
|
"""
|
|
277
|
-
res = await self._open_transfer(database_id, format)
|
|
297
|
+
res = await self._open_transfer(database_id, format, build)
|
|
278
298
|
try:
|
|
279
299
|
loop = asyncio.get_running_loop()
|
|
280
300
|
written = 0
|
|
@@ -288,7 +308,9 @@ class AsyncDatabaseApi:
|
|
|
288
308
|
finally:
|
|
289
309
|
await res.aclose()
|
|
290
310
|
|
|
291
|
-
async def download_bytes(
|
|
311
|
+
async def download_bytes(
|
|
312
|
+
self, database_id: str, format: Format, *, build: str | None = None
|
|
313
|
+
) -> bytes:
|
|
292
314
|
"""Download one database file and hand back its bytes.
|
|
293
315
|
|
|
294
316
|
**This holds the entire file in memory**, and the catalog spans seven orders of
|
|
@@ -296,7 +318,7 @@ class AsyncDatabaseApi:
|
|
|
296
318
|
small end, where the bytes go straight into a parser, and use `download` for
|
|
297
319
|
anything you have not checked `metadata` for.
|
|
298
320
|
"""
|
|
299
|
-
res = await self._open_transfer(database_id, format)
|
|
321
|
+
res = await self._open_transfer(database_id, format, build)
|
|
300
322
|
try:
|
|
301
323
|
body = await res.aread()
|
|
302
324
|
assert_whole_transfer(res, len(body))
|
|
@@ -311,8 +333,10 @@ class AsyncDatabaseApi:
|
|
|
311
333
|
#
|
|
312
334
|
# Returns the response with its body still unread, so the caller decides whether a
|
|
313
335
|
# database is going to disk or into memory.
|
|
314
|
-
async def _open_transfer(
|
|
315
|
-
|
|
336
|
+
async def _open_transfer(
|
|
337
|
+
self, database_id: str, format: Format, build: str | None
|
|
338
|
+
) -> httpx.Response:
|
|
339
|
+
url = await self.download_url(database_id, format, build=build)
|
|
316
340
|
transfer = self._owner._transfer
|
|
317
341
|
|
|
318
342
|
async def call() -> httpx.Response:
|
|
@@ -30,6 +30,7 @@ from ._core import (
|
|
|
30
30
|
authorization_url,
|
|
31
31
|
build_client,
|
|
32
32
|
build_transfer_client,
|
|
33
|
+
check_build,
|
|
33
34
|
check_retries,
|
|
34
35
|
check_timeout,
|
|
35
36
|
checksums_of,
|
|
@@ -252,7 +253,12 @@ class DatabaseApi:
|
|
|
252
253
|
return self._retrying(call)
|
|
253
254
|
|
|
254
255
|
def download_url(
|
|
255
|
-
self,
|
|
256
|
+
self,
|
|
257
|
+
database_id: str,
|
|
258
|
+
format: Format,
|
|
259
|
+
*,
|
|
260
|
+
build: str | None = None,
|
|
261
|
+
timeout: float | None = None,
|
|
256
262
|
) -> str:
|
|
257
263
|
"""The time-limited URL for one database file.
|
|
258
264
|
|
|
@@ -262,9 +268,15 @@ class DatabaseApi:
|
|
|
262
268
|
gigabytes; the link authorizes the START of a transfer, so one already running is
|
|
263
269
|
not interrupted when it lapses.
|
|
264
270
|
|
|
271
|
+
`build` names one build of the database, as a `database.updated` webhook gives it
|
|
272
|
+
(`20261105.0t53s5`), so the file is the one whose `sha256` the webhook carries.
|
|
273
|
+
None, the default, is the build that is live. A build is kept 7 days; past that
|
|
274
|
+
the call raises `bad_request` with the message `BUILD_GONE`.
|
|
275
|
+
|
|
265
276
|
`timeout` bounds each attempt at MINTING the link, which is an ordinary API
|
|
266
277
|
request, and says nothing about the transfer you then run with it.
|
|
267
278
|
"""
|
|
279
|
+
build_ = check_build(build)
|
|
268
280
|
|
|
269
281
|
def call() -> str:
|
|
270
282
|
res = request(
|
|
@@ -273,12 +285,20 @@ class DatabaseApi:
|
|
|
273
285
|
self._bound(timeout),
|
|
274
286
|
id=database_id,
|
|
275
287
|
format_=DatabaseFormat(format),
|
|
288
|
+
build=build_,
|
|
276
289
|
)
|
|
277
290
|
return redirect_location(res)
|
|
278
291
|
|
|
279
292
|
return self._retrying(call)
|
|
280
293
|
|
|
281
|
-
def download(
|
|
294
|
+
def download(
|
|
295
|
+
self,
|
|
296
|
+
database_id: str,
|
|
297
|
+
format: Format,
|
|
298
|
+
path: str | os.PathLike[str],
|
|
299
|
+
*,
|
|
300
|
+
build: str | None = None,
|
|
301
|
+
) -> int:
|
|
282
302
|
"""Download one database file to `path`, and return the bytes written.
|
|
283
303
|
|
|
284
304
|
The bytes are streamed straight to disk, so nothing larger than a chunk is ever
|
|
@@ -291,7 +311,7 @@ class DatabaseApi:
|
|
|
291
311
|
`OSError`, rather than as this library's error type: a reset socket and a full
|
|
292
312
|
disk are different problems, and only one of them is ours.
|
|
293
313
|
"""
|
|
294
|
-
res = self._open_transfer(database_id, format)
|
|
314
|
+
res = self._open_transfer(database_id, format, build)
|
|
295
315
|
try:
|
|
296
316
|
written = 0
|
|
297
317
|
with part_file(path) as sink:
|
|
@@ -304,7 +324,9 @@ class DatabaseApi:
|
|
|
304
324
|
finally:
|
|
305
325
|
res.close()
|
|
306
326
|
|
|
307
|
-
def download_bytes(
|
|
327
|
+
def download_bytes(
|
|
328
|
+
self, database_id: str, format: Format, *, build: str | None = None
|
|
329
|
+
) -> bytes:
|
|
308
330
|
"""Download one database file and hand back its bytes.
|
|
309
331
|
|
|
310
332
|
**This holds the entire file in memory**, and the catalog spans seven orders of
|
|
@@ -312,7 +334,7 @@ class DatabaseApi:
|
|
|
312
334
|
small end, where the bytes go straight into a parser, and use `download` for
|
|
313
335
|
anything you have not checked `metadata` for.
|
|
314
336
|
"""
|
|
315
|
-
res = self._open_transfer(database_id, format)
|
|
337
|
+
res = self._open_transfer(database_id, format, build)
|
|
316
338
|
try:
|
|
317
339
|
body = res.read()
|
|
318
340
|
assert_whole_transfer(res, len(body))
|
|
@@ -327,8 +349,8 @@ class DatabaseApi:
|
|
|
327
349
|
#
|
|
328
350
|
# Returns the response with its body still unread, so the caller decides whether a
|
|
329
351
|
# database is going to disk or into memory.
|
|
330
|
-
def _open_transfer(self, database_id: str, format: Format) -> httpx.Response:
|
|
331
|
-
url = self.download_url(database_id, format)
|
|
352
|
+
def _open_transfer(self, database_id: str, format: Format, build: str | None) -> httpx.Response:
|
|
353
|
+
url = self.download_url(database_id, format, build=build)
|
|
332
354
|
transfer = self._owner._transfer
|
|
333
355
|
|
|
334
356
|
def call() -> httpx.Response:
|
|
@@ -179,6 +179,56 @@ def test_download_url_hands_back_the_link_without_fetching_it(
|
|
|
179
179
|
assert served.paths() == [DOWNLOAD_PATH], "the link was fetched as well as returned"
|
|
180
180
|
|
|
181
181
|
|
|
182
|
+
def test_a_build_goes_on_the_download_request_and_none_without_one(
|
|
183
|
+
make_client: ClientFactory, tmp_path: Path
|
|
184
|
+
) -> None:
|
|
185
|
+
served = origin(make_client)
|
|
186
|
+
database = served.client.database
|
|
187
|
+
|
|
188
|
+
database.download_url("bogon_ip_v1", "csvgz", build="20261105.0t53s5")
|
|
189
|
+
database.download_bytes("bogon_ip_v1", "csvgz", build="20261105.0t53s5")
|
|
190
|
+
database.download("bogon_ip_v1", "csvgz", tmp_path / "built.csv.gz", build="20261105.0t53s5")
|
|
191
|
+
database.download_url("bogon_ip_v1", "csvgz", build="")
|
|
192
|
+
database.download_bytes("bogon_ip_v1", "csvgz")
|
|
193
|
+
|
|
194
|
+
named = {"id": "bogon_ip_v1", "format": "csvgz", "build": "20261105.0t53s5"}
|
|
195
|
+
live = {"id": "bogon_ip_v1", "format": "csvgz"}
|
|
196
|
+
asked = [dict(r.url.params) for r in served.requests if r.url.path == DOWNLOAD_PATH]
|
|
197
|
+
assert asked == [named, named, named, live, live]
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def test_a_build_that_is_no_string_is_refused_with_nothing_sent(
|
|
201
|
+
make_client: ClientFactory, tmp_path: Path
|
|
202
|
+
) -> None:
|
|
203
|
+
served = origin(make_client)
|
|
204
|
+
database = served.client.database
|
|
205
|
+
|
|
206
|
+
with pytest.raises(TypeError, match="build"):
|
|
207
|
+
database.download_url("bogon_ip_v1", "csvgz", build=20261105)
|
|
208
|
+
with pytest.raises(TypeError, match="build"):
|
|
209
|
+
database.download_bytes("bogon_ip_v1", "csvgz", build=b"20261105.0t53s5")
|
|
210
|
+
with pytest.raises(TypeError, match="build"):
|
|
211
|
+
database.download("bogon_ip_v1", "csvgz", tmp_path / "x", build=["20261105.0t53s5"])
|
|
212
|
+
assert served.requests == []
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def test_a_gone_build_is_a_bad_request_asked_once(make_client: ClientFactory) -> None:
|
|
216
|
+
seen: list[httpx.Request] = []
|
|
217
|
+
|
|
218
|
+
def gone(request: httpx.Request) -> httpx.Response:
|
|
219
|
+
seen.append(request)
|
|
220
|
+
return httpx.Response(410, json={"rc": "BUILD_GONE"})
|
|
221
|
+
|
|
222
|
+
client = make_client(api_key=API_KEY, base_url=API, transport=httpx.MockTransport(gone))
|
|
223
|
+
|
|
224
|
+
with pytest.raises(InternetDataError) as caught:
|
|
225
|
+
client.database.download_url("bogon_ip_v1", "csvgz", build="20261029.aaaaaa")
|
|
226
|
+
assert caught.value.kind == "bad_request"
|
|
227
|
+
assert caught.value.retryable is False
|
|
228
|
+
assert caught.value.message == "BUILD_GONE"
|
|
229
|
+
assert len(seen) == 1
|
|
230
|
+
|
|
231
|
+
|
|
182
232
|
# The link is the whole answer for this method, and it is only useful because it carries
|
|
183
233
|
# no credential of ours: it authorizes itself, so it can be handed to anything that speaks
|
|
184
234
|
# HTTP without also handing over the key.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/account/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/api_keys/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/authorization/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/database_v_2/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/api/organization/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/account_org.py
RENAMED
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/account_org_ref.py
RENAMED
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/account_org_wrap.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/account_user.py
RENAMED
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/apikey_detail.py
RENAMED
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/apikey_list.py
RENAMED
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/client_registration.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/database_format.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/database_metadata.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/database_version.py
RENAMED
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/db_checksums.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/download_outcome.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/oauth_error.py
RENAMED
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/oauth_metadata.py
RENAMED
|
File without changes
|
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/revoke_request.py
RENAMED
|
File without changes
|
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/token_request.py
RENAMED
|
File without changes
|
{internetdata-2.9.6 → internetdata-2.10.1}/src/internetdata/_generated/models/token_response.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|