Skip to content

Commit

Permalink
tiny type clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Jun 30, 2020
1 parent 9c4d702 commit 7d87a9d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ function disableAdminPrivileges(capabilities: MlCapabilities) {
capabilities.canDeleteAnnotation = false;
}

export type HasMlCapabilities = (capabilities: MlCapabilitiesKey[]) => void;

export function hasMlCapabilitiesProvider(resolveMlCapabilities: ResolveMlCapabilities) {
return (request: KibanaRequest) => {
return async (capabilities: MlCapabilitiesKey[]) => {
Expand Down
6 changes: 5 additions & 1 deletion x-pack/plugins/ml/server/lib/capabilities/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { capabilitiesProvider, hasMlCapabilitiesProvider } from './check_capabilities';
export {
capabilitiesProvider,
hasMlCapabilitiesProvider,
HasMlCapabilities,
} from './check_capabilities';
export { setupCapabilitiesSwitcher } from './capabilities_switcher';
6 changes: 3 additions & 3 deletions x-pack/plugins/ml/server/shared_services/shared_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {
AnomalyDetectorsProvider,
getAnomalyDetectorsProvider,
} from './providers/anomaly_detectors';
import { ResolveMlCapabilities, MlCapabilitiesKey } from '../../common/types/capabilities';
import { hasMlCapabilitiesProvider } from '../lib/capabilities';
import { ResolveMlCapabilities } from '../../common/types/capabilities';
import { hasMlCapabilitiesProvider, HasMlCapabilities } from '../lib/capabilities';

export type SharedServices = JobServiceProvider &
AnomalyDetectorsProvider &
Expand All @@ -30,7 +30,7 @@ export type SharedServices = JobServiceProvider &
export interface SharedServicesChecks {
isFullLicense(): void;
isMinimumLicense(): void;
getHasMlCapabilities(request: KibanaRequest): (capabilities: MlCapabilitiesKey[]) => void;
getHasMlCapabilities(request: KibanaRequest): HasMlCapabilities;
}

export function createSharedServices(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,11 @@ export const signalRulesAlertType = ({
}

const scopedMlCallCluster = services.getScopedCallCluster(ml.mlClient);
// Using fake KibanaRequest as it is needed to satisfy the ML Services API, but can be empty as it is
// currently unused by the jobsSummary function.
const summaryJobs = await (
await ml.jobServiceProvider(scopedMlCallCluster, ({} as unknown) as KibanaRequest)
) // TODO, this is now broken
.jobsSummary([machineLearningJobId]);
).jobsSummary([machineLearningJobId]);
const jobSummary = summaryJobs.find((job) => job.id === machineLearningJobId);

if (jobSummary == null || !isJobStarted(jobSummary.jobState, jobSummary.datafeedState)) {
Expand All @@ -184,9 +185,9 @@ export const signalRulesAlertType = ({
const anomalyResults = await findMlSignals({
ml,
callCluster: scopedMlCallCluster,
// This is needed to satisfy the ML Services API, but can be empty as it is
// Using fake KibanaRequest as it is needed to satisfy the ML Services API, but can be empty as it is
// currently unused by the mlAnomalySearch function.
request: ({} as unknown) as KibanaRequest, // TODO, this is now broken
request: ({} as unknown) as KibanaRequest,
jobId: machineLearningJobId,
anomalyThreshold,
from,
Expand Down

0 comments on commit 7d87a9d

Please sign in to comment.