mirror of https://github.com/jumpserver/jumpserver
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.1 KiB
49 lines
1.1 KiB
# -*- coding: utf-8 -*-
|
|
#
|
|
from abc import abstractmethod
|
|
|
|
from ..models import Asset
|
|
|
|
|
|
class BaseBackend:
|
|
@abstractmethod
|
|
def all(self):
|
|
pass
|
|
|
|
@abstractmethod
|
|
def filter(self, username=None, hostname=None, ip=None, assets=None,
|
|
node=None, prefer_id=None, **kwargs):
|
|
pass
|
|
|
|
@abstractmethod
|
|
def search(self, item):
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_queryset(self):
|
|
pass
|
|
|
|
@abstractmethod
|
|
def delete(self, union_id):
|
|
pass
|
|
|
|
@staticmethod
|
|
def qs_to_values(qs):
|
|
values = qs.values(
|
|
'hostname', 'ip', "asset_id",
|
|
'username', 'password', 'private_key', 'public_key',
|
|
'score', 'version',
|
|
"asset_username", "union_id",
|
|
'date_created', 'date_updated',
|
|
'org_id', 'backend',
|
|
)
|
|
return values
|
|
|
|
@staticmethod
|
|
def make_assets_as_id(assets):
|
|
if not assets:
|
|
return []
|
|
if isinstance(assets[0], Asset):
|
|
assets = [a.id for a in assets]
|
|
return assets
|