class HttpBin(object): base_uri = "https://httpbin.org" middleware = [ async_request_id(key="x-flabber-id"), async_timeout(1.0), async_accept("application/json"), async_ua("the-fabricator/1.0.0"), async_request_logger(AsyncDummyLogger()), ] response_as = async_json_response async def get(self): return await self.request.get("get") async def post(self, data): return await self.request.post("post", data=data) async def put(self, data): return await self.request.put("put", data=data) async def delete(self): return await self.request.delete("delete") async def get_4xx(self): return await self.request.get("status/404") async def post_4xx(self, data): return await self.request.post("status/404", data=data) async def put_4xx(self, data): return await self.request.put("status/404", data=data) async def delete_4xx(self): return await self.request.delete("status/404") async def get_5xx(self): return await self.request.get("status/501") async def post_5xx(self, data): return await self.request.post("status/501", data=data) async def put_5xx(self, data): return await self.request.put("status/501", data=data) async def delete_5xx(self): return await self.request.delete("status/501") async def get_3xx(self): return await self.request.get("status/301") async def post_3xx(self, data): return await self.request.post("status/301", data=data) async def put_3xx(self, data): return await self.request.put("status/301", data=data) async def delete_3xx(self): return await self.request.delete("status/301")
class AsyncGithub(object): base_uri = "https://api.github.com/" middleware = [async_request_logger(AsyncDummyLogger())] response_as = async_json_response async def stargazers(self, owner, repo): return await self.request.get("repos/:owner/:repo/stargazers", params=Query(owner, repo)) async def download(self, release): pass
class AsyncHttpBin(object): base_uri = "https://httpbin.org" middleware = [ async_timeout(0.1), async_accept("application/json"), async_ua("the-fabricator/1.0.0"), async_request_logger(AsyncDummyLogger()), ] response_as = async_json_response async def publish(self, data): return await self.request.post("post", data=data)
class Openapi(object): base_uri = "http://api-hub-production-qa.omcomcom.com" middleware = [ async_request_id(key="x-flabber-id"), async_timeout(1.0), async_accept("application/json"), async_ua("the-fabricator/1.0.0"), async_request_logger(AsyncDummyLogger()), async_request_duration(), ] response_as = async_json_response async def go(self, path="openapi.json"): return await self.request.get(path)
class AsyncBreaker(object): logger = AsyncDummyLogger() base_uri = "https://example.com" middleware = [ async_timeout(1), async_circuit_breaker( logger=logger, fail_max=1, name="breaker-1", reset_timeout=10 ), async_trigger_breaker_if(lambda res: False if randint(0, 5) < 2 else True), async_request_logger(logger), ] response_as = async_text_response async def go(self): return await self.request.get("/")