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 @@ -9,6 +9,7 @@ import type { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
import type { IHttpFetchError } from '@kbn/core-http-browser';
import { useQuery } from '@tanstack/react-query';
import { packagePolicyRouteService } from '@kbn/fleet-plugin/common';
import { API_VERSIONS } from '@kbn/fleet-plugin/common/constants';
import {
DefaultPolicyNotificationMessage,
DefaultPolicyRuleNotificationMessage,
Expand Down Expand Up @@ -45,7 +46,8 @@ export const useFetchEndpointPolicy = (
...options,
queryFn: async () => {
const apiResponse = await http.get<GetPolicyResponse>(
packagePolicyRouteService.getInfoPath(policyId)
packagePolicyRouteService.getInfoPath(policyId),
{ version: API_VERSIONS.public.v1 }
);

applyDefaultsToPolicyIfNeeded(apiResponse.item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { IHttpFetchError } from '@kbn/core-http-browser';
import type { GetAgentStatusResponse } from '@kbn/fleet-plugin/common';
import { useQuery } from '@tanstack/react-query';
import { agentRouteService } from '@kbn/fleet-plugin/common';
import { API_VERSIONS } from '@kbn/fleet-plugin/common/constants';
import { useHttp } from '../../../common/lib/kibana';

type EndpointPolicyAgentSummary = GetAgentStatusResponse['results'];
Expand All @@ -30,6 +31,7 @@ export const useFetchAgentByAgentPolicySummary = (
return (
await http.get<GetAgentStatusResponse>(agentRouteService.getStatusPath(), {
query: { policyId: agentPolicyId },
version: API_VERSIONS.public.v1,
})
).results;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { UseMutationOptions, UseMutationResult } from '@tanstack/react-quer
import type { IHttpFetchError } from '@kbn/core-http-browser';
import { useMutation } from '@tanstack/react-query';
import { packagePolicyRouteService } from '@kbn/fleet-plugin/common';
import { API_VERSIONS } from '@kbn/fleet-plugin/common/constants';
import { getPolicyDataForUpdate } from '../../../../common/endpoint/service/policy';
import { useHttp } from '../../../common/lib/kibana';
import type { PolicyData } from '../../../../common/endpoint/types';
Expand Down Expand Up @@ -39,6 +40,7 @@ export const useUpdateEndpointPolicy = (

return http.put(packagePolicyRouteService.getUpdatePath(policy.id), {
body: JSON.stringify(update),
version: API_VERSIONS.public.v1,
});
}, options);
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
GetInfoResponse,
} from '@kbn/fleet-plugin/common';
import { epmRouteService } from '@kbn/fleet-plugin/common';
import { API_VERSIONS } from '@kbn/fleet-plugin/common/constants';

import type { NewPolicyData } from '../../../../common/endpoint/types';
import type { GetPolicyResponse, UpdatePolicyResponse } from '../../pages/policy/types';
Expand All @@ -34,7 +35,10 @@ export const sendGetPackagePolicy = (
packagePolicyId: string,
options?: HttpFetchOptions
) => {
return http.get<GetPolicyResponse>(`${INGEST_API_PACKAGE_POLICIES}/${packagePolicyId}`, options);
return http.get<GetPolicyResponse>(`${INGEST_API_PACKAGE_POLICIES}/${packagePolicyId}`, {
...options,
version: API_VERSIONS.public.v1,
});
};

/**
Expand All @@ -50,6 +54,7 @@ export const sendBulkGetPackagePolicies = (
) => {
return http.post<GetPackagePoliciesResponse>(`${INGEST_API_PACKAGE_POLICIES}/_bulk_get`, {
...options,
version: API_VERSIONS.public.v1,
body: JSON.stringify({
ids: packagePolicyIds,
ignoreMissing: true,
Expand All @@ -73,6 +78,7 @@ export const sendPutPackagePolicy = (
): Promise<UpdatePolicyResponse> => {
return http.put(`${INGEST_API_PACKAGE_POLICIES}/${packagePolicyId}`, {
...options,
version: API_VERSIONS.public.v1,
body: JSON.stringify(packagePolicy),
});
};
Expand All @@ -92,6 +98,7 @@ export const sendGetFleetAgentStatusForPolicy = (
): Promise<GetAgentStatusResponse> => {
return http.get(INGEST_API_FLEET_AGENT_STATUS, {
...options,
version: API_VERSIONS.public.v1,
query: {
policyId,
},
Expand All @@ -105,7 +112,9 @@ export const sendGetEndpointSecurityPackage = async (
http: HttpStart
): Promise<GetInfoResponse['item']> => {
const path = epmRouteService.getInfoPath('endpoint');
const endpointPackageResponse = await http.get<GetInfoResponse>(path);
const endpointPackageResponse = await http.get<GetInfoResponse>(path, {
version: API_VERSIONS.public.v1,
});
const endpointPackageInfo = endpointPackageResponse.item;
if (!endpointPackageInfo) {
throw new Error('Endpoint package was not found.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import type { HttpFetchOptions, HttpStart } from '@kbn/core/public';
import type { GetPackagePoliciesRequest } from '@kbn/fleet-plugin/common';
import { PACKAGE_POLICY_SAVED_OBJECT_TYPE } from '@kbn/fleet-plugin/common';
import { API_VERSIONS } from '@kbn/fleet-plugin/common/constants';
import type { GetPolicyListResponse } from '../../pages/policy/types';
import { INGEST_API_PACKAGE_POLICIES } from './ingest';

Expand All @@ -29,5 +30,6 @@ export const sendGetEndpointSpecificPackagePolicies = (
options?.query?.kuery ? `${options.query.kuery} and ` : ''
}${PACKAGE_POLICY_SAVED_OBJECT_TYPE}.package.name: endpoint`,
},
version: API_VERSIONS.public.v1,
});
};