Skip to content

Commit

Permalink
C#, TS, Go and Java changes to use new API version (#322)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jfullerton44 authored Oct 11, 2023
1 parent 97233d2 commit 1c8fcc2
Show file tree
Hide file tree
Showing 65 changed files with 659 additions and 1,578 deletions.
4 changes: 3 additions & 1 deletion cs/src/Connections/TunnelRelayTunnelHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class TunnelRelayTunnelHost : TunnelHost, IRelayClient

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

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

if (Tunnel != null)
{
tasks.Add(ManagementClient!.DeleteTunnelEndpointsAsync(Tunnel, this.hostId, TunnelConnectionMode.TunnelRelay));
tasks.Add(ManagementClient!.DeleteTunnelEndpointsAsync(Tunnel, endpointId));
}

foreach (RemotePortForwarder forwarder in RemoteForwarders.Values)
Expand Down Expand Up @@ -123,6 +124,7 @@ protected override async Task<ITunnelConnector> CreateTunnelConnectorAsync(Cance
var endpoint = new TunnelRelayTunnelEndpoint
{
HostId = this.hostId,
Id = this.endpointId,
HostPublicKeys = hostPublicKeys,
};
List<KeyValuePair<string, string>>? additionalQueryParams = null;
Expand Down
14 changes: 7 additions & 7 deletions cs/src/Contracts/Tunnel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public Tunnel()
/// Gets or sets the generated ID of the tunnel, unique within the cluster.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[RegularExpression(OldTunnelIdPattern)]
[StringLength(OldTunnelIdLength, MinimumLength = OldTunnelIdLength)]
[RegularExpression(NewTunnelIdPattern)]
[StringLength(NewTunnelIdMaxLength, MinimumLength = NewTunnelIdMinLength)]
public string? TunnelId { get; set; }

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

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

/// <summary>
/// Gets or sets the optional parent domain of the tunnel, if it is not using
Expand Down
36 changes: 18 additions & 18 deletions cs/src/Contracts/TunnelConstraints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,23 @@ public static class TunnelConstraints
/// <summary>
/// Min length of a single tunnel or port tag.
/// </summary>
/// <seealso cref="Tunnel.Tags"/>
/// <seealso cref="TunnelPort.Tags"/>
public const int TagMinLength = 1;
/// <seealso cref="Tunnel.Labels"/>
/// <seealso cref="TunnelPort.Labels"/>
public const int LabelMinLength = 1;

/// <summary>
/// Max length of a single tunnel or port tag.
/// </summary>
/// <seealso cref="Tunnel.Tags"/>
/// <seealso cref="TunnelPort.Tags"/>
public const int TagMaxLength = 50;
/// <seealso cref="Tunnel.Labels"/>
/// <seealso cref="TunnelPort.Labels"/>
public const int LabelMaxLength = 50;

/// <summary>
/// Maximum number of tags that can be applied to a tunnel or port.
/// Maximum number of labels that can be applied to a tunnel or port.
/// </summary>
/// <seealso cref="Tunnel.Tags"/>
/// <seealso cref="TunnelPort.Tags"/>
public const int MaxTags = 100;
/// <seealso cref="Tunnel.Labels"/>
/// <seealso cref="TunnelPort.Labels"/>
public const int MaxLabels = 100;

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

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

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

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

var m = TagRegex.Match(tag);
var m = LabelRegex.Match(tag);
return m.Index == 0 && m.Length == tag.Length;
}

Expand Down
2 changes: 1 addition & 1 deletion cs/src/Contracts/TunnelListByRegion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class TunnelListByRegion
/// List of tunnels.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public TunnelV2[]? Value { get; set; }
public Tunnel[]? Value { get; set; }

/// <summary>
/// Error detail if getting list of tunnels in the region failed.
Expand Down
37 changes: 0 additions & 37 deletions cs/src/Contracts/TunnelListResponse.cs

This file was deleted.

14 changes: 7 additions & 7 deletions cs/src/Contracts/TunnelPort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public TunnelPort()
/// Gets or sets the generated ID of the tunnel, unique within the cluster.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[RegularExpression(OldTunnelIdPattern)]
[StringLength(OldTunnelIdLength, MinimumLength = OldTunnelIdLength)]
[RegularExpression(NewTunnelIdPattern)]
[StringLength(NewTunnelIdMaxLength, MinimumLength = NewTunnelIdMinLength)]
public string? TunnelId { get; set; }

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

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

/// <summary>
/// Gets or sets the protocol of the tunnel port.
Expand Down
4 changes: 2 additions & 2 deletions cs/src/Contracts/TunnelPortListResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ public class TunnelPortListResponse
/// </summary>
public TunnelPortListResponse()
{
Value = Array.Empty<TunnelPortV2>();
Value = Array.Empty<TunnelPort>();
}

/// <summary>
/// List of tunnels
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public TunnelPortV2[] Value { get; set; }
public TunnelPort[] Value { get; set; }

/// <summary>
/// Link to get next page of results
Expand Down
154 changes: 0 additions & 154 deletions cs/src/Contracts/TunnelPortV2.cs

This file was deleted.

Loading

0 comments on commit 1c8fcc2

Please sign in to comment.