forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get the assetClient ready for building inventory prototype (elastic#1…
- Loading branch information
1 parent
0f1a6e3
commit 88b85eb
Showing
43 changed files
with
700 additions
and
445 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
x-pack/plugins/asset_manager/server/lib/accessors/hosts/get_hosts_by_assets.ts
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
x-pack/plugins/asset_manager/server/lib/accessors/hosts/index.ts
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
x-pack/plugins/asset_manager/server/lib/accessors/index.ts
This file was deleted.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
x-pack/plugins/asset_manager/server/lib/accessors/services/get_services.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import { Asset } from '../../../../common/types_api'; | ||
import { collectServices } from '../../collectors/services'; | ||
import { parseEan } from '../../parse_ean'; | ||
import { GetServicesOptionsPublic } from '../../../../common/types_client'; | ||
import { | ||
AssetClientDependencies, | ||
AssetClientOptionsWithInjectedValues, | ||
} from '../../asset_client_types'; | ||
|
||
export type GetServicesOptions = GetServicesOptionsPublic & AssetClientDependencies; | ||
export type GetServicesOptionsInjected = AssetClientOptionsWithInjectedValues<GetServicesOptions>; | ||
|
||
export async function getServices( | ||
options: GetServicesOptionsInjected | ||
): Promise<{ services: Asset[] }> { | ||
const filters = []; | ||
|
||
if (options.parent) { | ||
const { kind, id } = parseEan(options.parent); | ||
|
||
if (kind === 'host') { | ||
filters.push({ | ||
bool: { | ||
should: [{ term: { 'host.name': id } }, { term: { 'host.hostname': id } }], | ||
minimum_should_match: 1, | ||
}, | ||
}); | ||
} | ||
|
||
if (kind === 'container') { | ||
filters.push({ | ||
bool: { | ||
should: [{ term: { 'container.id': id } }], | ||
minimum_should_match: 1, | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
const apmIndices = await options.getApmIndices(options.savedObjectsClient); | ||
const { assets } = await collectServices({ | ||
client: options.elasticsearchClient, | ||
from: options.from, | ||
to: options.to || 'now', | ||
sourceIndices: { | ||
apm: apmIndices, | ||
}, | ||
filters, | ||
}); | ||
|
||
return { services: assets }; | ||
} |
Oops, something went wrong.