oss_vizier/model/trial/optimal.rs
1// Copyright 2022 Sebastien Soudan.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Trial list optimal request builder.
16
17use crate::vizier::ListOptimalTrialsRequest;
18use crate::StudyName;
19
20/// [ListOptimalTrialsRequest] builder.
21pub struct RequestBuilder {
22 study_name: StudyName,
23 page_token: Option<String>,
24 page_size: Option<i32>,
25}
26
27impl RequestBuilder {
28 /// Creates a new instance of [ListOptimalTrialsRequest] builder.
29 pub fn new(study_name: StudyName) -> Self {
30 RequestBuilder {
31 study_name,
32 page_token: None,
33 page_size: None,
34 }
35 }
36
37 /// Sets the page token to the [ListOptimalTrialsRequest].
38 /// The page token is used to retrieve the next page of results.
39 /// If not set, the first page of results is returned.
40 /// The page token is returned in the response of a previous
41 /// [ListOptimalTrialsRequest].
42 pub fn with_page_token(mut self, page_token: String) -> Self {
43 self.page_token = Some(page_token);
44 self
45 }
46
47 /// Sets the page size to the [ListOptimalTrialsRequest].
48 /// The page size is used to limit the number of trials returned in the response.
49 pub fn with_page_size(mut self, page_size: i32) -> Self {
50 self.page_size = Some(page_size);
51 self
52 }
53
54 /// Builds the [ListOptimalTrialsRequest].
55 pub fn build(self) -> ListOptimalTrialsRequest {
56 ListOptimalTrialsRequest {
57 parent: self.study_name.into(),
58 page_token: self.page_token.unwrap_or_default(),
59 page_size: self.page_size.unwrap_or(0),
60 }
61 }
62}