httpnet 0.9.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.
httpnet/email.py ADDED
@@ -0,0 +1,179 @@
1
+ from collections.abc import Iterable
2
+ from datetime import datetime
3
+ from enum import Enum
4
+
5
+ from httpnet._core import CrudService, Element, Service, UpdatableService
6
+
7
+
8
+ class SpamFilter(Element):
9
+ banned_files_checks: bool | None
10
+ delete_spam: bool | None
11
+ header_checks: bool | None
12
+ malware_checks: bool | None
13
+ modify_subject_on_spam: bool | None
14
+ spam_checks: bool | None
15
+ spam_level: str | None
16
+ use_greylisting: bool | None
17
+
18
+
19
+ class MailboxType(Enum):
20
+ IMAP = 'ImapMailbox'
21
+ EXCHANGE = 'ExchangeMailbox'
22
+ FORWARDER = 'Forwarder'
23
+
24
+ def __repr__(self):
25
+ return f'{self.__class__.__qualname__}.{self.name}'
26
+
27
+ def __str__(self):
28
+ return self.value
29
+
30
+
31
+ class ForwarderType(Enum):
32
+ INTERNAL = 'internalForwarder'
33
+ EXTERNAL = 'externalForwarder'
34
+
35
+ def __repr__(self):
36
+ return f'{self.__class__.__qualname__}.{self.name}'
37
+
38
+ def __str__(self):
39
+ return self.value
40
+
41
+
42
+ class Mailbox(Element):
43
+ id: str | None
44
+ account_id: str | None
45
+ email_address: str
46
+ email_address_unicode: str | None
47
+ domain_name: str | None
48
+ domain_name_unicode: str | None
49
+ status: str | None
50
+ spam_filter: SpamFilter | None
51
+ type: MailboxType | None
52
+ product_code: str | None
53
+ forwarder_targets: Iterable[str] | None # only IMAP and Forwarder
54
+ smtp_forwarder_target: str | None # only IMAP
55
+ is_admin: bool | None # only IMAP
56
+ first_name: str | None # only Exchange
57
+ last_name: str | None # only Exchange
58
+ exchange_guid: str | None # only Exchange
59
+ organization_id: str | None # only Exchange
60
+ forwarder_type: ForwarderType | None # only Forwarder
61
+ password: str | None
62
+ storage_quota: int
63
+ storage_quota_used: int | None
64
+ paid_until: datetime | None
65
+ renew_on: datetime | None
66
+ deletion_scheduled_for: datetime | None
67
+ restorable_until: datetime | None
68
+ add_date: datetime | None
69
+ last_change_date: datetime | None
70
+
71
+ def __init__(self, **kwargs):
72
+ super().__init__(**kwargs)
73
+ if self.type == MailboxType.IMAP:
74
+ if self.forwarder_targets is None:
75
+ raise ValueError('List of forwarder targets is required for IMAP mailboxes.')
76
+ elif self.type == MailboxType.EXCHANGE:
77
+ if self.first_name is None:
78
+ raise ValueError('First name is required for Exchange mailboxes.')
79
+ if self.last_name is None:
80
+ raise ValueError('Last name is required for Exchange mailboxes.')
81
+ elif self.type == MailboxType.FORWARDER:
82
+ if self.forwarder_targets is None:
83
+ raise ValueError('List of forwarder targets is required for Forwarder mailboxes.')
84
+
85
+
86
+ class MailboxService(Service[Mailbox]):
87
+ _find_method_name = 'mailboxesFind'
88
+
89
+ def delete(self, mailbox_id: str | None = None, email_address: str | None = None,
90
+ exec_date: datetime | None = None) -> None:
91
+ parameters = {}
92
+ if mailbox_id:
93
+ parameters['mailboxId'] = mailbox_id
94
+ elif email_address:
95
+ parameters['emailAddress'] = email_address
96
+ else:
97
+ raise ValueError('Either mailbox id or email address are required.')
98
+ if exec_date is not None:
99
+ parameters['execDate'] = exec_date.isoformat()
100
+ self._call(
101
+ method='mailboxDelete',
102
+ parameters=parameters
103
+ )
104
+
105
+ def cancel_deletion(self, mailbox_id: str | None = None, email_address: str | None = None) -> Mailbox:
106
+ parameters = {}
107
+ if mailbox_id:
108
+ parameters['mailboxId'] = mailbox_id
109
+ elif email_address:
110
+ parameters['emailAddress'] = email_address
111
+ else:
112
+ raise ValueError('Either mailbox id or email address are required.')
113
+ response = self._call(
114
+ method='mailboxDeletionCancel',
115
+ parameters=parameters
116
+ )
117
+ return Mailbox.from_json(response.get('response', {}))
118
+
119
+ def restore(self, mailbox_id: str | None = None, email_address: str | None = None) -> Mailbox:
120
+ parameters = {}
121
+ if mailbox_id:
122
+ parameters['mailboxId'] = mailbox_id
123
+ elif email_address:
124
+ parameters['emailAddress'] = email_address
125
+ else:
126
+ raise ValueError('Either mailbox id or email address are required.')
127
+ response = self._call(
128
+ method='mailboxRestore',
129
+ parameters=parameters
130
+ )
131
+ return Mailbox.from_json(response.get('response', {}))
132
+
133
+ def purge_restorable(self, mailbox_id: str | None = None, email_address: str | None = None) -> None:
134
+ parameters = {}
135
+ if mailbox_id:
136
+ parameters['mailboxId'] = mailbox_id
137
+ elif email_address:
138
+ parameters['emailAddress'] = email_address
139
+ else:
140
+ raise ValueError('Either mailbox id or email address are required.')
141
+ self._call(
142
+ method='mailboxPurgeRestorable',
143
+ parameters=parameters
144
+ )
145
+
146
+
147
+ class Organization(Element):
148
+ id: str | None
149
+ account_id: str | None
150
+ comment: str | None
151
+ name: str
152
+ status: str | None
153
+ member_domains: Iterable[str] | None
154
+ add_date: datetime | None
155
+ last_change_date: datetime | None
156
+
157
+
158
+ class OrganizationService(CrudService[Organization]):
159
+ pass
160
+
161
+
162
+ class DomainSettings(Element):
163
+ domain_name: str
164
+ domain_name_unicode: str | None
165
+ storage_quota: int | None
166
+ storage_quota_allocated: int | None
167
+ mailbox_quota: int | None
168
+ exchange_mailbox_quota: int | None
169
+ exchange_storage_quota_allocated: int | None
170
+ exchange_storage_quota: int | None
171
+ add_date: datetime | None
172
+ last_change_date: datetime | None
173
+
174
+
175
+ class DomainSettingsService(UpdatableService[DomainSettings]):
176
+ """Domain settings exist for every domain, they can only be listed and updated."""
177
+
178
+ # Domain settings carry no ID of their own, they are keyed by domain name.
179
+ _find_filter_name = 'DomainName'
@@ -0,0 +1,151 @@
1
+ Metadata-Version: 2.5
2
+ Name: httpnet
3
+ Version: 0.9.0
4
+ Summary: http.net Partner API client
5
+ Project-URL: Homepage, https://github.com/eseifert/httpnet
6
+ Project-URL: Repository, https://github.com/eseifert/httpnet
7
+ Author-email: Erich Seifert <dev@erichseifert.de>
8
+ License-Expression: MIT
9
+ License-File: LICENSE.txt
10
+ Keywords: administration,dns,domain
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Programming Language :: Python :: 3.15
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Topic :: System :: Systems Administration
22
+ Requires-Python: >=3.11
23
+ Requires-Dist: python-dateutil>=2.8.0
24
+ Requires-Dist: requests>=2.22.0
25
+ Description-Content-Type: text/x-rst
26
+
27
+ Description
28
+ ===========
29
+
30
+ This package provides an unofficial Python client for the
31
+ `Partner API <https://www.http.net/docs/api/>`__ of http.net Internet GmbH.
32
+ So far, ``v1`` of the API (the only existing version) is supported. The same
33
+ API is also used by `hosting.de <https://www.hosting.de/api/>`__.
34
+
35
+ The full documentation, consisting of tutorials, how-to guides, a reference and
36
+ background explanations, is built from the ``docs`` directory and can be
37
+ published on Read the Docs.
38
+
39
+
40
+ Disclaimer
41
+ ==========
42
+
43
+ This package is not related to http.net Internet GmbH.
44
+
45
+ The reading part of the API has been exercised against a live account: every
46
+ listing, every ``get`` and the availability check answer and convert correctly.
47
+ The writing part is covered by unit tests only and has not been tried against a
48
+ real account. Where the live API turned out to differ from its documentation,
49
+ the deviations are collected under `Where the API differs from its
50
+ documentation
51
+ <https://httpnet.readthedocs.io/en/latest/explanation/differences-to-the-documentation.html>`__.
52
+
53
+
54
+ Installation
55
+ ============
56
+
57
+ ``httpnet`` requires Python 3.11 or newer. Use the package manager
58
+ `pip <https://pip.pypa.io/en/stable/>`__ to install it:
59
+
60
+ .. code::
61
+
62
+ pip install git+https://github.com/eseifert/httpnet.git
63
+
64
+ or add it to a project managed by `uv <https://docs.astral.sh/uv/>`__:
65
+
66
+ .. code::
67
+
68
+ uv add git+https://github.com/eseifert/httpnet.git
69
+
70
+
71
+ Usage
72
+ =====
73
+
74
+ First, we need a client instance:
75
+
76
+ .. code::
77
+
78
+ >>> from httpnet.client import HttpNetClient
79
+ >>> AUTH_TOKEN = '<your auth token>'
80
+ >>> api = HttpNetClient(auth_token=AUTH_TOKEN)
81
+
82
+ http.net Internet GmbH operates the same API for
83
+ `hosting.de <https://www.hosting.de/api/>`__. To use it, pass the respective
84
+ platform:
85
+
86
+ .. code::
87
+
88
+ >>> from httpnet.client import HttpNetClient, Platform
89
+ >>> api = HttpNetClient(auth_token=AUTH_TOKEN, base_url=Platform.HOSTING_DE)
90
+
91
+ The client provides access to all service categories in the API. They can be
92
+ counted and are iterable:
93
+
94
+ .. code::
95
+
96
+ >>> len(api.domains)
97
+ 123
98
+ >>> for domain in api.dns_zones:
99
+ ... print(domain.zone_config.name)
100
+
101
+ Almost all services provide a common query interface. ``find`` returns an
102
+ iterator, ``count`` returns the number of matches without retrieving them:
103
+
104
+ .. code::
105
+
106
+ >>> from httpnet.domain import ContactType
107
+ >>> persons = api.domain_contacts.find(ContactType=str(ContactType.PERSON))
108
+ >>> next(persons).handle
109
+ 'JS15'
110
+ >>> api.domain_contacts.count(ContactType=str(ContactType.PERSON))
111
+ 42
112
+
113
+
114
+ Contributing
115
+ ============
116
+
117
+ Pull requests are always welcome. For major changes, please open an issue first
118
+ to discuss what you would like to change.
119
+
120
+ Please make sure to update tests as appropriate.
121
+
122
+ The project is developed with `uv <https://docs.astral.sh/uv/>`__. The development
123
+ and documentation dependencies require Python 3.11.5 or newer. To set up a
124
+ development environment and run the checks:
125
+
126
+ .. code::
127
+
128
+ uv sync # create the virtual environment
129
+ uv run pytest # run the test suite
130
+ uv run ruff check # lint
131
+ uv run ruff format # format
132
+ uv run ty check # type check
133
+
134
+ To build the documentation:
135
+
136
+ .. code::
137
+
138
+ uv run sphinx-build --builder html --fail-on-warning docs docs/_build/html
139
+
140
+
141
+ See the `release guide <https://github.com/eseifert/httpnet/blob/master/RELEASING.rst>`__
142
+ for PyPI publishing instructions.
143
+
144
+
145
+ License
146
+ =======
147
+
148
+ `MIT <https://choosealicense.com/licenses/mit/>`__
149
+
150
+ By submitting a pull request for this project, you agree to license your
151
+ contribution under the MIT license to this project.
@@ -0,0 +1,10 @@
1
+ httpnet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ httpnet/_core.py,sha256=tThWtPPM_dVMXqap2LBQNIod7cbzMRRqdoBtbq_TB9k,19200
3
+ httpnet/client.py,sha256=xG0K_cX6Uo2r_AZEY2N9Kj3YDBZIg6k01cKg3IHwMsg,1587
4
+ httpnet/dns.py,sha256=XhYnLScoRhdQmAuvajJU4HvkupEbqFltjm9uE1ItDSQ,10292
5
+ httpnet/domain.py,sha256=eNIzU9kWTo8uVZMBV6klGBC5moQE3UnACEEYx-dtjOo,10528
6
+ httpnet/email.py,sha256=v4skUVWVZT4vdTuahqHexJaBdHbb9TY3z6VfJ54NJas,5947
7
+ httpnet-0.9.0.dist-info/METADATA,sha256=vLNBmCMN9cyKmZHbwMJ43W0-xg-vTwZRfM9q8upxrkA,4650
8
+ httpnet-0.9.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
9
+ httpnet-0.9.0.dist-info/licenses/LICENSE.txt,sha256=0PHoVPN4pX4Cmb3hiQ32yxcCniok6y7v2pB8RFShUgo,1057
10
+ httpnet-0.9.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2019 Erich Seifert
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.