Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { DeleteByQueryResponse } from '@elastic/elasticsearch/lib/api/types
import type { KbnClient } from '@kbn/test';
import type { Agent, FleetServerAgent, GetOneAgentResponse } from '@kbn/fleet-plugin/common';
import { AGENT_API_ROUTES } from '@kbn/fleet-plugin/common';
import { API_VERSIONS } from '@kbn/fleet-plugin/common/constants';
import type { HostMetadata } from '../types';
import { FleetAgentGenerator } from '../data_generators/fleet_agent_generator';
import { wrapErrorAndRejectPromise } from './utils';
Expand Down Expand Up @@ -90,6 +91,7 @@ const fetchFleetAgent = async (kbnClient: KbnClient, agentId: string): Promise<A
.request({
path: AGENT_API_ROUTES.INFO_PATTERN.replace('{agentId}', agentId),
method: 'GET',
headers: { 'elastic-api-version': API_VERSIONS.public.v1 },
})
.catch(wrapErrorAndRejectPromise)) as AxiosResponse<GetOneAgentResponse>
).data.item;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {
} from '@kbn/fleet-plugin/common';
import { AGENT_POLICY_API_ROUTES, PACKAGE_POLICY_API_ROUTES } from '@kbn/fleet-plugin/common';
import { memoize } from 'lodash';
import { API_VERSIONS } from '@kbn/fleet-plugin/common/constants';
import { getEndpointPackageInfo } from '../utils/package';
import type { PolicyData } from '../types';
import { policyFactory as policyConfigFactory } from '../models/policy_config';
Expand Down Expand Up @@ -62,6 +63,7 @@ export const indexFleetEndpointPolicy = async (
.request({
path: AGENT_POLICY_API_ROUTES.CREATE_PATTERN,
method: 'POST',
headers: { 'elastic-api-version': API_VERSIONS.public.v1 },
body: newAgentPolicyData,
})
.catch(wrapErrorAndRejectPromise)) as AxiosResponse<CreateAgentPolicyResponse>;
Expand Down Expand Up @@ -100,6 +102,7 @@ export const indexFleetEndpointPolicy = async (
.request({
path: PACKAGE_POLICY_API_ROUTES.CREATE_PATTERN,
method: 'POST',
headers: { 'elastic-api-version': API_VERSIONS.public.v1 },
body: newPackagePolicyData,
})
.catch(wrapErrorAndRejectPromise)) as AxiosResponse<CreatePackagePolicyResponse>;
Expand Down Expand Up @@ -136,6 +139,7 @@ export const deleteIndexedFleetEndpointPolicies = async (
.request({
path: PACKAGE_POLICY_API_ROUTES.DELETE_PATTERN,
method: 'POST',
headers: { 'elastic-api-version': API_VERSIONS.public.v1 },
body: {
packagePolicyIds: indexData.integrationPolicies.map((policy) => policy.id),
},
Expand All @@ -154,6 +158,7 @@ export const deleteIndexedFleetEndpointPolicies = async (
.request({
path: AGENT_POLICY_API_ROUTES.DELETE_PATTERN,
method: 'POST',
headers: { 'elastic-api-version': API_VERSIONS.public.v1 },
body: {
agentPolicyId: agentPolicy.id,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {
} from '@kbn/fleet-plugin/common';
import { AGENTS_SETUP_API_ROUTES, EPM_API_ROUTES, SETUP_API_ROUTE } from '@kbn/fleet-plugin/common';
import { ToolingLog } from '@kbn/tooling-log';
import { API_VERSIONS } from '@kbn/fleet-plugin/common/constants';
import { UsageTracker } from './usage_tracker';
import { EndpointDataLoadingError, retryOnError, wrapErrorAndRejectPromise } from './utils';

Expand Down Expand Up @@ -44,6 +45,9 @@ export const setupFleetForEndpoint = async (
.request({
path: SETUP_API_ROUTE,
method: 'POST',
headers: {
'elastic-api-version': API_VERSIONS.public.v1,
},
})
.catch(wrapErrorAndRejectPromise)) as AxiosResponse<PostFleetSetupResponse>;

Expand All @@ -64,6 +68,9 @@ export const setupFleetForEndpoint = async (
.request({
path: AGENTS_SETUP_API_ROUTES.CREATE_PATTERN,
method: 'POST',
headers: {
'elastic-api-version': API_VERSIONS.public.v1,
},
})
.catch(wrapErrorAndRejectPromise)) as AxiosResponse<PostFleetSetupResponse>;

Expand Down Expand Up @@ -112,6 +119,9 @@ export const installOrUpgradeEndpointFleetPackage = async (
.request({
path: EPM_API_ROUTES.BULK_INSTALL_PATTERN,
method: 'POST',
headers: {
'elastic-api-version': API_VERSIONS.public.v1,
},
body: {
packages: ['endpoint'],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { AxiosResponse } from 'axios';
import type { KbnClient } from '@kbn/test';
import type { GetInfoResponse } from '@kbn/fleet-plugin/common';
import { epmRouteService } from '@kbn/fleet-plugin/common';
import { API_VERSIONS } from '@kbn/fleet-plugin/common/constants';

export const getEndpointPackageInfo = async (
kbnClient: KbnClient
Expand All @@ -19,6 +20,9 @@ export const getEndpointPackageInfo = async (
(await kbnClient.request({
path,
method: 'GET',
headers: {
'elastic-api-version': API_VERSIONS.public.v1,
},
})) as AxiosResponse<GetInfoResponse>
).data.item;

Expand Down