Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server): Add RPC GetPrincipal #1157

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/docs/08-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,12 @@ languages [here](/docs/developer-guide/grpc), but we put this here for the true
| ------------ | ------------- | ------------|
| [PutPrincipalRequest](#putprincipalrequest) | [Principal](#principal) | EXPERIMENTAL: Creates an Principal. |

### RPC `GetPrincipal` {#getprincipal}

| Request Type | Response Type | Description |
| ------------ | ------------- | ------------|
| [PrincipalId](#principalid) | [Principal](#principal) | |

### RPC `Whoami` {#whoami}

| Request Type | Response Type | Description |
Expand Down
15 changes: 15 additions & 0 deletions lhctl/go.work.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cel.dev/expr v0.15.0/go.mod h1:TRSuuV7DlVCE/uwv5QbAiW/v8l5O8C4eEPHeu7gf7Sg=
github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
github.com/envoyproxy/go-control-plane v0.12.1-0.20240621013728-1eb8caab5155/go.mod h1:5Wkq+JduFtdAXihLmeTJf+tRYIT4KBc2vPXDhwVo1pA=
github.com/envoyproxy/protoc-gen-validate v1.0.4/go.mod h1:qys6tmnRsYrQqIhm2bvKZH4Blx/1gTIZ2UKVY1M+Yew=
github.com/golang/glog v1.2.1/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117/go.mod h1:OimBR/bc1wPO9iV4NC2bpyjy3VnAwZh5EBPQdtaE5oo=
16 changes: 16 additions & 0 deletions lhctl/internal/principal.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ var putPrincipalCmd = &cobra.Command{
},
}

var getPrincipalCmd = &cobra.Command{
Use: "principal <id>",
Short: "Get a Principal",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
littlehorse.PrintResp(getGlobalClient(cmd).GetPrincipal(
requestContext(cmd),
&lhproto.PrincipalId{
Id: args[0],
},
))
},
}

var searchPrincipalCmd = &cobra.Command{
Use: "principal",
Short: "Search for Principals",
Expand Down Expand Up @@ -201,6 +215,8 @@ func init() {
searchPrincipalCmd.Flags().Int("earliestMinutesAgo", -1, "Search only for Principals that were created no more than this number of minutes ago")
searchPrincipalCmd.Flags().Int("latestMinutesAgo", -1, "Search only for Principals that were created at least this number of minutes ago")

getCmd.AddCommand(getPrincipalCmd)

deployCmd.AddCommand(deployPrincipalCmd)
deleteCmd.AddCommand(deletePrincipalCmd)
}
2 changes: 2 additions & 0 deletions schemas/littlehorse/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ service LittleHorse {
// EXPERIMENTAL: Creates an Principal.
rpc PutPrincipal(PutPrincipalRequest) returns (Principal) {}

rpc GetPrincipal(PrincipalId) returns (Principal) {}

// Returns the Principal of the caller.
rpc Whoami(google.protobuf.Empty) returns (Principal) {}

Expand Down
194 changes: 100 additions & 94 deletions sdk-go/lhproto/service.pb.go

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions sdk-go/lhproto/service_grpc.pb.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -2247,6 +2247,37 @@ io.littlehorse.sdk.common.proto.Principal> getPutPrincipalMethod() {
return getPutPrincipalMethod;
}

private static volatile io.grpc.MethodDescriptor<io.littlehorse.sdk.common.proto.PrincipalId,
io.littlehorse.sdk.common.proto.Principal> getGetPrincipalMethod;

@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "GetPrincipal",
requestType = io.littlehorse.sdk.common.proto.PrincipalId.class,
responseType = io.littlehorse.sdk.common.proto.Principal.class,
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
public static io.grpc.MethodDescriptor<io.littlehorse.sdk.common.proto.PrincipalId,
io.littlehorse.sdk.common.proto.Principal> getGetPrincipalMethod() {
io.grpc.MethodDescriptor<io.littlehorse.sdk.common.proto.PrincipalId, io.littlehorse.sdk.common.proto.Principal> getGetPrincipalMethod;
if ((getGetPrincipalMethod = LittleHorseGrpc.getGetPrincipalMethod) == null) {
synchronized (LittleHorseGrpc.class) {
if ((getGetPrincipalMethod = LittleHorseGrpc.getGetPrincipalMethod) == null) {
LittleHorseGrpc.getGetPrincipalMethod = getGetPrincipalMethod =
io.grpc.MethodDescriptor.<io.littlehorse.sdk.common.proto.PrincipalId, io.littlehorse.sdk.common.proto.Principal>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetPrincipal"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
io.littlehorse.sdk.common.proto.PrincipalId.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
io.littlehorse.sdk.common.proto.Principal.getDefaultInstance()))
.setSchemaDescriptor(new LittleHorseMethodDescriptorSupplier("GetPrincipal"))
.build();
}
}
}
return getGetPrincipalMethod;
}

private static volatile io.grpc.MethodDescriptor<com.google.protobuf.Empty,
io.littlehorse.sdk.common.proto.Principal> getWhoamiMethod;

Expand Down Expand Up @@ -3119,6 +3150,13 @@ default void putPrincipal(io.littlehorse.sdk.common.proto.PutPrincipalRequest re
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getPutPrincipalMethod(), responseObserver);
}

/**
*/
default void getPrincipal(io.littlehorse.sdk.common.proto.PrincipalId request,
io.grpc.stub.StreamObserver<io.littlehorse.sdk.common.proto.Principal> responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetPrincipalMethod(), responseObserver);
}

/**
* <pre>
* Returns the Principal of the caller.
Expand Down Expand Up @@ -4001,6 +4039,14 @@ public void putPrincipal(io.littlehorse.sdk.common.proto.PutPrincipalRequest req
getChannel().newCall(getPutPrincipalMethod(), getCallOptions()), request, responseObserver);
}

/**
*/
public void getPrincipal(io.littlehorse.sdk.common.proto.PrincipalId request,
io.grpc.stub.StreamObserver<io.littlehorse.sdk.common.proto.Principal> responseObserver) {
io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getGetPrincipalMethod(), getCallOptions()), request, responseObserver);
}

/**
* <pre>
* Returns the Principal of the caller.
Expand Down Expand Up @@ -4791,6 +4837,13 @@ public io.littlehorse.sdk.common.proto.Principal putPrincipal(io.littlehorse.sdk
getChannel(), getPutPrincipalMethod(), getCallOptions(), request);
}

/**
*/
public io.littlehorse.sdk.common.proto.Principal getPrincipal(io.littlehorse.sdk.common.proto.PrincipalId request) {
return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getGetPrincipalMethod(), getCallOptions(), request);
}

/**
* <pre>
* Returns the Principal of the caller.
Expand Down Expand Up @@ -5650,6 +5703,14 @@ public com.google.common.util.concurrent.ListenableFuture<io.littlehorse.sdk.com
getChannel().newCall(getPutPrincipalMethod(), getCallOptions()), request);
}

/**
*/
public com.google.common.util.concurrent.ListenableFuture<io.littlehorse.sdk.common.proto.Principal> getPrincipal(
io.littlehorse.sdk.common.proto.PrincipalId request) {
return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getGetPrincipalMethod(), getCallOptions()), request);
}

/**
* <pre>
* Returns the Principal of the caller.
Expand Down Expand Up @@ -5744,9 +5805,10 @@ public com.google.common.util.concurrent.ListenableFuture<io.littlehorse.sdk.com
private static final int METHODID_PUT_TENANT = 68;
private static final int METHODID_GET_TENANT = 69;
private static final int METHODID_PUT_PRINCIPAL = 70;
private static final int METHODID_WHOAMI = 71;
private static final int METHODID_GET_SERVER_VERSION = 72;
private static final int METHODID_POLL_TASK = 73;
private static final int METHODID_GET_PRINCIPAL = 71;
private static final int METHODID_WHOAMI = 72;
private static final int METHODID_GET_SERVER_VERSION = 73;
private static final int METHODID_POLL_TASK = 74;

private static final class MethodHandlers<Req, Resp> implements
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
Expand Down Expand Up @@ -6049,6 +6111,10 @@ public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserv
serviceImpl.putPrincipal((io.littlehorse.sdk.common.proto.PutPrincipalRequest) request,
(io.grpc.stub.StreamObserver<io.littlehorse.sdk.common.proto.Principal>) responseObserver);
break;
case METHODID_GET_PRINCIPAL:
serviceImpl.getPrincipal((io.littlehorse.sdk.common.proto.PrincipalId) request,
(io.grpc.stub.StreamObserver<io.littlehorse.sdk.common.proto.Principal>) responseObserver);
break;
case METHODID_WHOAMI:
serviceImpl.whoami((com.google.protobuf.Empty) request,
(io.grpc.stub.StreamObserver<io.littlehorse.sdk.common.proto.Principal>) responseObserver);
Expand Down Expand Up @@ -6582,6 +6648,13 @@ public static final io.grpc.ServerServiceDefinition bindService(AsyncService ser
io.littlehorse.sdk.common.proto.PutPrincipalRequest,
io.littlehorse.sdk.common.proto.Principal>(
service, METHODID_PUT_PRINCIPAL)))
.addMethod(
getGetPrincipalMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
new MethodHandlers<
io.littlehorse.sdk.common.proto.PrincipalId,
io.littlehorse.sdk.common.proto.Principal>(
service, METHODID_GET_PRINCIPAL)))
.addMethod(
getWhoamiMethod(),
io.grpc.stub.ServerCalls.asyncUnaryCall(
Expand Down Expand Up @@ -6716,6 +6789,7 @@ public static io.grpc.ServiceDescriptor getServiceDescriptor() {
.addMethod(getPutTenantMethod())
.addMethod(getGetTenantMethod())
.addMethod(getPutPrincipalMethod())
.addMethod(getGetPrincipalMethod())
.addMethod(getWhoamiMethod())
.addMethod(getGetServerVersionMethod())
.build();
Expand Down

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

10 changes: 10 additions & 0 deletions sdk-js/src/proto/service.ts

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

2 changes: 1 addition & 1 deletion sdk-python/littlehorse/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from .node_run_pb2 import *
from .object_id_pb2 import *
from .scheduled_wf_run_pb2 import *
from .service_pb2_grpc import *
from .service_pb2 import *
from .service_pb2_grpc import *
from .task_def_pb2 import *
from .task_run_pb2 import *
from .user_tasks_pb2 import *
Expand Down
4 changes: 2 additions & 2 deletions sdk-python/littlehorse/model/service_pb2.py

Large diffs are not rendered by default.

Loading
Loading