This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from tsuru.models.base import BaseModel | ||
|
||
|
||
class Unit(BaseModel): | ||
_RESOURCE_NAME = 'units' | ||
|
||
@property | ||
def name(self): | ||
return self._get('Name') | ||
|
||
@property | ||
def process_name(self): | ||
return self._get('ProcessName') | ||
|
||
@property | ||
def app_name(self): | ||
return self._get('AppName') | ||
|
||
@property | ||
def type(self): | ||
return self._get('Type') | ||
|
||
@property | ||
def ip(self): | ||
return self._get('IP') | ||
|
||
@property | ||
def status(self): | ||
return self._get('Status') | ||
|
||
@property | ||
def address(self): | ||
data = self._get('Address') | ||
scheme = data['Scheme'] | ||
user = data['User'] | ||
host = data['Host'] | ||
path = data['Path'] | ||
raw_query = data['RawQuery'] | ||
|
||
auth = f'{user}@' if user else '' | ||
query = f'?{raw_query}' if raw_query else '' | ||
return f"{scheme}://{auth}{host}{path}{query}" | ||
|
||
@property | ||
def host_(self): | ||
address = self._get('HostAddr') | ||
port = self._get('HostPort') | ||
return f"{address}:{port}" | ||
|
||
def app(self): | ||
from tsuru import App | ||
|
||
return App(data={'name': self.app_name}) |