Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,65 @@ describe('repository_serialization', () => {
isManagedPolicy: true,
});
});

it('should deserialize a policy with indices defined as strings', () => {
expect(
deserializePolicy(
'my-backups-snapshots',
{
version: 1,
modified_date: '2019-07-09T22:11:55.761Z',
modified_date_millis: 1562710315761,
policy: {
name: '<daily-snap-{now/d}>',
schedule: '0 30 1 * * ?',
repository: 'my-backups',
config: {
indices: 'index-1,index-2,index-3',
ignore_unavailable: false,
include_global_state: false,
metadata: {
foo: 'bar',
},
},
retention: {
expire_after: '14d',
max_count: 30,
min_count: 4,
},
},
next_execution: '2019-07-11T01:30:00.000Z',
next_execution_millis: 1562722200000,
},
['my-backups-snapshots']
)
).toEqual({
name: 'my-backups-snapshots',
version: 1,
modifiedDate: '2019-07-09T22:11:55.761Z',
modifiedDateMillis: 1562710315761,
snapshotName: '<daily-snap-{now/d}>',
schedule: '0 30 1 * * ?',
repository: 'my-backups',
config: {
indices: ['index-1', 'index-2', 'index-3'],
includeGlobalState: false,
ignoreUnavailable: false,
metadata: {
foo: 'bar',
},
},
retention: {
expireAfterValue: 14,
expireAfterUnit: 'd',
maxCount: 30,
minCount: 4,
},
nextExecution: '2019-07-11T01:30:00.000Z',
nextExecutionMillis: 1562722200000,
isManagedPolicy: true,
});
});
});

describe('serializePolicy()', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ export function deserializeSnapshotConfig(snapshotConfigEs: SnapshotConfigEs): S
} = snapshotConfigEs;

const snapshotConfig: SnapshotConfig = {
indices,
// The ES API supports indices defined as an array or comma-separated string
// If a string is defined, we'll convert to an array for the UI to more easily consume
indices: typeof indices === 'string' ? indices.split(',') : indices,
ignoreUnavailable,
includeGlobalState,
partial,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,6 @@ export const validatePolicy = (
);
}

if (config && typeof config.indices === 'string' && config.indices.trim().length === 0) {
validation.errors.indices.push(
i18n.translate('xpack.snapshotRestore.policyValidation.indexPatternRequiredErrorMessage', {
defaultMessage: 'At least one index pattern is required.',
})
);
}

if (config && Array.isArray(config.indices) && config.indices.length === 0) {
validation.errors.indices.push(
i18n.translate('xpack.snapshotRestore.policyValidation.indicesRequiredErrorMessage', {
Expand Down
7 changes: 3 additions & 4 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -12029,7 +12029,7 @@
"xpack.ml.newJob.wizard.jobDetailsStep.advancedSection.enableModelPlot.title": "モデルプロットを有効にする",
"xpack.ml.newJob.wizard.jobDetailsStep.advancedSection.enableModelPlotAnnotations.description": "選択すると、モデルが大幅に変更されたときに注釈を生成します。たとえば、ステップが変更されると、期間や傾向が検出されます。",
"xpack.ml.newJob.wizard.jobDetailsStep.advancedSection.enableModelPlotAnnotations.title": "モデル変更注釈を有効にする",
"xpack.ml.newJob.wizard.jobDetailsStep.advancedSection.mmlWarning.message": "モデルプロットの作成には大量のリソースを消費する可能性があり、選択されたフィールドの基数が100を超える場合はお勧めしません。このジョブの予測基数は{highCardinality}です。 この構成でモデルプロットを有効にする場合、専用の結果インデックスを選択することをお勧めします。",
"xpack.ml.newJob.wizard.jobDetailsStep.advancedSection.mmlWarning.message": "モデルプロットの作成には大量のリソースを消費する可能性があり、選択されたフィールドの基数が100を超える場合はお勧めしません。このジョブの予測基数は{highCardinality}です。 この構成でモデルプロットを有効にする場合、専用の結果インデックスを選択することをお勧めします。",
"xpack.ml.newJob.wizard.jobDetailsStep.advancedSection.mmlWarning.title": "十分ご注意ください!",
"xpack.ml.newJob.wizard.jobDetailsStep.advancedSection.modelMemoryLimit.description": "分析モデルが使用するメモリー容量の上限を設定します。",
"xpack.ml.newJob.wizard.jobDetailsStep.advancedSection.modelMemoryLimit.title": "モデルメモリー制限",
Expand Down Expand Up @@ -12364,7 +12364,7 @@
"xpack.ml.ruleEditor.scopeSection.noPermissionToViewFilterListsTitle": "フィルターリストを表示するパーミッションがありません",
"xpack.ml.ruleEditor.scopeSection.scopeTitle": "範囲",
"xpack.ml.ruleEditor.selectRuleAction.createRuleLinkText": "ルールを作成",
"xpack.ml.ruleEditor.selectRuleAction.orText": "OR ",
"xpack.ml.ruleEditor.selectRuleAction.orText": "OR ",
"xpack.ml.ruleEditor.typicalAppliesTypeText": "通常",
"xpack.ml.sampleDataLinkLabel": "ML ジョブ",
"xpack.ml.settings.anomalyDetection.anomalyDetectionTitle": "異常検知",
Expand Down Expand Up @@ -17356,7 +17356,6 @@
"xpack.snapshotRestore.policyRetentionSchedulePanel.retentionScheduleExecuteLinkTooltip": "今すぐ保存を実行",
"xpack.snapshotRestore.policyScheduleWarningDescription": "一度に 1 つのスナップショットしか撮影できません。スナップショットのエラーを避けるために、ポリシーを編集または削除してください。",
"xpack.snapshotRestore.policyScheduleWarningTitle": "2 つ以上のポリシーに同じスケジュールが設定されています",
"xpack.snapshotRestore.policyValidation.indexPatternRequiredErrorMessage": "インデックスパターンが最低 1 つ必要です。",
"xpack.snapshotRestore.policyValidation.indicesRequiredErrorMessage": "1つ以上のデータストリームまたはインデックスを選択する必要があります。",
"xpack.snapshotRestore.policyValidation.invalidMinCountErrorMessage": "最低カウントは最高カウントよりも大きい値にできません。",
"xpack.snapshotRestore.policyValidation.invalidNegativeDeleteAfterErrorMessage": "次の期間後削除は負数にすることができません。",
Expand Down Expand Up @@ -19461,4 +19460,4 @@
"xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "フィールドを選択してください。",
"xpack.watcher.watcherDescription": "アラートの作成、管理、監視によりデータへの変更を検知します。"
}
}
}
5 changes: 2 additions & 3 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -12368,7 +12368,7 @@
"xpack.ml.ruleEditor.scopeSection.noPermissionToViewFilterListsTitle": "您无权查看筛选列表",
"xpack.ml.ruleEditor.scopeSection.scopeTitle": "范围",
"xpack.ml.ruleEditor.selectRuleAction.createRuleLinkText": "创建规则",
"xpack.ml.ruleEditor.selectRuleAction.orText": "或 ",
"xpack.ml.ruleEditor.selectRuleAction.orText": "或 ",
"xpack.ml.ruleEditor.typicalAppliesTypeText": "典型",
"xpack.ml.sampleDataLinkLabel": "ML 作业",
"xpack.ml.settings.anomalyDetection.anomalyDetectionTitle": "异常检测",
Expand Down Expand Up @@ -17363,7 +17363,6 @@
"xpack.snapshotRestore.policyRetentionSchedulePanel.retentionScheduleExecuteLinkTooltip": "立即运行保留",
"xpack.snapshotRestore.policyScheduleWarningDescription": "一次仅可以拍取一个快照。要避免快照失败,请编辑或删除策略。",
"xpack.snapshotRestore.policyScheduleWarningTitle": "两个或更多策略有相同的计划",
"xpack.snapshotRestore.policyValidation.indexPatternRequiredErrorMessage": "至少需要一个索引模式。",
"xpack.snapshotRestore.policyValidation.indicesRequiredErrorMessage": "必须至少选择一个数据流或索引。",
"xpack.snapshotRestore.policyValidation.invalidMinCountErrorMessage": "最小计数不能大于最大计数。",
"xpack.snapshotRestore.policyValidation.invalidNegativeDeleteAfterErrorMessage": "“在指定时间后删除”不能为负。",
Expand Down Expand Up @@ -19469,4 +19468,4 @@
"xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "此字段必填。",
"xpack.watcher.watcherDescription": "通过创建、管理和监测警报来检测数据中的更改。"
}
}
}