mirror of
https://github.com/ansible/awx.git
synced 2026-02-20 12:40:06 -03:30
30 lines
841 B
Python
30 lines
841 B
Python
from django.db import models
|
|
|
|
|
|
class ReceptorAddress(models.Model):
|
|
address = models.CharField(max_length=255)
|
|
port = models.IntegerField(null=True)
|
|
protocol = models.CharField(max_length=10)
|
|
websocket_path = models.CharField(max_length=255, default="", blank=True)
|
|
is_internal = models.BooleanField(default=False)
|
|
instance = models.ForeignKey(
|
|
'Instance',
|
|
related_name='receptor_addresses',
|
|
on_delete=models.CASCADE,
|
|
)
|
|
|
|
def get_full_address(self):
|
|
scheme = ""
|
|
path = ""
|
|
port = ""
|
|
if self.protocol == "ws":
|
|
scheme = "wss://"
|
|
|
|
if self.protocol == "ws" and self.websocket_path:
|
|
path = f"/{self.websocket_path}"
|
|
|
|
if self.port:
|
|
port = f":{self.port}"
|
|
|
|
return f"{scheme}{self.address}{port}{path}"
|