forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial version of upgrade assistant integration
- Loading branch information
1 parent
37aa7fd
commit d649f56
Showing
5 changed files
with
63 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import { errors } from '@elastic/elasticsearch'; | ||
import { API_MIGRATE_ILM_POLICY_URL } from '../../common/constants'; | ||
import { ReportingCore } from '../core'; | ||
import { LevelLogger as Logger } from '../lib'; | ||
|
||
export const registerDeprecationsRoutes = (reporting: ReportingCore, logger: Logger) => { | ||
const { router } = reporting.getPluginSetupDeps(); | ||
|
||
router.put({ path: API_MIGRATE_ILM_POLICY_URL, validate: false }, async (ctx, req, res) => { | ||
const store = await reporting.getStore(); | ||
const { asInternalUser: client } = await reporting.getEsClient(); | ||
|
||
const indexPattern = store.getReportingIndexPattern(); | ||
const reportingIlmPolicy = store.getIlmPolicyName(); | ||
|
||
try { | ||
await client.indices.putSettings({ | ||
index: indexPattern, | ||
body: { | ||
index: { | ||
lifecycle: { | ||
name: reportingIlmPolicy, | ||
}, | ||
}, | ||
}, | ||
}); | ||
return res.ok(); | ||
} catch (err) { | ||
logger.error(err); | ||
|
||
if (err instanceof errors.ResponseError) { | ||
return res.customError({ | ||
statusCode: 500, | ||
body: { | ||
message: err.message, | ||
name: err.name, | ||
}, | ||
}); | ||
} | ||
|
||
throw err; | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters