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.
[8.6] [Enterprise Search] Set featureset on native connector creation (…
…elastic#146534) (elastic#146543) # Backport This will backport the following commits from `main` to `8.6`: - [[Enterprise Search] Set featureset on native connector creation (elastic#146534)](elastic#146534) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Sander Philipse","email":"[email protected]"},"sourceCommit":{"committedDate":"2022-11-29T13:16:26Z","message":"[Enterprise Search] Set featureset on native connector creation (elastic#146534)\n\nThis moves setting native connector features to selecting a connector\r\ntype.","sha":"7c557a26cd1b35e94a1c1b7a88e85ac38d3cd6e3","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","auto-backport","Team:EnterpriseSearch","v8.6.0","v8.7.0"],"number":146534,"url":"https://github.com/elastic/kibana/pull/146534","mergeCommit":{"message":"[Enterprise Search] Set featureset on native connector creation (elastic#146534)\n\nThis moves setting native connector features to selecting a connector\r\ntype.","sha":"7c557a26cd1b35e94a1c1b7a88e85ac38d3cd6e3"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/146534","number":146534,"mergeCommit":{"message":"[Enterprise Search] Set featureset on native connector creation (elastic#146534)\n\nThis moves setting native connector features to selecting a connector\r\ntype.","sha":"7c557a26cd1b35e94a1c1b7a88e85ac38d3cd6e3"}}]}] BACKPORT--> Co-authored-by: Sander Philipse <[email protected]>
- Loading branch information
1 parent
85e6fc5
commit 6249c39
Showing
8 changed files
with
203 additions
and
129 deletions.
There are no files selected for viewing
133 changes: 133 additions & 0 deletions
133
x-pack/plugins/enterprise_search/common/connectors/native_connectors.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,133 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
|
||
import { FeatureName, NativeConnector } from '../types/connectors'; | ||
|
||
export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | undefined> = { | ||
mongodb: { | ||
configuration: { | ||
host: { | ||
label: i18n.translate( | ||
'xpack.enterpriseSearch.nativeConnectors.mongodb.configuration.hostLabel', | ||
{ | ||
defaultMessage: 'Host', | ||
} | ||
), | ||
value: '', | ||
}, | ||
user: { | ||
label: i18n.translate( | ||
'xpack.enterpriseSearch.nativeConnectors.mongodb.configuration.usernameLabel', | ||
{ | ||
defaultMessage: 'Username', | ||
} | ||
), | ||
value: '', | ||
}, | ||
password: { | ||
label: i18n.translate( | ||
'xpack.enterpriseSearch.nativeConnectors.mongodb.configuration.passwordLabel', | ||
{ | ||
defaultMessage: 'Password', | ||
} | ||
), | ||
value: '', | ||
}, | ||
database: { | ||
label: i18n.translate( | ||
'xpack.enterpriseSearch.nativeConnectors.mongodb.configuration.databaseLabel', | ||
{ | ||
defaultMessage: 'Database', | ||
} | ||
), | ||
value: '', | ||
}, | ||
collection: { | ||
label: i18n.translate( | ||
'xpack.enterpriseSearch.nativeConnectors.mongodb.configuration.collectionLabel', | ||
{ | ||
defaultMessage: 'Collection', | ||
} | ||
), | ||
value: '', | ||
}, | ||
direct_connection: { | ||
label: i18n.translate( | ||
'xpack.enterpriseSearch.nativeConnectors.mongodb.configuration.directConnectionLabel', | ||
{ | ||
defaultMessage: 'Direct connection (true/false)', | ||
} | ||
), | ||
value: '', | ||
}, | ||
}, | ||
features: { | ||
[FeatureName.FILTERING_ADVANCED_CONFIG]: true, | ||
[FeatureName.FILTERING_RULES]: true, | ||
}, | ||
name: i18n.translate('xpack.enterpriseSearch.nativeConnectors.mongodb.name', { | ||
defaultMessage: 'MongoDB', | ||
}), | ||
serviceType: 'mongodb', | ||
}, | ||
mysql: { | ||
configuration: { | ||
host: { | ||
label: i18n.translate( | ||
'xpack.enterpriseSearch.nativeConnectors.mysql.configuration.hostLabel', | ||
{ | ||
defaultMessage: 'Host', | ||
} | ||
), | ||
value: '', | ||
}, | ||
port: { | ||
label: i18n.translate( | ||
'xpack.enterpriseSearch.nativeConnectors.mysql.configuration.portLabel', | ||
{ | ||
defaultMessage: 'Port', | ||
} | ||
), | ||
value: '', | ||
}, | ||
user: { | ||
label: i18n.translate( | ||
'xpack.enterpriseSearch.nativeConnectors.mysql.configuration.usernameLabel', | ||
{ | ||
defaultMessage: 'Username', | ||
} | ||
), | ||
value: '', | ||
}, | ||
password: { | ||
value: '', | ||
label: i18n.translate( | ||
'xpack.enterpriseSearch.nativeConnectors.mysql.configuration.passwordLabel', | ||
{ | ||
defaultMessage: 'Password', | ||
} | ||
), | ||
}, | ||
database: { | ||
label: i18n.translate( | ||
'xpack.enterpriseSearch.nativeConnectors.mysql.configuration.databasesLabel', | ||
{ | ||
defaultMessage: 'Databases', | ||
} | ||
), | ||
value: '', | ||
}, | ||
}, | ||
features: {}, | ||
name: i18n.translate('xpack.enterpriseSearch.nativeConnectors.mysql.name', { | ||
defaultMessage: 'MySQL', | ||
}), | ||
serviceType: 'mysql', | ||
}, | ||
}; |
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
39 changes: 39 additions & 0 deletions
39
x-pack/plugins/enterprise_search/server/lib/connectors/put_configure_native.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,39 @@ | ||
/* | ||
* 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 { IScopedClusterClient } from '@kbn/core-elasticsearch-server'; | ||
|
||
import { CONNECTORS_INDEX } from '../..'; | ||
import { NATIVE_CONNECTOR_DEFINITIONS } from '../../../common/connectors/native_connectors'; | ||
import { Connector, ConnectorStatus } from '../../../common/types/connectors'; | ||
|
||
export const configureNativeConnector = async ( | ||
client: IScopedClusterClient, | ||
connectorId: string, | ||
serviceType: string | ||
): Promise<boolean> => { | ||
const nativeConnector = NATIVE_CONNECTOR_DEFINITIONS[serviceType]; | ||
|
||
if (!nativeConnector) { | ||
throw new Error(`Could not find connector definition for service type ${serviceType}`); | ||
} | ||
|
||
const result = await client.asCurrentUser.update<Connector>({ | ||
doc: { | ||
configuration: nativeConnector.configuration, | ||
features: nativeConnector.features, | ||
name: nativeConnector.name, | ||
service_type: serviceType, | ||
status: ConnectorStatus.NEEDS_CONFIGURATION, | ||
}, | ||
id: connectorId, | ||
index: CONNECTORS_INDEX, | ||
refresh: true, | ||
}); | ||
|
||
return result.result === 'updated' ? true : false; | ||
}; |
Oops, something went wrong.