# Path: smc/api/exceptions.py
# class ActionCommandFailed(SMCException):
#     """
#     Action type commands use this exception
#     """
# 
# class ResourceNotFound(SMCException):
#     """
#     Used to indicate a resource link is not found on the
#     queried node. For example, the :py:class:`smc.core.engine.Engine` class
#     will expose available resources but some engines may not have those
#     links.
#     """
# 
# Path: smc/api/common.py
# class SMCRequest(object):
#     """
#     SMCRequest represents the data structure that will be submitted to the web
#     layer for submission to the SMC API.
# 
#     :param str href: href for request, required by all methods
#     :param dict json: json to submit, required by create, update
#     :param dict params: query string parameters
#     :param str filename: name of file for download, optional for create
#     :param str etag: etag of element, required for update
#     """
#     _session_manager = None
#     
#     def __init__(self, href=None, json=None, params=None, filename=None,
#                  etag=None, user_session=None, **kwargs):
#         
#         #: Filename if a file download is requested
#         self.filename = filename
#         #: dictionary of query parameters
#         self.params = params
#         #: href for this request
#         self.href = href
#         #: ETag for PUT or DELETE request modifications
#         self.etag = etag
#         #: JSON data to send in request
#         self.json = {} if json is None else json
#         
#         # Only used in the case of streaming file download/upload
#         self.files = None
#         #: Default headers
#         self.headers = {'Content-Type': 'application/json'}
#         
#         # Optional user session for this request
#         #self.user_session = user_session # smc.api.session.Session
#         
#         for k, v in kwargs.items():
#             setattr(self, k, v)
#     
#     def __call__(self, session):
#         pass
#     
#     def create(self):
#         return self._make_request(method='POST')
# 
#     def delete(self):
#         return self._make_request(method='DELETE')
# 
#     def update(self):
#         return self._make_request(method='PUT')
# 
#     def read(self):
#         return self._make_request(method='GET')
#     
#     def _make_request(self, method):
#         err = None
#         result = None
#         try:
#             # Obtain the session
#             session = _get_session(getattr(self, '_session_manager', None))
#             
#             if method == 'GET':
#                 if not self.href:
#                     self.href = session.entry_points.get('elements')
#             
#             result = send_request(session, method, self)
#             
#         except SMCOperationFailure as e:
#             result = e.smcresult
#             try:
#                 err = self.exception(result.msg)  # Exception set
#             except AttributeError:
#                 pass
#         except (SessionManagerNotFound, SMCConnectionError,
#                 IOError, TypeError) as e:
#             err = e
#         finally:
#             if err:
#                 raise err
#             return result
# 
#     def __str__(self):
#         sb = []
#         for key in self.__dict__:
#             sb.append(
#                 "{key}='{value}'".format(
#                     key=key,
#                     value=self.__dict__[key]))
#         return 'SMCRequest({})'.format(','.join(sb))    


from smc.api.exceptions import ActionCommandFailed, ResourceNotFound
from smc.api.common import SMCRequest
    import sys


class RequestAction(object):
    """
    A Generic request action provides a simple interface to
    building and executing an SMCRequest. This will raise
    the exception specified if the resource is not found.
    
    Valid parameters that can be provided in kwargs are:
    
    :param str method: method for which to call. Can be
        'read', 'create', 'update' or 'delete' (default: 'read')
    :param str resource: The element resource to act on. If the
        href is already known, this can be provided as href
    :param bool raw_result: Return the raw SMCResult
    """
    def make_request(self, *exception, **kwargs):
        raw_result = kwargs.pop('raw_result', False)
        method = kwargs.pop('method', 'read')

# Path: smc/api/exceptions.py
# class ActionCommandFailed(SMCException):
#     """
#     Action type commands use this exception
#     """
# 
# class ResourceNotFound(SMCException):
#     """
#     Used to indicate a resource link is not found on the
#     queried node. For example, the :py:class:`smc.core.engine.Engine` class
#     will expose available resources but some engines may not have those
#     links.
#     """
# 
# Path: smc/api/common.py
# class SMCRequest(object):
#     """
#     SMCRequest represents the data structure that will be submitted to the web
#     layer for submission to the SMC API.
# 
#     :param str href: href for request, required by all methods
#     :param dict json: json to submit, required by create, update
#     :param dict params: query string parameters
#     :param str filename: name of file for download, optional for create
#     :param str etag: etag of element, required for update
#     """
#     _session_manager = None
#     
#     def __init__(self, href=None, json=None, params=None, filename=None,
#                  etag=None, user_session=None, **kwargs):
#         
#         #: Filename if a file download is requested
#         self.filename = filename
#         #: dictionary of query parameters
#         self.params = params
#         #: href for this request
#         self.href = href
#         #: ETag for PUT or DELETE request modifications
#         self.etag = etag
#         #: JSON data to send in request
#         self.json = {} if json is None else json
#         
#         # Only used in the case of streaming file download/upload
#         self.files = None
#         #: Default headers
#         self.headers = {'Content-Type': 'application/json'}
#         
#         # Optional user session for this request
#         #self.user_session = user_session # smc.api.session.Session
#         
#         for k, v in kwargs.items():
#             setattr(self, k, v)
#     
#     def __call__(self, session):
#         pass
#     
#     def create(self):
#         return self._make_request(method='POST')
# 
#     def delete(self):
#         return self._make_request(method='DELETE')
# 
#     def update(self):
#         return self._make_request(method='PUT')
# 
#     def read(self):
#         return self._make_request(method='GET')
#     
#     def _make_request(self, method):
#         err = None
#         result = None
#         try:
#             # Obtain the session
#             session = _get_session(getattr(self, '_session_manager', None))
#             
#             if method == 'GET':
#                 if not self.href:
#                     self.href = session.entry_points.get('elements')
#             
#             result = send_request(session, method, self)
#             
#         except SMCOperationFailure as e:
#             result = e.smcresult
#             try:
#                 err = self.exception(result.msg)  # Exception set
#             except AttributeError:
#                 pass
#         except (SessionManagerNotFound, SMCConnectionError,
#                 IOError, TypeError) as e:
#             err = e
#         finally:
#             if err:
#                 raise err
#             return result
# 
#     def __str__(self):
#         sb = []
#         for key in self.__dict__:
#             sb.append(
#                 "{key}='{value}'".format(
#                     key=key,
#                     value=self.__dict__[key]))
#         return 'SMCRequest({})'.format(','.join(sb))    


# Path: smc/base/mixins.py
from smc.api.exceptions import ActionCommandFailed, ResourceNotFound
from smc.api.common import SMCRequest
    import sys



class RequestAction(object):
    """
    A Generic request action provides a simple interface to
    building and executing an SMCRequest. This will raise
    the exception specified if the resource is not found.
    
    Valid parameters that can be provided in kwargs are:
    
    :param str method: method for which to call. Can be
        'read', 'create', 'update' or 'delete' (default: 'read')
    :param str resource: The element resource to act on. If the
        href is already known, this can be provided as href
    :param bool raw_result: Return the raw SMCResult
    """
    def make_request(self, *exception, **kwargs):
        raw_result = kwargs.pop('raw_result', False)
        method = kwargs.pop('method', 'read')

        ex = exception[0] if exception else ActionCommandFailed