Skip to content

Commit

Permalink
feat: support multiArchiveTag when creating an archive
Browse files Browse the repository at this point in the history
  • Loading branch information
Tr00d committed Feb 29, 2024
1 parent 28701c2 commit 142c988
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"name": "Foo",
"outputMode": "individual",
"resolution": "1280x720",
"streamMode": "manual"
"streamMode": "manual",
"multiArchiveTag": "custom-tag"
}
24 changes: 4 additions & 20 deletions Vonage.Test/Video/Archives/CreateArchive/E2ETest.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using System.Net;
using System.Net;
using System.Threading.Tasks;
using Vonage.Server;
using Vonage.Test.Common.Extensions;
using Vonage.Video.Archives.CreateArchive;
using WireMock.ResponseBuilders;
using Xunit;

Expand All @@ -25,18 +22,7 @@ public async Task CreateArchive()
.UsingPost())
.RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK)
.WithBody(this.Serialization.GetResponseJson(nameof(SerializationTest.ShouldDeserialize200))));
await this.Helper.VonageClient.VideoClient.ArchiveClient.CreateArchiveAsync(CreateArchiveRequest.Build()
.WithApplicationId(Guid.Parse("5e782e3b-9f63-426f-bd2e-b7d618d546cd"))
.WithSessionId("flR1ZSBPY3QgMjkgMTI6MTM6MjMgUERUIDIwMTN")
.WithArchiveLayout(new Layout(LayoutType.Pip,
"stream.instructor {position: absolute; width: 100%; height:50%;}", LayoutType.BestFit))
.WithName("Foo")
.WithOutputMode(OutputMode.Individual)
.WithRenderResolution(RenderResolution.HighDefinitionLandscape)
.WithStreamMode(StreamMode.Manual)
.DisableVideo()
.DisableAudio()
.Create())
await this.Helper.VonageClient.VideoClient.ArchiveClient.CreateArchiveAsync(SerializationTest.BuildRequest())
.Should()
.BeSuccessAsync(SerializationTest.VerifyArchive);
}
Expand All @@ -50,10 +36,8 @@ public async Task CreateDefaultArchive()
.UsingPost())
.RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK)
.WithBody(this.Serialization.GetResponseJson(nameof(SerializationTest.ShouldDeserialize200))));
await this.Helper.VonageClient.VideoClient.ArchiveClient.CreateArchiveAsync(CreateArchiveRequest.Build()
.WithApplicationId(Guid.Parse("5e782e3b-9f63-426f-bd2e-b7d618d546cd"))
.WithSessionId("flR1ZSBPY3QgMjkgMTI6MTM6MjMgUERUIDIwMTN")
.Create())
await this.Helper.VonageClient.VideoClient.ArchiveClient
.CreateArchiveAsync(SerializationTest.BuildDefaultRequest())
.Should()
.BeSuccessAsync(SerializationTest.VerifyArchive);
}
Expand Down
22 changes: 22 additions & 0 deletions Vonage.Test/Video/Archives/CreateArchive/RequestBuilderTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using AutoFixture;
using FluentAssertions;
using Vonage.Common.Monads;
using Vonage.Server;
using Vonage.Test.Common.Extensions;
using Vonage.Video.Archives.CreateArchive;
Expand Down Expand Up @@ -142,4 +143,25 @@ public void Build_ShouldReturnSuccess_WithDefaultValues() =>
request.StreamMode.Should().Be(StreamMode.Auto);
request.Layout.Should().Be(default(Layout));
});

[Fact]
public void Build_ShouldHaveNoMultiArchiveTag_GivenDefault() =>
CreateArchiveRequest.Build()
.WithApplicationId(this.applicationId)
.WithSessionId(this.sessionId)
.Create()
.Map(request => request.MultiArchiveTag)
.Should()
.BeSuccess(Maybe<string>.None);

[Fact]
public void Build_ShouldSetMultiArchiveTag() =>
CreateArchiveRequest.Build()
.WithApplicationId(this.applicationId)
.WithSessionId(this.sessionId)
.WithMultiArchiveTag("custom-tag")
.Create()
.Map(request => request.MultiArchiveTag)
.Should()
.BeSuccess("custom-tag");
}
26 changes: 17 additions & 9 deletions Vonage.Test/Video/Archives/CreateArchive/SerializationTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using FluentAssertions;
using Vonage.Common.Monads;
using Vonage.Serialization;
using Vonage.Server;
using Vonage.Test.Common;
Expand All @@ -26,9 +27,15 @@ public void ShouldDeserialize200() =>

[Fact]
public void ShouldSerialize() =>
BuildRequest()
.GetStringContent()
.Should()
.BeSuccess(this.helper.GetRequestJson());

internal static Result<CreateArchiveRequest> BuildRequest() =>
CreateArchiveRequest
.Build()
.WithApplicationId(Guid.NewGuid())
.WithApplicationId(Guid.Parse("5e782e3b-9f63-426f-bd2e-b7d618d546cd"))
.WithSessionId("flR1ZSBPY3QgMjkgMTI6MTM6MjMgUERUIDIwMTN")
.WithArchiveLayout(new Layout(LayoutType.Pip,
"stream.instructor {position: absolute; width: 100%; height:50%;}", LayoutType.BestFit))
Expand All @@ -38,21 +45,22 @@ public void ShouldSerialize() =>
.WithStreamMode(StreamMode.Manual)
.DisableVideo()
.DisableAudio()
.Create()
.WithMultiArchiveTag("custom-tag")
.Create();

[Fact]
public void ShouldSerializeDefault() =>
BuildDefaultRequest()
.GetStringContent()
.Should()
.BeSuccess(this.helper.GetRequestJson());

[Fact]
public void ShouldSerializeDefault() =>
internal static Result<CreateArchiveRequest> BuildDefaultRequest() =>
CreateArchiveRequest
.Build()
.WithApplicationId(Guid.NewGuid())
.WithApplicationId(Guid.Parse("5e782e3b-9f63-426f-bd2e-b7d618d546cd"))
.WithSessionId("flR1ZSBPY3QgMjkgMTI6MTM6MjMgUERUIDIwMTN")
.Create()
.GetStringContent()
.Should()
.BeSuccess(this.helper.GetRequestJson());
.Create();

internal static void VerifyArchive(Archive success)
{
Expand Down
11 changes: 11 additions & 0 deletions Vonage/Video/Archives/CreateArchive/CreateArchiveRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ namespace Vonage.Video.Archives.CreateArchive;
[JsonPropertyOrder(7)]
public StreamMode StreamMode { get; internal init; }

/// <summary>
/// Set this to support recording multiple archives for the same session simultaneously. Set this to a unique string
/// for each simultaneous archive of an ongoing session. You must also set this option when manually starting an
/// archive in a session that is automatically archived. If you do not specify a unique multiArchiveTag, you can only
/// record one archive at a time for a given session.
/// </summary>
[JsonPropertyOrder(8)]
[JsonConverter(typeof(MaybeJsonConverter<string>))]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public Maybe<string> MultiArchiveTag { get; internal init; }

/// <summary>
/// Initializes a builder.
/// </summary>
Expand Down
16 changes: 16 additions & 0 deletions Vonage/Video/Archives/CreateArchive/CreateArchiveRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal class CreateArchiveRequestBuilder : IBuilderForSessionId, IBuilderForAp
private bool hasAudio = true;
private bool hasVideo = true;
private Layout layout;
private Maybe<string> multiArchiveTag;
private Maybe<string> name;
private OutputMode outputMode = OutputMode.Composed;
private Maybe<RenderResolution> resolution;
Expand All @@ -38,6 +39,7 @@ public Result<CreateArchiveRequest> Create() =>
Layout = this.layout,
Name = this.name,
Resolution = this.resolution,
MultiArchiveTag = this.multiArchiveTag,
})
.Map(InputEvaluation<CreateArchiveRequest>.Evaluate)
.Bind(evaluation => evaluation.WithRules(VerifySessionId, VerifyApplicationId));
Expand Down Expand Up @@ -91,6 +93,13 @@ public IBuilderForOptional WithStreamMode(StreamMode value)
return this;
}

/// <inheritdoc />
public IBuilderForOptional WithMultiArchiveTag(string value)
{
this.multiArchiveTag = value;
return this;
}

/// <inheritdoc />
public IBuilderForOptional WithSessionId(string value)
{
Expand Down Expand Up @@ -182,4 +191,11 @@ public interface IBuilderForOptional : IVonageRequestBuilder<CreateArchiveReques
/// <param name="value">The value.</param>
/// <returns>The builder.</returns>
IBuilderForOptional WithStreamMode(StreamMode value);

/// <summary>
/// Sets the multi-archive tag.
/// </summary>
/// <param name="value">The tag/</param>
/// <returns>The builder.</returns>
IBuilderForOptional WithMultiArchiveTag(string value);
}

0 comments on commit 142c988

Please sign in to comment.