Skip to content

Commit 1c8fcc2

Browse files
authored
C#, TS, Go and Java changes to use new API version (#322)
* update c# to use new api version * add IdGeneration * Update API version * first pass of typescript * update id gen * update references * update flatten * update ts contract gen * update create ports * update writer * update go and java * update name in typescript * auto gen ts and cs ids * id gen in java and go * remove old files * java and go retries * update retry * add endpoint query param * fix e2e test bugs * use old chars * update request objects * go list response * update ids * update exports * remove unused * update relay ids * update tags to labels * remove tag references * fix namespace export * generated contracts * update return * update words
1 parent 97233d2 commit 1c8fcc2

File tree

65 files changed

+659
-1578
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+659
-1578
lines changed

cs/src/Connections/TunnelRelayTunnelHost.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public class TunnelRelayTunnelHost : TunnelHost, IRelayClient
5050

5151
private SshClientSession? hostSession;
5252
private Uri? relayUri;
53+
private string endpointId { get { return hostId + "-relay"; } }
5354

5455
/// <summary>
5556
/// Creates a new instance of a host that connects to a tunnel via a tunnel relay.
@@ -92,7 +93,7 @@ public override async ValueTask DisposeAsync()
9293

9394
if (Tunnel != null)
9495
{
95-
tasks.Add(ManagementClient!.DeleteTunnelEndpointsAsync(Tunnel, this.hostId, TunnelConnectionMode.TunnelRelay));
96+
tasks.Add(ManagementClient!.DeleteTunnelEndpointsAsync(Tunnel, endpointId));
9697
}
9798

9899
foreach (RemotePortForwarder forwarder in RemoteForwarders.Values)
@@ -123,6 +124,7 @@ protected override async Task<ITunnelConnector> CreateTunnelConnectorAsync(Cance
123124
var endpoint = new TunnelRelayTunnelEndpoint
124125
{
125126
HostId = this.hostId,
127+
Id = this.endpointId,
126128
HostPublicKeys = hostPublicKeys,
127129
};
128130
List<KeyValuePair<string, string>>? additionalQueryParams = null;

cs/src/Contracts/Tunnel.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public Tunnel()
3737
/// Gets or sets the generated ID of the tunnel, unique within the cluster.
3838
/// </summary>
3939
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
40-
[RegularExpression(OldTunnelIdPattern)]
41-
[StringLength(OldTunnelIdLength, MinimumLength = OldTunnelIdLength)]
40+
[RegularExpression(NewTunnelIdPattern)]
41+
[StringLength(NewTunnelIdMaxLength, MinimumLength = NewTunnelIdMinLength)]
4242
public string? TunnelId { get; set; }
4343

4444
/// <summary>
@@ -61,13 +61,13 @@ public Tunnel()
6161
public string? Description { get; set; }
6262

6363
/// <summary>
64-
/// Gets or sets the tags of the tunnel.
64+
/// Gets or sets the labels of the tunnel.
6565
/// </summary>
6666
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
67-
[MaxLength(MaxTags)]
68-
[ArrayStringLength(TagMaxLength, MinimumLength = TagMinLength)]
69-
[ArrayRegularExpression(TagPattern)]
70-
public string[]? Tags { get; set; }
67+
[MaxLength(MaxLabels)]
68+
[ArrayStringLength(LabelMaxLength, MinimumLength = LabelMinLength)]
69+
[ArrayRegularExpression(LabelPattern)]
70+
public string[]? Labels { get; set; }
7171

7272
/// <summary>
7373
/// Gets or sets the optional parent domain of the tunnel, if it is not using

cs/src/Contracts/TunnelConstraints.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,23 @@ public static class TunnelConstraints
7272
/// <summary>
7373
/// Min length of a single tunnel or port tag.
7474
/// </summary>
75-
/// <seealso cref="Tunnel.Tags"/>
76-
/// <seealso cref="TunnelPort.Tags"/>
77-
public const int TagMinLength = 1;
75+
/// <seealso cref="Tunnel.Labels"/>
76+
/// <seealso cref="TunnelPort.Labels"/>
77+
public const int LabelMinLength = 1;
7878

7979
/// <summary>
8080
/// Max length of a single tunnel or port tag.
8181
/// </summary>
82-
/// <seealso cref="Tunnel.Tags"/>
83-
/// <seealso cref="TunnelPort.Tags"/>
84-
public const int TagMaxLength = 50;
82+
/// <seealso cref="Tunnel.Labels"/>
83+
/// <seealso cref="TunnelPort.Labels"/>
84+
public const int LabelMaxLength = 50;
8585

8686
/// <summary>
87-
/// Maximum number of tags that can be applied to a tunnel or port.
87+
/// Maximum number of labels that can be applied to a tunnel or port.
8888
/// </summary>
89-
/// <seealso cref="Tunnel.Tags"/>
90-
/// <seealso cref="TunnelPort.Tags"/>
91-
public const int MaxTags = 100;
89+
/// <seealso cref="Tunnel.Labels"/>
90+
/// <seealso cref="TunnelPort.Labels"/>
91+
public const int MaxLabels = 100;
9292

9393
/// <summary>
9494
/// Min length of a tunnel domain.
@@ -265,17 +265,17 @@ public static class TunnelConstraints
265265
public static Regex TunnelNameRegex { get; } = new Regex(TunnelNamePattern);
266266

267267
/// <summary>
268-
/// Regular expression that can match or validate tunnel or port tags.
268+
/// Regular expression that can match or validate tunnel or port labels.
269269
/// </summary>
270-
/// <seealso cref="TunnelPort.Tags"/>
271-
public const string TagPattern = "[\\w-=]{1,50}";
270+
/// <seealso cref="TunnelPort.Labels"/>
271+
public const string LabelPattern = "[\\w-=]{1,50}";
272272

273273
/// <summary>
274-
/// Regular expression that can match or validate tunnel or port tags.
274+
/// Regular expression that can match or validate tunnel or port labels.
275275
/// </summary>
276-
/// <seealso cref="Tunnel.Tags"/>
277-
/// <seealso cref="TunnelPort.Tags"/>
278-
public static Regex TagRegex { get; } = new Regex(TagPattern);
276+
/// <seealso cref="Tunnel.Labels"/>
277+
/// <seealso cref="TunnelPort.Labels"/>
278+
public static Regex LabelRegex { get; } = new Regex(LabelPattern);
279279

280280
/// <summary>
281281
/// Regular expression that can match or validate tunnel domains.
@@ -422,7 +422,7 @@ public static bool IsValidTag(string tag)
422422
return false;
423423
}
424424

425-
var m = TagRegex.Match(tag);
425+
var m = LabelRegex.Match(tag);
426426
return m.Index == 0 && m.Length == tag.Length;
427427
}
428428

cs/src/Contracts/TunnelListByRegion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class TunnelListByRegion
2929
/// List of tunnels.
3030
/// </summary>
3131
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
32-
public TunnelV2[]? Value { get; set; }
32+
public Tunnel[]? Value { get; set; }
3333

3434
/// <summary>
3535
/// Error detail if getting list of tunnels in the region failed.

cs/src/Contracts/TunnelListResponse.cs

Lines changed: 0 additions & 37 deletions
This file was deleted.

cs/src/Contracts/TunnelPort.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public TunnelPort()
3636
/// Gets or sets the generated ID of the tunnel, unique within the cluster.
3737
/// </summary>
3838
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
39-
[RegularExpression(OldTunnelIdPattern)]
40-
[StringLength(OldTunnelIdLength, MinimumLength = OldTunnelIdLength)]
39+
[RegularExpression(NewTunnelIdPattern)]
40+
[StringLength(NewTunnelIdMaxLength, MinimumLength = NewTunnelIdMinLength)]
4141
public string? TunnelId { get; set; }
4242

4343
/// <summary>
@@ -64,13 +64,13 @@ public TunnelPort()
6464
public string? Description { get; set; }
6565

6666
/// <summary>
67-
/// Gets or sets the tags of the port.
67+
/// Gets or sets the labels of the port.
6868
/// </summary>
6969
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
70-
[MaxLength(MaxTags)]
71-
[ArrayStringLength(TagMaxLength, MinimumLength = TagMinLength)]
72-
[ArrayRegularExpression(TagPattern)]
73-
public string[]? Tags { get; set; }
70+
[MaxLength(MaxLabels)]
71+
[ArrayStringLength(LabelMaxLength, MinimumLength = LabelMinLength)]
72+
[ArrayRegularExpression(LabelPattern)]
73+
public string[]? Labels { get; set; }
7474

7575
/// <summary>
7676
/// Gets or sets the protocol of the tunnel port.

cs/src/Contracts/TunnelPortListResponse.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ public class TunnelPortListResponse
1919
/// </summary>
2020
public TunnelPortListResponse()
2121
{
22-
Value = Array.Empty<TunnelPortV2>();
22+
Value = Array.Empty<TunnelPort>();
2323
}
2424

2525
/// <summary>
2626
/// List of tunnels
2727
/// </summary>
2828
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
29-
public TunnelPortV2[] Value { get; set; }
29+
public TunnelPort[] Value { get; set; }
3030

3131
/// <summary>
3232
/// Link to get next page of results

cs/src/Contracts/TunnelPortV2.cs

Lines changed: 0 additions & 154 deletions
This file was deleted.

0 commit comments

Comments
 (0)