diff --git a/x-pack/plugins/ml/common/openapi/README.md b/x-pack/plugins/ml/common/openapi/README.md index 28246e8b43d3c5..4b667402817481 100644 --- a/x-pack/plugins/ml/common/openapi/README.md +++ b/x-pack/plugins/ml/common/openapi/README.md @@ -4,17 +4,21 @@ The current self-contained spec file can be used for online tools like those fou A guide about the openApi specification can be found at [https://swagger.io/docs/specification/about/](https://swagger.io/docs/specification/about/). +The `ml_apis_v3.yaml` file uses OpenAPI Specification Version 3.0. + +The `ml_apis_v2.json` file uses OpenAPI Specification Version 2.0. + ## 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 + npx swagger-cli validate ml_apis_v3.yaml ``` -Then generate the `bundled` files with the following commands: +You can optionally generate `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 + npx @redocly/openapi-cli bundle --ext yaml --output bundled.yaml ml_apis_v3.yaml + npx @redocly/openapi-cli bundle --ext json --output bundled.json ml_apis_v3.yaml ``` diff --git a/x-pack/plugins/ml/common/openapi/bundled.json b/x-pack/plugins/ml/common/openapi/bundled.json deleted file mode 100644 index 7814b4c6f5e5e8..00000000000000 --- a/x-pack/plugins/ml/common/openapi/bundled.json +++ /dev/null @@ -1,251 +0,0 @@ -{ - "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": { - "$ref": "#/components/schemas/syncResponse" - }, - "examples": { - "syncExample": { - "$ref": "#/components/examples/syncExample" - } - } - } - } - } - } - } - }, - "/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": { - "$ref": "#/components/schemas/syncResponse" - }, - "examples": { - "syncExample": { - "$ref": "#/components/examples/syncExample" - } - } - } - } - } - } - } - } - }, - "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 - } - } - } - } - } - } - } - } - }, - "examples": { - "syncExample": { - "summary": "Two anomaly detection jobs required synchronization in this example.", - "value": { - "savedObjectsCreated": { - "anomaly_detector": { - "myjob1": { - "success": true - }, - "myjob2": { - "success": true - } - } - }, - "savedObjectsDeleted": {}, - "datafeedsAdded": {}, - "datafeedsRemoved": {} - } - } - } - }, - "security": [ - { - "basicAuth": [] - } - ] -} \ No newline at end of file diff --git a/x-pack/plugins/ml/common/openapi/bundled.yaml b/x-pack/plugins/ml/common/openapi/bundled.yaml deleted file mode 100644 index 0796f0ecf7502a..00000000000000 --- a/x-pack/plugins/ml/common/openapi/bundled.yaml +++ /dev/null @@ -1,184 +0,0 @@ -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. - parameters: - - $ref: '#/components/parameters/spaceParam' - - $ref: '#/components/parameters/simulateParam' - responses: - '200': - description: Indicates a successful call - content: - application/json: - schema: - $ref: '#/components/schemas/syncResponse' - examples: - syncExample: - $ref: '#/components/examples/syncExample' - /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. - parameters: - - $ref: '#/components/parameters/simulateParam' - responses: - '200': - description: Indicates a successful call - content: - application/json: - schema: - $ref: '#/components/schemas/syncResponse' - examples: - syncExample: - $ref: '#/components/examples/syncExample' -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 - examples: - syncExample: - summary: Two anomaly detection jobs required synchronization in this example. - value: - savedObjectsCreated: - anomaly_detector: - myjob1: - success: true - myjob2: - success: true - savedObjectsDeleted: {} - datafeedsAdded: {} - datafeedsRemoved: {} -security: - - basicAuth: [] diff --git a/x-pack/plugins/ml/common/openapi/ml_apis_v2.json b/x-pack/plugins/ml/common/openapi/ml_apis_v2.json new file mode 100644 index 00000000000000..5146a51df12e5c --- /dev/null +++ b/x-pack/plugins/ml/common/openapi/ml_apis_v2.json @@ -0,0 +1,212 @@ +{ + "swagger" : "2.0", + "info" : { + "version" : "1", + "title" : "Machine learning APIs", + "description": "Kibana APIs for the machine learning feature", + "termsOfService" : "", + "license": { + "name": "Elastic License 2.0", + "url": "https://www.elastic.co/licensing/elastic-license" + } + }, + "host" : "localhost:5601", + "basePath" : "/", + "tags" : [ { + "name" : "ml", + "description": "Machine learning" + } ], + "schemes" : [ "https" ], + "security" : [ + { + "basicAuth": [ ] + }, + { + "apiKey" : [ ] + } + ], + "paths" : { + "/s/{spaceId}/api/ml/saved_objects/sync" : { + "get" : { + "tags" : [ "ml" ], + "summary" : "Sync machine learning saved objects", + "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.", + "operationId" : "ml-sync", + "parameters" : [ { + "name" : "spaceId", + "in" : "path", + "description" : "An identifier for the space.", + "required" : true, + "type" : "string" + }, { + "name" : "simulate", + "in" : "query", + "description" : "When true, simulates the synchronization by returning only the list actions that would be performed.", + "required" : false, + "type" : "boolean", + "default" : false + } ], + "responses" : { + "200" : { + "description" : "Indicates a successful call.", + "schema" : { + "$ref" : "#/definitions/MLSyncResponse" + } + } + }, + "x-doc" : { + "tag" : "Machine learning APIs" + } + } + }, + "/api/ml/saved_objects/sync" : { + "get" : { + "tags" : [ "ml" ], + "summary" : "Sync machine learning saved objects in the default space", + "description" : "Synchronizes Kibana saved objects for machine learning jobs and trained models in the default space. 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.", + "operationId" : "ml-sync-default", + "parameters" : [ { + "name" : "simulate", + "in" : "query", + "description" : "When true, simulates the synchronization by returning only the list actions that would be performed.", + "required" : false, + "type" : "boolean", + "default" : false + } ], + "responses" : { + "200" : { + "description" : "Indicates a successful call.", + "schema" : { + "$ref" : "#/definitions/MLSyncResponse" + } + } + }, + "x-doc" : { + "tag" : "Machine learning APIs" + } + } + } + }, + "securityDefinitions" : { + "apiKey" : { + "type" : "apiKey", + "name" : "Authorization", + "in" : "header" + }, + "basicAuth": { + "type": "basic" + } + }, + "definitions": { + "MLSyncResponse-Datafeeds": { + "type": "object", + "description": "The sync machine learning saved objects API response contains this object when there are datafeeds affected by the synchronization. There is an object for each relevant datafeed, which contains the synchronization status.", + "properties" : { + "success": { + "type" : "boolean", + "description": "The success or failure of the synchronization." + } + } + }, + "MLSyncResponse-Jobs": { + "type": "object", + "description": "The sync machine learning saved objects API response contains this object when there are machine learning jobs affected by the synchronization. There is an object for each relevant job, which contains the synchronization status.", + "properties": { + "success": { + "type" : "boolean", + "description": "The success or failure of the synchronization." + } + } + }, + "MLSyncResponse-Models": { + "type": "object", + "description": "The sync machine learning saved objects API response contains this object when there are trained models affected by the synchronization. There is an object for each relevant trained model, which contains the synchronization status.", + "properties": { + "success": { + "type" : "boolean", + "description": "The success or failure of the synchronization." + } + } + }, + "MLSyncResponse-SavedObjectsCreated":{ + "type": "object", + "description": "If saved objects are missing for machine learning jobs or trained models, they are created when you run the sync machine learning saved objects API.", + "properties": { + "anomaly-detector": { + "type": "object", + "description": "This object is present if there are anomaly detection jobs affected by the synchronization.", + "additionalProperties": { + "$ref" : "#/definitions/MLSyncResponse-Jobs" + } + }, + "data-frame-analytics": { + "type": "object", + "description": "This object is present if there are data frame analytics jobs affected by the synchronization.", + "additionalProperties": { + "$ref" : "#/definitions/MLSyncResponse-Jobs" + } + }, + "trained-model": { + "type": "object", + "description": "This object is present if there are trained models affected by the synchronization.", + "additionalProperties": { + "$ref" : "#/definitions/MLSyncResponse-Models" + } + } + } + }, + "MLSyncResponse-SavedObjectsDeleted":{ + "type": "object", + "description": "If saved objects exist for machine learning jobs or trained models that no longer exist, they are deleted when you run the sync machine learning saved objects API.", + "properties": { + "anomaly-detector": { + "type": "object", + "description": "This object is present if there are anomaly detection jobs affected by the synchronization.", + "additionalProperties": { + "$ref" : "#/definitions/MLSyncResponse-Jobs" + } + }, + "data-frame-analytics": { + "type": "object", + "description": "This object is present if there are data frame analytics jobs affected by the synchronization.", + "additionalProperties": { + "$ref" : "#/definitions/MLSyncResponse-Jobs" + } + }, + "trained-model": { + "type": "object", + "description": "This object is present if there are trained models affected by the synchronization.", + "additionalProperties": { + "$ref" : "#/definitions/MLSyncResponse-Models" + } + } + } + }, + "MLSyncResponse": { + "type": "object", + "description": "The sync machine learning saved objects API returns this list of machine learning saved objects that required synchronization.", + "properties": { + "savedObjectsCreated": { + "$ref" : "#/definitions/MLSyncResponse-SavedObjectsCreated" + }, + "savedObjectsDeleted": { + "$ref" : "#/definitions/MLSyncResponse-SavedObjectsDeleted" + }, + "datafeedsAdded": { + "type": "object", + "description": "If a saved object for an anomaly detection job is missing a datafeed identifier, it is added when you run the sync machine learning saved objects API.", + "additionalProperties":{ + "$ref" : "#/definitions/MLSyncResponse-Datafeeds" + } + }, + "datafeedsRemoved": { + "type": "object", + "description": "If a saved object for an anomaly detection job references a datafeed that no longer exists, it is deleted when you run the sync machine learning saved objects API.", + "additionalProperties": { + "$ref" : "#/definitions/MLSyncResponse-Datafeeds" + } + } + } + } + } +} \ No newline at end of file diff --git a/x-pack/plugins/ml/common/openapi/ml_apis.yaml b/x-pack/plugins/ml/common/openapi/ml_apis_v3.yaml similarity index 57% rename from x-pack/plugins/ml/common/openapi/ml_apis.yaml rename to x-pack/plugins/ml/common/openapi/ml_apis_v3.yaml index c222d578243d20..ee91fefba40412 100644 --- a/x-pack/plugins/ml/common/openapi/ml_apis.yaml +++ b/x-pack/plugins/ml/common/openapi/ml_apis_v3.yaml @@ -14,10 +14,14 @@ servers: paths: /s/{spaceId}/api/ml/saved_objects/sync: get: + summary: Synchronizes Kibana saved objects for machine learning jobs and trained models. 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. + operationId: ml-sync + tags: + - ml parameters: - $ref: '#/components/parameters/spaceParam' - $ref: '#/components/parameters/simulateParam' @@ -27,16 +31,19 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/syncResponse' + $ref: '#/components/schemas/mlSyncResponse' examples: syncExample: - $ref: '#/components/examples/syncExample' + $ref: '#/components/examples/mlSyncExample' /api/ml/saved_objects/sync: get: + summary: Synchronizes Kibana saved objects for machine learning jobs and trained models in the default space. 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. + operationId: ml-sync-default + tags: + - ml parameters: - $ref: '#/components/parameters/simulateParam' responses: @@ -45,10 +52,10 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/syncResponse' + $ref: '#/components/schemas/mlSyncResponse' examples: syncExample: - $ref: '#/components/examples/syncExample' + $ref: '#/components/examples/mlSyncExample' components: parameters: spaceParam: @@ -70,84 +77,79 @@ components: basicAuth: type: http scheme: basic + apiKeyAuth: + type: apiKey + in: header + name: ApiKey schemas: - syncResponse: + mlSyncResponseSuccess: + type: boolean + description: The success or failure of the synchronization. + mlSyncResponseDatafeeds: + type: object + description: The sync machine learning saved objects API response contains this object when there are datafeeds affected by the synchronization. There is an object for each relevant datafeed, which contains the synchronization status. + properties: + success: + $ref: '#/components/schemas/mlSyncResponseSuccess' + mlSyncResponseJobs: + type: object + description: The sync machine learning saved objects API response contains this object when there are machine learning jobs affected by the synchronization. There is an object for each relevant job, which contains the synchronization status. + properties: + success: + $ref: '#/components/schemas/mlSyncResponseSuccess' + mlSyncResponseModels: + type: object + description: The sync machine learning saved objects API response contains this object when there are trained models affected by the synchronization. There is an object for each relevant trained model, which contains the synchronization status. + properties: + success: + $ref: '#/components/schemas/mlSyncResponseSuccess' + mlSyncResponse: 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. + description: If a saved object for an anomaly detection job is missing a datafeed identifier, it is added when you run the sync machine learning saved objects API. additionalProperties: - type: object - properties: - success: - type: boolean + $ref: '#/components/schemas/mlSyncResponseDatafeeds' 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. + description: If a saved object for an anomaly detection job references a datafeed that no longer exists, it is deleted when you run the sync machine learning saved objects API. additionalProperties: - type: object - properties: - success: - type: boolean + $ref: '#/components/schemas/mlSyncResponseDatafeeds' 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. + description: If saved objects are missing for machine learning jobs or trained models, they are created when you run the sync machine learning saved objects API. properties: anomaly-detector: type: object additionalProperties: - type: object - properties: - success: - type: boolean - example: true + $ref: '#/components/schemas/mlSyncResponseJobs' data-frame-analytics: type: object additionalProperties: - type: object - properties: - success: - type: boolean - example: true + $ref: '#/components/schemas/mlSyncResponseDatafeeds' trained-model: type: object additionalProperties: - type: object - properties: - success: - type: boolean - example: true + $ref: '#/components/schemas/mlSyncResponseModels' 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. + description: If saved objects exist for machine learning jobs or trained models that no longer exist, they are deleted when you run the sync machine learning saved objects API. properties: anomaly-detector: type: object additionalProperties: - type: object - properties: - success: - type: boolean - example: true + $ref: '#/components/schemas/mlSyncResponseJobs' data-frame-analytics: type: object additionalProperties: - type: object - properties: - success: - type: boolean - example: true + $ref: '#/components/schemas/mlSyncResponseJobs' trained-model: type: object additionalProperties: - type: object - properties: - success: - type: boolean - example: true + $ref: '#/components/schemas/mlSyncResponseModels' examples: - syncExample: + mlSyncExample: summary: Two anomaly detection jobs required synchronization in this example. value: { @@ -162,4 +164,5 @@ components: "datafeedsRemoved":{} } security: - - basicAuth: [] \ No newline at end of file + - basicAuth: [ ] + - ApiKeyAuth: [ ] \ No newline at end of file