-
Notifications
You must be signed in to change notification settings - Fork 0
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
simplify client program api #93
Conversation
target_type: Option<TargetLabel>, | ||
targets: &[&str], | ||
filter: Filter<'_>, |
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.
now consistent with the equivalent api for events
/// Get a single program from the VTN that matches the given target | ||
pub async fn get_program(&self, target: Target<'_>) -> Result<ProgramClient> { | ||
let pagination = PaginationOptions { skip: 0, limit: 2 }; | ||
|
||
let mut programs = self | ||
.get_programs_request( | ||
Some(target.target_label()), | ||
target.target_values(), | ||
pagination, | ||
) | ||
.await?; | ||
|
||
match programs[..] { | ||
[] => Err(crate::Error::ObjectNotFound), | ||
[_] => Ok(programs.remove(0)), | ||
[..] => Err(crate::Error::DuplicateObject), | ||
} | ||
} | ||
|
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.
the only target that you can give that gives a single result is ProgramName, so we can just use a get_program_by_name
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #93 +/- ##
==========================================
- Coverage 72.88% 72.86% -0.03%
==========================================
Files 28 28
Lines 3552 3541 -11
==========================================
- Hits 2589 2580 -9
+ Misses 963 961 -2 ☔ View full report in Codecov by Sentry. |
No description provided.