-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add select host checks endpoint #1544
Conversation
f1c1c03
to
836e98c
Compare
responses: [ | ||
accepted: "The Selection has been successfully collected", | ||
not_found: Schema.NotFound.response(), | ||
bad_request: Schema.BadRequest.response(), |
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 have a doubt on this. I am tempted to remove it. I couldn't make it respond a 400.
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.
So, we only have 404 and 422. Yes it looks correct.
PD: I guess the command dispatch command returns {:error, :host_not_registered}
, right?
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 took advantage by cleaning up also other controllers defining an unnecessary bad_request
We have bad_request also used in cluster controller and tags controller.
We might want to clean those up at a certain point, however that change is not backward compatible so we'd need to bump version. I would not touch them yet, and track the thing. wdty?
I guess the command dispatch command returns {:error, :host_not_registered}, right?
yes if the host is not registered yet. It might also return {:error, :host_rolling_up}
if the aggregate is in the rollup process.
684c3dd
to
91908df
Compare
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.
Nice!
PD: We will have fun with the conflicts at some point hehe
@@ -36,4 +40,16 @@ defmodule Trento.Hosts do | |||
subscription_count | |||
end | |||
end | |||
|
|||
@spec select_checks(String.t(), [String.t()]) :: :ok | {:error, any} |
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.
More conflicts to come in this file most probably 🙈
responses: [ | ||
accepted: "The Selection has been successfully collected", | ||
not_found: Schema.NotFound.response(), | ||
bad_request: Schema.BadRequest.response(), |
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.
So, we only have 404 and 422. Yes it looks correct.
PD: I guess the command dispatch command returns {:error, :host_not_registered}
, right?
cd967a8
to
064a6ec
Compare
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.
Just a nitpick but good job overall 👍
describe "Check Selection" do | ||
test "should dispatch command on Check Selection" do | ||
host_id = Faker.UUID.v4() | ||
selected_checks = Enum.map(0..4, fn _ -> Faker.Cat.name() end) |
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.
Maybe we want to use UUIDs here (file under the usual topic: not mandatorily a uuid, but still for the sake of uniqueness)
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.
Uniqueness here is not strictly necessary, however I changed in favor of a uuid.
Hope it does not become uuid all the things 😅
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.
Oh well for tests I tend to prefer them because there's really no risk of collisions 😅
064a6ec
to
023e3f3
Compare
Description
Exposes a
POST /api/v1/hosts/:id/checks
for host checks selection.How was this tested?
Automated test.