class documentation

Responsible for implementing the wire protocol for making requests to the Dropbox API.

Method __enter__ Undocumented
Method __exit__ Undocumented
Method __init__ :param str oauth2_access_token: OAuth2 access token for making client requests. :param int max_retries_on_error: On 5xx errors, the number of times to retry. :param Optional[int] max_retries_on_rate_limit: On 429 errors, the number of times to retry...
Method check_and_refresh_access_token Checks if access token needs to be refreshed and refreshes if possible :return:
Method clone Creates a new copy of the Dropbox client with the same defaults unless modified by arguments to clone()
Method close Cleans up all resources like the request session/network connection.
Method raise_dropbox_error_for_resp Checks for errors from a res and handles appropiately.
Method refresh_access_token Refreshes an access token via refresh token if available
Method request Makes a request to the Dropbox API and in the process validates that the route argument and result are the expected data types. The request_arg is converted to JSON based on the arg_data_type. Likewise, the response is deserialized from JSON and converted to an object based on the {result,error}_data_type.
Method request_json_object Makes a request to the Dropbox API, taking a JSON-serializable Python object as an argument, and returning one as a response.
Method request_json_string See :meth:`request_json_string_with_retry` for description of parameters.
Method request_json_string_with_retry See :meth:`request_json_object` for description of parameters.
Method with_path_root Creates a clone of the Dropbox instance with the Dropbox-API-Path-Root header as the appropriate serialized instance of PathRoot.
Method _get_route_url Returns the URL of the route.
Method _save_body_to_file Saves the body of an HTTP response to a file.
Constant _API_VERSION Undocumented
Constant _ROUTE_STYLE_DOWNLOAD Undocumented
Constant _ROUTE_STYLE_RPC Undocumented
Constant _ROUTE_STYLE_UPLOAD Undocumented
Instance Variable _app_key Undocumented
Instance Variable _app_secret Undocumented
Instance Variable _headers Undocumented
Instance Variable _host_map Undocumented
Instance Variable _logger Undocumented
Instance Variable _max_retries_on_error Undocumented
Instance Variable _max_retries_on_rate_limit Undocumented
Instance Variable _oauth2_access_token Undocumented
Instance Variable _oauth2_access_token_expiration Undocumented
Instance Variable _oauth2_refresh_token Undocumented
Instance Variable _raw_user_agent Undocumented
Instance Variable _scope Undocumented
Instance Variable _session Undocumented
Instance Variable _timeout Undocumented
Instance Variable _user_agent Undocumented
def __enter__(self): (source)

Undocumented

def __exit__(self, *args): (source)

Undocumented

def __init__(self, oauth2_access_token=None, max_retries_on_error=4, max_retries_on_rate_limit=None, user_agent=None, session=None, headers=None, timeout=DEFAULT_TIMEOUT, oauth2_refresh_token=None, oauth2_access_token_expiration=None, app_key=None, app_secret=None, scope=None, ca_certs=None): (source)

:param str oauth2_access_token: OAuth2 access token for making client requests. :param int max_retries_on_error: On 5xx errors, the number of times to retry. :param Optional[int] max_retries_on_rate_limit: On 429 errors, the number of times to retry. If `None`, always retries. :param str user_agent: The user agent to use when making requests. This helps us identify requests coming from your application. We recommend you use the format "AppName/Version". If set, we append "/OfficialDropboxPythonSDKv2/__version__" to the user_agent, :param session: If not provided, a new session (connection pool) is created. To share a session across multiple clients, use :func:`create_session`. :type session: :class:`requests.sessions.Session` :param dict headers: Additional headers to add to requests. :param Optional[float] timeout: Maximum duration in seconds that client will wait for any single packet from the server. After the timeout the client will give up on connection. If `None`, client will wait forever. Defaults to 100 seconds. :param str oauth2_refresh_token: OAuth2 refresh token for refreshing access token :param datetime oauth2_access_token_expiration: Expiration for oauth2_access_token :param str app_key: application key of requesting application; used for token refresh :param str app_secret: application secret of requesting application; used for token refresh Not required if PKCE was used to authorize the token :param list scope: list of scopes to request on refresh. If left blank, refresh will request all available scopes for application :param str ca_certs: path to CA certificate. If left blank, default certificate location will be used

def check_and_refresh_access_token(self): (source)

Checks if access token needs to be refreshed and refreshes if possible :return:

def clone(self, oauth2_access_token=None, max_retries_on_error=None, max_retries_on_rate_limit=None, user_agent=None, session=None, headers=None, timeout=None, oauth2_refresh_token=None, oauth2_access_token_expiration=None, app_key=None, app_secret=None, scope=None): (source)

Creates a new copy of the Dropbox client with the same defaults unless modified by arguments to clone() See constructor for original parameter descriptions. :return: New instance of Dropbox client :rtype: Dropbox

def close(self): (source)

Cleans up all resources like the request session/network connection.

def raise_dropbox_error_for_resp(self, res): (source)

Checks for errors from a res and handles appropiately. :param res: Response of an api request.

def refresh_access_token(self, host=API_HOST, scope=None): (source)

Refreshes an access token via refresh token if available :param host: host to hit token endpoint with :param scope: list of permission scopes for access token :return:

def request(self, route, namespace, request_arg, request_binary, timeout=None): (source)

Makes a request to the Dropbox API and in the process validates that the route argument and result are the expected data types. The request_arg is converted to JSON based on the arg_data_type. Likewise, the response is deserialized from JSON and converted to an object based on the {result,error}_data_type. :param host: The Dropbox API host to connect to. :param route: The route to make the request to. :type route: :class:`stone.backends.python_rsrc.stone_base.Route` :param request_arg: Argument for the route that conforms to the validator specified by route.arg_type. :param request_binary: String or file pointer representing the binary payload. Use None if there is no binary payload. :param Optional[float] timeout: Maximum duration in seconds that client will wait for any single packet from the server. After the timeout the client will give up on connection. If `None`, will use default timeout set on Dropbox object. Defaults to `None`. :return: The route's result.

def request_json_object(self, host, route_name, route_style, request_arg, auth_type, request_binary, timeout=None): (source)

Makes a request to the Dropbox API, taking a JSON-serializable Python object as an argument, and returning one as a response. :param host: The Dropbox API host to connect to. :param route_name: The name of the route to invoke. :param route_style: The style of the route. :param str request_arg: A JSON-serializable Python object representing the argument for the route. :param auth_type str :param Optional[bytes] request_binary: Bytes representing the binary payload. Use None if there is no binary payload. :param Optional[float] timeout: Maximum duration in seconds that client will wait for any single packet from the server. After the timeout the client will give up on connection. If `None`, will use default timeout set on Dropbox object. Defaults to `None`. :return: The route's result as a JSON-serializable Python object.

def request_json_string(self, host, func_name, route_style, request_json_arg, auth_type, request_binary, timeout=None): (source)

See :meth:`request_json_string_with_retry` for description of parameters.

def request_json_string_with_retry(self, host, route_name, route_style, request_json_arg, auth_type, request_binary, timeout=None): (source)

See :meth:`request_json_object` for description of parameters. :param request_json_arg: A string representing the serialized JSON argument to the route.

def with_path_root(self, path_root): (source)

Creates a clone of the Dropbox instance with the Dropbox-API-Path-Root header as the appropriate serialized instance of PathRoot. For more information, see https://www.dropbox.com/developers/reference/namespace-guide#pathrootmodes :param PathRoot path_root: instance of PathRoot to serialize into the headers field :return: A :class: `Dropbox` :rtype: Dropbox

def _get_route_url(self, hostname, route_name): (source)

Returns the URL of the route. :param str hostname: Hostname to make the request to. :param str route_name: Name of the route. :rtype: str

def _save_body_to_file(self, download_path, http_resp, chunksize=2**16): (source)

Saves the body of an HTTP response to a file. :param str download_path: Local path to save data to. :param http_resp: The HTTP response whose body will be saved. :type http_resp: :class:`requests.models.Response` :rtype: None

_API_VERSION: str = (source)

Undocumented

Value
'2'
_ROUTE_STYLE_DOWNLOAD: str = (source)

Undocumented

Value
'download'
_ROUTE_STYLE_RPC: str = (source)

Undocumented

Value
'rpc'
_ROUTE_STYLE_UPLOAD: str = (source)

Undocumented

Value
'upload'
_app_key = (source)

Undocumented

_app_secret = (source)

Undocumented

_headers = (source)

Undocumented

_host_map = (source)

Undocumented

Undocumented

_max_retries_on_error = (source)

Undocumented

_max_retries_on_rate_limit = (source)

Undocumented

_oauth2_access_token = (source)

Undocumented

_oauth2_access_token_expiration = (source)

Undocumented

_oauth2_refresh_token = (source)

Undocumented

_raw_user_agent = (source)

Undocumented

Undocumented

_session = (source)

Undocumented

_timeout = (source)

Undocumented

_user_agent = (source)

Undocumented