[OAS] Create runtime field API (#163776)

This PR drafts openAPI specifications for:

- [Create runtime field
API](https://www.elastic.co/guide/en/kibana/master/data-views-runtime-field-api-create.html).
- [Upsert runtime field
API](https://www.elastic.co/guide/en/kibana/master/data-views-runtime-field-api-upsert.html)

Relates to https://github.com/elastic/kibana/issues/137240
This commit is contained in:
amyjtechwriter 2023-08-15 14:31:05 +01:00 committed by GitHub
parent 82531f8f9d
commit f4381ac0d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 316 additions and 2 deletions

View file

@ -293,6 +293,120 @@
}
]
},
"/api/data_views/data_view/{viewId}/runtime_field": {
"post": {
"summary": "Creates a runtime field.",
"operationId": "createRuntimeField",
"description": "This functionality is in technical preview and may be changed or removed in a future release. Elastic will apply best effort to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.\n",
"tags": [
"data views"
],
"parameters": [
{
"$ref": "#/components/parameters/kbn_xsrf"
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"data_view_id": {
"description": "The ID of the data view.",
"type": "string",
"required": true
},
"space_id": {
"description": "An identifier for the space. If space_id is not provided in the URL, the default space is used.",
"type": "string",
"required": false
}
}
},
"examples": {
"createRuntimeFieldRequest": {
"$ref": "#/components/examples/create_runtime_field_request"
}
}
}
}
}
},
"put": {
"summary": "Create or update an existing runtime field.",
"operationId": "updateRuntimeField",
"description": "This functionality is in technical preview and may be changed or removed in a future release. Elastic will apply best effort to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.\n",
"tags": [
"data views"
],
"parameters": [
{
"$ref": "#/components/parameters/kbn_xsrf"
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"data_view_id": {
"description": "The ID of the data view.",
"type": "string",
"required": true
},
"space_id": {
"description": "An identifier for the space. If space_id is not provided in the URL, the default space is used.",
"type": "string",
"required": false
}
}
},
"examples": {
"updateRuntimeFieldRequest": {
"$ref": "#/components/examples/create_runtime_field_request"
}
}
}
}
},
"responses": {
"200": {
"description": "Indicates a successful call.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/create_runtime_field_response"
}
}
}
},
"400": {
"description": "Bad request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/400_response"
}
}
}
}
},
"servers": [
{
"url": "https://localhost:5601"
}
]
},
"servers": [
{
"url": "https://localhost:5601"
}
]
},
"/api/data_views/data_view/{viewId}/runtime_field/{fieldName}": {
"get": {
"summary": "Retrieves a runtime field.",
@ -1690,6 +1804,18 @@
"refresh_fields": true
}
},
"create_runtime_field_request": {
"summary": "Create a runtime field.",
"value": {
"name": "runtimeFoo",
"runtimeField": {
"type": "long",
"script": {
"source": "emit(doc[\"foo\"].value)"
}
}
}
},
"get_runtime_field_response": {
"summary": "The get runtime field API returns a JSON object that contains information about the runtime field (`hour_of_day`) and the data view (`d3d7af60-4c81-11e8-b3d7-01146121b73d`).",
"value": {
@ -2611,6 +2737,17 @@
"default": false
}
}
},
"create_runtime_field_response": {
"summary": "The API returns created runtime field object array and updated data view object.",
"value": {
"data_view": {
"...": null
},
"fields": [
"..."
]
}
}
}
}

View file

@ -174,6 +174,78 @@ paths:
- url: https://localhost:5601
servers:
- url: https://localhost:5601
/api/data_views/data_view/{viewId}/runtime_field:
post:
summary: Creates a runtime field.
operationId: createRuntimeField
description: |
This functionality is in technical preview and may be changed or removed in a future release. Elastic will apply best effort to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.
tags:
- data views
parameters:
- $ref: '#/components/parameters/kbn_xsrf'
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
data_view_id:
description: The ID of the data view.
type: string
required: true
space_id:
description: An identifier for the space. If space_id is not provided in the URL, the default space is used.
type: string
required: false
examples:
createRuntimeFieldRequest:
$ref: '#/components/examples/create_runtime_field_request'
put:
summary: Create or update an existing runtime field.
operationId: updateRuntimeField
description: |
This functionality is in technical preview and may be changed or removed in a future release. Elastic will apply best effort to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.
tags:
- data views
parameters:
- $ref: '#/components/parameters/kbn_xsrf'
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
data_view_id:
description: The ID of the data view.
type: string
required: true
space_id:
description: An identifier for the space. If space_id is not provided in the URL, the default space is used.
type: string
required: false
examples:
updateRuntimeFieldRequest:
$ref: '#/components/examples/create_runtime_field_request'
responses:
'200':
description: Indicates a successful call.
content:
application/json:
schema:
$ref: '#/components/schemas/create_runtime_field_response'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/400_response'
servers:
- url: https://localhost:5601
servers:
- url: https://localhost:5601
/api/data_views/data_view/{viewId}/runtime_field/{fieldName}:
get:
summary: Retrieves a runtime field.
@ -1253,6 +1325,14 @@ components:
allowNoIndex: false
name: Kibana Sample Data eCommerce
refresh_fields: true
create_runtime_field_request:
summary: Create a runtime field.
value:
name: runtimeFoo
runtimeField:
type: long
script:
source: emit(doc["foo"].value)
get_runtime_field_response:
summary: The get runtime field API returns a JSON object that contains information about the runtime field (`hour_of_day`) and the data view (`d3d7af60-4c81-11e8-b3d7-01146121b73d`).
value:
@ -1967,3 +2047,10 @@ components:
type: boolean
description: Reloads the data view fields after the data view is updated.
default: false
create_runtime_field_response:
summary: The API returns created runtime field object array and updated data view object.
value:
data_view:
...: null
fields:
- ...

View file

@ -0,0 +1,11 @@
summary: Create a runtime field.
value:
{
"name": "runtimeFoo",
"runtimeField": {
"type": "long",
"script": {
"source": 'emit(doc["foo"].value)'
}
}
}

View file

@ -0,0 +1,6 @@
summary: The API returns created runtime field object array and updated data view object.
value:
{
"data_view": {...},
"fields": [...]
}

View file

@ -24,8 +24,8 @@ paths:
$ref: 'paths/api@data_views@data_view@{viewid}.yaml'
# '/api/data_views/data_view/{viewId}/fields':
# $ref: 'paths/api@data_views@data_view@{viewid}@fields.yaml'
# '/api/data_views/data_view/{viewId}/runtime_field':
# $ref: 'paths/api@data_views@data_view@{viewid}@runtime_field.yaml'
'/api/data_views/data_view/{viewId}/runtime_field':
$ref: 'paths/api@data_views@data_view@{viewid}@runtime_field.yaml'
'/api/data_views/data_view/{viewId}/runtime_field/{fieldName}':
$ref: 'paths/api@data_views@data_view@{viewid}@runtime_field@{fieldname}.yaml'
'/api/data_views/default':

View file

@ -0,0 +1,73 @@
post:
summary: Creates a runtime field.
operationId: createRuntimeField
description: >
This functionality is in technical preview and may be changed or removed in a future release. Elastic will apply best effort to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.
tags:
- data views
parameters:
- $ref: '../components/headers/kbn_xsrf.yaml'
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
data_view_id:
description: The ID of the data view.
type: string
required: true
space_id:
description: An identifier for the space. If space_id is not provided in the URL, the default space is used.
type: string
required: false
examples:
createRuntimeFieldRequest:
$ref: '../components/examples/create_runtime_field_request.yaml'
put:
summary: Create or update an existing runtime field.
operationId: updateRuntimeField
description: >
This functionality is in technical preview and may be changed or removed in a future release. Elastic will apply best effort to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.
tags:
- data views
parameters:
- $ref: '../components/headers/kbn_xsrf.yaml'
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
data_view_id:
description: The ID of the data view.
type: string
required: true
space_id:
description: An identifier for the space. If space_id is not provided in the URL, the default space is used.
type: string
required: false
examples:
updateRuntimeFieldRequest:
$ref: '../components/examples/create_runtime_field_request.yaml'
responses:
'200':
description: Indicates a successful call.
content:
application/json:
schema:
$ref: '../components/examples/create_runtime_field_response.yaml'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '../components/schemas/400_response.yaml'
servers:
- url: https://localhost:5601
servers:
- url: https://localhost:5601