Skip to content

Commit 89e2af8

Browse files
authored
Rename batchSize parameter to batch_size to be consisten with the API namings guidelines. (#82123)
1 parent 31a7cd2 commit 89e2af8

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

docs/api/saved-objects/rotate_encryption_key.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Bulk key rotation can consume a considerable amount of resources and hence only
2525
`type`::
2626
(Optional, string) Limits encryption key rotation only to the saved objects with the specified type. By default, {kib} tries to rotate the encryption key for all saved object types that may contain encrypted attributes.
2727

28-
`batchSize`::
28+
`batch_size`::
2929
(Optional, number) Specifies a maximum number of saved objects that {kib} can process in a single batch. Bulk key rotation is an iterative process since {kib} may not be able to fetch and process all required saved objects in one go and splits processing into consequent batches. By default, the batch size is 10000, which is also a maximum allowed value.
3030

3131
[[saved-objects-api-rotate-encryption-key-response-body]]
@@ -91,7 +91,7 @@ In this example, key rotation is performed for all saved objects with the `alert
9191

9292
[source,sh]
9393
--------------------------------------------------
94-
$ curl -X POST /api/encrypted_saved_objects/_rotate_key?type=alert&batchSize=5000
94+
$ curl -X POST /api/encrypted_saved_objects/_rotate_key?type=alert&batch_size=5000
9595
--------------------------------------------------
9696
// KIBANA
9797

x-pack/plugins/encrypted_saved_objects/server/routes/key_rotation.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,24 @@ describe('Key rotation routes', () => {
5757
const queryValidator = (routeConfig.validate as any).query as Type<any>;
5858
expect(
5959
queryValidator.validate({
60-
batchSize: 100,
60+
batch_size: 100,
6161
type: 'some-type',
6262
})
6363
).toEqual({
64-
batchSize: 100,
64+
batch_size: 100,
6565
type: 'some-type',
6666
});
67-
expect(queryValidator.validate({ batchSize: 1 })).toEqual({ batchSize: 1 });
68-
expect(queryValidator.validate({ batchSize: 10000 })).toEqual({ batchSize: 10000 });
69-
expect(queryValidator.validate({})).toEqual({ batchSize: 10000 });
67+
expect(queryValidator.validate({ batch_size: 1 })).toEqual({ batch_size: 1 });
68+
expect(queryValidator.validate({ batch_size: 10000 })).toEqual({ batch_size: 10000 });
69+
expect(queryValidator.validate({})).toEqual({ batch_size: 10000 });
7070

71-
expect(() => queryValidator.validate({ batchSize: 0 })).toThrowErrorMatchingInlineSnapshot(
72-
`"[batchSize]: Value must be equal to or greater than [1]."`
71+
expect(() => queryValidator.validate({ batch_size: 0 })).toThrowErrorMatchingInlineSnapshot(
72+
`"[batch_size]: Value must be equal to or greater than [1]."`
7373
);
7474
expect(() =>
75-
queryValidator.validate({ batchSize: 10001 })
75+
queryValidator.validate({ batch_size: 10001 })
7676
).toThrowErrorMatchingInlineSnapshot(
77-
`"[batchSize]: Value must be equal to or lower than [10000]."`
77+
`"[batch_size]: Value must be equal to or lower than [10000]."`
7878
);
7979

8080
expect(() => queryValidator.validate({ type: 100 })).toThrowErrorMatchingInlineSnapshot(
@@ -106,7 +106,7 @@ describe('Key rotation routes', () => {
106106
const unhandledException = new Error('Something went wrong.');
107107
mockEncryptionKeyRotationService.rotate.mockRejectedValue(unhandledException);
108108

109-
const mockRequest = httpServerMock.createKibanaRequest({ query: { batchSize: 1234 } });
109+
const mockRequest = httpServerMock.createKibanaRequest({ query: { batch_size: 1234 } });
110110
const response = await routeHandler(mockContext, mockRequest, kibanaResponseFactory);
111111

112112
expect(response.status).toBe(500);
@@ -117,7 +117,7 @@ describe('Key rotation routes', () => {
117117
});
118118

119119
it('returns whatever `rotate` returns.', async () => {
120-
const mockRequest = httpServerMock.createKibanaRequest({ query: { batchSize: 1234 } });
120+
const mockRequest = httpServerMock.createKibanaRequest({ query: { batch_size: 1234 } });
121121
mockEncryptionKeyRotationService.rotate.mockResolvedValue({
122122
total: 3,
123123
successful: 6,
@@ -132,7 +132,7 @@ describe('Key rotation routes', () => {
132132
});
133133

134134
it('returns 429 if called while rotation is in progress.', async () => {
135-
const mockRequest = httpServerMock.createKibanaRequest({ query: { batchSize: 1234 } });
135+
const mockRequest = httpServerMock.createKibanaRequest({ query: { batch_size: 1234 } });
136136
mockEncryptionKeyRotationService.rotate.mockResolvedValue({
137137
total: 3,
138138
successful: 6,

x-pack/plugins/encrypted_saved_objects/server/routes/key_rotation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function defineKeyRotationRoutes({
2828
path: '/api/encrypted_saved_objects/_rotate_key',
2929
validate: {
3030
query: schema.object({
31-
batchSize: schema.number({
31+
batch_size: schema.number({
3232
min: 1,
3333
max: DEFAULT_MAX_RESULT_WINDOW,
3434
defaultValue: DEFAULT_MAX_RESULT_WINDOW,
@@ -60,7 +60,7 @@ export function defineKeyRotationRoutes({
6060
try {
6161
return response.ok({
6262
body: await encryptionKeyRotationService.rotate(request, {
63-
batchSize: request.query.batchSize,
63+
batchSize: request.query.batch_size,
6464
type: request.query.type,
6565
}),
6666
});

0 commit comments

Comments
 (0)