Skip to content

Commit

Permalink
handle use casse
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Oct 25, 2024
1 parent b650e8b commit 2a80569
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import { isEmpty } from 'lodash';
import { INITIAL_REST_VERSION, SYNTHETICS_API_URLS } from '../../../../../common/constants';
import {
DeleteParamsResponse,
Expand Down Expand Up @@ -35,16 +36,22 @@ export const editGlobalParam = async ({
id,
}: {
id: string;
paramRequest: SyntheticsParamRequest;
}): Promise<SyntheticsParams> =>
apiService.put<SyntheticsParams>(
paramRequest: Partial<SyntheticsParamRequest>;
}): Promise<SyntheticsParams> => {
const data = paramRequest;
if (isEmpty(paramRequest.value)) {
// omit empty value
delete data.value;
}
return await apiService.put<SyntheticsParams>(
SYNTHETICS_API_URLS.PARAMS + `/${id}`,
paramRequest,
data,
SyntheticsParamsCodec,
{
version: INITIAL_REST_VERSION,
}
);
};

export const deleteGlobalParams = async (ids: string[]): Promise<DeleteParamsResponse[]> =>
apiService.delete(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ import { syntheticsParamType } from '../../../../common/types/saved_objects';
import { SYNTHETICS_API_URLS } from '../../../../common/constants';

const ParamsObjectSchema = schema.object({
key: schema.string(),
value: schema.string(),
key: schema.string({
minLength: 1,
}),
value: schema.string({
minLength: 1,
}),
description: schema.maybe(schema.string()),
tags: schema.maybe(schema.arrayOf(schema.string())),
share_across_spaces: schema.maybe(schema.boolean()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,16 @@ export const editSyntheticsParamsRoute: SyntheticsRestApiRouteFactory<
request: {
params: RequestParamsSchema,
body: schema.object({
key: schema.maybe(schema.string()),
value: schema.maybe(schema.string()),
key: schema.maybe(
schema.string({
minLength: 1,
})
),
value: schema.maybe(
schema.string({
minLength: 1,
})
),
description: schema.maybe(schema.string()),
tags: schema.maybe(schema.arrayOf(schema.string())),
}),
Expand Down

0 comments on commit 2a80569

Please sign in to comment.