-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RAM] Category fields endpoint #138245
[RAM] Category fields endpoint #138245
Conversation
…-ref HEAD~1..HEAD --fix'
…nto 137988-category-field-api
ab8955f
to
34a2cfd
Compare
@elasticmachine merge upstream |
x-pack/plugins/rule_registry/server/routes/get_browser_fields_by_feature_id.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jcger we should create some api integration test under this folder , and can we add basic unit test too?
x-pack/plugins/rule_registry/server/routes/get_browser_fields_by_feature_id.ts
Outdated
Show resolved
Hide resolved
query: buildRouteValidation( | ||
t.exact( | ||
t.type({ | ||
featureIds: t.union([t.string, t.array(t.string)]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jcger That's one of the reason why your API integration was not working because before you only allow for array. However, when you just have one item in a query parameter, it is automatically converted to just be a string.
expectedStatusCode: number = 200 | ||
) => { | ||
const resp = await supertestWithoutAuth | ||
.get(`${getSpaceUrlPrefix(SPACE1)}${TEST_URL}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jcger I had to add the space because your user secOnlyRead
only have access to space 1. On Monday let's go over kibana privileges together. It is always confusing for everybody.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…-ref HEAD~1..HEAD --fix'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested it locally, LGTM!
import { BrowserField, BrowserFields } from '../../types'; | ||
|
||
const getFieldCategory = (fieldCapability: FieldSpec) => { | ||
const name = fieldCapability.name.split('.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Since it is an array, names would be a better naming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I agree. It's still the name capability but split into one array, each element of the name would a part of the name but not a name by itself. Calling it names would mean that each part is a name but I think it isn't, not sure though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean, maybe nameParts
or nameSections
? In general, it helps when for arrays, we have a plural name but up to you :)
}; | ||
|
||
export const fieldDescriptorToBrowserFieldMapper = ( | ||
fieldDescriptor: FieldSpec[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: We can call this fields
for this variable and when we iterate over it, use field
for each item.
): BrowserFields => { | ||
return fieldDescriptor.reduce((browserFields: BrowserFields, fieldCapability: FieldSpec) => { | ||
const category = getFieldCategory(fieldCapability); | ||
const field = browserFieldFactory(fieldCapability, category); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This field
is browserField
, right? We can name it browserField
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Public APIs missing exports
History
To update your PR or re-run it, just comment with: |
Summary
Implements #137988 server part
Checklist
How to QA
internal/rac/alerts/browser_fields
and it expectsfeatureIds
as query param, for examplecurl -u 'user:password' '[HOST:PORT/BASE_PATH]/internal/rac/alerts/browser_fields?featureIds=logs&featureIds=apm'
should return all field capabilities inlogs
andapm