parameters: (ctx, host, port, uwsgi, nginx)
docstring: Operate the Cuckoo REST API.
docstring_summary: Operate the Cuckoo REST API.
docstring_tokens: Operate the Cuckoo REST API .
function: def api(ctx, host, port, uwsgi, nginx):
      """Operate the Cuckoo REST API."""
      username = ctx.parent.user or getuser()
      if uwsgi:
          print "[uwsgi]"
          print "plugins = python"
          if os.environ.get("VIRTUAL_ENV"):
              print "virtualenv =", os.environ["VIRTUAL_ENV"]
          print "module = cuckoo.apps.api"
          print "callable = app"
          print "uid =", username
          print "gid =", username
          print "env = CUCKOO_APP=api"
          print "env = CUCKOO_CWD=%s" % cwd()
          return
  
      if nginx:
          print "upstream _uwsgi_cuckoo_api {"
          print "    server unix:/run/uwsgi/app/cuckoo-api/socket;"
          print "}"
          print
          print "server {"
          print "    listen %s:%d;" % (host, port)
          print
          print "    # REST API app"
          print "    location / {"
          print "        client_max_body_size 1G;"
          print "        uwsgi_pass  _uwsgi_cuckoo_api;"
          print "        include     uwsgi_params;"
          print "    }"
          print "}"
          return
  
      init_console_logging(level=ctx.parent.level)
      Database().connect()
  
      if not ensure_tmpdir():
          sys.exit(1)
  
      cuckoo_api(host, port, ctx.parent.level == logging.DEBUG)
function_tokens: def api ( ctx , host , port , uwsgi , nginx ) : username = ctx . parent . user or getuser ( ) if uwsgi : print "[uwsgi]" print "plugins = python" if os . environ . get ( "VIRTUAL_ENV" ) : print "virtualenv =" , os . environ [ "VIRTUAL_ENV" ] print "module = cuckoo.apps.api" print "callable = app" print "uid =" , username print "gid =" , username print "env = CUCKOO_APP=api" print "env = CUCKOO_CWD=%s" % cwd ( ) return if nginx : print "upstream _uwsgi_cuckoo_api {" print "    server unix:/run/uwsgi/app/cuckoo-api/socket;" print "}" print print "server {" print "    listen %s:%d;" % ( host , port ) print print "    # REST API app" print "    location / {" print "        client_max_body_size 1G;" print "        uwsgi_pass  _uwsgi_cuckoo_api;" print "        include     uwsgi_params;" print "    }" print "}" return init_console_logging ( level = ctx . parent . level ) Database ( ) . connect ( ) if not ensure_tmpdir ( ) : sys . exit ( 1 ) cuckoo_api ( host , port , ctx . parent . level == logging . DEBUG )