From 1a549d5dbce37d1490fdfc030c21a4a7fa1e04dd Mon Sep 17 00:00:00 2001 From: usanth <111899981+usanth@users.noreply.github.com> Date: Wed, 23 Aug 2023 17:00:24 -0700 Subject: [PATCH] Custom expiration cli changes (#293) * Adding SDK changes for custom tunnel expiration * adding related contracts * updating contract to include seconds --------- Co-authored-by: Utsa Santhosh --- cs/src/Contracts/Tunnel.cs | 6 ++++ cs/src/Management/TunnelManagementClient.cs | 1 + go/tunnels/tunnel.go | 32 +++++++++++-------- .../microsoft/tunnels/contracts/Tunnel.java | 7 ++++ rs/src/contracts/tunnel.rs | 4 +++ ts/src/contracts/tunnel.ts | 6 ++++ 6 files changed, 42 insertions(+), 14 deletions(-) diff --git a/cs/src/Contracts/Tunnel.cs b/cs/src/Contracts/Tunnel.cs index 7358738c..f491e2b1 100644 --- a/cs/src/Contracts/Tunnel.cs +++ b/cs/src/Contracts/Tunnel.cs @@ -138,4 +138,10 @@ public Tunnel() /// [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public DateTime? Expiration { get; set; } + + /// + /// Gets or the custom amount of time the tunnel will be valid if it is not used or updated in seconds. + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public uint? CustomExpiration { get; set; } } diff --git a/cs/src/Management/TunnelManagementClient.cs b/cs/src/Management/TunnelManagementClient.cs index 53c48cbd..7803c1d0 100644 --- a/cs/src/Management/TunnelManagementClient.cs +++ b/cs/src/Management/TunnelManagementClient.cs @@ -1178,6 +1178,7 @@ private Tunnel ConvertTunnelForRequest(Tunnel tunnel) Domain = tunnel.Domain, Description = tunnel.Description, Tags = tunnel.Tags, + CustomExpiration = tunnel.CustomExpiration, Options = tunnel.Options, AccessControl = tunnel.AccessControl == null ? null : new TunnelAccessControl( tunnel.AccessControl.Where((ace) => !ace.IsInherited)), diff --git a/go/tunnels/tunnel.go b/go/tunnels/tunnel.go index 4b6a0a22..ebc7717f 100644 --- a/go/tunnels/tunnel.go +++ b/go/tunnels/tunnel.go @@ -11,44 +11,44 @@ import ( // Data contract for tunnel objects managed through the tunnel service REST API. type Tunnel struct { // Gets or sets the ID of the cluster the tunnel was created in. - ClusterID string `json:"clusterId,omitempty"` + ClusterID string `json:"clusterId,omitempty"` // Gets or sets the generated ID of the tunnel, unique within the cluster. - TunnelID string `json:"tunnelId,omitempty"` + TunnelID string `json:"tunnelId,omitempty"` // Gets or sets the optional short name (alias) of the tunnel. // // The name must be globally unique within the parent domain, and must be a valid // subdomain. - Name string `json:"name,omitempty"` + Name string `json:"name,omitempty"` // Gets or sets the description of the tunnel. - Description string `json:"description,omitempty"` + Description string `json:"description,omitempty"` // Gets or sets the tags of the tunnel. - Tags []string `json:"tags,omitempty"` + Tags []string `json:"tags,omitempty"` // Gets or sets the optional parent domain of the tunnel, if it is not using the default // parent domain. - Domain string `json:"domain,omitempty"` + Domain string `json:"domain,omitempty"` // Gets or sets a dictionary mapping from scopes to tunnel access tokens. - AccessTokens map[TunnelAccessScope]string `json:"accessTokens,omitempty"` + AccessTokens map[TunnelAccessScope]string `json:"accessTokens,omitempty"` // Gets or sets access control settings for the tunnel. // // See `TunnelAccessControl` documentation for details about the access control model. - AccessControl *TunnelAccessControl `json:"accessControl,omitempty"` + AccessControl *TunnelAccessControl `json:"accessControl,omitempty"` // Gets or sets default options for the tunnel. - Options *TunnelOptions `json:"options,omitempty"` + Options *TunnelOptions `json:"options,omitempty"` // Gets or sets current connection status of the tunnel. - Status *TunnelStatus `json:"status,omitempty"` + Status *TunnelStatus `json:"status,omitempty"` // Gets or sets an array of endpoints where hosts are currently accepting client // connections to the tunnel. - Endpoints []TunnelEndpoint `json:"endpoints,omitempty"` + Endpoints []TunnelEndpoint `json:"endpoints,omitempty"` // Gets or sets a list of ports in the tunnel. // @@ -57,11 +57,15 @@ type Tunnel struct { // creating a tunnel. It is omitted when listing (multiple) tunnels, or when updating // tunnel properties. (For the latter, use APIs to create/update/delete individual ports // instead.) - Ports []TunnelPort `json:"ports,omitempty"` + Ports []TunnelPort `json:"ports,omitempty"` // Gets or sets the time in UTC of tunnel creation. - Created *time.Time `json:"created,omitempty"` + Created *time.Time `json:"created,omitempty"` // Gets or the time the tunnel will be deleted if it is not used or updated. - Expiration *time.Time `json:"expiration,omitempty"` + Expiration *time.Time `json:"expiration,omitempty"` + + // Gets or the custom amount of time the tunnel will be valid if it is not used or + // updated in seconds. + CustomExpiration uint32 `json:"customExpiration,omitempty"` } diff --git a/java/src/main/java/com/microsoft/tunnels/contracts/Tunnel.java b/java/src/main/java/com/microsoft/tunnels/contracts/Tunnel.java index 0ba3de50..887f0af1 100644 --- a/java/src/main/java/com/microsoft/tunnels/contracts/Tunnel.java +++ b/java/src/main/java/com/microsoft/tunnels/contracts/Tunnel.java @@ -109,4 +109,11 @@ public class Tunnel { */ @Expose public Date expiration; + + /** + * Gets or the custom amount of time the tunnel will be valid if it is not used or + * updated in seconds. + */ + @Expose + public int customExpiration; } diff --git a/rs/src/contracts/tunnel.rs b/rs/src/contracts/tunnel.rs index a5a25904..41c5288a 100644 --- a/rs/src/contracts/tunnel.rs +++ b/rs/src/contracts/tunnel.rs @@ -72,4 +72,8 @@ pub struct Tunnel { // Gets or the time the tunnel will be deleted if it is not used or updated. pub expiration: Option>, + + // Gets or the custom amount of time the tunnel will be valid if it is not used or + // updated in seconds. + pub custom_expiration: Option, } diff --git a/ts/src/contracts/tunnel.ts b/ts/src/contracts/tunnel.ts index f723bd31..8e5edd46 100644 --- a/ts/src/contracts/tunnel.ts +++ b/ts/src/contracts/tunnel.ts @@ -96,4 +96,10 @@ export interface Tunnel { * Gets or the time the tunnel will be deleted if it is not used or updated. */ expiration?: Date; + + /** + * Gets or the custom amount of time the tunnel will be valid if it is not used or + * updated in seconds. + */ + customExpiration?: number; }