def _GenClientLibFromContents(discovery_doc, language, output_path,<EOL>build_system, client_name):
body = urllib.parse.urlencode({'<STR_LIT>': language, '<STR_LIT:content>': discovery_doc,<EOL>'<STR_LIT>': build_system})<EOL>request = urllib.request.Request(CLIENT_LIBRARY_BASE, body)<EOL>try:<EOL><INDENT>with contextlib.closing(urllib.request.urlopen(request)) as response:<EOL><INDENT>content = response.read()<EOL>return _WriteFile(output_path, client_name, content)<EOL><DEDENT><DEDENT>except urllib.error.HTTPError as error:<EOL><INDENT>raise ServerRequestException(error)<EOL><DEDENT>
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.