brn: Introduce BRN as a class
This commit is contained in:
parent
8c411e39bc
commit
a0da4d4641
8 changed files with 116 additions and 9 deletions
|
@ -3,6 +3,7 @@ from typing import Optional, List
|
|||
from flask import current_app
|
||||
from tldextract import extract
|
||||
|
||||
from app.brm.brn import BRN
|
||||
from app.extensions import db
|
||||
from app.models import AbstractConfiguration, AbstractResource
|
||||
from app.models.onions import Onion
|
||||
|
@ -53,8 +54,14 @@ class Proxy(AbstractResource):
|
|||
origin = db.relationship("Origin", back_populates="proxies")
|
||||
|
||||
@property
|
||||
def brn(self) -> str:
|
||||
return f"brn:{current_app.config['GLOBAL_NAMESPACE']}:{self.origin.group_id}:mirror:{self.provider}:proxy/{self.id}"
|
||||
def brn(self) -> BRN:
|
||||
return BRN(
|
||||
group_id=self.origin.group_id,
|
||||
product="mirror",
|
||||
provider=self.provider,
|
||||
resource_type="proxy",
|
||||
resource_id=self.id
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def csv_header(cls) -> List[str]:
|
||||
|
@ -72,5 +79,11 @@ class SmartProxy(AbstractResource):
|
|||
group = db.relationship("Group", back_populates="smart_proxies")
|
||||
|
||||
@property
|
||||
def brn(self) -> str:
|
||||
return f"brn:{current_app.config['GLOBAL_NAMESPACE']}:{self.group_id}:mirror:{self.provider}:smart-proxy/1"
|
||||
def brn(self) -> BRN:
|
||||
return BRN(
|
||||
group_id=self.group_id,
|
||||
product="mirror",
|
||||
provider=self.provider,
|
||||
resource_type="smart_proxy",
|
||||
resource_id=str(1)
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue