diff --git a/Client.UnitTests/DeploymentTest.cs b/Client.UnitTests/DeploymentTest.cs index 02a09351..06df67d7 100644 --- a/Client.UnitTests/DeploymentTest.cs +++ b/Client.UnitTests/DeploymentTest.cs @@ -339,5 +339,31 @@ public async Task ShouldSendMultipleDeployResourceAndGetResponseAsExpected() Assert.AreEqual("nameRequirement", decisionRequirementsMetadata.DmnDecisionRequirementsName); Assert.AreEqual("id", decisionRequirementsMetadata.DmnDecisionRequirementsId); } + + [Test] + public async Task ShouldSetTenantIdAsExpected() + { + // given + var expectedRequest = new DeployResourceRequest + { + TenantId = "1234", + Resources = + { + new Resource + { + Content = ByteString.FromStream(File.OpenRead(_demoProcessPath)), + Name = _demoProcessPath + } + } + }; + + // when + await ZeebeClient.NewDeployCommand().AddResourceFile(_demoProcessPath).AddTenantId("1234").Send(); + + // then + var actualRequest = TestService.Requests[typeof(DeployResourceRequest)][0]; + + Assert.AreEqual(expectedRequest, actualRequest); + } } } diff --git a/Client/Api/Commands/IDeployResourceCommandStep1.cs b/Client/Api/Commands/IDeployResourceCommandStep1.cs index 4e106904..8e09cb97 100644 --- a/Client/Api/Commands/IDeployResourceCommandStep1.cs +++ b/Client/Api/Commands/IDeployResourceCommandStep1.cs @@ -70,7 +70,7 @@ IDeployResourceCommandBuilderStep2 AddResourceStream( IDeployResourceCommandBuilderStep2 AddResourceFile(string filename); } - public interface IDeployResourceCommandBuilderStep2 : IDeployResourceCommandStep1, IFinalCommandWithRetryStep + public interface IDeployResourceCommandBuilderStep2 : IDeployResourceCommandStep1, ITenantIdCommandStep, IFinalCommandWithRetryStep { // the place for new optional parameters } diff --git a/Client/Api/Commands/ITenantIdCommandStep.cs b/Client/Api/Commands/ITenantIdCommandStep.cs new file mode 100644 index 00000000..b4802150 --- /dev/null +++ b/Client/Api/Commands/ITenantIdCommandStep.cs @@ -0,0 +1,13 @@ +namespace Zeebe.Client.Api.Commands +{ + public interface ITenantIdCommandStep + { + /// + /// Set the tenantId for the resource. + /// + /// the tenantId to associate to this resource + /// The builder for this command. Call to complete the command and send it + /// to the broker. + T AddTenantId(string tenantId); + } +} \ No newline at end of file diff --git a/Client/Impl/Commands/DeployResourceCommand.cs b/Client/Impl/Commands/DeployResourceCommand.cs index 5650e859..d947efdb 100644 --- a/Client/Impl/Commands/DeployResourceCommand.cs +++ b/Client/Impl/Commands/DeployResourceCommand.cs @@ -73,6 +73,12 @@ public IDeployResourceCommandBuilderStep2 AddResourceStringUtf8(string resourceS return this; } + public IDeployResourceCommandBuilderStep2 AddTenantId(string tenantId) + { + request.TenantId = tenantId; + return this; + } + public async Task Send(TimeSpan? timeout = null, CancellationToken token = default) { var asyncReply = gatewayClient.DeployResourceAsync(request, deadline: timeout?.FromUtcNow(), cancellationToken: token);