export async function pushLegacy()

in src/push/index.ts [325:359]


export async function pushLegacy(monitors: Monitor[], options: PushOptions) {
  if (isLightweightMonitorSupported(monitors, options)) {
    throw error(
      `Aborted: Lightweight monitors are not supported in ${options.kibanaVersion}. Please upgrade to 8.5.0 or above.`
    );
  }

  let schemas: MonitorSchema[] = [];
  let sizes: Map<string, number> = new Map();
  if (monitors.length > 0) {
    progress(`preparing ${monitors.length} monitors`);
    ({ schemas, sizes } = await buildMonitorSchema(monitors, false));
    const batches = getSizedBatches(schemas, sizes, MAX_PAYLOAD_SIZE_KB, 10);
    if (batches.length > 1) {
      progress(`Monitors will be pushed as ${batches.length} batches.`);
    }
    for (const batch of batches) {
      await liveProgress(
        createMonitorsLegacy({ schemas: batch, keepStale: true, options }),
        `creating or updating ${batch.length} monitors`
      );
    }
  } else {
    await confirmDelete(
      `Pushing without any monitors will delete all monitors associated with the project.\n Do you want to continue?`,
      options.yes
    );
  }
  await liveProgress(
    createMonitorsLegacy({ schemas, keepStale: false, options }),
    `deleting all stale monitors`
  );

  done(`Pushed: ${underline(getMonitorManagementURL(options.url))}`);
}