From 841e95c64b6fa29e680906140e356be43e73f75c Mon Sep 17 00:00:00 2001 From: Lisa Cawley Date: Fri, 26 Jul 2024 13:28:43 -0700 Subject: [PATCH] [OAS][ML] Add sync API tags and description, minor OpenAPI fixes (#189230) --- oas_docs/output/kibana.serverless.yaml | 6 -- 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 + 6 files changed, 40 insertions(+), 127 deletions(-) diff --git a/oas_docs/output/kibana.serverless.yaml b/oas_docs/output/kibana.serverless.yaml index 2a1df7a13f67a..31d4d1605d028 100644 --- a/oas_docs/output/kibana.serverless.yaml +++ b/oas_docs/output/kibana.serverless.yaml @@ -1073,8 +1073,6 @@ paths: application/json: schema: $ref: '#/components/schemas/Machine_learning_APIs_mlSync4xxResponse' - security: - - Machine_learning_APIs_apiKeyAuth: [] /api/saved_objects/_export: post: summary: Export saved objects in the default space @@ -9063,10 +9061,6 @@ components: enum: - 404 securitySchemes: - Machine_learning_APIs_apiKeyAuth: - type: apiKey - in: header - name: ApiKey Serverless_saved_objects_apiKeyAuth: type: apiKey in: header diff --git a/oas_docs/output/kibana.yaml b/oas_docs/output/kibana.yaml index c663e48f324cf..ae95ff01ac315 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 @@ -3127,15 +3090,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 @@ -11340,13 +11294,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( {