-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Derek Ho <dxho@amazon.com>
- Loading branch information
Showing
8 changed files
with
457 additions
and
2 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
245 changes: 245 additions & 0 deletions
245
public/components/datasources/components/new/configure_cloudwatch_datasource.tsx
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,245 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { | ||
EuiPanel, | ||
EuiTitle, | ||
EuiSpacer, | ||
EuiText, | ||
EuiLink, | ||
EuiFormRow, | ||
EuiFieldText, | ||
EuiTextArea, | ||
EuiSelect, | ||
} from '@elastic/eui'; | ||
import React, { useState } from 'react'; | ||
import { | ||
AuthMethod, | ||
OPENSEARCH_DOCUMENTATION_URL, | ||
} from '../../../../../common/constants/data_connections'; | ||
import { QueryPermissionsConfiguration } from './query_permissions'; | ||
import { Role } from '../../../../../common/types/data_connections'; | ||
import { AuthDetails } from './auth_details'; | ||
import { NameRow } from './name_row'; | ||
|
||
export interface ConfigureCloudWatchDatasourceProps { | ||
roles: Role[]; | ||
selectedQueryPermissionRoles: Role[]; | ||
setSelectedQueryPermissionRoles: React.Dispatch<React.SetStateAction<Role[]>>; | ||
currentName: string; | ||
currentDetails: string; | ||
currentArn: string; | ||
currentStore: string; | ||
currentAuthMethod: AuthMethod; | ||
currentUsername: string; | ||
currentPassword: string; | ||
hasSecurityAccess: boolean; | ||
error: string; | ||
currentRegion: string; | ||
setRegionForRequest: React.Dispatch<React.SetStateAction<string>>; | ||
setError: React.Dispatch<React.SetStateAction<string>>; | ||
setAuthMethodForRequest: React.Dispatch<React.SetStateAction<AuthMethod>>; | ||
setPasswordForRequest: React.Dispatch<React.SetStateAction<string>>; | ||
setUsernameForRequest: React.Dispatch<React.SetStateAction<string>>; | ||
setStoreForRequest: React.Dispatch<React.SetStateAction<string>>; | ||
setNameForRequest: React.Dispatch<React.SetStateAction<string>>; | ||
setDetailsForRequest: React.Dispatch<React.SetStateAction<string>>; | ||
setArnForRequest: React.Dispatch<React.SetStateAction<string>>; | ||
} | ||
|
||
export const ConfigureCloudWatchDatasource = (props: ConfigureCloudWatchDatasourceProps) => { | ||
const { | ||
setNameForRequest, | ||
setDetailsForRequest, | ||
setArnForRequest, | ||
setStoreForRequest, | ||
currentStore, | ||
currentName, | ||
currentDetails, | ||
currentArn, | ||
roles, | ||
currentAuthMethod, | ||
setAuthMethodForRequest, | ||
selectedQueryPermissionRoles, | ||
setSelectedQueryPermissionRoles, | ||
currentPassword, | ||
currentUsername, | ||
setPasswordForRequest, | ||
setUsernameForRequest, | ||
hasSecurityAccess, | ||
error, | ||
setError, | ||
currentRegion, | ||
setRegionForRequest, | ||
} = props; | ||
|
||
const [details, setDetails] = useState(currentDetails); | ||
const [arn, setArn] = useState(currentArn); | ||
const [region, setRegion] = useState(currentRegion); | ||
const [store, setStore] = useState(currentStore); | ||
const authOptions = [ | ||
{ value: 'basicauth', text: 'Basic authentication' }, | ||
{ value: 'noauth', text: 'No authentication' }, | ||
]; | ||
|
||
return ( | ||
<div> | ||
<EuiPanel> | ||
<EuiTitle> | ||
<h1>{`Configure Amazon CloudWatch Logs data source`}</h1> | ||
</EuiTitle> | ||
<EuiSpacer size="s" /> | ||
<EuiText size="s" color="subdued"> | ||
{`Connect to Amazon CloudWatch Logs with OpenSearch and OpenSearch Dashboards. `} | ||
<EuiLink external={true} href={OPENSEARCH_DOCUMENTATION_URL} target="blank"> | ||
Learn more | ||
</EuiLink> | ||
</EuiText> | ||
<EuiSpacer /> | ||
<EuiText> | ||
<h3>Data source details</h3> | ||
</EuiText> | ||
<EuiSpacer /> | ||
<NameRow | ||
key={error} | ||
currentName={currentName} | ||
setNameForRequest={setNameForRequest} | ||
currentError={error} | ||
setErrorForForm={setError} | ||
/> | ||
<EuiFormRow label="Description - Optional"> | ||
<EuiTextArea | ||
placeholder="Describe data source" | ||
value={details} | ||
onBlur={(e) => { | ||
setDetailsForRequest(e.target.value); | ||
}} | ||
onChange={(e) => { | ||
setDetails(e.target.value); | ||
}} | ||
/> | ||
</EuiFormRow> | ||
<EuiSpacer /> | ||
|
||
<EuiText> | ||
<h3>Amazon CloudWatch Logs</h3> | ||
</EuiText> | ||
<EuiSpacer /> | ||
|
||
<EuiFormRow label="Amazon CloudWatch Logs region"> | ||
<> | ||
<EuiText size="xs"> | ||
<p>This should be the region for Amazon CloudWatch Logs</p> | ||
</EuiText> | ||
<EuiFieldText | ||
data-test-subj="region" | ||
placeholder="Region" | ||
value={region} | ||
onChange={(e) => { | ||
setRegion(e.target.value); | ||
}} | ||
onBlur={(e) => { | ||
setRegionForRequest(e.target.value); | ||
}} | ||
/> | ||
</> | ||
</EuiFormRow> | ||
|
||
<EuiFormRow label="Authentication Method"> | ||
<> | ||
<EuiText size="xs"> | ||
<p> | ||
This parameter provides the authentication type information required for execution | ||
engine to connect to Amazon CloudWatch Logs. | ||
</p> | ||
</EuiText> | ||
<EuiFieldText data-test-subj="authentication-method" value="IAM role" disabled /> | ||
</> | ||
</EuiFormRow> | ||
|
||
<EuiFormRow label="Amazon CloudWatch Logs authentication ARN"> | ||
<> | ||
<EuiText size="xs"> | ||
<p>This should be the IAM role ARN</p> | ||
</EuiText> | ||
<EuiFieldText | ||
data-test-subj="role-ARN" | ||
placeholder="Role ARN" | ||
value={arn} | ||
onChange={(e) => { | ||
setArn(e.target.value); | ||
}} | ||
onBlur={(e) => { | ||
setArnForRequest(e.target.value); | ||
}} | ||
/> | ||
</> | ||
</EuiFormRow> | ||
|
||
<EuiSpacer /> | ||
|
||
<EuiText> | ||
<h3>Amazon CloudWatch Logs index store details</h3> | ||
</EuiText> | ||
<EuiSpacer /> | ||
|
||
<EuiFormRow label="Amazon CloudWatch Logs index store URI"> | ||
<> | ||
<EuiText size="xs"> | ||
<p> | ||
This parameter provides the OpenSearch cluster host information for Amazon | ||
CloudWatch Logs. This OpenSearch instance is used for writing index data back. | ||
</p> | ||
</EuiText> | ||
<EuiFieldText | ||
data-test-subj="index-URI" | ||
placeholder="Index store URI" | ||
value={store} | ||
onChange={(e) => { | ||
setStore(e.target.value); | ||
}} | ||
onBlur={(e) => { | ||
setStoreForRequest(e.target.value); | ||
}} | ||
/> | ||
</> | ||
</EuiFormRow> | ||
|
||
<EuiFormRow label="Amazon CloudWatch Logs index store authentication"> | ||
<> | ||
<EuiText size="xs"> | ||
<p>Authentication settings to access the index store.</p> | ||
</EuiText> | ||
<EuiSelect | ||
id="selectAuthMethod" | ||
options={authOptions} | ||
value={currentAuthMethod} | ||
onChange={(e) => { | ||
setAuthMethodForRequest(e.target.value as AuthMethod); | ||
}} | ||
/> | ||
</> | ||
</EuiFormRow> | ||
<AuthDetails | ||
currentUsername={currentUsername} | ||
setUsernameForRequest={setUsernameForRequest} | ||
currentPassword={currentPassword} | ||
setPasswordForRequest={setPasswordForRequest} | ||
currentAuthMethod={currentAuthMethod} | ||
/> | ||
|
||
<EuiSpacer /> | ||
|
||
<QueryPermissionsConfiguration | ||
roles={roles} | ||
selectedRoles={selectedQueryPermissionRoles} | ||
setSelectedRoles={setSelectedQueryPermissionRoles} | ||
layout={'vertical'} | ||
hasSecurityAccess={hasSecurityAccess} | ||
/> | ||
</EuiPanel> | ||
</div> | ||
); | ||
}; |
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
Oops, something went wrong.