api.py
This file
Path
http3/api.py
272 lines · 6.0 KiB · Python
Last changed by
Multipart support (#90)Tom Christiebefore adoption6a44b05
History of this fileTake it
http3 (#86)Tom Christiebefore adoptionc9747aa
lines 1–10why, one step back1import typing23from .client import Client4from .config import CertTypes, TimeoutTypes, VerifyTypes5from .models import (6 AuthTypes,7 CookieTypes,8 HeaderTypes,9 QueryParamTypes,10 RequestData,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 11why, one step back11 RequestFiles,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 12–21why, one step back12 Response,13 URLTypes,14)151617def request(18 method: str,19 url: URLTypes,20 *,21 params: QueryParamTypes = None,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 22–23why, one step back22 data: RequestData = None,23 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 24–40why, one step back24 json: typing.Any = None,25 headers: HeaderTypes = None,26 cookies: CookieTypes = None,27 # files28 auth: AuthTypes = None,29 timeout: TimeoutTypes = None,30 allow_redirects: bool = True,31 # proxies32 cert: CertTypes = None,33 verify: VerifyTypes = True,34 stream: bool = False,35) -> Response:36 with Client() as client:37 return client.request(38 method=method,39 url=url,40 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 41why, one step back41 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 42–141why, one step back42 json=json,43 params=params,44 headers=headers,45 cookies=cookies,46 stream=stream,47 auth=auth,48 allow_redirects=allow_redirects,49 cert=cert,50 verify=verify,51 timeout=timeout,52 )535455def get(56 url: URLTypes,57 *,58 params: QueryParamTypes = None,59 headers: HeaderTypes = None,60 cookies: CookieTypes = None,61 stream: bool = False,62 auth: AuthTypes = None,63 allow_redirects: bool = True,64 cert: CertTypes = None,65 verify: VerifyTypes = True,66 timeout: TimeoutTypes = None,67) -> Response:68 return request(69 "GET",70 url,71 params=params,72 headers=headers,73 cookies=cookies,74 stream=stream,75 auth=auth,76 allow_redirects=allow_redirects,77 cert=cert,78 verify=verify,79 timeout=timeout,80 )818283def options(84 url: URLTypes,85 *,86 params: QueryParamTypes = None,87 headers: HeaderTypes = None,88 cookies: CookieTypes = None,89 stream: bool = False,90 auth: AuthTypes = None,91 allow_redirects: bool = True,92 cert: CertTypes = None,93 verify: VerifyTypes = True,94 timeout: TimeoutTypes = None,95) -> Response:96 return request(97 "OPTIONS",98 url,99 params=params,100 headers=headers,101 cookies=cookies,102 stream=stream,103 auth=auth,104 allow_redirects=allow_redirects,105 cert=cert,106 verify=verify,107 timeout=timeout,108 )109110111def head(112 url: URLTypes,113 *,114 params: QueryParamTypes = None,115 headers: HeaderTypes = None,116 cookies: CookieTypes = None,117 stream: bool = False,118 auth: AuthTypes = None,119 allow_redirects: bool = False, # Note: Differs to usual default.120 cert: CertTypes = None,121 verify: VerifyTypes = True,122 timeout: TimeoutTypes = None,123) -> Response:124 return request(125 "HEAD",126 url,127 params=params,128 headers=headers,129 cookies=cookies,130 stream=stream,131 auth=auth,132 allow_redirects=allow_redirects,133 cert=cert,134 verify=verify,135 timeout=timeout,136 )137138139def post(140 url: URLTypes,141 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 142–143why, one step back142 data: RequestData = None,143 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 144–158why, one step back144 json: typing.Any = None,145 params: QueryParamTypes = None,146 headers: HeaderTypes = None,147 cookies: CookieTypes = None,148 stream: bool = False,149 auth: AuthTypes = None,150 allow_redirects: bool = True,151 cert: CertTypes = None,152 verify: VerifyTypes = True,153 timeout: TimeoutTypes = None,154) -> Response:155 return request(156 "POST",157 url,158 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 159why, one step back159 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 160–175why, one step back160 json=json,161 params=params,162 headers=headers,163 cookies=cookies,164 stream=stream,165 auth=auth,166 allow_redirects=allow_redirects,167 cert=cert,168 verify=verify,169 timeout=timeout,170 )171172173def put(174 url: URLTypes,175 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 176–177why, one step back176 data: RequestData = None,177 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 178–192why, one step back178 json: typing.Any = None,179 params: QueryParamTypes = None,180 headers: HeaderTypes = None,181 cookies: CookieTypes = None,182 stream: bool = False,183 auth: AuthTypes = None,184 allow_redirects: bool = True,185 cert: CertTypes = None,186 verify: VerifyTypes = True,187 timeout: TimeoutTypes = None,188) -> Response:189 return request(190 "PUT",191 url,192 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 193why, one step back193 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 194–209why, one step back194 json=json,195 params=params,196 headers=headers,197 cookies=cookies,198 stream=stream,199 auth=auth,200 allow_redirects=allow_redirects,201 cert=cert,202 verify=verify,203 timeout=timeout,204 )205206207def patch(208 url: URLTypes,209 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 210–211why, one step back210 data: RequestData = None,211 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 212–226why, one step back212 json: typing.Any = None,213 params: QueryParamTypes = None,214 headers: HeaderTypes = None,215 cookies: CookieTypes = None,216 stream: bool = False,217 auth: AuthTypes = None,218 allow_redirects: bool = True,219 cert: CertTypes = None,220 verify: VerifyTypes = True,221 timeout: TimeoutTypes = None,222) -> Response:223 return request(224 "PATCH",225 url,226 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 227why, one step back227 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 228–243why, one step back228 json=json,229 params=params,230 headers=headers,231 cookies=cookies,232 stream=stream,233 auth=auth,234 allow_redirects=allow_redirects,235 cert=cert,236 verify=verify,237 timeout=timeout,238 )239240241def delete(242 url: URLTypes,243 *,Multipart support (#90)Tom Christiebefore adoption6a44b05
lines 244–245why, one step back244 data: RequestData = None,245 files: RequestFiles = None,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 246–260why, one step back246 json: typing.Any = None,247 params: QueryParamTypes = None,248 headers: HeaderTypes = None,249 cookies: CookieTypes = None,250 stream: bool = False,251 auth: AuthTypes = None,252 allow_redirects: bool = True,253 cert: CertTypes = None,254 verify: VerifyTypes = True,255 timeout: TimeoutTypes = None,256) -> Response:257 return request(258 "DELETE",259 url,260 data=data,Multipart support (#90)Tom Christiebefore adoption6a44b05
line 261why, one step back261 files=files,http3 (#86)Tom Christiebefore adoptionc9747aa
lines 262–272why, one step back262 json=json,263 params=params,264 headers=headers,265 cookies=cookies,266 stream=stream,267 auth=auth,268 allow_redirects=allow_redirects,269 cert=cert,270 verify=verify,271 timeout=timeout,272 )