code: def delete_services_from_servers(gis, user=None):
      """delete services from federated servers"""
      for server in gis.admin.servers.list():
          for folder_name in server.services.folders:
              if folder_name not in ignore_server_folders:
                  """stop and delete services per folder (per user)"""
                  for service in server.services.list(
                      folder=folder_name
                  ):
                      if (
                          service.type == "FeatureServer"
                          or service.type == "SceneServer"
                      ):
                          item_id = (
                              service.properties.portalProperties.get(
                                  "portalItems"
                              )[0]["itemID"]
                          )
                          item = gis.content.get(item_id)
                          if user is None:
                              if item.owner is None:
                                  print(
                                      "=== deleting service (admin)",
                                      service.type,
                                      service.serviceName,
                                      item.owner,
                                      service.url,
                                  )
                                  service.stop()
                                  service.delete()
                          elif item.owner == user.username:
                              print(
                                  "=== deleting service",
                                  service.type,
                                  service.serviceName,
                                  item.owner,
                              )
                              service.stop()
                              service.delete()
                          else:
                              pass
                      elif (
                          service.type == "ImageServer"
                          or service.type == "MapServer"
                      ):
                          service_owner = (
                              service.properties.properties.get(
                                  "userName"
                              )
                          )
                          if user is None:
                              if service_owner is None and any(
                                  token in service.serviceName
                                  for token in image_service_prefixes
                              ):
                                  print(
                                      "=== deleting service (admin)",
                                      service.type,
                                      service.serviceName,
                                      service_owner,
                                      service.url,
                                  )
                                  service.stop()
                                  service.delete()
                          elif service_owner == user.username:
                              print(
                                  "=== deleting service",
                                  service.type,
                                  service.serviceName,
                                  service_owner,
                              )
                              service.stop()
                              service.delete()
                          else:
                              pass
                      elif service.type in preserved_service_types:
                          pass
                      else:
                          print(
                              "=== Unrecognized Service Type",
                              service.type,
                              service.serviceName,
                              service.properties,
                          )
  
file_path: arcgis-python-api/misc/_common.py
imports: from arcgis.gis import GIS
label_desc: Use image node_id 1 for calling a global function with example usage: delete_services_from_servers(gis, user) without return types