feat: expose domain dns records via api (#259)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "usesend"
|
||||
version = "0.2.3"
|
||||
version = "0.2.4"
|
||||
description = "Python SDK for the UseSend API"
|
||||
authors = ["UseSend"]
|
||||
license = "MIT"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Python client for the UseSend API."""
|
||||
|
||||
from .usesend import UseSend, UseSendHTTPError
|
||||
from .domains import Domains # type: ignore
|
||||
from . import types
|
||||
|
||||
__all__ = ["UseSend", "UseSendHTTPError", "types"]
|
||||
__all__ = ["UseSend", "UseSendHTTPError", "types", "Domains"]
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
"""Domain resource client using TypedDict shapes (no Pydantic)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Optional, Tuple, List
|
||||
|
||||
from .types import (
|
||||
APIError,
|
||||
Domain,
|
||||
DomainCreate,
|
||||
DomainCreateResponse,
|
||||
DomainVerifyResponse,
|
||||
)
|
||||
|
||||
|
||||
class Domains:
|
||||
"""Client for `/domains` endpoints."""
|
||||
|
||||
def __init__(self, usesend: "UseSend") -> None:
|
||||
self.usesend = usesend
|
||||
|
||||
def list(self) -> Tuple[Optional[List[Domain]], Optional[APIError]]:
|
||||
data, err = self.usesend.get("/domains")
|
||||
return (data, err) # type: ignore[return-value]
|
||||
|
||||
def create(self, payload: DomainCreate) -> Tuple[Optional[DomainCreateResponse], Optional[APIError]]:
|
||||
data, err = self.usesend.post("/domains", payload)
|
||||
return (data, err) # type: ignore[return-value]
|
||||
|
||||
def verify(self, domain_id: int) -> Tuple[Optional[DomainVerifyResponse], Optional[APIError]]:
|
||||
data, err = self.usesend.put(f"/domains/{domain_id}/verify", {})
|
||||
return (data, err) # type: ignore[return-value]
|
||||
|
||||
def get(self, domain_id: int) -> Tuple[Optional[Domain], Optional[APIError]]:
|
||||
data, err = self.usesend.get(f"/domains/{domain_id}")
|
||||
return (data, err) # type: ignore[return-value]
|
||||
|
||||
from .usesend import UseSend # noqa: E402 pylint: disable=wrong-import-position
|
||||
@@ -22,6 +22,21 @@ DomainStatus = Literal[
|
||||
'TEMPORARY_FAILURE',
|
||||
]
|
||||
|
||||
DNSRecordType = Literal['MX', 'TXT']
|
||||
|
||||
|
||||
class DNSRecord(TypedDict, total=False):
|
||||
type: DNSRecordType
|
||||
name: str
|
||||
value: str
|
||||
ttl: str
|
||||
priority: Optional[str]
|
||||
status: DomainStatus
|
||||
recommended: Optional[bool]
|
||||
|
||||
|
||||
DNSRecords = List[DNSRecord]
|
||||
|
||||
|
||||
class Domain(TypedDict, total=False):
|
||||
id: float
|
||||
@@ -40,6 +55,9 @@ class Domain(TypedDict, total=False):
|
||||
isVerifying: bool
|
||||
errorMessage: Optional[str]
|
||||
subdomain: Optional[str]
|
||||
verificationError: Optional[str]
|
||||
lastCheckedTime: Optional[str]
|
||||
dnsRecords: DNSRecords
|
||||
|
||||
|
||||
DomainList = List[Domain]
|
||||
@@ -67,6 +85,9 @@ class DomainCreateResponse(TypedDict, total=False):
|
||||
isVerifying: bool
|
||||
errorMessage: Optional[str]
|
||||
subdomain: Optional[str]
|
||||
verificationError: Optional[str]
|
||||
lastCheckedTime: Optional[str]
|
||||
dnsRecords: DNSRecords
|
||||
|
||||
|
||||
class DomainVerifyResponse(TypedDict):
|
||||
|
||||
@@ -71,6 +71,7 @@ class UseSend:
|
||||
# Lazily initialise resource clients.
|
||||
self.emails = Emails(self)
|
||||
self.contacts = Contacts(self)
|
||||
self.domains = Domains(self)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Internal request helper
|
||||
@@ -123,3 +124,4 @@ class UseSend:
|
||||
# Import here to avoid circular dependency during type checking
|
||||
from .emails import Emails # noqa: E402 pylint: disable=wrong-import-position
|
||||
from .contacts import Contacts # noqa: E402 pylint: disable=wrong-import-position
|
||||
from .domains import Domains # type: ignore # noqa: E402
|
||||
|
||||
Reference in New Issue
Block a user