From 77bd553d639efdd55d9f8ab1af34de36ee735908 Mon Sep 17 00:00:00 2001 From: Lisa Cawley Date: Mon, 29 Jul 2024 14:23:53 -0700 Subject: [PATCH] [8.15] [OAS][ML] Add sync API tags and description, minor OpenAPI fixes (#189230) (#189320) # Backport This will backport the following commits from `main` to `8.15`: - [[OAS][ML] Add sync API tags and description, minor OpenAPI fixes (#189230)](https://github.com/elastic/kibana/pull/189230) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) --- oas_docs/output/kibana.yaml | 53 ------------ x-pack/plugins/ml/common/openapi/README.md | 15 +--- x-pack/plugins/ml/common/openapi/ml_apis.yaml | 83 ++++++++----------- .../ml/common/openapi/ml_apis_serverless.yaml | 7 -- .../plugins/ml/server/routes/saved_objects.ts | 3 + 5 files changed, 40 insertions(+), 121 deletions(-) diff --git a/oas_docs/output/kibana.yaml b/oas_docs/output/kibana.yaml index f9b33636232f0..e824e38be508a 100644 --- a/oas_docs/output/kibana.yaml +++ b/oas_docs/output/kibana.yaml @@ -1401,43 +1401,6 @@ paths: application/json: schema: $ref: '#/components/schemas/Machine_learning_APIs_mlSync4xxResponse' - security: - - Machine_learning_APIs_basicAuth: [] - - Machine_learning_APIs_apiKeyAuth: [] - /s/{spaceId}/api/ml/saved_objects/sync: - get: - summary: Sync 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: mlSyncWithSpaceId - tags: - - ml - parameters: - - $ref: '#/components/parameters/Machine_learning_APIs_spaceParam' - - $ref: '#/components/parameters/Machine_learning_APIs_simulateParam' - responses: - '200': - description: Indicates a successful call - content: - application/json: - schema: - $ref: '#/components/schemas/Machine_learning_APIs_mlSync200Response' - examples: - syncExample: - $ref: '#/components/examples/Machine_learning_APIs_mlSyncExample' - '401': - description: Authorization information is missing or invalid. - content: - application/json: - schema: - $ref: '#/components/schemas/Machine_learning_APIs_mlSync4xxResponse' - security: - - Machine_learning_APIs_basicAuth: [] - - Machine_learning_APIs_apiKeyAuth: [] /api/encrypted_saved_objects/_rotate_key: post: summary: Rotate a key for encrypted saved objects @@ -3123,15 +3086,6 @@ components: schema: type: string example: hour_of_day - Machine_learning_APIs_spaceParam: - in: path - name: spaceId - description: >- - An identifier for the space. If `/s/` and the identifier are omitted - from the path, the default space is used. - required: true - schema: - type: string Machine_learning_APIs_simulateParam: in: query name: simulate @@ -11374,13 +11328,6 @@ components: schema: $ref: '#/components/schemas/Connectors_action_response_properties' securitySchemes: - Machine_learning_APIs_basicAuth: - type: http - scheme: basic - Machine_learning_APIs_apiKeyAuth: - type: apiKey - in: header - name: ApiKey Saved_objects_basicAuth: type: http scheme: basic diff --git a/x-pack/plugins/ml/common/openapi/README.md b/x-pack/plugins/ml/common/openapi/README.md index 7a79e55608894..a1f212de75b7d 100644 --- a/x-pack/plugins/ml/common/openapi/README.md +++ b/x-pack/plugins/ml/common/openapi/README.md @@ -4,17 +4,4 @@ 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.1. - - ## Tools - -It is possible to validate the docs before bundling them by running these -commands in the `x-pack/plugins/ml/common/openapi/` folder: - -``` -npx swagger-cli validate ml_apis.yaml -npx @redocly/cli lint ml_apis.yaml - -npx swagger-cli validate ml_apis_serverless.yaml -npx @redocly/cli lint ml_apis_serverless.yaml -``` +These files are joined with the rest of the Kibana APIs per `oas_docs/README.md` diff --git a/x-pack/plugins/ml/common/openapi/ml_apis.yaml b/x-pack/plugins/ml/common/openapi/ml_apis.yaml index d2854d049098e..3a029ef598dfc 100644 --- a/x-pack/plugins/ml/common/openapi/ml_apis.yaml +++ b/x-pack/plugins/ml/common/openapi/ml_apis.yaml @@ -41,44 +41,44 @@ paths: schema: $ref: '#/components/schemas/mlSync4xxResponse' - /s/{spaceId}/api/ml/saved_objects/sync: - get: - summary: Sync 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: mlSyncWithSpaceId - tags: - - ml - parameters: - - $ref: '#/components/parameters/spaceParam' - - $ref: '#/components/parameters/simulateParam' - responses: - '200': - description: Indicates a successful call - content: - application/json: - schema: - $ref: '#/components/schemas/mlSync200Response' - examples: - syncExample: - $ref: '#/components/examples/mlSyncExample' - '401': - description: Authorization information is missing or invalid. - content: - application/json: - schema: - $ref: '#/components/schemas/mlSync4xxResponse' + # /s/{spaceId}/api/ml/saved_objects/sync: + # get: + # summary: Sync 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: mlSyncWithSpaceId + # tags: + # - ml + # parameters: + # - $ref: '#/components/parameters/spaceParam' + # - $ref: '#/components/parameters/simulateParam' + # responses: + # '200': + # description: Indicates a successful call + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/mlSync200Response' + # examples: + # syncExample: + # $ref: '#/components/examples/mlSyncExample' + # '401': + # description: Authorization information is missing or invalid. + # content: + # application/json: + # schema: + # $ref: '#/components/schemas/mlSync4xxResponse' components: parameters: - spaceParam: - in: path - name: spaceId - description: An identifier for the space. If `/s/` and the identifier are omitted from the path, the default space is used. - required: true - schema: - type: string + # spaceParam: + # in: path + # name: spaceId + # description: An identifier for the space. If `/s/` and the identifier are omitted from the path, the default space is used. + # required: true + # schema: + # type: string simulateParam: in: query name: simulate @@ -87,14 +87,6 @@ components: schema: type: boolean example: 'true' - securitySchemes: - basicAuth: - type: http - scheme: basic - apiKeyAuth: - type: apiKey - in: header - name: ApiKey schemas: mlSyncResponseSuccess: type: boolean @@ -212,6 +204,3 @@ components: "datafeedsAdded": {}, "datafeedsRemoved": {} } -security: - - basicAuth: [ ] - - apiKeyAuth: [ ] \ No newline at end of file diff --git a/x-pack/plugins/ml/common/openapi/ml_apis_serverless.yaml b/x-pack/plugins/ml/common/openapi/ml_apis_serverless.yaml index d09b78c1155ae..891b58fd7b512 100644 --- a/x-pack/plugins/ml/common/openapi/ml_apis_serverless.yaml +++ b/x-pack/plugins/ml/common/openapi/ml_apis_serverless.yaml @@ -49,11 +49,6 @@ components: schema: type: boolean example: 'true' - securitySchemes: - apiKeyAuth: - type: apiKey - in: header - name: ApiKey schemas: mlSyncResponseSuccess: type: boolean @@ -171,5 +166,3 @@ components: "datafeedsAdded": {}, "datafeedsRemoved": {} } -security: - - apiKeyAuth: [ ] \ No newline at end of file diff --git a/x-pack/plugins/ml/server/routes/saved_objects.ts b/x-pack/plugins/ml/server/routes/saved_objects.ts index 6d13b815ee338..485ce7ffe1f72 100644 --- a/x-pack/plugins/ml/server/routes/saved_objects.ts +++ b/x-pack/plugins/ml/server/routes/saved_objects.ts @@ -84,8 +84,11 @@ export function savedObjectsRoutes( 'access:ml:canCreateJob', 'access:ml:canCreateDataFrameAnalytics', 'access:ml:canCreateTrainedModels', + 'oas-tag:machine learning', ], }, + description: + 'Synchronizes Kibana saved objects for machine learning jobs and trained models. This API runs automatically when you start Kibana and periodically thereafter.', }) .addVersion( {