Skip to content

Commit

Permalink
Merge branch 'main' into eui/55.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Apr 27, 2022
2 parents 35bd584 + 56d0112 commit f017309
Show file tree
Hide file tree
Showing 30 changed files with 1,279 additions and 78 deletions.
6 changes: 3 additions & 3 deletions docs/api/machine-learning/sync.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ it is added. This list contains the {dfeed} identifiers and indicates whether
the synchronization was successful.

`datafeedsRemoved`::
(array) If saved objects exist for {dfeeds} that no longer exist, they are
deleted. This list contains the {dfeed} identifiers and indicates whether the
synchronization was successful.
(array) If a saved object for an anomaly detection job references a datafeed
that no longer exists, it is deleted. This list contains the {dfeed} identifiers
and indicates whether the synchronization was successful.

`savedObjectsCreated`::
(array) If saved objects are missing for {ml} jobs or trained models, they are
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@
"@types/redux-logger": "^3.0.8",
"@types/resolve": "^1.20.1",
"@types/seedrandom": ">=2.0.0 <4.0.0",
"@types/selenium-webdriver": "^4.0.18",
"@types/selenium-webdriver": "^4.0.19",
"@types/semver": "^7",
"@types/set-value": "^2.0.0",
"@types/sinon": "^7.0.13",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ import * as TEXT from '../translations';
import cisLogoIcon from '../../../assets/icons/cis_logo.svg';
import k8sLogoIcon from '../../../assets/icons/k8s_logo.svg';
import { ResourceTab } from './resource_tab';
import { JsonTab } from './json_tab';

const tabs = ['remediation', 'resource', 'general'] as const;
const tabs = ['remediation', 'resource', 'general', 'json'] as const;

const CodeBlock: React.FC<PropsOf<typeof EuiCodeBlock>> = (props) => (
<EuiCodeBlock {...props} isCopyable paddingSize="s" />
Expand Down Expand Up @@ -80,6 +81,8 @@ const FindingsTab = ({ tab, findings }: { findings: CspFinding; tab: FindingsTab
return <ResourceTab data={findings} />;
case 'general':
return <Cards data={getGeneralCards(findings)} />;
case 'json':
return <JsonTab data={findings} />;
default:
assertNever(tab);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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 React from 'react';
import { CodeEditor } from '@kbn/kibana-react-plugin/public';
import { XJsonLang } from '@kbn/monaco';
import { CspFinding } from '../types';

const offsetHeight = 120;

export const JsonTab = ({ data }: { data: CspFinding }) => (
<div style={{ position: 'absolute', inset: 0, top: offsetHeight }}>
<CodeEditor
isCopyable
allowFullScreen
languageId={XJsonLang.ID}
value={JSON.stringify(data, null, 2)}
options={{
readOnly: true,
lineNumbers: 'on',
folding: true,
}}
/>
</div>
);
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const AuditLogsModal: React.FC = () => {
},
{
type: 'field',
field: 'outcome',
field: 'event.outcome',
header: i18n.translate(
'xpack.enterpriseSearch.appSearch.engines.auditLogsModal.headers.outcome',
{
Expand All @@ -101,7 +101,8 @@ export const AuditLogsModal: React.FC = () => {
),
},
{
type: 'message',
type: 'field',
field: 'message',
width: '50%',
},
]}
Expand Down
20 changes: 20 additions & 0 deletions x-pack/plugins/ml/common/openapi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# OpenAPI (Experimental)

The current self-contained spec file can be used for online tools like those found at https://openapi.tools/. This spec is experimental and may be incomplete or change later.

A guide about the openApi specification can be found at [https://swagger.io/docs/specification/about/](https://swagger.io/docs/specification/about/).

## Tools

It is possible to validate the docs before bundling them by running the following command in the `x-pack/plugins/ml/common/openapi/` folder:
```
npx swagger-cli validate ml_apis.yaml
```

Then generate the `bundled` files with the following commands:

```
npx @redocly/openapi-cli bundle --ext yaml --output bundled.yaml ml_apis.yaml
npx @redocly/openapi-cli bundle --ext json --output bundled.json ml_apis.yaml
```

225 changes: 225 additions & 0 deletions x-pack/plugins/ml/common/openapi/bundled.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
{
"openapi": "3.0.1",
"info": {
"title": "Machine learning APIs",
"description": "Kibana APIs for the machine learning feature",
"version": "1.0.0",
"license": {
"name": "Elastic License 2.0",
"url": "https://www.elastic.co/licensing/elastic-license"
}
},
"tags": [
{
"name": "ml",
"description": "Machine learning"
}
],
"servers": [
{
"url": "https://localhost:5601/"
}
],
"paths": {
"/s/{spaceId}/api/ml/saved_objects/sync": {
"get": {
"description": "Synchronizes Kibana saved objects for machine learning jobs and trained models. You must have `all` privileges for the **Machine Learning** feature in the **Analytics** section of the Kibana feature privileges. This API runs automatically when you start Kibana and periodically thereafter.\n",
"parameters": [
{
"$ref": "#/components/parameters/spaceParam"
},
{
"$ref": "#/components/parameters/simulateParam"
}
],
"responses": {
"200": {
"description": "Indicates a successful call",
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/syncResponse"
}
}
}
}
}
}
}
},
"/api/ml/saved_objects/sync": {
"get": {
"description": "Synchronizes Kibana saved objects for machine learning jobs and trained models. You must have `all` privileges for the **Machine Learning** feature in the **Analytics** section of the Kibana feature privileges. This API runs automatically when you start Kibana and periodically thereafter.\n",
"parameters": [
{
"$ref": "#/components/parameters/simulateParam"
}
],
"responses": {
"200": {
"description": "Indicates a successful call",
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/syncResponse"
}
}
}
}
}
}
}
}
},
"components": {
"parameters": {
"spaceParam": {
"in": "path",
"name": "spaceId",
"description": "An identifier for the space.",
"required": true,
"schema": {
"type": "string"
}
},
"simulateParam": {
"in": "query",
"name": "simulate",
"description": "When true, simulates the synchronization by returning only the list actions that would be performed.",
"required": false,
"schema": {
"type": "boolean"
},
"example": "true"
}
},
"securitySchemes": {
"basicAuth": {
"type": "http",
"scheme": "basic"
}
},
"schemas": {
"syncResponse": {
"type": "object",
"properties": {
"datafeedsAdded": {
"type": "object",
"description": "If a saved object for an anomaly detection job is missing a datafeed identifier, it is added. This list contains the datafeed identifiers and indicates whether the synchronization was successful.",
"additionalProperties": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
}
}
}
},
"datafeedsRemoved": {
"type": "object",
"description": "If a saved object for an anomaly detection job references a datafeed that no longer exists, it is deleted. This list contains the datafeed identifiers and indicates whether the synchronization was successful.",
"additionalProperties": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
}
}
}
},
"savedObjectsCreated": {
"type": "object",
"description": "If saved objects are missing for machine learning jobs or trained models, they are created. This list contains the job and model identifiers and indicates whether the synchronization was successful.",
"properties": {
"anomaly-detector": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": true
}
}
}
},
"data-frame-analytics": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": true
}
}
}
},
"trained-model": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": true
}
}
}
}
}
},
"savedObjectsDeleted": {
"type": "object",
"description": "If saved objects exist for machine learning jobs or trained models that no longer exist, they are deleted. This list contains the job and model identifiers and indicates whether the synchronization was successful.",
"properties": {
"anomaly-detector": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": true
}
}
}
},
"data-frame-analytics": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": true
}
}
}
},
"trained-model": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"example": true
}
}
}
}
}
}
}
}
}
},
"security": [
{
"basicAuth": []
}
]
}
Loading

0 comments on commit f017309

Please sign in to comment.