Skip to content

Commit b92a589

Browse files
Maximilian WilhelmBarbarossaTM
Maximilian Wilhelm
authored andcommitted
Add GetDevice() gRPC endpoint
Signed-off-by: Maximilian Wilhelm <[email protected]>
1 parent a66cd86 commit b92a589

File tree

4 files changed

+235
-38
lines changed

4 files changed

+235
-38
lines changed

pkg/octopus/server.go

+15
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,18 @@ func (os *ocotopusServer) GetTopology(context.Context, *api.TopologyRequest) (*a
3636
Topology: topology.ToProto(),
3737
}, nil
3838
}
39+
40+
func (os *ocotopusServer) GetDevice(context context.Context, deviceRequest *api.DeviceRequest) (*api.DeviceResponse, error) {
41+
topology := os.octopus.GetTopology()
42+
if topology == nil {
43+
return nil, status.New(codes.Unavailable, "Octopus not ready.").Err()
44+
}
45+
46+
if deviceRequest == nil {
47+
return nil, status.New(codes.InvalidArgument, "No device_name provided.").Err()
48+
}
49+
50+
return &api.DeviceResponse{
51+
Device: topology.GetDevice(deviceRequest.DeviceName).ToProto(),
52+
}, nil
53+
}

proto/octopus.proto

+9
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ message TopologyResponse {
160160
Topology topology = 1;
161161
}
162162

163+
message DeviceRequest {
164+
string device_name = 1;
165+
}
166+
167+
message DeviceResponse {
168+
Device device = 1;
169+
}
170+
163171
service OctopusService {
164172
rpc GetTopology(TopologyRequest) returns (TopologyResponse) {}
173+
rpc GetDevice(DeviceRequest) returns (DeviceResponse) {}
165174
}

proto/octopus/octopus.pb.go

+175-38
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/octopus/octopus_grpc.pb.go

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)