(service_url: str, payload: Dict, api_key: str)
| 126 | |
| 127 | def update_challenge(service_url: str, payload: Dict, api_key: str) -> bool: |
| 128 | url = f"{service_url.rstrip('/')}/api/v1/challenges" |
| 129 | headers = {"Authorization": f"Bearer {api_key}"} if api_key else {} |
| 130 | |
| 131 | try: |
| 132 | with requests.Session() as session: |
| 133 | r = session.post(url, json=payload, headers=headers, timeout=30, allow_redirects=True) |
| 134 | r.raise_for_status() |
| 135 | logger.info("Updated challenge %s: %s", payload["id"], payload["title"]) |
| 136 | return True |
| 137 | except Exception as e: |
| 138 | logger.error("Failed challenge %s: %s", payload["id"], e) |
| 139 | return False |
| 140 | |
| 141 | |
| 142 | def main(): |
| 143 | parser = argparse.ArgumentParser() |
nothing calls this directly
no outgoing calls
no test coverage detected