|
18 | 18 | */ |
19 | 19 |
|
20 | 20 | import { ToolingLog } from '../tooling_log'; |
21 | | -import { KibanaConfig, KbnClientRequester, ReqOptions } from './kbn_client_requester'; |
| 21 | +import { KbnClientRequester, ReqOptions } from './kbn_client_requester'; |
22 | 22 | import { KbnClientStatus } from './kbn_client_status'; |
23 | 23 | import { KbnClientPlugins } from './kbn_client_plugins'; |
24 | 24 | import { KbnClientVersion } from './kbn_client_version'; |
25 | 25 | import { KbnClientSavedObjects } from './kbn_client_saved_objects'; |
26 | 26 | import { KbnClientUiSettings, UiSettingValues } from './kbn_client_ui_settings'; |
27 | 27 |
|
| 28 | +export interface KbnClientOptions { |
| 29 | + url: string; |
| 30 | + certificateAuthorities?: Buffer[]; |
| 31 | + log: ToolingLog; |
| 32 | + uiSettingDefaults?: UiSettingValues; |
| 33 | +} |
| 34 | + |
28 | 35 | export class KbnClient { |
29 | | - private readonly requester = new KbnClientRequester(this.log, this.kibanaConfig); |
30 | | - readonly status = new KbnClientStatus(this.requester); |
31 | | - readonly plugins = new KbnClientPlugins(this.status); |
32 | | - readonly version = new KbnClientVersion(this.status); |
33 | | - readonly savedObjects = new KbnClientSavedObjects(this.log, this.requester); |
34 | | - readonly uiSettings = new KbnClientUiSettings(this.log, this.requester, this.uiSettingDefaults); |
| 36 | + readonly status: KbnClientStatus; |
| 37 | + readonly plugins: KbnClientPlugins; |
| 38 | + readonly version: KbnClientVersion; |
| 39 | + readonly savedObjects: KbnClientSavedObjects; |
| 40 | + readonly uiSettings: KbnClientUiSettings; |
| 41 | + |
| 42 | + private readonly requester: KbnClientRequester; |
| 43 | + private readonly log: ToolingLog; |
| 44 | + private readonly uiSettingDefaults?: UiSettingValues; |
35 | 45 |
|
36 | 46 | /** |
37 | 47 | * Basic Kibana server client that implements common behaviors for talking |
38 | 48 | * to the Kibana server from dev tooling. |
39 | | - * |
40 | | - * @param log ToolingLog |
41 | | - * @param kibanaUrls Array of kibana server urls to send requests to |
42 | | - * @param uiSettingDefaults Map of uiSetting values that will be merged with all uiSetting resets |
43 | 49 | */ |
44 | | - constructor( |
45 | | - private readonly log: ToolingLog, |
46 | | - private readonly kibanaConfig: KibanaConfig, |
47 | | - private readonly uiSettingDefaults?: UiSettingValues |
48 | | - ) { |
49 | | - if (!kibanaConfig.url) { |
50 | | - throw new Error('missing Kibana urls'); |
| 50 | + constructor(options: KbnClientOptions) { |
| 51 | + if (!options.url) { |
| 52 | + throw new Error('missing Kibana url'); |
51 | 53 | } |
| 54 | + if (!options.log) { |
| 55 | + throw new Error('missing ToolingLog'); |
| 56 | + } |
| 57 | + |
| 58 | + this.log = options.log; |
| 59 | + this.uiSettingDefaults = options.uiSettingDefaults; |
| 60 | + |
| 61 | + this.requester = new KbnClientRequester(this.log, { |
| 62 | + url: options.url, |
| 63 | + certificateAuthorities: options.certificateAuthorities, |
| 64 | + }); |
| 65 | + this.status = new KbnClientStatus(this.requester); |
| 66 | + this.plugins = new KbnClientPlugins(this.status); |
| 67 | + this.version = new KbnClientVersion(this.status); |
| 68 | + this.savedObjects = new KbnClientSavedObjects(this.log, this.requester); |
| 69 | + this.uiSettings = new KbnClientUiSettings(this.log, this.requester, this.uiSettingDefaults); |
52 | 70 | } |
53 | 71 |
|
54 | 72 | /** |
|
0 commit comments