from lib.services.gslb.gslb_client import GslbClientInterface


class FlavaGslbClient(GslbClientInterface):
    """Flava GSLB Client implementation"""

    flava_gslb_uri = "/projects"

    def list_instances(self, gslb_base):
        """List GSLB instances

        API reference:
        https://line-objects-internal.com/flava-gslbaas/gslbaas/index.html#tag/Instance/operation/GetV1ProjectsProjectInstance
        """
        uri = f"{self.flava_gslb_uri}/{gslb_base.tenant_name}/instance"
        return gslb_base._list_instances(uri=uri)

    def show_instance(self, gslb_base, instance_id):
        """Get a GSLB instance

        API reference:
        https://line-objects-internal.com/flava-gslbaas/gslbaas/index.html#tag/Instance/operation/GetV1ProjectsProjectInstanceInstanceID
        """
        uri = f"{self.flava_gslb_uri}/{gslb_base.tenant_name}/instance/{instance_id}"
        return gslb_base._show_instance(uri=uri)

    def create_instance(self, gslb_base, **kwargs):
        """Create a GSLB instance

        API reference:
        https://line-objects-internal.com/flava-gslbaas/gslbaas/index.html#tag/Instance/operation/PostV1ProjectsProjectInstance
        """
        uri = f"{self.flava_gslb_uri}/{gslb_base.tenant_name}/instance"
        return gslb_base._create_instance(uri=uri, req_body=kwargs)

    def update_instance(self, gslb_base, instance_id, update_body):
        """Update a GSLB instance

        API reference:
        https://line-objects-internal.com/flava-gslbaas/gslbaas/index.html#tag/Instance/operation/PostV1ProjectsProjectInstanceInstanceID
        """
        uri = f"{self.flava_gslb_uri}/{gslb_base.tenant_name}/instance/{instance_id}"
        return gslb_base._update_instance(uri=uri, req_body=update_body)

    def delete_instance(self, gslb_base, instance_id):
        """Delete a GSLB instance

        API reference:
        https://line-objects-internal.com/flava-gslbaas/gslbaas/index.html#tag/Instance/operation/DeleteV1ProjectsProjectInstanceInstanceID
        """
        uri = f"{self.flava_gslb_uri}/{gslb_base.tenant_name}/instance/{instance_id}"
        return gslb_base._delete_instance(uri=uri)
