def __call__(self, request): logger.info('[{ip_address}] {method} {path}: {params}'.format( ip_address=get_client_ip(request), method=request.method.upper(), path=request.path, params=json.dumps( obj=request.GET if request.method == 'GET' else request.POST), )) return self.get_response(request)
def _process(value: Any, path: iterutil.IterPath) -> str: if not is_encrypted(value): path = _str_path(path) if hidden_re.search(path): encrypted_data = encrypt_data(json.dumps({'value': value})) return f'{settings.ENCRYPT_PREFIX}{encrypted_data}' return value
def create_backup(user: User = None, comment: str = None) -> Backup: data = { 'environments': [], 'components': [], 'configs': configstore.get_all_data(), } for environment in Environment.objects.order_by('pk'): if environment.fallback_id: fallback = environment.fallback.alias else: fallback = None data['environments'].append({ 'id': environment.pk, 'name': environment.name, 'alias': environment.alias, 'order': environment.order, 'fallback': fallback, 'is_active': environment.is_active, 'created_at': environment.created_at, 'updated_at': environment.updated_at, }) for component in Component.objects.all(): data['components'].append({ 'id': component.pk, 'name': component.name, 'alias': component.alias, 'schema_json': component.schema_json, 'is_global': component.is_global, 'require_schema': component.require_schema, 'strict_keys': component.strict_keys, 'is_active': component.is_active, 'created_at': component.created_at, 'updated_at': component.updated_at, }) backup = Backup() backup.data_file.save(name=f'configfactory-backup-{timezone.now()}.json', content=ContentFile(json.dumps(data, indent=4))) backup.user = user backup.comment = comment backup.save() # Notify about created backup backup_created.send(sender=Backup, backup=backup) return backup
def get_settings_inject_keys( environment: Environment, override_settings: dict = None) -> Dict[str, Set[str]]: """ Get inject keys by component. """ inject_keys = {} env_settings = get_environment_settings(environment) env_settings.update(override_settings or {}) for component_alias, data in env_settings.items(): keys = tplcontext.findkeys(json.dumps(data, compress=True)) if keys: inject_keys[component_alias] = keys return inject_keys
def new_data(self, data: dict): self.new_data_json = json.dumps(data)
def old_data(self, data: dict): self.old_data_json = json.dumps(data)
def prepare_value(self, value): if isinstance(value, dict): return json.dumps(value, indent=4) return value
def schema(self, value): self.schema_json = json.dumps(value)
def update_data(environment: str, component: str, data: dict): _store.update(environment=environment, component=component, data=json.dumps(data, compress=True))