Skip to content

Commit

Permalink
[Enterprise Search] Update config template for self managed connector…
Browse files Browse the repository at this point in the history
  • Loading branch information
efegurkan committed Aug 25, 2023
1 parent a8fd321 commit 0b2b482
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { createApiLogic } from '../../../shared/api_logic/create_api_logic';
import { HttpLogic } from '../../../shared/http';

interface ApiKey {
export interface ApiKey {
api_key: string;
encoded: string;
id: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { FormattedMessage } from '@kbn/i18n-react';

import { ConnectorStatus } from '../../../../../../common/types/connectors';
import { BetaConnectorCallout } from '../../../../shared/beta/beta_connector_callout';
import { useCloudDetails } from '../../../../shared/cloud_details/cloud_details';
import { docLinks } from '../../../../shared/doc_links';
import { generateEncodedPath } from '../../../../shared/encode_path_params';
import { EuiButtonTo, EuiLinkTo } from '../../../../shared/react_router_helpers';
Expand All @@ -45,14 +46,16 @@ import { SearchIndexTabId } from '../search_index';
import { ApiKeyConfig } from './api_key_configuration';
import { ConnectorConfigurationConfig } from './connector_configuration_config';
import { ConnectorNameAndDescription } from './connector_name_and_description/connector_name_and_description';
import { BETA_CONNECTORS, CONNECTORS } from './constants';
import { BETA_CONNECTORS, CONNECTORS, getConnectorTemplate } from './constants';
import { NativeConnectorConfiguration } from './native_connector_configuration/native_connector_configuration';

export const ConnectorConfiguration: React.FC = () => {
const { data: apiKeyData } = useValues(GenerateConnectorApiKeyApiLogic);
const { index, recheckIndexLoading } = useValues(IndexViewLogic);
const { indexName } = useValues(IndexNameLogic);
const { recheckIndex } = useActions(IndexViewLogic);
const cloudContext = useCloudDetails();

if (!isConnectorIndex(index)) {
return <></>;
}
Expand Down Expand Up @@ -151,15 +154,14 @@ export const ConnectorConfiguration: React.FC = () => {
</EuiText>
<EuiSpacer />
<EuiCodeBlock fontSize="m" paddingSize="m" color="dark" isCopyable>
{`connectors:
-
connector_id: "${index.connector.id}"
service_type: "${index.connector.service_type || 'changeme'}"${
apiKeyData?.encoded
? `
api_key: "${apiKeyData?.encoded}"`
: ''
}`}
{getConnectorTemplate({
apiKeyData,
connectorData: {
id: index.connector.id,
service_type: index.connector.service_type,
},
host: cloudContext.elasticsearchUrl,
})}
</EuiCodeBlock>
<EuiSpacer />
<EuiText size="s">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
* 2.0.
*/

import dedent from 'dedent';

import { CONNECTOR_DEFINITIONS } from '../../../../../../common/connectors/connectors';

import { docLinks } from '../../../../shared/doc_links';
import { CONNECTOR_ICONS } from '../../../../shared/icons/connector_icons';
import { ApiKey } from '../../../api/connector/generate_connector_api_key_api_logic';

import { ConnectorClientSideDefinition } from './types';

Expand Down Expand Up @@ -163,3 +166,29 @@ export const CUSTOM_CONNECTORS = CONNECTORS.filter(({ isNative }) => !isNative);
export const NATIVE_CONNECTORS = CONNECTORS.filter(({ isNative }) => isNative);

export const BETA_CONNECTORS = CONNECTORS.filter(({ isBeta }) => isBeta);

export const getConnectorTemplate = ({
apiKeyData,
connectorData,
host,
}: {
apiKeyData: ApiKey | undefined;
connectorData: {
id: string;
service_type: string | null;
};
host?: string;
}) => dedent`connectors:
-
connector_id: "${connectorData.id}"
service_type: "${connectorData.service_type || 'changeme'}"${
apiKeyData?.encoded
? `
api_key: "${apiKeyData?.encoded}"`
: ''
}
elasticsearch:
host: "${host || 'https://locahost:9200'}"
api_key: "${apiKeyData?.encoded || ''}"
`;

0 comments on commit 0b2b482

Please sign in to comment.