-
-
Notifications
You must be signed in to change notification settings - Fork 221
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retrieve the events list for a project for v2 #1307
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
use anyhow::Result; | ||
use clap::{ArgMatches, Command}; | ||
|
||
use crate::api::Api; | ||
use crate::config::Config; | ||
use crate::utils::formatting::Table; | ||
|
||
pub fn make_command(command: Command) -> Command { | ||
command.about("List all events in your organization.") | ||
} | ||
|
||
pub fn execute(matches: &ArgMatches) -> Result<()> { | ||
let api = Api::current(); | ||
|
||
let config = Config::current(); | ||
let org = config.get_org(matches)?; | ||
let project = config.get_project(matches)?; | ||
let limit = matches.value_of("limit").unwrap(); | ||
|
||
let events = | ||
api.list_organization_project_events(&org, &project, limit.parse::<u16>().unwrap())?; | ||
|
||
let mut table = Table::new(); | ||
let row = table.title_row().add("Event ID").add("Date").add("Title"); | ||
if matches.is_present("user") { | ||
row.add("User"); | ||
} | ||
|
||
if matches.is_present("tags") { | ||
row.add("Tags"); | ||
} | ||
|
||
let max_rows = if matches.is_present("max-rows") { | ||
matches | ||
.value_of("max-rows") | ||
.unwrap() | ||
.parse::<usize>() | ||
.unwrap() | ||
} else { | ||
events.len() | ||
}; | ||
|
||
for event in &events[..max_rows] { | ||
boozec marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let row = table.add_row(); | ||
row.add(&event.event_id) | ||
.add(&event.date_created) | ||
.add(&event.title); | ||
|
||
if matches.is_present("user") { | ||
row.add(&event.user); | ||
} | ||
|
||
if matches.is_present("tags") { | ||
row.add(&event.tags); | ||
} | ||
} | ||
|
||
if table.is_empty() { | ||
println!("No events found"); | ||
} else { | ||
table.print(); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
use anyhow::Result; | ||
use clap::{Arg, ArgMatches, Command}; | ||
|
||
use crate::utils::args::ArgExt; | ||
|
||
pub mod list; | ||
|
||
macro_rules! each_subcommand { | ||
($mac:ident) => { | ||
$mac!(list); | ||
}; | ||
} | ||
|
||
pub fn make_command(mut command: Command) -> Command { | ||
macro_rules! add_subcommand { | ||
($name:ident) => {{ | ||
command = command.subcommand(crate::commands::events::$name::make_command( | ||
Command::new(stringify!($name).replace('_', "-")), | ||
)); | ||
}}; | ||
} | ||
|
||
command = command | ||
boozec marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.about("Manage events on Sentry.") | ||
.subcommand_required(true) | ||
.arg_required_else_help(true) | ||
.org_arg() | ||
.project_arg(true) | ||
.arg( | ||
Arg::with_name("user") | ||
.long("user") | ||
.short('u') | ||
.global(true) | ||
.help("Include user's info into the list."), | ||
) | ||
.arg( | ||
Arg::with_name("tags") | ||
.long("tags") | ||
.short('t') | ||
.global(true) | ||
.help("Include tags into the list."), | ||
) | ||
.arg( | ||
Arg::new("max-rows") | ||
.long("max-rows") | ||
.value_name("MAX-ROWS") | ||
.global(true) | ||
.help("Max of rows for a table."), | ||
) | ||
.arg( | ||
Arg::new("limit") | ||
.long("limit") | ||
.global(true) | ||
.value_name("LIMIT") | ||
.default_value("10") | ||
.help("Limit of requests."), | ||
); | ||
each_subcommand!(add_subcommand); | ||
command | ||
} | ||
|
||
pub fn execute(matches: &ArgMatches) -> Result<()> { | ||
macro_rules! execute_subcommand { | ||
($name:ident) => {{ | ||
if let Some(sub_matches) = | ||
matches.subcommand_matches(&stringify!($name).replace('_', "-")) | ||
{ | ||
return crate::commands::events::$name::execute(&sub_matches); | ||
} | ||
}}; | ||
} | ||
each_subcommand!(execute_subcommand); | ||
unreachable!(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We already have all those types in sentry-sdk crate.
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.
Hi @kamilogorek I found
Event
but I don't think you're talking about this one because it is not good for this JSON response.For
EventUser
you were right because we can usesentry::protocol::User
instead ofEventUserOption
.For
EventTags
I suggest to keep theVec<EventTag>
due the JSON serialization. If we use the same way used for sentry-sdk we have to refactortags
inVec<BTreeMap<String, String>>
(orHashMap
) but we always have a BTreeMap (or HashMap) with a tuple("key", "...")
and a("value", "...")
cause the nature of the response.