from eolymp.universe import DescribeSpaceInput, universe_pb2
from eolymp.universe.universe_http import UniverseClient

from peolymp.abstract import AbstractAPI


class UniverseAPI(AbstractAPI):
    def __init__(self, space):
        super(UniverseAPI, self).__init__(space)
        self.client = UniverseClient(self.http_client)

    def get_space(self):
        return self.client.DescribeSpace(DescribeSpaceInput(space_id=self.space_id)).space

    def add_custom_admin_access(self, user_id):
        return self.client.GrantPermission(
            universe_pb2.GrantPermissionInput(space_id=self.space_id, role=4, user_id=user_id))
