code: def _GenClientLibFromContents(discovery_doc, language, output_path,
                                build_system, client_name):
    
  
    body = urllib.urlencode({'lang': language, 'content': discovery_doc,
                             'layout': build_system})
    request = urllib2.Request(CLIENT_LIBRARY_BASE, body)
    try:
      with contextlib.closing(urllib2.urlopen(request)) as response:
        content = response.read()
        return _WriteFile(output_path, client_name, content)
    except urllib2.HTTPError, error:
      raise ServerRequestException(error)
docs: Write a client library from a discovery doc.
  
    Args:
      discovery_doc: A string, the contents of the discovery doc used to
        generate the client library.
      language: A string, the client library language to generate. (java)
      output_path: A string, the directory to output the client library zip to.
      build_system: A string, the target build system for the client language.
      client_name: A string, the filename used to save the client lib.
  
    Raises:
      IOError: If reading the discovery doc fails.
      ServerRequestException: If fetching the generated client library fails.
  
    Returns:
      The path to the zipped client library.