disco.api.http

Constants

HTTPMethod = Enum(
  GET = GET,
  POST = POST,
  PUT = PUT,
  PATCH = PATCH,
  DELETE = DELETE)

Classes

Routes

Simple Python object-enum of all method/url route combinations available to this client.

APIResponse

Functions

init(self)

APIException

Inherits From Exception

Exception thrown when an HTTP-client level error occurs. Usually this will be a non-success status-code, or a transient network issue.

Attributes
Name Type Description
status_code int The status code returned by the API for the request that triggered this error.

Functions

init(self, response, retries)

HTTPClient

Inherits From LoggingClass

A simple HTTP client which wraps the requests library, adding support for Discords rate-limit headers, authorization, and request/response validation.

Functions

init(self, token, after_request)

call(self, route, args,**kwargs)

call(self, route, args,**kwargs)

Makes a request to the given route (as specified in :class:disco.api.http.Routes) with a set of URL arguments, and keyword arguments passed to requests.

Returns
The response object for the request
Raises
Raised when an unrecoverable error occurs, or when we've exhausted
the number of retries.
Parameters
Name Type Description
route tuple(:class:`HTTPMethod`, str) The method.URL combination that when compiled with URL arguments creates a requestable route which the HTTPClient will make the request too.
args dict(str, str) A dictionary of URL arguments that will be compiled with the raw URL to create the requestable route. The HTTPClient uses this to track rate limits as well.
kwargs dict Keyword arguments that will be passed along to the requests library

random_backoff(</code>)

Returns a random backoff (in milliseconds) to be used for any error the client suspects is transient. Will always return a value between 500 and 5000 milliseconds.

:returns: a random backoff in milliseconds :rtype: float

Functions

to_bytes(obj)

results matching ""

    No results matching ""