code: def create_token(
      id,
      secret,
      expires_after,
      alls,
      databases,
      resources,
      debug,
      plugins_dir,
  ):
      """
      Create a signed API token for the specified actor ID
  
      Example:
  
          datasette create-token root --secret mysecret
  
      To allow only "view-database-download" for all databases:
  
      \b
          datasette create-token root --secret mysecret \\
              --all view-database-download
  
      To allow "create-table" against a specific database:
  
      \b
          datasette create-token root --secret mysecret \\
              --database mydb create-table
  
      To allow "insert-row" against a specific table:
  
      \b
          datasette create-token root --secret myscret \\
              --resource mydb mytable insert-row
  
      Restricted actions can be specified multiple times using
      multiple --all, --database, and --resource options.
  
      Add --debug to see a decoded version of the token.
      """
      ds = Datasette(secret=secret, plugins_dir=plugins_dir)
  
      # Run ds.invoke_startup() in an event loop
      loop = asyncio.get_event_loop()
      loop.run_until_complete(ds.invoke_startup())
  
      # Warn about any unknown actions
      actions = []
      actions.extend(alls)
      actions.extend([p[1] for p in databases])
      actions.extend([p[2] for p in resources])
      for action in actions:
          if not ds.permissions.get(action):
              click.secho(
                  f"  Unknown permission: {action} ",
                  fg="red",
                  err=True,
              )
  
      restrict_database = {}
      for database, action in databases:
          restrict_database.setdefault(database, []).append(action)
      restrict_resource = {}
      for database, resource, action in resources:
          restrict_resource.setdefault(database, {}).setdefault(
              resource, []
          ).append(action)
  
      token = ds.create_token(
          id,
          expires_after=expires_after,
          restrict_all=alls,
          restrict_database=restrict_database,
          restrict_resource=restrict_resource,
      )
      click.echo(token)
      if debug:
          encoded = token[len("dstok_") :]
          click.echo("\nDecoded:\n")
          click.echo(
              json.dumps(
                  ds.unsign(encoded, namespace="token"), indent=2
              )
          )
  
imports: import asyncio
  import uvicorn
  import click
  from click import formatting
  from click.types import CompositeParamType
  from click_default_group import DefaultGroup
  import functools
  import json
  import os
  import pathlib
  from runpy import run_module
  import shutil
  from subprocess import call
  import sys
  import textwrap
  import webbrowser
  from .app import OBSOLETE_SETTINGS, Datasette, DEFAULT_SETTINGS, SETTINGS, SQLITE_LIMIT_ATTACHED, pm
  from .utils import LoadExtension, StartupError, check_connection, find_spatialite, parse_metadata, ConnectionProblem, SpatialiteConnectionProblem, initial_path_for_datasette, pairs_to_nested_config, temporary_docker_directory, fail_if_plugins_in_metadata, value_as_boolean, SpatialiteNotFound, StaticMount, ValueAsBooleanError
  from .utils.sqlite import sqlite3
  from .utils.testing import TestClient
  from .version import __version__
label_desc: Use image node_id 10 for calling a global function with example usage: create_token(id, secret, expires_after, alls, databases, resources, debug, plugins_dir) without return types