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

Updated DeployResourceCommand to support TenantId. #593

Merged
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
26 changes: 26 additions & 0 deletions Client.UnitTests/DeploymentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
2 changes: 1 addition & 1 deletion Client/Api/Commands/IDeployResourceCommandStep1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ IDeployResourceCommandBuilderStep2 AddResourceStream(
IDeployResourceCommandBuilderStep2 AddResourceFile(string filename);
}

public interface IDeployResourceCommandBuilderStep2 : IDeployResourceCommandStep1, IFinalCommandWithRetryStep<IDeployResourceResponse>
public interface IDeployResourceCommandBuilderStep2 : IDeployResourceCommandStep1, ITenantIdCommandStep<IDeployResourceCommandBuilderStep2>, IFinalCommandWithRetryStep<IDeployResourceResponse>
{
// the place for new optional parameters
}
Expand Down
13 changes: 13 additions & 0 deletions Client/Api/Commands/ITenantIdCommandStep.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Zeebe.Client.Api.Commands
{
public interface ITenantIdCommandStep<out T>
{
/// <summary>
/// Set the tenantId for the resource.
/// </summary>
/// <param name="tenantId">the tenantId to associate to this resource</param>
/// <returns>The builder for this command. Call <see cref="IFinalCommandStep{T}.Send"/> to complete the command and send it
/// to the broker.</returns>
T AddTenantId(string tenantId);
}
}
6 changes: 6 additions & 0 deletions Client/Impl/Commands/DeployResourceCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public IDeployResourceCommandBuilderStep2 AddResourceStringUtf8(string resourceS
return this;
}

public IDeployResourceCommandBuilderStep2 AddTenantId(string tenantId)
{
request.TenantId = tenantId;
return this;
}

public async Task<IDeployResourceResponse> Send(TimeSpan? timeout = null, CancellationToken token = default)
{
var asyncReply = gatewayClient.DeployResourceAsync(request, deadline: timeout?.FromUtcNow(), cancellationToken: token);
Expand Down
Loading