def send(cls, method, url, params, request, description=None, log_count_field=None): loggers = build_logger(request, __name__) if description: loggers.info("===== Start {} =====".format(description)) headers = build_auth_header_from_request(request) if len(params) > 0: loggers.info("Request data: {} ".format(params)) if method == 'GET': is_success, status_code, data = RestFulClient.get(url, loggers, headers) status_message = None elif method == 'POST': is_success, status_code, status_message, data = RestFulClient.post(url, headers, loggers, params) elif method == 'PUT': is_success, status_code, status_message, data = RestFulClient.put(url, headers, loggers, params) elif method == 'DELETE': is_success, status_code, status_message = RestFulClient.delete(url, headers, loggers, params) data = None if status_code in ["access_token_expire", 'authentication_fail', 'invalid_access_token']: raise InvalidAccessToken(status_message) if log_count_field: log_data = data for field in log_count_field.split('.'): if field == "data": continue if log_data: log_data = log_data.get(field, {}) else: log_data = {} count = len(log_data) loggers.info('Response count: {}'.format(count)) else: loggers.info('Response data: {}'.format(data)) if description: loggers.info("===== Finish {} =====".format(description)) return is_success, status_code, status_message, data
def dispatch(self, request, *args, **kwargs): check_permissions(request, "CAN_DELETE_GW_SERVICE") self.logger = build_logger(request, __name__) return super(DeleteView, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): check_permissions(request, "CAN_EDIT_GW_API") self.logger = build_logger(request, __name__) return super(EditView, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): self.logger = build_logger(request, __name__) return super(TierLevelEdit, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): self.logger = build_logger(self.request, __name__) return super(AddCondition, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): check_permissions(request, "CAN_SEARCH_TRUST") self.logger = build_logger(request, __name__) return super(ListTrust, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): check_permissions(request, 'CAN_CHANGE_SCOPES_CHANNEL_GW_CLIENTS') self.logger = build_logger(request, __name__) return super(ClientChannelGatewayScopeList, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): self.logger = build_logger(request, __name__) return super(MechanicDetail, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): check_permissions(request, "CAN_LABEL_TIER_CONFIGURATION") self.logger = build_logger(request, __name__) return super(TierLevelView, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): check_permissions(request, 'CAN_CREATE_GW_API') self.logger = build_logger(request, __name__) return super(CreateView, self).dispatch(request, *args, **kwargs)