Skip to content

Commit 2c7b9b2

Browse files
committed
feat(api): enhance gRPC client support and versioning
- Added new service clients for Application, Project, Action, Authorization, Feature, Telemetry, SAML, and WebKey services. - Updated the `justfile` to use a specific git tag for protobuf generation. - Introduced `ZitadelGrpcVersion` class to manage version information for generated gRPC clients.
1 parent 6f30042 commit 2c7b9b2

4 files changed

Lines changed: 119 additions & 4 deletions

File tree

justfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
default: clean generate-grpc
44

5+
# Keep this in sync with `Zitadel.Api.ZitadelGrpcVersion.SupportedTag`.
6+
zitadel_tag := "v4.15.0"
7+
58
@clean:
69
rm -rf ./src/Zitadel/Api/Generated
710

811
generate-grpc:
9-
buf generate https://github.com/zitadel/zitadel.git#depth=1 --include-imports --path ./proto/zitadel
12+
buf generate https://github.com/zitadel/zitadel.git#ref={{zitadel_tag}},depth=1 --include-imports --path ./proto/zitadel

src/Zitadel/Api/Clients.cs

Lines changed: 102 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
using Grpc.Core;
22
using Grpc.Net.Client;
33

4+
using Zitadel.Action.V2;
45
using Zitadel.Admin.V1;
6+
using Zitadel.Analytics.V2beta;
7+
using Zitadel.Application.V2;
58
using Zitadel.Auth.V1;
69
using Zitadel.Authentication;
10+
using Zitadel.Authorization.V2;
11+
using Zitadel.Feature.V2;
12+
using Zitadel.Idp.V2;
13+
using Zitadel.Instance.V2;
14+
using Zitadel.InternalPermission.V2;
715
using Zitadel.Management.V1;
816
using Zitadel.Oidc.V2;
917
using Zitadel.Org.V2;
18+
using Zitadel.Project.V2;
19+
using Zitadel.Saml.V2;
1020
using Zitadel.Session.V2;
1121
using Zitadel.Settings.V2;
1222
using Zitadel.System.V1;
1323
using Zitadel.User.V2;
24+
using Zitadel.Webkey.V2;
1425

1526
namespace Zitadel.Api;
1627

1728
/// <summary>
18-
/// Helper class to instantiate (gRPC) api service clients for the ZITADEL API with correct settings.
19-
/// All other versions are still available, but the latest version is used by default.
29+
/// Provides static methods to create and configure instances of gRPC API service clients for the ZITADEL API.
30+
/// The clients are instantiated with default or specified options to ensure proper connectivity and authentication.
2031
/// </summary>
2132
public static class Clients
2233
{
@@ -44,6 +55,70 @@ public static AuthService.AuthServiceClient AuthService(Options options) =>
4455
public static ManagementService.ManagementServiceClient ManagementService(Options options) =>
4556
GetClient<ManagementService.ManagementServiceClient>(options);
4657

58+
/// <summary>
59+
/// Create a service client for the application service.
60+
/// </summary>
61+
/// <param name="options">Options for the client, including endpoint and authorization method.</param>
62+
/// <returns>The <see cref="Application.V2.ApplicationService.ApplicationServiceClient"/>.</returns>
63+
public static ApplicationService.ApplicationServiceClient ApplicationService(Options options) =>
64+
GetClient<ApplicationService.ApplicationServiceClient>(options);
65+
66+
/// <summary>
67+
/// Create a service client for the project service.
68+
/// </summary>
69+
/// <param name="options">Options for the client like authorization method.</param>
70+
/// <returns>The <see cref="Project.V2.ProjectService.ProjectServiceClient"/>.</returns>
71+
public static ProjectService.ProjectServiceClient ProjectService(Options options) =>
72+
GetClient<ProjectService.ProjectServiceClient>(options);
73+
74+
/// <summary>
75+
/// Create a service client for the action service.
76+
/// </summary>
77+
/// <param name="options">Options for the client like authorization method.</param>
78+
/// <returns>The <see cref="Action.V2.ActionService.ActionServiceClient"/>.</returns>
79+
public static ActionService.ActionServiceClient ActionService(Options options) =>
80+
GetClient<ActionService.ActionServiceClient>(options);
81+
82+
/// <summary>
83+
/// Create a service client for the authorization service.
84+
/// </summary>
85+
/// <param name="options">Options for the client like authorization method.</param>
86+
/// <returns>The <see cref="Authorization.V2.AuthorizationService.AuthorizationServiceClient"/>.</returns>
87+
public static AuthorizationService.AuthorizationServiceClient AuthorizationService(Options options) =>
88+
GetClient<AuthorizationService.AuthorizationServiceClient>(options);
89+
90+
/// <summary>
91+
/// Create a service client for the feature service.
92+
/// </summary>
93+
/// <param name="options">Options for the client like authorization method.</param>
94+
/// <returns>The <see cref="Feature.V2.FeatureService.FeatureServiceClient"/>.</returns>
95+
public static FeatureService.FeatureServiceClient FeatureService(Options options) =>
96+
GetClient<FeatureService.FeatureServiceClient>(options);
97+
98+
/// <summary>
99+
/// Create a service client for the telemetry service.
100+
/// </summary>
101+
/// <param name="options">Options for the client like authorization method.</param>
102+
/// <returns>The <see cref="TelemetryService.TelemetryServiceClient"/>.</returns>
103+
public static TelemetryService.TelemetryServiceClient TelemetryService(Options options) =>
104+
GetClient<TelemetryService.TelemetryServiceClient>(options);
105+
106+
/// <summary>
107+
/// Create a service client for the SAML service.
108+
/// </summary>
109+
/// <param name="options">Options for the client like authorization method.</param>
110+
/// <returns>The <see cref="Saml.V2.SAMLService.SAMLServiceClient"/>.</returns>
111+
public static SAMLService.SAMLServiceClient SAMLService(Options options) =>
112+
GetClient<SAMLService.SAMLServiceClient>(options);
113+
114+
/// <summary>
115+
/// Create a service client for the web key service.
116+
/// </summary>
117+
/// <param name="options">Options for the client like authorization method.</param>
118+
/// <returns>The <see cref="Webkey.V2.WebKeyService.WebKeyServiceClient"/>.</returns>
119+
public static WebKeyService.WebKeyServiceClient WebKeyService(Options options) =>
120+
GetClient<WebKeyService.WebKeyServiceClient>(options);
121+
47122
/// <summary>
48123
/// Create a service client for the oidc service.
49124
/// </summary>
@@ -92,6 +167,31 @@ public static SystemService.SystemServiceClient SystemService(Options options) =
92167
public static UserService.UserServiceClient UserService(Options options) =>
93168
GetClient<UserService.UserServiceClient>(options);
94169

170+
/// <summary>
171+
/// Create a service client for the identity provider service.
172+
/// </summary>
173+
/// <param name="options">Options for the client like authorization method.</param>
174+
/// <returns>The <see cref="IdentityProviderService.IdentityProviderServiceClient"/>.</returns>
175+
public static IdentityProviderService.IdentityProviderServiceClient IdentityProviderService(Options options) =>
176+
GetClient<IdentityProviderService.IdentityProviderServiceClient>(options);
177+
178+
/// <summary>
179+
/// Create a service client for the instance service.
180+
/// </summary>
181+
/// <param name="options">Options for the client like authorization method.</param>
182+
/// <returns>The <see cref="Instance.V2.InstanceService.InstanceServiceClient"/>.</returns>
183+
public static InstanceService.InstanceServiceClient InstanceService(Options options) =>
184+
GetClient<InstanceService.InstanceServiceClient>(options);
185+
186+
/// <summary>
187+
/// Create a service client for the internal permission service.
188+
/// </summary>
189+
/// <param name="options">Options for the client like authorization method.</param>
190+
/// <returns>The <see cref="InternalPermission.V2.InternalPermissionService.InternalPermissionServiceClient"/>.</returns>
191+
public static InternalPermissionService.InternalPermissionServiceClient
192+
InternalPermissionService(Options options) =>
193+
GetClient<InternalPermissionService.InternalPermissionServiceClient>(options);
194+
95195
private static TClient GetClient<TClient>(Options options)
96196
where TClient : ClientBase<TClient>
97197
{
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Zitadel.Api;
2+
3+
/// <summary>
4+
/// Version information about the generated ZITADEL gRPC API clients in this package.
5+
/// </summary>
6+
public static class ZitadelGrpcVersion
7+
{
8+
/// <summary>
9+
/// Upstream ZITADEL git tag used as source for protobuf generation.
10+
/// </summary>
11+
public const string SupportedTag = "v4.15.0";
12+
}

tests/Zitadel.Test/Credentials/ServiceAccount.Test.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ public async Task Should_Throw_With_Meaningful_Error()
3030
var sa = await ServiceAccount.LoadFromJsonStringAsync(TestData.InvalidServiceAccountJson);
3131
var ex = await Assert.ThrowsAsync<HttpRequestException>(() => sa.AuthenticateAsync(TestData.ApiUrl));
3232

33-
ex.Message.Should().Contain("Errors.Internal");
33+
ex.Message.Should().Contain("invalid_grant");
3434
}
3535
}

0 commit comments

Comments
 (0)