Skip to content

Commit

Permalink
[7.10] Rename batchSize parameter to batch_size to be consistent …
Browse files Browse the repository at this point in the history
…with the API namings guidelines. (elastic#82225)
  • Loading branch information
azasypkin committed Nov 1, 2020
1 parent f2cf1dd commit 2450fd9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions docs/api/saved-objects/rotate_encryption_key.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Bulk key rotation can consume a considerable amount of resources and hence only
`type`::
(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.

`batchSize`::
`batch_size`::
(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.

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

[source,sh]
--------------------------------------------------
$ curl -X POST /api/encrypted_saved_objects/_rotate_key?type=alert&batchSize=5000
$ curl -X POST /api/encrypted_saved_objects/_rotate_key?type=alert&batch_size=5000
--------------------------------------------------
// KIBANA

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,24 @@ describe('Key rotation routes', () => {
const queryValidator = (routeConfig.validate as any).query as Type<any>;
expect(
queryValidator.validate({
batchSize: 100,
batch_size: 100,
type: 'some-type',
})
).toEqual({
batchSize: 100,
batch_size: 100,
type: 'some-type',
});
expect(queryValidator.validate({ batchSize: 1 })).toEqual({ batchSize: 1 });
expect(queryValidator.validate({ batchSize: 10000 })).toEqual({ batchSize: 10000 });
expect(queryValidator.validate({})).toEqual({ batchSize: 10000 });
expect(queryValidator.validate({ batch_size: 1 })).toEqual({ batch_size: 1 });
expect(queryValidator.validate({ batch_size: 10000 })).toEqual({ batch_size: 10000 });
expect(queryValidator.validate({})).toEqual({ batch_size: 10000 });

expect(() => queryValidator.validate({ batchSize: 0 })).toThrowErrorMatchingInlineSnapshot(
`"[batchSize]: Value must be equal to or greater than [1]."`
expect(() => queryValidator.validate({ batch_size: 0 })).toThrowErrorMatchingInlineSnapshot(
`"[batch_size]: Value must be equal to or greater than [1]."`
);
expect(() =>
queryValidator.validate({ batchSize: 10001 })
queryValidator.validate({ batch_size: 10001 })
).toThrowErrorMatchingInlineSnapshot(
`"[batchSize]: Value must be equal to or lower than [10000]."`
`"[batch_size]: Value must be equal to or lower than [10000]."`
);

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

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

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

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

it('returns 429 if called while rotation is in progress.', async () => {
const mockRequest = httpServerMock.createKibanaRequest({ query: { batchSize: 1234 } });
const mockRequest = httpServerMock.createKibanaRequest({ query: { batch_size: 1234 } });
mockEncryptionKeyRotationService.rotate.mockResolvedValue({
total: 3,
successful: 6,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function defineKeyRotationRoutes({
path: '/api/encrypted_saved_objects/_rotate_key',
validate: {
query: schema.object({
batchSize: schema.number({
batch_size: schema.number({
min: 1,
max: DEFAULT_MAX_RESULT_WINDOW,
defaultValue: DEFAULT_MAX_RESULT_WINDOW,
Expand Down Expand Up @@ -60,7 +60,7 @@ export function defineKeyRotationRoutes({
try {
return response.ok({
body: await encryptionKeyRotationService.rotate(request, {
batchSize: request.query.batchSize,
batchSize: request.query.batch_size,
type: request.query.type,
}),
});
Expand Down

0 comments on commit 2450fd9

Please sign in to comment.