Skip to content

Commit 56cb8d7

Browse files
committed
chore: code review feedback.
1 parent 033845f commit 56cb8d7

File tree

5 files changed

+35
-9
lines changed

5 files changed

+35
-9
lines changed

examples/task-list-all.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async fn list_all_tasks(client: &Client) -> Result<()> {
3232
loop {
3333
let response = client
3434
.list_tasks(Some(&ListTasksParams {
35-
view: View::Full,
35+
view: Some(View::Full),
3636
page_token: last_token,
3737
..Default::default()
3838
}))

src/v1/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl Client {
169169
None => "tasks".to_string(),
170170
};
171171

172-
match params.map(|p| p.view).unwrap_or_default() {
172+
match params.and_then(|p| p.view).unwrap_or_default() {
173173
View::Minimal => {
174174
let results = self.get::<ListTasks<MinimalTask>>(url).await?;
175175

src/v1/types/requests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ pub struct ListTasksParams {
6161
/// If empty, no task tags filtering is done.
6262
#[cfg_attr(
6363
feature = "serde",
64-
serde(rename = "tag_key", default, skip_serializing_if = "Vec::is_empty")
64+
serde(rename = "tag_key", default, skip_serializing_if = "Option::is_none")
6565
)]
66-
pub tag_keys: Vec<String>,
66+
pub tag_keys: Option<Vec<String>>,
6767
/// The filter for task tag values.
6868
///
6969
/// This is zipped with `tag_keys`.
@@ -73,9 +73,9 @@ pub struct ListTasksParams {
7373
/// It is an error if more values are supplied than keys.
7474
#[cfg_attr(
7575
feature = "serde",
76-
serde(rename = "tag_value", default, skip_serializing_if = "Vec::is_empty")
76+
serde(rename = "tag_value", default, skip_serializing_if = "Option::is_none")
7777
)]
78-
pub tag_values: Vec<String>,
78+
pub tag_values: Option<Vec<String>>,
7979
/// The number of tasks to return in one page.
8080
///
8181
/// Must be less than 2048. Defaults to 256.
@@ -90,8 +90,8 @@ pub struct ListTasksParams {
9090
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
9191
pub page_token: Option<String>,
9292
/// The view of the returned task(s).
93-
#[cfg_attr(feature = "serde", serde(default))]
94-
pub view: View,
93+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
94+
pub view: Option<View>,
9595
}
9696

9797
/// Represents the request body of the `CreateTask` endpoint.

src/v1/types/responses/service_info.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ pub struct ServiceInfo {
9999
/// service.
100100
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
101101
storage: Option<Vec<String>>,
102+
103+
/// Lists all resource.backend_parameters keys supported by the service.
104+
#[cfg_attr(
105+
feature = "serde",
106+
serde(
107+
rename = "tesResources_backend_parameters",
108+
skip_serializing_if = "Option::is_none"
109+
)
110+
)]
111+
backend_parameters: Option<Vec<String>>,
102112
}
103113

104114
impl ServiceInfo {
@@ -263,12 +273,13 @@ mod tests {
263273
String::from("file:///path/to/local/funnel-storage"),
264274
String::from("s3://ohsu-compbio-funnel/storage"),
265275
]),
276+
backend_parameters: Some(vec!["foo".into(), "bar".into()]),
266277
};
267278

268279
let serialized = serde_json::to_string(&info).unwrap();
269280
assert_eq!(
270281
serialized,
271-
r#"{"id":"org.ga4gh.myservice","name":"My Server","type":{"group":"org.ga4gh","artifact":"tes","version":"1.0.0"},"description":"A description","organization":{"name":"My Organization","url":"https://example.com/"},"contactUrl":"mailto:foo@bar.com","documentationUrl":"https://docs.myservice.example.com/","createdAt":"2024-09-07T20:27:35.345673Z","updatedAt":"2024-09-07T20:27:35.345673Z","environment":"test","version":"1.5.0","storage":["file:///path/to/local/funnel-storage","s3://ohsu-compbio-funnel/storage"]}"#
282+
r#"{"id":"org.ga4gh.myservice","name":"My Server","type":{"group":"org.ga4gh","artifact":"tes","version":"1.0.0"},"description":"A description","organization":{"name":"My Organization","url":"https://example.com/"},"contactUrl":"mailto:foo@bar.com","documentationUrl":"https://docs.myservice.example.com/","createdAt":"2024-09-07T20:27:35.345673Z","updatedAt":"2024-09-07T20:27:35.345673Z","environment":"test","version":"1.5.0","storage":["file:///path/to/local/funnel-storage","s3://ohsu-compbio-funnel/storage"],"tesResources_backend_parameters":["foo","bar"]}"#
272283
);
273284

274285
let deserialized: ServiceInfo = serde_json::from_str(&serialized).unwrap();

src/v1/types/responses/service_info/builder.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ pub struct Builder {
7777
///
7878
/// This does not necessarily have to list _all_ storage locations.
7979
storage: Option<Vec<String>>,
80+
81+
/// Lists all resource.backend_parameters keys supported by the service.
82+
backend_parameters: Option<Vec<String>>,
8083
}
8184

8285
impl Builder {
@@ -215,6 +218,17 @@ impl Builder {
215218
self
216219
}
217220

221+
/// Sets all resource.backend_parameters keys supported by the service.
222+
///
223+
/// # Notes
224+
///
225+
/// This silently overrides any previously set supported backend parameters
226+
/// for the service.
227+
pub fn backend_parameters(mut self, value: impl Into<Vec<String>>) -> Self {
228+
self.backend_parameters = Some(value.into());
229+
self
230+
}
231+
218232
/// Consumes `self` and attempts to builde a [`ServiceInfo`].
219233
pub fn try_build(self) -> Result<ServiceInfo> {
220234
let id = self.id.ok_or(Error::Missing("id"))?;
@@ -249,6 +263,7 @@ impl Builder {
249263
environment: self.environment,
250264
version,
251265
storage: self.storage,
266+
backend_parameters: self.backend_parameters,
252267
})
253268
}
254269
}

0 commit comments

Comments
 (0)