# Path: canvas_sdk/client/auth.py
# class OAuth2Bearer(AuthBase):
# 
#     """ Attached Oauth2 HTTP Bearer Authentication to the given Request object """
# 
#     def __init__(self, oauth2_token):
#         if not oauth2_token:
#             raise AttributeError("OAuth2 token must be a non-empty string value.")
#         self.oauth2_token = oauth2_token
# 
#     def __call__(self, r):
#         # Modify and return the request
#         r.headers['Authorization'] = 'Bearer ' + self.oauth2_token
#         return r
# 
# Path: canvas_sdk/exceptions.py
# class CanvasAPIError(SDKException):
# 
#     """
#     Error that gets returned from Canvas API calls via request library.  Contains the
#     http status code and the raw json response from the API request.  Note that the
#     structure of the json sent back by Canvas can vary depending on the type of error.
#     """
# 
#     def __init__(self, status_code=500, msg=None, error_json=None):
#         self.status_code = status_code
#         self.error_msg = msg
#         self.error_json = error_json
# 
#     """
#     NOTE: this method of fully defining unicode and having str call upon it is referenced
#     in official pydocs (https://docs.python.org/2/howto/pyporting.html) and other porting
#     libraries (like Django utils).  If we move to Python 3, we'd rewrite this to just have
#     a __str__ method and use futures and mixins to play nice with Python 2.
#     """
# 
#     def __str__(self):
#         if self.error_msg:
#             return '%s: %s' % (self.status_code, self.error_msg)
#         else:
#             return '%s' % self.status_code
# 
# class InvalidOAuthTokenError(SDKException):
#     """ Indicates that an invalid access token made the request """
#     pass


import logging
import requests
import time
from requests.exceptions import HTTPError
from .auth import OAuth2Bearer
from canvas_sdk.exceptions import (CanvasAPIError, InvalidOAuthTokenError)



log = logging.getLogger(__name__)

RETRY_ERROR_CODES = (
    requests.codes['conflict'],  # 409
    requests.codes['internal_server_error'],  # 500
    requests.codes['bad_gateway'],  # 502
    requests.codes['service_unavailable'],  # 503
    requests.codes['gateway_timeout']  # 504
)



# Path: canvas_sdk/client/auth.py
# class OAuth2Bearer(AuthBase):
# 
#     """ Attached Oauth2 HTTP Bearer Authentication to the given Request object """
# 
#     def __init__(self, oauth2_token):
#         if not oauth2_token:
#             raise AttributeError("OAuth2 token must be a non-empty string value.")
#         self.oauth2_token = oauth2_token
# 
#     def __call__(self, r):
#         # Modify and return the request
#         r.headers['Authorization'] = 'Bearer ' + self.oauth2_token
#         return r
# 
# Path: canvas_sdk/exceptions.py
# class CanvasAPIError(SDKException):
# 
#     """
#     Error that gets returned from Canvas API calls via request library.  Contains the
#     http status code and the raw json response from the API request.  Note that the
#     structure of the json sent back by Canvas can vary depending on the type of error.
#     """
# 
#     def __init__(self, status_code=500, msg=None, error_json=None):
#         self.status_code = status_code
#         self.error_msg = msg
#         self.error_json = error_json
# 
#     """
#     NOTE: this method of fully defining unicode and having str call upon it is referenced
#     in official pydocs (https://docs.python.org/2/howto/pyporting.html) and other porting
#     libraries (like Django utils).  If we move to Python 3, we'd rewrite this to just have
#     a __str__ method and use futures and mixins to play nice with Python 2.
#     """
# 
#     def __str__(self):
#         if self.error_msg:
#             return '%s: %s' % (self.status_code, self.error_msg)
#         else:
#             return '%s' % self.status_code
# 
# class InvalidOAuthTokenError(SDKException):
#     """ Indicates that an invalid access token made the request """
#     pass


# Path: canvas_sdk/client/base.py
import logging
import requests
import time
from requests.exceptions import HTTPError
from .auth import OAuth2Bearer
from canvas_sdk.exceptions import (CanvasAPIError, InvalidOAuthTokenError)




log = logging.getLogger(__name__)

RETRY_ERROR_CODES = (
    requests.codes['conflict'],  # 409
    requests.codes['internal_server_error'],  # 500
    requests.codes['bad_gateway'],  # 502
    requests.codes['service_unavailable'],  # 503
    requests.codes['gateway_timeout']  # 504
)



def merge_or_create_key_value_for_dictionary(target, key, value=None):