docs: def publishItem(self,
                      fileType,
                      publishParameters=None,
                      itemId=None,
                      filePath=None,
                      text=None,
                      outputType=None,
                      buildIntialCache=False,
                      wait=False,
                      overwrite=False
                      ):
          """
          Publishes a hosted service based on an existing source item.
          Publishers can create feature services as well as tiled map
          services.
          Feature services can be created using input files of type csv,
          shapefile, serviceDefinition, featureCollection, and
          fileGeodatabase.
  
          Inputs:
             fileType - Item type.
                        Values: serviceDefinition | shapefile | csv |
                        tilePackage | featureService | featureCollection |
                        fileGeodata | geojson | scenePackage
             publishParameters - object describing the service to be created
                                 as part of the publish operation. Only
                                 required for CSV, Shapefiles, feature
                                 collection, and file geodatabase.
             itemId - The ID of the item to be published.
             text - The text in the file to be published. This ONLY applies
                    to CSV files.
             filePath - The file to be uploaded.
             outputType - Only used when a feature service is published as a
                          tile service.
             buildIntialCache - default false.  Allows the user to prevent
                                the creation of the initial cache for tiled
                                services.
          """
          _allowed_types = ["serviceDefinition", "shapefile", "csv",
                            "tilePackage", "featureService",
                            "featureCollection", "fileGeodatabase",
                            "geojson", "scenePackage"]
          if fileType.lower() not in [t.lower() for t in _allowed_types]:
              raise AttributeError("Invalid fileType: %s" % fileType)
  
          url = "%s/publish" % self.location
          params = {
              "f" : "json",
              'fileType': fileType
          }
  
          if isinstance(buildIntialCache, bool):
              params['buildInitialCache'] = buildIntialCache
          if publishParameters is not None and \
             isinstance(publishParameters, PublishCSVParameters) == False:
              params['publishParameters'] = json.dumps(publishParameters.value)
          elif isinstance(publishParameters, PublishCSVParameters):
              params['publishParameters'] = json.dumps(publishParameters.value)
  
          if itemId is not None:
              params['itemId'] = itemId
          if text is not None and fileType.lower() == 'csv':
              params['text'] = text
          if overwrite != False:
              params['overwrite'] = overwrite
          if filePath is not None:
  
              files = {}
              files['file'] = filePath
              res = self._post(url=url,
                               param_dict=params,
                               files=files,
                               securityHandler=self._securityHandler,
                               proxy_url=self._proxy_url,
                               proxy_port=self._proxy_port)
          else:
              res = self._post(url=url,
                                   param_dict=params,
                                   securityHandler=self._securityHandler,
                                   proxy_port=self._proxy_port,
                                   proxy_url=self._proxy_url)
          if 'services' in res:
              if len(res['services']) > 0:
                  if 'error' in res['services'][0]:
                      if 'message' in res['services'][0]['error']:
                          print(res['services'][0]['error']['message'])
                      else:
                          print(res['services'][0]['error'])
                      raise Exception("Could not publish item: %s" % itemId)
                  else:
                      itemId = res['services'][0]['serviceItemId']
                      ui = UserItem(url="%s/items/%s" % (self.location, itemId),
                                      securityHandler=self._securityHandler,
                                      proxy_url=self._proxy_url,
                                      proxy_port=self._proxy_port)
                      if wait == True:
                          status = "partial"
                          while status != "completed":
                              status = ui.status(jobId=res['services'][0]['jobId'], jobType="publish")
  
                              if status['status'] == 'failed':
                                  #if 'statusMessage' in status:
                                      #print( status['statusMessage'])
                                  print (str(status))
                                  raise Exception("Could not publish item: %s" % itemId)
  
                              elif status['status'].lower() == "completed":
                                  break
                              time.sleep(2)
                      return ui
              else:
                  print (res)
                  raise Exception("Could not publish item: %s" % itemId)
          else:
              print (res)
              raise Exception("Could not publish item: %s" % itemId)
          return None