Skip to content

Commit

Permalink
[Backport 2.x] Add integrations queries for Flint (opensearch-project…
Browse files Browse the repository at this point in the history
…#1194)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
(cherry picked from commit fe3ebaf)
  • Loading branch information
opensearch-trigger-bot[bot] authored and A9 Swift Project User committed Jan 8, 2024
1 parent e3ef043 commit 4e51ea1
Show file tree
Hide file tree
Showing 11 changed files with 239 additions and 52 deletions.
4 changes: 2 additions & 2 deletions auto_sync_commit_metadata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"last_github_commit": "1ba75c531f4398aab50abd44f2a85bebe47342b5",
"last_gitfarm_commit": "69f13e377fe148674856cab8ce4c2857d50102c3"
"last_github_commit": "fe3ebafd99ed3d1cb92a4923245b722360cc012f",
"last_gitfarm_commit": "8748ad62979234aedfc552da0be3c9048dad6851"
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
Object {
"connectionDataSource": "",
"connectionLocation": "",
"connectionTableName": "sample",
"connectionType": "index",
"displayName": "sample Integration",
}
Expand Down Expand Up @@ -87,9 +88,15 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
<EuiFormRow
describedByIds={Array []}
display="row"
error={
Array [
"Must be at least 1 character.",
]
}
fullWidth={false}
hasChildLabel={true}
hasEmptyLabelSpace={false}
isInvalid={false}
label="Display Name"
labelType="label"
>
Expand All @@ -101,12 +108,15 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
className="euiFormRow__labelWrapper"
>
<EuiFormLabel
aria-invalid={false}
className="euiFormRow__label"
htmlFor="random_html_id"
isFocused={false}
isInvalid={false}
type="label"
>
<label
aria-invalid={false}
className="euiFormLabel euiFormRow__label"
htmlFor="random_html_id"
>
Expand All @@ -119,6 +129,7 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
>
<EuiFieldText
id="random_html_id"
isInvalid={false}
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
Expand All @@ -135,7 +146,9 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
<div
className="euiFormControlLayout__childrenWrapper"
>
<EuiValidatableControl>
<EuiValidatableControl
isInvalid={false}
>
<input
className="euiFieldText"
id="random_html_id"
Expand Down Expand Up @@ -354,12 +367,14 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
aria-describedby="random_html_id-help-0"
async={false}
compressed={false}
customOptionText="Select {searchValue} as your index"
fullWidth={false}
id="random_html_id"
isClearable={true}
isLoading={true}
onBlur={[Function]}
onChange={[Function]}
onCreateOption={[Function]}
onFocus={[Function]}
options={Array []}
selectedOptions={
Expand Down Expand Up @@ -680,6 +695,7 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
Object {
"connectionDataSource": "",
"connectionLocation": "",
"connectionTableName": "sample",
"connectionType": "index",
"displayName": "sample Integration",
}
Expand Down Expand Up @@ -817,6 +833,7 @@ exports[`Integration Setup Page Renders integration setup page as expected 1`] =
>
<EuiButtonEmpty
color="text"
disabled={false}
iconType="cross"
onClick={[Function]}
>
Expand Down Expand Up @@ -1068,9 +1085,15 @@ exports[`Integration Setup Page Renders the form as expected 1`] = `
<EuiFormRow
describedByIds={Array []}
display="row"
error={
Array [
"Must be at least 1 character.",
]
}
fullWidth={false}
hasChildLabel={true}
hasEmptyLabelSpace={false}
isInvalid={false}
label="Display Name"
labelType="label"
>
Expand All @@ -1082,12 +1105,15 @@ exports[`Integration Setup Page Renders the form as expected 1`] = `
className="euiFormRow__labelWrapper"
>
<EuiFormLabel
aria-invalid={false}
className="euiFormRow__label"
htmlFor="random_html_id"
isFocused={false}
isInvalid={false}
type="label"
>
<label
aria-invalid={false}
className="euiFormLabel euiFormRow__label"
htmlFor="random_html_id"
>
Expand All @@ -1100,6 +1126,7 @@ exports[`Integration Setup Page Renders the form as expected 1`] = `
>
<EuiFieldText
id="random_html_id"
isInvalid={false}
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
Expand All @@ -1116,7 +1143,9 @@ exports[`Integration Setup Page Renders the form as expected 1`] = `
<div
className="euiFormControlLayout__childrenWrapper"
>
<EuiValidatableControl>
<EuiValidatableControl
isInvalid={false}
>
<input
className="euiFieldText"
id="random_html_id"
Expand Down Expand Up @@ -1354,12 +1383,14 @@ exports[`Integration Setup Page Renders the form as expected 1`] = `
aria-describedby="random_html_id-help-0"
async={false}
compressed={false}
customOptionText="Select {searchValue} as your index"
fullWidth={false}
id="random_html_id"
isClearable={true}
isLoading={true}
onBlur={[Function]}
onChange={[Function]}
onCreateOption={[Function]}
onFocus={[Function]}
options={Array []}
selectedOptions={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export async function addIntegrationRequest(
setToast: (title: string, color?: Color, text?: string | undefined) => void,
name?: string,
dataSource?: string
) {
): Promise<boolean> {
const http = coreRefs.http!;
if (addSample) {
createDataSourceMappings(
Expand All @@ -309,7 +309,7 @@ export async function addIntegrationRequest(
dataSource = `ss4o_${integration.type}-${integrationTemplateId}-sample-sample`;
}

const response: boolean = await http
let response: boolean = await http
.post(`${INTEGRATIONS_BASE}/store/${templateName}`, {
body: JSON.stringify({ name, dataSource }),
})
Expand All @@ -323,7 +323,7 @@ export async function addIntegrationRequest(
return false;
});
if (!addSample || !response) {
return;
return response;
}
const data: { sampleData: unknown[] } = await http
.get(`${INTEGRATIONS_BASE}/repository/${templateName}/data`)
Expand All @@ -337,16 +337,21 @@ export async function addIntegrationRequest(
data.sampleData
.map((record) => `{"create": { "_index": "${dataSource}" } }\n${JSON.stringify(record)}`)
.join('\n') + '\n';
http
response = await http
.post(CONSOLE_PROXY, {
body: requestBody,
query: {
path: `${dataSource}/_bulk?refresh=wait_for`,
method: 'POST',
},
})
.then((_) => {
return true;
})
.catch((err) => {
console.error(err);
setToast('Failed to load sample data', 'danger');
return false;
});
return response;
}
Loading

0 comments on commit 4e51ea1

Please sign in to comment.