import { SavedObjectsClientContract } from 'kibana/server' ; import { Maybe } from '../../../typings/common' ; import { AgentPolicy , PackagePolicy } from '../../../../fleet/common' ; import { APMPluginStartDependencies } from '../../types' ; import { POLICY_ELASTIC_AGENT_ON_CLOUD } from '../../../common/fleet' ; export const APM_PACKAGE_NAME = 'apm' ; export async function getCloudAgentPolicy ( { fleetPluginStart , savedObjectsClient , } ) { try { return await fleetPluginStart . agentPolicyService . get ( savedObjectsClient , POLICY_ELASTIC_AGENT_ON_CLOUD ) ; } catch ( error ) { if ( error ?. output . statusCode === 404 ) { return ; } throw error ; } } export function getApmPackagePolicy ( agentPolicy ) { if ( ! agentPolicy ) { return ; } const packagePolicies = agentPolicy . package_policies as PackagePolicy [ ] ; return packagePolicies . find ( ( packagePolicy ) => packagePolicy ?. package ?. name === APM_PACKAGE_NAME ) ; }