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

simplify client program api #93

Merged
merged 1 commit into from
Sep 3, 2024
Merged

simplify client program api #93

merged 1 commit into from
Sep 3, 2024

Conversation

folkertdev
Copy link
Collaborator

No description provided.

target_type: Option<TargetLabel>,
targets: &[&str],
filter: Filter<'_>,
Copy link
Collaborator Author

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

Comment on lines -414 to -432
/// 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),
}
}

Copy link
Collaborator Author

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

Copy link

codecov bot commented Aug 27, 2024

Codecov Report

Attention: Patch coverage is 73.33333% with 8 lines in your changes missing coverage. Please review.

Project coverage is 72.86%. Comparing base (f562e56) to head (907fb5f).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
openadr-client/src/lib.rs 76.92% 6 Missing ⚠️
openadr-client/src/bin/cli.rs 0.00% 1 Missing ⚠️
openadr-client/src/bin/everest.rs 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@rnijveld rnijveld merged commit 86ed007 into main Sep 3, 2024
11 checks passed
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