Beispiel #1
0
 def _verify_api_version(self, version):
     """Verify the provided API version."""
     if version not in CONSTANTS.SUPPORTED_API_VERSIONS:
         msg = str('API version [' + version + '] does not match any '
                   'accepted version.')
         error = 'ApiHandlerError # ' + msg
         self.local_tools.logger.error(msg)
         raise RbkcliException.ApiHandlerError(error)
Beispiel #2
0
    def api_requester(self, *args, **kwargs):
        """Instantiate requester and request API."""
        method, endpoint = args
        endpoint_key = kwargs['endpoint_key']
        data = kwargs['data']
        params = kwargs['params']

        if self.focus_list != [] and endpoint_key not in self.focus_list:
            msg = str('Requested endpoint [' + endpoint_key + '] not found on'
                      ' authorized endpoints list.')
            raise RbkcliException.ApiHandlerError(str(msg))

        endpoint = '/%s/%s' % (self.version, endpoint)
        api_rs = ApiRequester(self.local_tools.logger,
                              self.local_tools.user_profile,
                              auth=self.local_tools.auth).demand(method,
                                                                 endpoint,
                                                                 data=data,
                                                                 params=params)
        return api_rs