From 7d57984650836ddccb8730b6b5eb513760ffcbc4 Mon Sep 17 00:00:00 2001 From: Abhinandan Purkait Date: Thu, 24 Aug 2023 07:15:48 +0000 Subject: [PATCH 1/4] refactor: replica listing based on query Signed-off-by: Abhinandan Purkait --- protobuf/v1/replica.proto | 17 ++++++++--------- src/v1.rs | 5 ++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/protobuf/v1/replica.proto b/protobuf/v1/replica.proto index b45ae9ec..65598d38 100644 --- a/protobuf/v1/replica.proto +++ b/protobuf/v1/replica.proto @@ -83,18 +83,17 @@ message ListReplicasResponse { repeated Replica replicas = 1; // list of the replicas } -/// ReplicaType enum is used to filter replica in listreplica response. -enum ReplicaType { - AllReplicas = 0; // Default value, to return all the replicas including snapshots and clones - AllReplicasExceptSnapshots = 1; // Return replicas and snapshot clones, without snapshots - OnlySnapshotClones = 2; // Returns only snapshot clones - OnlyReplicas = 3; // Returns only replicas -} - message ListReplicaOptions { google.protobuf.StringValue name = 1; // list the replica with the name if provided google.protobuf.StringValue poolname = 2; // list the replicas on the provided pool, by name google.protobuf.StringValue uuid = 3; // list the replica with the uuid if provided google.protobuf.StringValue pooluuid = 4; // list the replicas on the provided pool, by uuid - ReplicaType replicatype = 5; // list replica based on ReplicaType value + Query query = 5; // list replica based on Query value + + /// Query used for getting specific types of replicas. These are mutually exclusive, ex. a snapshot cannot be clone. + message Query { + bool replica = 1; // query for selecting or normal replica types. + bool snapshot = 2; // query for selecting or snapshot types. + bool clone = 3; // query for selecting or clone types. + } } diff --git a/src/v1.rs b/src/v1.rs index 5922634c..72b092ff 100644 --- a/src/v1.rs +++ b/src/v1.rs @@ -41,12 +41,11 @@ pub mod pool { pub mod replica { pub use super::pb::{ - destroy_replica_request, + destroy_replica_request, list_replica_options, replica_rpc_client::ReplicaRpcClient, replica_rpc_server::{ReplicaRpc, ReplicaRpcServer}, CreateReplicaRequest, DestroyReplicaRequest, ListReplicaOptions, ListReplicasResponse, - Replica, ReplicaSpaceUsage, ReplicaType, ShareReplicaRequest, SnapshotInfo, - UnshareReplicaRequest, + Replica, ReplicaSpaceUsage, ShareReplicaRequest, SnapshotInfo, UnshareReplicaRequest, }; } pub mod snapshot { From 034d401afbcbda3eb351139c256f4cecce59c886 Mon Sep 17 00:00:00 2001 From: Abhinandan Purkait Date: Thu, 24 Aug 2023 13:47:05 +0000 Subject: [PATCH 2/4] chore: update gitignore Signed-off-by: Abhinandan Purkait --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c5901838..ce94e4bc 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,6 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk -/rust-toolchain.toml \ No newline at end of file +/rust-toolchain.toml +.idea +.vscode \ No newline at end of file From be2bf45fe4a020d00c6053fcfae96aae86031b1f Mon Sep 17 00:00:00 2001 From: Abhinandan Purkait Date: Thu, 24 Aug 2023 13:58:22 +0000 Subject: [PATCH 3/4] chore: update rust version Signed-off-by: Abhinandan Purkait --- nix/sources.json | 14 +++++++------- shell.nix | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/nix/sources.json b/nix/sources.json index d06c49cc..88ac51f1 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -1,14 +1,14 @@ { "nixpkgs": { - "branch": "release-22.05", + "branch": "release-23.05", "description": "Nix Packages collection", "homepage": "", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b8720c8492d2ad2f892a6e0a0064d6da2969aba4", - "sha256": "0lpnfb94qyrv7sw8vjrpdlrrn2n2q75r93mc8q5afm5a0pdzrkax", + "rev": "d540c6348227dff41a708db5c0b70cc3018080ea", + "sha256": "10348aq69kvxf3zvkn60dh53l85prbjpr2k2i7ianl31lvrgyaw9", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/b8720c8492d2ad2f892a6e0a0064d6da2969aba4.tar.gz", + "url": "https://github.com/NixOS/nixpkgs/archive/d540c6348227dff41a708db5c0b70cc3018080ea.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "rust-overlay": { @@ -17,10 +17,10 @@ "homepage": "", "owner": "oxalica", "repo": "rust-overlay", - "rev": "b4fb0f8454fe4e6ebb0a564a28a87cc88cc3cb2c", - "sha256": "01912q23pd67q4adsl6b1ayi3kn92w0daj2dvihajmh8239iplf3", + "rev": "8f6d56270ec028a340583111609b12663f5d7490", + "sha256": "1nc55v895m9q592jjsjk5n8mbm769dw82j1x6638g8qkk2rjv6al", "type": "tarball", - "url": "https://github.com/oxalica/rust-overlay/archive/b4fb0f8454fe4e6ebb0a564a28a87cc88cc3cb2c.tar.gz", + "url": "https://github.com/oxalica/rust-overlay/archive/8f6d56270ec028a340583111609b12663f5d7490.tar.gz", "url_template": "https://github.com///archive/.tar.gz" } } diff --git a/shell.nix b/shell.nix index 2b870f1b..6acefb78 100644 --- a/shell.nix +++ b/shell.nix @@ -1,4 +1,4 @@ -{ profile ? "nightly", date ? "2022-06-22", rustup ? false }: +{ profile ? "nightly", date ? "2023-08-10", rustup ? false }: let sources = import ./nix/sources.nix; pkgs = import sources.nixpkgs { From 573bf7e2f37349a7954bfef6ed2dfb54c0b506d4 Mon Sep 17 00:00:00 2001 From: Abhinandan Purkait Date: Thu, 24 Aug 2023 14:17:00 +0000 Subject: [PATCH 4/4] fix: doc comment format Signed-off-by: Abhinandan Purkait --- src/v1.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v1.rs b/src/v1.rs index 72b092ff..05515845 100644 --- a/src/v1.rs +++ b/src/v1.rs @@ -1,4 +1,4 @@ -///!module to access v1 version of grpc APIs +//! Module to access v1 version of grpc APIs use std::str::FromStr; // dont export the raw pb generated code mod pb {