@@ -26,7 +26,6 @@ import {
2626 excess ,
2727 GetConfigureFindRequest ,
2828 GetConfigureFindRequestRt ,
29- GetFieldsResponse ,
3029 throwErrors ,
3130 CasesConfigurationsResponse ,
3231 CaseConfigurationsResponseRt ,
@@ -41,20 +40,14 @@ import {
4140} from '../../common' ;
4241import { CasesClientInternal } from '../client_internal' ;
4342import { CasesClientArgs } from '../types' ;
44- import { getFields } from './get_fields' ;
4543import { getMappings } from './get_mappings' ;
4644
4745// eslint-disable-next-line @kbn/eslint/no-restricted-paths
4846import { FindActionResult } from '../../../../actions/server/types' ;
4947import { ActionType } from '../../../../actions/common' ;
5048import { Operations } from '../../authorization' ;
5149import { combineAuthorizedAndOwnerFilter } from '../utils' ;
52- import {
53- ConfigurationGetFields ,
54- MappingsArgs ,
55- CreateMappingsArgs ,
56- UpdateMappingsArgs ,
57- } from './types' ;
50+ import { MappingsArgs , CreateMappingsArgs , UpdateMappingsArgs } from './types' ;
5851import { createMappings } from './create_mappings' ;
5952import { updateMappings } from './update_mappings' ;
6053import {
@@ -69,7 +62,6 @@ import {
6962 * @ignore
7063 */
7164export interface InternalConfigureSubClient {
72- getFields ( params : ConfigurationGetFields ) : Promise < GetFieldsResponse > ;
7365 getMappings (
7466 params : MappingsArgs
7567 ) : Promise < SavedObjectsFindResponse < ConnectorMappings > [ 'saved_objects' ] > ;
@@ -116,12 +108,9 @@ export const createInternalConfigurationSubClient = (
116108 casesClientInternal : CasesClientInternal
117109) : InternalConfigureSubClient => {
118110 const configureSubClient : InternalConfigureSubClient = {
119- getFields : ( params : ConfigurationGetFields ) => getFields ( params , clientArgs ) ,
120111 getMappings : ( params : MappingsArgs ) => getMappings ( params , clientArgs ) ,
121- createMappings : ( params : CreateMappingsArgs ) =>
122- createMappings ( params , clientArgs , casesClientInternal ) ,
123- updateMappings : ( params : UpdateMappingsArgs ) =>
124- updateMappings ( params , clientArgs , casesClientInternal ) ,
112+ createMappings : ( params : CreateMappingsArgs ) => createMappings ( params , clientArgs ) ,
113+ updateMappings : ( params : UpdateMappingsArgs ) => updateMappings ( params , clientArgs ) ,
125114 } ;
126115
127116 return Object . freeze ( configureSubClient ) ;
@@ -194,8 +183,7 @@ async function get(
194183 if ( connector != null ) {
195184 try {
196185 mappings = await casesClientInternal . configuration . getMappings ( {
197- connectorId : connector . id ,
198- connectorType : connector . type ,
186+ connector : transformESConnectorToCaseConnector ( connector ) ,
199187 } ) ;
200188 } catch ( e ) {
201189 error = e . isBoom
@@ -303,32 +291,32 @@ async function update(
303291
304292 try {
305293 const resMappings = await casesClientInternal . configuration . getMappings ( {
306- connectorId : connector != null ? connector . id : configuration . attributes . connector . id ,
307- connectorType : connector != null ? connector . type : configuration . attributes . connector . type ,
294+ connector :
295+ connector != null
296+ ? connector
297+ : transformESConnectorToCaseConnector ( configuration . attributes . connector ) ,
308298 } ) ;
309299 mappings = resMappings . length > 0 ? resMappings [ 0 ] . attributes . mappings : [ ] ;
310300
311301 if ( connector != null ) {
312302 if ( resMappings . length !== 0 ) {
313303 mappings = await casesClientInternal . configuration . updateMappings ( {
314- connectorId : connector . id ,
315- connectorType : connector . type ,
304+ connector,
316305 mappingId : resMappings [ 0 ] . id ,
317306 } ) ;
318307 } else {
319308 mappings = await casesClientInternal . configuration . createMappings ( {
320- connectorId : connector . id ,
321- connectorType : connector . type ,
309+ connector,
322310 owner : configuration . attributes . owner ,
323311 } ) ;
324312 }
325313 }
326314 } catch ( e ) {
327315 error = e . isBoom
328316 ? e . output . payload . message
329- : `Error connecting to ${
317+ : `Error creating mapping for ${
330318 connector != null ? connector . name : configuration . attributes . connector . name
331- } instance `;
319+ } `;
332320 }
333321
334322 const patch = await caseConfigureService . patch ( {
@@ -429,14 +417,13 @@ async function create(
429417
430418 try {
431419 mappings = await casesClientInternal . configuration . createMappings ( {
432- connectorId : configuration . connector . id ,
433- connectorType : configuration . connector . type ,
420+ connector : configuration . connector ,
434421 owner : configuration . owner ,
435422 } ) ;
436423 } catch ( e ) {
437424 error = e . isBoom
438425 ? e . output . payload . message
439- : `Error connecting to ${ configuration . connector . name } instance ` ;
426+ : `Error creating mapping for ${ configuration . connector . name } ` ;
440427 }
441428
442429 const post = await caseConfigureService . post ( {
0 commit comments