from xosresource import XOSResource
from core.models import Tenant, Service
from services.vpgwu.models import VPGWUTenant

class XOSVPGWUTenant(XOSResource):
    provides = "tosca.nodes.VPGWUTenant"
    xos_model = VPGWUTenant
    name_field = None
    copyin_props = ["s5s8_pgw_tag", "display_message", "image_name"]

    def get_xos_args(self, throw_exception=True):
        args = super(XOSVPGWUTenant, self).get_xos_args()

        provider_name = self.get_requirement("tosca.relationships.TenantOfService", throw_exception=True)
        if provider_name:
            args["provider_service"] = self.get_xos_object(Service, throw_exception=True, name=provider_name)

        return args

    def get_existing_objs(self):
        args = self.get_xos_args(throw_exception=False)
        provider_service = args.get("provider", None)
        if provider_service:
            return [self.get_xos_object(provider_service=provider_service)]
        return []

    def postprocess(self, obj):
        pass

    def can_delete(self, obj):
        return super(XOSVPGWUTenant, self).can_delete(obj)
