scim
scim copied to clipboard
Publish filters package
I've stumbled upon a need to use the filters package, which is internal at the moment. This proposal aims at making it usable from other packages. What do you think?
Any chance this can be merged or commented upon?
As it stands, I believe there's a problem with the code flow. I am trying to implement my resource handler. In the GetAll
method, I need to apply query filters. I cannot do that in the persistence layer.
I am using schemasHandler
in handlers.go
as an example - I was hoping I can just call PassesFilter
on the ListRequestParams.Filter
parameter. However, that is a expression.Expression
- I would have to convert it to a validator, which is inside an internal package.
There are two ways out of my dilemma:
- wait for this patch to be merged, and re-implement the validator
- or change the signature of
ListRequestParams.Params
to beinternal.filter.Validator
, and changegetFilter
to return aValidator
instead. Then a small amount of code inhandlers.go
can be removed since it would immediately benefit from it.
Thank you!
I have run into this problem as well. Because the validator is on the internal
package there is no way for the end user to use it. It feels like ListRequestParams
should have a function that returns the validator for the filter so you can do
func (t userHandler) GetAll(r *http.Request, params scim.ListRequestParams) (scim.Page, error) {
validator := params.GetValidator()
users, _ := MyClient().ListUsers()
for _, user := range users {
attributes := scim.ResourceAttributes{}
attributes["userName"] = user.Email
if validator.Passes(attributes) != nil {
continue
}
... Continue Processing User ...
}
}
Currently as it stands there is literally no way for an end user of this library to use filters without forking the codebase.