Skip to content

Commit

Permalink
Merge branch 'main-create-workspace-OSDAdmin' of github.com:yubonluo/…
Browse files Browse the repository at this point in the history
…OpenSearch-Dashboards into main-create-workspace-OSDAdmin
  • Loading branch information
yubonluo committed Jun 3, 2024
2 parents 35b04bd + edf33c2 commit 4962ab2
Show file tree
Hide file tree
Showing 20 changed files with 400 additions and 17 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/6843.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
refactor:
- Unify getDefaultDataSourceId and export ([#6843](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6843))
2 changes: 2 additions & 0 deletions changelogs/fragments/6879.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Remove unused import and property which broke compilation ([#6879](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6879))
2 changes: 2 additions & 0 deletions changelogs/fragments/6885.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
doc:
- Add OpenAPI specifications for resolve import errors api ([#6885](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6885))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
summary: The export objects API response contains JSON records for each exported object.
value:
{"attributes":{"fields":"[{\"count\":0,\"name\":\"@timestamp\",\"type\":\"date\",\"esTypes\":[\"date\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"count\":0,\"name\":\"customer_gender\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"count\":0,\"name\":\"manufacturer\",\"type\":\"string\",\"esTypes\":[\"text\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":false,\"readFromDocValues\":false},{\"count\":0,\"name\":\"url.keyword\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true,\"subType\":{\"multi\":{\"parent\":\"url\"}}},{\"count\":0,\"name\":\"user\",\"type\":\"string\",\"esTypes\":[\"keyword\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"count\":0,\"name\":\"utc_time\",\"type\":\"date\",\"esTypes\":[\"date\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]","timeFieldName":"@timestamp","title":"open*"},"id":"4b3a6220-1e02-11ef-891d-992edd5ce25b","migrationVersion":{"index-pattern":"7.6.0"},"references":[],"type":"index-pattern","updated_at":"2024-05-29T21:27:47.266Z","version":"Wzc0LDFd"}
2 changes: 2 additions & 0 deletions docs/openapi/saved_objects/examples/import.ndjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"attributes":{"fields":"[{\"count\":0,\"name\":\"@timestamp\",\"type\":\"date\",\"esTypes\":[\"date\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"count\":0,\"name\":\"AvgTicketPrice\",\"type\":\"number\",\"esTypes\":[\"float\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"count\":0,\"name\":\"utc_time\",\"type\":\"date\",\"esTypes\":[\"date\"],\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]","timeFieldName":"@timestamp","title":"open*"},"id":"4b3a6220-1e02-11ef-891d-992edd5ce25b","migrationVersion":{"index-pattern":"7.6.0"},"references":[],"type":"index-pattern","updated_at":"2024-05-29T21:27:47.266Z","version":"Wzc0LDFd"}
{"exportedCount":1,"missingRefCount":0,"missingReferences":[]}
310 changes: 310 additions & 0 deletions docs/openapi/saved_objects/saved_objects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,316 @@ paths:
- id: 67a9021c-c97e-4499-8150-9722ab44edd4
type: visualization
fields: ['title', 'fieldFormatMap']
responses:
'200':
description: The bulk get request is successful.
content:
application/json:
schema:
type: object
/api/saved_objects/_import:
post:
tags:
- saved objects
summary: Create sets of saved objects from a file created through the export API
parameters:
- in: query
name: overwrite
description: Overwrites saved objects when they already exist. This option cannot be used with the `createNewCopies` option.
schema:
type: boolean
default: false
- in: query
name: createNewCopies
description: Creates copies of saved objects, regenerates each object ID, and resets the origin. This option cannot be used with the `overwrite` option.
schema:
type: boolean
default: false
- in: query
name: dataSourceId
description: The ID of the data source to use for the import.
schema:
type: string
- in: query
name: workspace
description: Workspaces that the saved objects exist in.
schema:
oneOf:
- type: string
- type: array
- in: query
name: dataSourceEnabled
description: If set to true, will enable the multiple data source.
schema:
type: boolean
default: false
requestBody:
required: true
description: The ndjson file containing the saved objects to import
content:
multipart/form-data:
schema:
type: object
properties:
file:
description: |
A file exported using the export API. NOTE: The `savedObjects.maxImportExportSize` and `savedObjects.maxImportPayloadBytes` settings in the config file determine the maximum size of the file that can be imported.
example:
importObjectRequest:
summary: Example of importing saved objects
value:
$ref: '../examples/import.ndjson'
responses:
'200':
description: The import request is successful.
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
description: Indicates if the import was successful.
successCount:
type: integer
description: The number of successful imports.
errors:
type: array
description: Indicates the import was unsuccessful and specifies the objects that failed to import.
items:
type: object
successResults:
type: array
description: Indicates the objects that are successfully imported, with any metadata if applicable.
items:
type: object
examples:
importObjectSuccessResponse:
summary: Example of successful import
value:
success: true
successCount: 1
successResults:
- type: index-pattern
id: 4b3a6220-1e02-11ef-891d-992edd5ce25b
meta:
title: 'opensearch_dashboards_sample_data_ecommerce'
icon: indexPatternApp
overwrite: true
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/400_bad_request'
/api/saved_objects/_export:
post:
tags:
- saved objects
summary: Export set of saved objects into ndjson file
requestBody:
required: true
description: Can use type, objects and search to filter the objects to export
content:
application/json:
schema:
type: object
properties:
type:
oneOf:
- type: string
- type: array
items:
type: string
description: The saved object types to include in the export. Use * to export all the types.
objects:
type: array
items:
type: object
properties:
id:
type: string
required: true
description: Unique id of the saved object.
type:
type: string
required: true
description: The type of saved object.
description: The list of saved objects to export.
search:
type: string
description: The simple_query_string query that filters the objects.
includeReferencesDeep:
type: boolean
default: false
description: If set to true, will include references of the saved objects.
excludeExportDetails:
type: boolean
default: false
description: If set to true, will exclude export details at the end of the stream.
workspace:
type: array
items:
type: string
description: Workspaces that the saved objects exist in.
examples:
exportDashboards:
summary: Example of exporting dashboards
value:
objects:
- id: 67a9021c-c97e-4499-8150-9722ab44edd4
type: dashboard
includeReferencesDeep: true
excludeExportDetails: false
exportIndexPatterns:
summary: Example of exporting index patterns
value:
objects:
- id: 4b3a6220-1e02-11ef-891d-992edd5ce25b
type: index-pattern
includeReferencesDeep: false
excludeExportDetails: true
responses:
'200':
description: The export request is successful.
content:
application/x-ndjson:
schema:
type: object
examples:
exportSavedObjectsResponse:
$ref: '../examples/export_objects_response.yaml'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/400_bad_request'
/api/saved_objects/_resolve_import_errors:
post:
tags:
- saved objects
summary: Resolve import errors from import objects API
parameters:
- in: query
name: createNewCopies
description: Creates copies of saved objects, regenerates each object ID, and resets the origin.
schema:
type: boolean
default: false
- in: query
name: dataSourceId
description: The ID of the data source to use for the import.
schema:
type: string
- in: query
name: workspace
description: Workspaces that the saved objects exist in.
schema:
oneOf:
- type: string
- type: array
requestBody:
required: true
description: The request body must include the multipart/form-data type.
content:
multipart/form-data:
schema:
type: object
properties:
file:
description: The same file given to the import API.
type: string
format: binary
retries:
description: The retry operations, which can specify how to resolve different types of errors.
type: array
items:
type: object
properties:
type:
type: string
description: The type of error to resolve.
id:
type: string
description: The ID of the saved object.
overwrite:
type: boolean
default: false
description: If set to true, will overwrite the existing saved object with the same type and ID.
destinationId:
type: string
description: Specifies the destination ID that the imported object should have, if different from the current ID.
replaceReferences:
description: A list of `type`, `from`, and `to` used to change the object references.
type: array
items:
type: object
properties:
type:
type: string
from:
type: string
to:
type: string
createNewCopy:
type: boolean
description: If set to true, will create a copy of the saved objects, regenerates each object ID, and resets the origin.
ignoreMissingReferences:
type: boolean
description: If set to true, will ignore missing references. When set to `false`, does nothing.
examples:
resolveImportErrorsRequest:
summary: Example of resolving import errors
value:
file: 'import.ndjson'
retries:
- type: index-pattern
id: 4b3a6220-1e02-11ef-891d-992edd5ce25b
overwrite: true
responses:
'200':
description: The resolve import errors request is successful.
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
description: Indicates if the import was successful.
successCount:
type: integer
description: The number of successful imports.
errors:
type: array
description: Indicates the import was unsuccessful and specifies the objects that failed to import.
items:
type: object
successResults:
type: array
description: Indicates the objects that are successfully imported, with any metadata if applicable.
items:
type: object
examples:
resolveImportErrorSuccessResponse:
summary: Example of successful import
value:
success: true
successCount: 1
successResults:
- type: index-pattern
id: 4b3a6220-1e02-11ef-891d-992edd5ce25b
meta:
title: 'opensearch_dashboards_sample_data_ecommerce'
icon: indexPatternApp
overwrite: true
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/400_bad_request'
components:
parameters:
type:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { CoreStart, MountPoint } from 'opensearch-dashboards/public';
import {
DataSourceManagementPluginSetup,
DataSourceViewConfig,
DataSourceSelectionService,
} from 'src/plugins/data_source_management/public';
import { ComponentProp } from './types';
import { COLUMNS } from './constants';
Expand Down Expand Up @@ -89,7 +88,6 @@ export const DataSourceViewExample = ({
setSelectedDataSources(ds);
},
}}
dataSourceSelection={new DataSourceSelectionService()}
/>
);
}, [setActionMenu, notifications, savedObjects]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ export const NO_DATASOURCES_CONNECTED_MESSAGE = 'No data sources connected yet.'
export const CONNECT_DATASOURCES_MESSAGE = 'Connect your data sources to get started.';
export const NO_COMPATIBLE_DATASOURCES_MESSAGE = 'No compatible data sources are available.';
export const ADD_COMPATIBLE_DATASOURCES_MESSAGE = 'Add a compatible data source.';

export const DEFAULT_DATA_SOURCE_UI_SETTINGS_ID = 'defaultDataSource';
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
handleNoAvailableDataSourceError,
generateComponentId,
getDataSourceSelection,
getDefaultDataSourceId,
} from '../utils';
import { SavedObject } from '../../../../../core/public';
import { DataSourceAttributes } from '../../types';
Expand Down Expand Up @@ -132,7 +133,7 @@ export class DataSourceAggregatedView extends React.Component<
this.setState({
...this.state,
allDataSourcesIdToTitleMap,
defaultDataSource: this.props.uiSettings?.get('defaultDataSource', null) ?? null,
defaultDataSource: getDefaultDataSourceId(this.props.uiSettings) ?? null,
showEmptyState: allDataSourcesIdToTitleMap.size === 0,
});
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
handleNoAvailableDataSourceError,
generateComponentId,
getDataSourceSelection,
getDefaultDataSourceId,
} from '../utils';
import { DataSourceBaseState } from '../data_source_menu/types';
import { DataSourceErrorMenu } from '../data_source_error_menu';
Expand Down Expand Up @@ -76,7 +77,7 @@ export class DataSourceMultiSelectable extends React.Component<
async componentDidMount() {
this._isMounted = true;
try {
const defaultDataSource = this.props.uiSettings?.get('defaultDataSource', null) ?? null;
const defaultDataSource = getDefaultDataSourceId(this.props.uiSettings) ?? null;
let selectedOptions: SelectedDataSourceOption[] = [];
const fetchedDataSources = await getDataSourcesWithFields(this.props.savedObjectsClient, [
'id',
Expand Down
Loading

0 comments on commit 4962ab2

Please sign in to comment.