Skip to content

Commit

Permalink
grpc: add with_defaults parameter to the Get RPC
Browse files Browse the repository at this point in the history
Signed-off-by: Renato Westphal <[email protected]>
  • Loading branch information
rwestphal committed Jul 3, 2024
1 parent 795340d commit bbeaa7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 6 additions & 4 deletions holo-daemon/src/northbound/client/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ impl proto::Northbound for NorthboundService {
let data_type = api::DataType::try_from(grpc_request.r#type)?;
let encoding = proto::Encoding::try_from(grpc_request.encoding)
.map_err(|_| Status::invalid_argument("Invalid data encoding"))?;
let with_defaults = grpc_request.with_defaults;
let path = (!grpc_request.path.is_empty()).then_some(grpc_request.path);
let nb_request = api::client::Request::Get(api::client::GetRequest {
data_type,
Expand All @@ -110,12 +111,13 @@ impl proto::Northbound for NorthboundService {
let nb_response = responder_rx.await.unwrap()?;

// Convert and relay northbound response to the gRPC client.
let mut printer_flags = DataPrinterFlags::WITH_SIBLINGS;
if with_defaults {
printer_flags.insert(DataPrinterFlags::WD_ALL);
}
let data = nb_response
.dtree
.print_string(
DataFormat::from(encoding),
DataPrinterFlags::WITH_SIBLINGS,
)
.print_string(DataFormat::from(encoding), printer_flags)
.map_err(|error| Status::internal(error.to_string()))?
.unwrap_or_default();
let grpc_response = proto::GetResponse {
Expand Down
5 changes: 4 additions & 1 deletion proto/holo.proto
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,11 @@ message GetRequest {
// Encoding to be used.
Encoding encoding = 2;

// Include implicit default nodes.
bool with_defaults = 3;

// Requested YANG path.
string path = 3;
string path = 4;
}

message GetResponse {
Expand Down

0 comments on commit bbeaa7e

Please sign in to comment.