Skip to content
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

feat: add owner/name filter to list clients #2637

Merged
merged 6 commits into from
Aug 2, 2021

Conversation

pike1212
Copy link
Contributor

This adds client name and owner filters to the client list endpoint.

Related issue(s)

#1485

Checklist

Further Comments

Still need to update documentation, looking for any initial feedback first

Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you for your contribution! This looks pretty good and I have some ideas how to improve it further :)

client/client.go Outdated
@@ -200,6 +200,13 @@ type Client struct {
Metadata sqlxx.JSONRawMessage `json:"metadata,omitempty" db:"metadata"`
}

type ClientFilters struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be added to the swagger spec:

type swaggerListClientsParameter struct {

You can also probably re-use / re-purpose that struct as ClientFilter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the name/owner params to that struct, is that all that needs done?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's all that's needed - I think this can be removed then!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ClientFilters struct is used internally to get passed to the client manager, so new filers could be easily added...

Comment on lines +86 to +91
if filters.Name != "" {
query.Where("client_name = ?", filters.Name)
}
if filters.Owner != "" {
query.Where("owner = ?", filters.Owner)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably means that we need to index these fields? Otherwise this will get very slow when you have lots of clients. Then again, if we just have like 1000 clients, it probably wouldn't matter too much (maybe 5ms with index, 200ms without). What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For our use case, the index won't make much of a difference

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, we can keep the filter omitted for now and add it later.

@codecov
Copy link

codecov bot commented Jul 14, 2021

Codecov Report

Merging #2637 (7c86062) into master (a8675dd) will increase coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2637      +/-   ##
==========================================
+ Coverage   52.47%   52.54%   +0.07%     
==========================================
  Files         234      234              
  Lines       13905    13924      +19     
==========================================
+ Hits         7296     7317      +21     
+ Misses       5986     5985       -1     
+ Partials      623      622       -1     
Impacted Files Coverage Δ
client/handler.go 61.46% <100.00%> (+1.85%) ⬆️
client/manager_test_helpers.go 97.61% <100.00%> (+0.16%) ⬆️
persistence/sql/persister_client.go 80.00% <100.00%> (+1.27%) ⬆️
persistence/sql/persister_oauth2.go 81.61% <0.00%> (+0.89%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a4e9461...7c86062. Read the comment docs.

Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there, sorry for the slow review. Was quite a busy few days at Ory as we were working on the cloud platform. Next week I have much more time for reviews and merging things, which is also where I want to merge this PR!

Comment on lines +86 to +91
if filters.Name != "" {
query.Where("client_name = ?", filters.Name)
}
if filters.Owner != "" {
query.Where("owner = ?", filters.Owner)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, we can keep the filter omitted for now and add it later.

client/client.go Outdated
@@ -200,6 +200,13 @@ type Client struct {
Metadata sqlxx.JSONRawMessage `json:"metadata,omitempty" db:"metadata"`
}

type ClientFilters struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's all that's needed - I think this can be removed then!

@aeneasr
Copy link
Member

aeneasr commented Jul 30, 2021

This is what I had in mind :)

a4492df

aeneasr
aeneasr previously approved these changes Jul 30, 2021
@aeneasr aeneasr merged commit ea6fdfd into ory:master Aug 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants