feat: add new api services (#5619)

* feat: add new services

* improve demos and comments

* remove unused field

* add comment to demo proto calls

* Apply suggestions from code review

Co-authored-by: Silvan <silvan.reusser@gmail.com>

---------

Co-authored-by: Silvan <silvan.reusser@gmail.com>
This commit is contained in:
Livio Spring
2023-04-11 15:37:42 +02:00
committed by GitHub
parent c0c76a8ea9
commit b3d8787921
18 changed files with 516 additions and 44 deletions

View File

@@ -0,0 +1,12 @@
syntax = "proto3";
package zitadel.session.v2alpha;
import "zitadel/user/v2alpha/user.proto";
option go_package = "github.com/zitadel/zitadel/pkg/grpc/session/v2alpha;session";
message Session {
string id = 1;
zitadel.user.v2alpha.User user = 2;
}

View File

@@ -0,0 +1,33 @@
syntax = "proto3";
package zitadel.session.v2alpha;
import "zitadel/options.proto";
import "zitadel/session/v2alpha/session.proto";
import "google/api/annotations.proto";
import "validate/validate.proto";
option go_package = "github.com/zitadel/zitadel/pkg/grpc/session/v2alpha;session";
service SessionService {
// GetSession is to demonstrate an authenticated request, where the authenticated user (usage of another grpc package) is returned
//
// this request is subject to change and currently used for demonstration only
rpc GetSession (GetSessionRequest) returns (GetSessionResponse) {
option (google.api.http) = {
get: "/v2alpha/sessions/{id}"
};
option (zitadel.v1.auth_option) = {
permission: "authenticated"
};
}
}
message GetSessionRequest{
string id = 1;
}
message GetSessionResponse{
Session session = 1;
}

View File

@@ -0,0 +1,9 @@
syntax = "proto3";
package zitadel.user.v2alpha;
option go_package = "github.com/zitadel/zitadel/pkg/grpc/user/v2alpha;user";
message User {
string id = 1;
}

View File

@@ -0,0 +1,78 @@
syntax = "proto3";
package zitadel.user.v2alpha;
import "zitadel/options.proto";
import "zitadel/user/v2alpha/user.proto";
import "google/api/annotations.proto";
import "validate/validate.proto";
option go_package = "github.com/zitadel/zitadel/pkg/grpc/user/v2alpha;user";
service UserService {
// TestGet simply demonstrates how the context (org, instance) could be handled in a GET request //
//
// this request is subject to change and currently used for demonstration only
rpc TestGet (TestGetRequest) returns (TestGetResponse) {
option (google.api.http) = {
get: "/v2alpha/users/test"
};
}
// TestPOST simply demonstrates how the context (org, instance) could be handled in a POST request
//
// this request is subject to change and currently used for demonstration only
rpc TestPost (TestPostRequest) returns (TestPostResponse) {
option (google.api.http) = {
post: "/v2alpha/users/test"
body: "*"
};
}
// TestAuth demonstrates how the context (org, instance) could be handled in combination of the authorized context
//
// this request is subject to change and currently used for demonstration only
rpc TestAuth (TestAuthRequest) returns (TestAuthResponse) {
option (google.api.http) = {
get: "/v2alpha/users/test_auth"
};
option (zitadel.v1.auth_option) = {
permission: "authenticated"
};
}
}
message TestGetRequest{
Context ctx = 1;
}
message TestGetResponse{
string ctx = 1;
}
message TestPostRequest{
Context ctx = 1;
}
message TestPostResponse{
string ctx = 1;
}
message TestAuthRequest{
Context ctx = 1;
}
message TestAuthResponse{
User user = 1;
Context ctx = 2;
}
message Context {
oneof ctx {
bool instance = 1;
string org_id = 2;
string org_domain = 3;
}
}