Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pypi/warehouse
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3e07a63fada59fab43ce4f1ff574fccc558002dc
Choose a base ref
..
head repository: pypi/warehouse
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: dc30b12f6a33b24b85eb824b52a1f60f3de51182
Choose a head ref
Showing with 8 additions and 8 deletions.
  1. +8 −8 warehouse/accounts/services.py
16 changes: 8 additions & 8 deletions warehouse/accounts/services.py
Original file line number Diff line number Diff line change
@@ -983,28 +983,28 @@ def get_domain_status(self, _domain: str) -> list[str]:

@implementer(IDomainStatusService)
class DomainrDomainStatusService:
def __init__(self, session, api_key):
def __init__(self, session, client_id):
self._http = session
self.api_key = api_key
self.client_id = client_id

@classmethod
def create_service(cls, _context, request: Request) -> DomainrDomainStatusService:
domainr_api_key = request.registry.settings.get("domainr.api_key")
return cls(session=request.http, api_key=domainr_api_key)
domainr_client_id = request.registry.settings.get("domainr.client_id")
return cls(session=request.http, client_id=domainr_client_id)

def get_domain_status(self, domain: str) -> list[str]:
"""
Check if a domain is available or not.
See https://domainr.com/docs/api/v2/status
"""
# bail early if no api key is set, so we don't send failing requests
if not self.api_key:
return []
# bail early if no client ID is set, so we don't send failing requests
if not self.client_id:
raise RuntimeError("Domainr client ID not set")

try:
resp = self._http.get(
"https://api.domainr.com/v2/status",
params={"client_id": self.api_key, "domain": domain},
params={"client_id": self.client_id, "domain": domain},
timeout=5,
)
resp.raise_for_status()