From 2d0a0fdd8e502026b45aaa8a7ee5912538882f80 Mon Sep 17 00:00:00 2001 From: Florian Bernd Date: Tue, 22 Oct 2024 20:01:56 +0200 Subject: [PATCH] Improve `SearchApplication` definition (and related) (#3040) --- .../_types/SearchApplication.ts | 27 +++----------- .../_types/SearchApplicationParameters.ts | 36 +++++++++++++++++++ .../_types/SearchApplicationTemplate.ts | 27 ++++++++++++++ .../get/SearchApplicationsGetResponse.ts | 2 +- .../list/SearchApplicationsListResponse.ts | 24 ++----------- .../put/SearchApplicationsPutRequest.ts | 4 +-- 6 files changed, 72 insertions(+), 48 deletions(-) create mode 100644 specification/search_application/_types/SearchApplicationParameters.ts create mode 100644 specification/search_application/_types/SearchApplicationTemplate.ts diff --git a/specification/search_application/_types/SearchApplication.ts b/specification/search_application/_types/SearchApplication.ts index 20d468a130..4b316828c2 100644 --- a/specification/search_application/_types/SearchApplication.ts +++ b/specification/search_application/_types/SearchApplication.ts @@ -17,36 +17,17 @@ * under the License. */ -import { IndexName, Name } from '@_types/common' -import { Script } from '@_types/Scripting' +import { Name } from '@_types/common' import { EpochTime, UnitMillis } from '@_types/Time' +import { SearchApplicationParameters } from './SearchApplicationParameters' -export class SearchApplication { +export class SearchApplication extends SearchApplicationParameters { /** - * Search Application name. + * Search Application name */ name: Name - /** - * Indices that are part of the Search Application. - */ - indices: IndexName[] /** * Last time the Search Application was updated. */ updated_at_millis: EpochTime - /** - * Analytics collection associated to the Search Application. - */ - analytics_collection_name?: Name - /** - * Search template to use on search operations. - */ - template?: SearchApplicationTemplate -} - -export class SearchApplicationTemplate { - /** - * The associated mustache template. - */ - script: Script } diff --git a/specification/search_application/_types/SearchApplicationParameters.ts b/specification/search_application/_types/SearchApplicationParameters.ts new file mode 100644 index 0000000000..f2b1055ff3 --- /dev/null +++ b/specification/search_application/_types/SearchApplicationParameters.ts @@ -0,0 +1,36 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { IndexName, Name } from '@_types/common' +import { SearchApplicationTemplate } from './SearchApplicationTemplate' + +export class SearchApplicationParameters { + /** + * Indices that are part of the Search Application. + */ + indices: IndexName[] + /** + * Analytics collection associated to the Search Application. + */ + analytics_collection_name?: Name + /** + * Search template to use on search operations. + */ + template?: SearchApplicationTemplate +} diff --git a/specification/search_application/_types/SearchApplicationTemplate.ts b/specification/search_application/_types/SearchApplicationTemplate.ts new file mode 100644 index 0000000000..2f95e85059 --- /dev/null +++ b/specification/search_application/_types/SearchApplicationTemplate.ts @@ -0,0 +1,27 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { Script } from '@_types/Scripting' + +export class SearchApplicationTemplate { + /** + * The associated mustache template. + */ + script: Script +} diff --git a/specification/search_application/get/SearchApplicationsGetResponse.ts b/specification/search_application/get/SearchApplicationsGetResponse.ts index 29673c3f15..46c7d051ee 100644 --- a/specification/search_application/get/SearchApplicationsGetResponse.ts +++ b/specification/search_application/get/SearchApplicationsGetResponse.ts @@ -17,7 +17,7 @@ * under the License. */ -import { SearchApplication } from '../_types/SearchApplication' +import { SearchApplication } from '@search_application/_types/SearchApplication' export class Response { body: SearchApplication diff --git a/specification/search_application/list/SearchApplicationsListResponse.ts b/specification/search_application/list/SearchApplicationsListResponse.ts index 49ebbedc6a..1532ded8da 100644 --- a/specification/search_application/list/SearchApplicationsListResponse.ts +++ b/specification/search_application/list/SearchApplicationsListResponse.ts @@ -17,32 +17,12 @@ * under the License. */ -import { IndexName, Name } from '@_types/common' +import { SearchApplication } from '@search_application/_types/SearchApplication' import { long } from '@_types/Numeric' -import { EpochTime, UnitMillis } from '@_types/Time' export class Response { body: { count: long - results: SearchApplicationListItem[] + results: SearchApplication[] } } - -export class SearchApplicationListItem { - /** - * Search Application name - */ - name: Name - /** - * Indices that are part of the Search Application - */ - indices: IndexName[] - /** - * Last time the Search Application was updated - */ - updated_at_millis: EpochTime - /** - * Analytics collection associated to the Search Application - */ - analytics_collection_name?: Name -} diff --git a/specification/search_application/put/SearchApplicationsPutRequest.ts b/specification/search_application/put/SearchApplicationsPutRequest.ts index df5efd5ff0..b5d66e6f50 100644 --- a/specification/search_application/put/SearchApplicationsPutRequest.ts +++ b/specification/search_application/put/SearchApplicationsPutRequest.ts @@ -18,7 +18,7 @@ */ import { RequestBase } from '@_types/Base' import { Name } from '@_types/common' -import { SearchApplication } from '../_types/SearchApplication' +import { SearchApplicationParameters } from '../_types/SearchApplicationParameters' /** * Create or update a search application. @@ -44,5 +44,5 @@ export interface Request extends RequestBase { * Contains parameters for a search application. */ /** @codegen_name search_application */ - body: SearchApplication + body: SearchApplicationParameters }