    def server_model(self, spawner, *, user=None):
        """Get the JSON model for a Spawner
        Assume server permission already granted
        """
        if isinstance(spawner, orm.Spawner):
            # if an orm.Spawner is passed,
            # create a model for a stopped Spawner
            # not all info is available without the higher-level Spawner wrapper
            orm_spawner = spawner
            pending = None
            ready = False
            stopped = True
            user = user
            if user is None:
                raise RuntimeError("Must specify User with orm.Spawner")
            state = orm_spawner.state
        else:
            orm_spawner = spawner.orm_spawner
            pending = spawner.pending
            ready = spawner.ready
            user = spawner.user
            stopped = not spawner.active
            state = spawner.get_state()

        model = {
            'name': orm_spawner.name,
            'full_name': f"{orm_spawner.user.name}/{orm_spawner.name}",
            'last_activity': isoformat(orm_spawner.last_activity),
            'started': isoformat(orm_spawner.started),
            'pending': pending,
            'ready': ready,
            'stopped': stopped,
            'url': url_path_join(user.url, url_escape_path(spawner.name), '/'),
            'user_options': spawner.user_options,
            'progress_url': user.progress_url(spawner.name),
            'full_url': None,
            'full_progress_url': None,
        }
        # fill out full_url fields
        public_url = self.settings.get("public_url")
        if urlparse(model["url"]).netloc:
            # if using subdomains, this is already a full URL
            model["full_url"] = model["url"]
        if public_url:
            model["full_progress_url"] = urlunparse(
                public_url._replace(path=model["progress_url"])
            )
            if not model["full_url"]:
                # set if not defined already by subdomain
                model["full_url"] = urlunparse(public_url._replace(path=model["url"]))

        scope_filter = self.get_scope_filter('admin:server_state')
        if scope_filter(spawner, kind='server'):
            model['state'] = state
        return model
Get the JSON model for a Spawner
Assume server permission already granted
jupyterhub/apihandlers/base.py