-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ksqlDB.RestApi.Client]: reduced namespaces in KSQL parameters folder
- Loading branch information
1 parent
6219390
commit 96876f8
Showing
11 changed files
with
175 additions
and
90 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
ksqlDb.RestApi.Client/KSql/RestApi/Parameters/IKSqlDbParameters.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
namespace ksqlDB.RestApi.Client.KSql.RestApi.Parameters; | ||
|
||
/// <summary> | ||
/// Represents parameters for a KSqlDb endpoint. | ||
/// </summary> | ||
public interface IKSqlDbParameters : IQueryParameters | ||
{ | ||
/// <summary> | ||
/// Clones the current parameters. | ||
/// </summary> | ||
/// <returns>A new instance of the parameters with the same values.</returns> | ||
IKSqlDbParameters Clone(); | ||
} |
10 changes: 6 additions & 4 deletions
10
ksqlDb.RestApi.Client/KSql/RestApi/Parameters/IPullQueryParameters.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
namespace ksqlDB.RestApi.Client.KSql.RestApi.Parameters | ||
namespace ksqlDB.RestApi.Client.KSql.RestApi.Parameters; | ||
|
||
/// <summary> | ||
/// Represents parameters for a pull query. | ||
/// </summary> | ||
public interface IPullQueryParameters : IKSqlDbParameters | ||
{ | ||
public interface IPullQueryParameters : IKSqlDbParameters | ||
{ | ||
} | ||
} |
12 changes: 7 additions & 5 deletions
12
ksqlDb.RestApi.Client/KSql/RestApi/Parameters/IPushQueryParameters.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
using ksqlDB.RestApi.Client.KSql.Query.Options; | ||
|
||
namespace ksqlDB.RestApi.Client.KSql.RestApi.Parameters | ||
namespace ksqlDB.RestApi.Client.KSql.RestApi.Parameters; | ||
|
||
/// <summary> | ||
/// Represents parameters for a push query. | ||
/// </summary> | ||
public interface IPushQueryParameters : IKSqlDbParameters | ||
{ | ||
public interface IPushQueryParameters : IKSqlDbParameters | ||
{ | ||
AutoOffsetReset AutoOffsetReset { get; set; } | ||
} | ||
AutoOffsetReset AutoOffsetReset { get; set; } | ||
} |
17 changes: 14 additions & 3 deletions
17
ksqlDb.RestApi.Client/KSql/RestApi/Parameters/IQueryParameters.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
namespace ksqlDB.RestApi.Client.KSql.RestApi.Parameters; | ||
namespace ksqlDB.RestApi.Client.KSql.RestApi.Parameters; | ||
|
||
/// <summary> | ||
/// Represents query parameters for a KSqlDb endpoint. | ||
/// </summary> | ||
public interface IQueryParameters : IQueryOptions | ||
{ | ||
/// <summary> | ||
/// A semicolon-delimited sequence of SQL statements to run. | ||
/// </summary> | ||
string Sql { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Indexer to access properties by key. | ||
/// </summary> | ||
/// <param name="key">The key of the property.</param> | ||
/// <returns>The value of the property.</returns> | ||
string this[string key] { get; set; } | ||
} | ||
} |
10 changes: 6 additions & 4 deletions
10
ksqlDb.RestApi.Client/KSql/RestApi/Parameters/PullQueryParameters.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
namespace ksqlDB.RestApi.Client.KSql.RestApi.Parameters | ||
namespace ksqlDB.RestApi.Client.KSql.RestApi.Parameters; | ||
|
||
/// <summary> | ||
/// Represents parameters for a pull query endpoint. | ||
/// </summary> | ||
public class PullQueryParameters : QueryEndpointParameters<PullQueryParameters>, IPullQueryParameters | ||
{ | ||
public class PullQueryParameters : QueryEndpointParameters<PullQueryParameters>, IPullQueryParameters | ||
{ | ||
} | ||
} |
10 changes: 6 additions & 4 deletions
10
ksqlDb.RestApi.Client/KSql/RestApi/Parameters/PullQueryStreamParameters.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
namespace ksqlDB.RestApi.Client.KSql.RestApi.Parameters | ||
namespace ksqlDB.RestApi.Client.KSql.RestApi.Parameters; | ||
|
||
/// <summary> | ||
/// Represents parameters for a pull query stream endpoint. | ||
/// </summary> | ||
public class PullQueryStreamParameters : QueryStreamEndpointParameters<PullQueryStreamParameters>, IPullQueryParameters | ||
{ | ||
public class PullQueryStreamParameters : QueryStreamEndpointParameters<PullQueryStreamParameters>, IPullQueryParameters | ||
{ | ||
} | ||
} |
98 changes: 59 additions & 39 deletions
98
ksqlDb.RestApi.Client/KSql/RestApi/Parameters/QueryEndpointParameters.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,73 @@ | ||
using System.Text.Json.Serialization; | ||
using ksqlDB.RestApi.Client.KSql.RestApi.Statements; | ||
|
||
namespace ksqlDB.RestApi.Client.KSql.RestApi.Parameters | ||
namespace ksqlDB.RestApi.Client.KSql.RestApi.Parameters; | ||
|
||
/// <summary> | ||
/// Represents parameters for a '/query' endpoint. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the query stream endpoint parameters.</typeparam> | ||
public class QueryEndpointParameters<T> : IKSqlDbParameters | ||
where T : QueryEndpointParameters<T>, new() | ||
{ | ||
public class QueryEndpointParameters<T> : IKSqlDbParameters | ||
where T : QueryEndpointParameters<T>, new() | ||
/// <summary> | ||
/// A semicolon-delimited sequence of SQL statements to run. | ||
/// </summary> | ||
[JsonPropertyName("ksql")] | ||
public string Sql { get; set; } = null!; | ||
|
||
/// <summary> | ||
/// Property overrides to run the statements with. | ||
/// </summary> | ||
[JsonPropertyName("streamsProperties")] | ||
public Dictionary<string, string> Properties { get; } = new(); | ||
|
||
/// <summary> | ||
/// Indexer to access properties by key. | ||
/// </summary> | ||
/// <param name="key">The key of the property.</param> | ||
/// <returns>The value of the property.</returns> | ||
public string this[string key] | ||
{ | ||
/// <summary> | ||
/// A semicolon-delimited sequence of SQL statements to run. | ||
/// </summary> | ||
[JsonPropertyName("ksql")] | ||
public string Sql { get; set; } = null!; | ||
|
||
/// <summary> | ||
/// Property overrides to run the statements with. | ||
/// </summary> | ||
[JsonPropertyName("streamsProperties")] | ||
public Dictionary<string, string> Properties { get; } = new(); | ||
|
||
public string this[string key] | ||
{ | ||
get => Properties[key]; | ||
set => Properties[key] = value; | ||
} | ||
get => Properties[key]; | ||
set => Properties[key] = value; | ||
} | ||
|
||
internal EndpointType EndpointType { get; set; } = EndpointType.Query; | ||
internal EndpointType EndpointType { get; set; } = EndpointType.Query; | ||
|
||
public void FillFrom(IKSqlDbParameters parameters) | ||
{ | ||
this.FillQueryParametersFrom(parameters); | ||
} | ||
/// <summary> | ||
/// Fills the parameters from another set of parameters. | ||
/// </summary> | ||
/// <param name="parameters">The parameters to fill from.</param> | ||
public void FillFrom(IKSqlDbParameters parameters) | ||
{ | ||
this.FillQueryParametersFrom(parameters); | ||
} | ||
|
||
public IKSqlDbParameters Clone() | ||
/// <summary> | ||
/// Clones the current parameters. | ||
/// </summary> | ||
/// <returns>A new instance of the parameters with the same values.</returns> | ||
public IKSqlDbParameters Clone() | ||
{ | ||
var queryParams = new T() | ||
{ | ||
var queryParams = new T() | ||
{ | ||
Sql = Sql, | ||
EndpointType = EndpointType | ||
}; | ||
Sql = Sql, | ||
EndpointType = EndpointType | ||
}; | ||
|
||
foreach (var entry in Properties) | ||
queryParams.Properties.Add(entry.Key, entry.Value); | ||
foreach (var entry in Properties) | ||
queryParams.Properties.Add(entry.Key, entry.Value); | ||
|
||
return queryParams; | ||
} | ||
return queryParams; | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return this.ToLogInfo(); | ||
} | ||
/// <summary> | ||
/// Returns a string representation of the object. | ||
/// </summary> | ||
/// <returns>A string representation of the object.</returns> | ||
public override string ToString() | ||
{ | ||
return this.ToLogInfo(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 57 additions & 30 deletions
87
ksqlDb.RestApi.Client/KSql/RestApi/Parameters/QueryStreamEndpointParameters.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,70 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace ksqlDB.RestApi.Client.KSql.RestApi.Parameters | ||
namespace ksqlDB.RestApi.Client.KSql.RestApi.Parameters; | ||
|
||
/// <summary> | ||
/// Represents parameters for a '/query-stream' endpoint. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the query stream endpoint parameters.</typeparam> | ||
public class QueryStreamEndpointParameters<T> : IKSqlDbParameters | ||
where T : QueryStreamEndpointParameters<T>, new() | ||
{ | ||
public class QueryStreamEndpointParameters<T> : IKSqlDbParameters | ||
where T : QueryStreamEndpointParameters<T>, new() | ||
{ | ||
[JsonPropertyName("sql")] | ||
public string Sql { get; set; } = null!; | ||
/// <summary> | ||
/// A semicolon-delimited sequence of SQL statements to run. | ||
/// </summary> | ||
[JsonPropertyName("sql")] | ||
public string Sql { get; set; } = null!; | ||
|
||
[JsonPropertyName("properties")] | ||
public Dictionary<string, string> Properties { get; } = new(); | ||
/// <summary> | ||
/// Property overrides to run the statements with. | ||
/// </summary> | ||
[JsonPropertyName("properties")] | ||
public Dictionary<string, string> Properties { get; } = new(); | ||
|
||
public string this[string key] | ||
{ | ||
get => Properties[key]; | ||
set => Properties[key] = value; | ||
} | ||
/// <summary> | ||
/// Indexer to access properties by key. | ||
/// </summary> | ||
/// <param name="key">The key of the property.</param> | ||
/// <returns>The value of the property.</returns> | ||
public string this[string key] | ||
{ | ||
get => Properties[key]; | ||
set => Properties[key] = value; | ||
} | ||
|
||
/// <summary> | ||
/// Fills the parameters from another set of parameters. | ||
/// </summary> | ||
/// <param name="parameters">The parameters to fill from.</param> | ||
public void FillFrom(IKSqlDbParameters parameters) | ||
{ | ||
this.FillQueryParametersFrom(parameters); | ||
} | ||
|
||
public void FillFrom(IKSqlDbParameters parameters) | ||
{ | ||
this.FillQueryParametersFrom(parameters); | ||
} | ||
|
||
public IKSqlDbParameters Clone() | ||
/// <summary> | ||
/// Clones the current parameters. | ||
/// </summary> | ||
/// <returns>A new instance of the parameters with the same values.</returns> | ||
public IKSqlDbParameters Clone() | ||
{ | ||
var queryParams = new T() | ||
{ | ||
var queryParams = new T() | ||
{ | ||
Sql = Sql | ||
}; | ||
Sql = Sql | ||
}; | ||
|
||
foreach (var entry in Properties) | ||
queryParams.Properties.Add(entry.Key, entry.Value); | ||
foreach (var entry in Properties) | ||
queryParams.Properties.Add(entry.Key, entry.Value); | ||
|
||
return queryParams; | ||
} | ||
return queryParams; | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return this.ToLogInfo(); | ||
} | ||
/// <summary> | ||
/// Returns a string representation of the object. | ||
/// </summary> | ||
/// <returns>A string representation of the object.</returns> | ||
public override string ToString() | ||
{ | ||
return this.ToLogInfo(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters