"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.registerGetApmServiceSummaryFunction = registerGetApmServiceSummaryFunction;
var _i18n = require("@kbn/i18n");
var _create_call_apm_api = require("../services/rest/create_call_apm_api");
var _non_empty_string_ref = require("../utils/non_empty_string_ref");
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0; you may not use this file except in compliance with the Elastic License
 * 2.0.
 */

function registerGetApmServiceSummaryFunction({
  registerFunction
}) {
  registerFunction({
    name: 'get_apm_service_summary',
    contexts: ['apm'],
    description: `Gets a summary of a single service, including: the language, service version, 
deployments, the environments, and the infrastructure that it is running in, for instance on how 
many pods, and a list of its downstream dependencies. It also returns active 
alerts and anomalies.`,
    descriptionForUser: _i18n.i18n.translate('xpack.apm.observabilityAiAssistant.functions.registerGetApmServiceSummary.descriptionForUser', {
      defaultMessage: `Gets a summary of a single service, including: the language, service version, 
deployments, the environments, and the infrastructure that it is running in, for instance on how 
many pods, and a list of its downstream dependencies. It also returns active 
alerts and anomalies.`
    }),
    parameters: {
      type: 'object',
      properties: {
        'service.name': {
          ..._non_empty_string_ref.NON_EMPTY_STRING,
          description: 'The name of the service that should be summarized.'
        },
        'service.environment': {
          ..._non_empty_string_ref.NON_EMPTY_STRING,
          description: 'The environment that the service is running in'
        },
        start: {
          ..._non_empty_string_ref.NON_EMPTY_STRING,
          description: 'The start of the time range, in Elasticsearch date math, like `now`.'
        },
        end: {
          ..._non_empty_string_ref.NON_EMPTY_STRING,
          description: 'The end of the time range, in Elasticsearch date math, like `now-24h`.'
        }
      },
      required: ['service.name', 'start', 'end']
    }
  }, async ({
    arguments: args
  }, signal) => {
    return (0, _create_call_apm_api.callApmApi)('GET /internal/apm/assistant/get_service_summary', {
      signal,
      params: {
        query: args
      }
    });
  });
}