Skip to content

Commit

Permalink
Add GetDevice() gRPC endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Wilhelm <[email protected]>
  • Loading branch information
Maximilian Wilhelm authored and BarbarossaTM committed Oct 27, 2023
1 parent a66cd86 commit b92a589
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 38 deletions.
15 changes: 15 additions & 0 deletions pkg/octopus/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,18 @@ func (os *ocotopusServer) GetTopology(context.Context, *api.TopologyRequest) (*a
Topology: topology.ToProto(),
}, nil
}

func (os *ocotopusServer) GetDevice(context context.Context, deviceRequest *api.DeviceRequest) (*api.DeviceResponse, error) {
topology := os.octopus.GetTopology()
if topology == nil {
return nil, status.New(codes.Unavailable, "Octopus not ready.").Err()
}

if deviceRequest == nil {
return nil, status.New(codes.InvalidArgument, "No device_name provided.").Err()
}

return &api.DeviceResponse{
Device: topology.GetDevice(deviceRequest.DeviceName).ToProto(),
}, nil
}
9 changes: 9 additions & 0 deletions proto/octopus.proto
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ message TopologyResponse {
Topology topology = 1;
}

message DeviceRequest {
string device_name = 1;
}

message DeviceResponse {
Device device = 1;
}

service OctopusService {
rpc GetTopology(TopologyRequest) returns (TopologyResponse) {}
rpc GetDevice(DeviceRequest) returns (DeviceResponse) {}
}
213 changes: 175 additions & 38 deletions proto/octopus/octopus.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions proto/octopus/octopus_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b92a589

Please sign in to comment.