import requests from ddtrace import tracer class Swagger: def __init__(self, base_url: str): self.base_url = base_url @tracer.wrap(service="datadog-tools", resource="Swagger.spec_exists") def spec_exists(self, service_name: str) -> bool: """Return true if a Swagger spec exists for the given service name.""" url = f"{self.base_url}/docs/{service_name}" response = requests.get(url, timeout=10) return response.status_code == 200 @tracer.wrap(service="datadog-tools", resource="Swagger.spec_url") def spec_url(self, service_name: str) -> str: """Return a link to the Swagger spec for the given service name.""" return f"{self.base_url}/service/{service_name}"