From f68ba94824c9ef89f11f7ef52f907365493ba261 Mon Sep 17 00:00:00 2001 From: Caleb Lloyd Date: Thu, 13 Jul 2023 00:21:47 -0400 Subject: [PATCH] generate JetStream models with NJsonSchema Signed-off-by: Caleb Lloyd --- NATS.Client.sln | 9 + src/NATS.Client.JetStream/JSContext.cs | 4 +- .../Models/AccountInfoResponse.cs | 9 + .../Models/AccountLimits.cs | 85 +- .../Models/AccountPurgeResponse.cs | 15 + .../Models/AccountStatistics.cs | 28 - .../Models/AccountStats.cs | 57 + .../Models/AccountTier.cs | 34 - src/NATS.Client.JetStream/Models/ApiError.cs | 27 + .../Models/ApiResponse.cs | 25 - src/NATS.Client.JetStream/Models/ApiStats.cs | 33 +- src/NATS.Client.JetStream/Models/Cluster.cs | 9 - .../Models/ClusterInfo.cs | 39 +- .../Models/ConsumerConfiguration.cs | 302 ++- .../Models/ConsumerConfigurationAckPolicy.cs | 13 + .../ConsumerConfigurationDeliverPolicy.cs | 22 + .../ConsumerConfigurationReplayPolicy.cs | 10 + .../Models/ConsumerCreateRequest.cs | 36 +- .../Models/ConsumerCreateResponse.cs | 9 + .../Models/ConsumerDeleteResponse.cs | 12 + .../Models/ConsumerGetnextRequest.cs | 47 + .../Models/ConsumerInfo.cs | 121 +- .../Models/ConsumerInfoResponse.cs | 9 + .../Models/ConsumerLeaderStepdownResponse.cs | 15 + .../Models/ConsumerListRequest.cs | 9 + .../Models/ConsumerListResponse.cs | 16 + .../Models/ConsumerNamesRequest.cs | 15 + .../Models/ConsumerNamesResponse.cs | 13 + src/NATS.Client.JetStream/Models/Error.cs | 28 - .../Models/ErrorResponse.cs | 9 + src/NATS.Client.JetStream/Models/External.cs | 25 - .../Models/ExternalStreamSource.cs | 23 + .../Models/IterableRequest.cs | 9 + .../Models/IterableResponse.cs | 19 + .../Models/LostStreamData.cs | 36 +- .../Models/MessageDeleteRequest.cs | 25 - .../Models/MessageGetRequest.cs | 28 - .../Models/MessageInfo.cs | 37 - .../Models/MetaLeaderStepdownRequest.cs | 12 + .../Models/MetaLeaderStepdownResponse.cs | 15 + .../Models/MetaServerRemoveRequest.cs | 22 + .../Models/MetaServerRemoveResponse.cs | 15 + src/NATS.Client.JetStream/Models/Mirror.cs | 34 - .../Models/MirrorInfo.cs | 31 - src/NATS.Client.JetStream/Models/PeerInfo.cs | 57 +- src/NATS.Client.JetStream/Models/Placement.cs | 36 +- .../Models/PubAckResponse.cs | 42 + .../Models/PublishAck.cs | 31 - .../Models/PublishOptions.cs | 19 - .../Models/PurgeOptions.cs | 28 - .../Models/PurgeResponse.cs | 25 - src/NATS.Client.JetStream/Models/Replica.cs | 35 - src/NATS.Client.JetStream/Models/Republish.cs | 45 +- .../Models/SequenceInfo.cs | 39 +- .../Models/SequencePair.cs | 33 +- .../Models/ServerInfo.cs | 73 - src/NATS.Client.JetStream/Models/Source.cs | 34 - .../Models/SourceInfo.cs | 31 - .../Models/StoredMessage.cs | 43 + .../Models/StreamAlternate.cs | 31 + .../Models/StreamConfig.cs | 63 - .../Models/StreamConfiguration.cs | 321 ++- .../Models/StreamConfigurationCompression.cs | 10 + .../Models/StreamConfigurationDiscard.cs | 10 + .../Models/StreamConfigurationRetention.cs | 13 + .../Models/StreamConfigurationStorage.cs | 10 + .../Models/StreamCreateRequest.cs | 67 +- .../Models/StreamCreateResponse.cs | 22 +- .../Models/StreamDeleteResponse.cs | 12 + .../Models/StreamInfo.cs | 84 +- .../Models/StreamInfoOptions.cs | 25 - .../Models/StreamInfoRequest.cs | 30 + .../Models/StreamInfoResponse.cs | 45 +- .../Models/StreamLeaderStepdownResponse.cs | 15 + .../Models/StreamListRequest.cs | 20 + .../Models/StreamListResponse.cs | 23 + .../Models/StreamMsgDeleteRequest.cs | 23 + .../Models/StreamMsgDeleteResponse.cs | 12 + .../Models/StreamMsgGetRequest.cs | 29 + .../Models/StreamMsgGetResponse.cs | 13 + .../Models/StreamNamesRequest.cs | 20 + .../Models/StreamNamesResponse.cs | 12 + .../Models/StreamPurgeRequest.cs | 31 + .../Models/StreamPurgeResponse.cs | 20 + .../Models/StreamRemovePeerRequest.cs | 16 + .../Models/StreamRemovePeerResponse.cs | 15 + .../Models/StreamRestoreRequest.cs | 18 + .../Models/StreamRestoreResponse.cs | 16 + .../Models/StreamSnapshotRequest.cs | 38 + .../Models/StreamSnapshotResponse.cs | 18 + .../Models/StreamSource.cs | 51 + .../Models/StreamSourceInfo.cs | 54 + .../Models/StreamState.cs | 115 +- .../Models/StreamTemplateConfiguration.cs | 31 + .../Models/StreamTemplateCreateRequest.cs | 9 + .../Models/StreamTemplateCreateResponse.cs | 9 + .../Models/StreamTemplateDeleteResponse.cs | 12 + .../Models/StreamTemplateInfo.cs | 17 + .../Models/StreamTemplateInfoResponse.cs | 9 + .../Models/StreamTemplateNamesRequest.cs | 9 + .../Models/StreamTemplateNamesResponse.cs | 12 + .../Models/StreamUpdateRequest.cs | 9 + .../Models/StreamUpdateResponse.cs | 9 + src/NATS.Client.JetStream/Models/Subject.cs | 19 - .../Models/SubjectTransform.cs | 23 + .../Models/SubscribeOptions.cs | 19 - .../Models/SuccessApiResponse.cs | 22 - src/NATS.Client.JetStream/Models/Tier.cs | 41 + tools/Schema.Generation/Program.cs | 97 + tools/Schema.Generation/README.md | 13 + .../Schema.Generation.csproj | 15 + tools/Schema.Generation/prepare.js | 22 + .../schema/jetstream.api.v1.json | 1984 +++++++++++++++++ .../api/v1/account_info_response.json | 10 + .../api/v1/account_purge_response.json | 14 + .../api/v1/consumer_create_request.json | 22 + .../api/v1/consumer_create_response.json | 12 + .../api/v1/consumer_delete_response.json | 13 + .../api/v1/consumer_getnext_request.json | 32 + .../api/v1/consumer_info_response.json | 12 + .../v1/consumer_leader_stepdown_response.json | 15 + .../api/v1/consumer_list_request.json | 10 + .../api/v1/consumer_list_response.json | 29 + .../api/v1/consumer_names_request.json | 18 + .../api/v1/consumer_names_response.json | 21 + .../jetstream/api/v1/definitions.json | 1097 +++++++++ .../api/v1/meta_leader_stepdown_request.json | 12 + .../api/v1/meta_leader_stepdown_response.json | 15 + .../api/v1/meta_server_remove_request.json | 18 + .../api/v1/meta_server_remove_response.json | 15 + .../jetstream/api/v1/pub_ack_response.json | 33 + .../api/v1/stream_create_request.json | 10 + .../api/v1/stream_create_response.json | 12 + .../api/v1/stream_delete_response.json | 13 + .../jetstream/api/v1/stream_info_request.json | 22 + .../api/v1/stream_info_response.json | 26 + .../v1/stream_leader_stepdown_response.json | 15 + .../jetstream/api/v1/stream_list_request.json | 17 + .../api/v1/stream_list_response.json | 29 + .../api/v1/stream_msg_delete_request.json | 18 + .../api/v1/stream_msg_delete_response.json | 13 + .../api/v1/stream_msg_get_request.json | 21 + .../api/v1/stream_msg_get_response.json | 13 + .../api/v1/stream_names_request.json | 17 + .../api/v1/stream_names_response.json | 21 + .../api/v1/stream_purge_request.json | 21 + .../api/v1/stream_purge_response.json | 17 + .../api/v1/stream_remove_peer_request.json | 16 + .../api/v1/stream_remove_peer_response.json | 15 + .../api/v1/stream_restore_request.json | 16 + .../api/v1/stream_restore_response.json | 15 + .../api/v1/stream_snapshot_request.json | 31 + .../api/v1/stream_snapshot_response.json | 16 + .../api/v1/stream_template_configuration.json | 28 + .../v1/stream_template_create_request.json | 10 + .../v1/stream_template_create_response.json | 12 + .../v1/stream_template_delete_response.json | 13 + .../api/v1/stream_template_info_response.json | 12 + .../api/v1/stream_template_names_request.json | 10 + .../v1/stream_template_names_response.json | 21 + .../api/v1/stream_update_request.json | 10 + .../api/v1/stream_update_response.json | 12 + 162 files changed, 6214 insertions(+), 1351 deletions(-) create mode 100644 src/NATS.Client.JetStream/Models/AccountInfoResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/AccountPurgeResponse.cs delete mode 100644 src/NATS.Client.JetStream/Models/AccountStatistics.cs create mode 100644 src/NATS.Client.JetStream/Models/AccountStats.cs delete mode 100644 src/NATS.Client.JetStream/Models/AccountTier.cs create mode 100644 src/NATS.Client.JetStream/Models/ApiError.cs delete mode 100644 src/NATS.Client.JetStream/Models/ApiResponse.cs delete mode 100644 src/NATS.Client.JetStream/Models/Cluster.cs create mode 100644 src/NATS.Client.JetStream/Models/ConsumerConfigurationAckPolicy.cs create mode 100644 src/NATS.Client.JetStream/Models/ConsumerConfigurationDeliverPolicy.cs create mode 100644 src/NATS.Client.JetStream/Models/ConsumerConfigurationReplayPolicy.cs create mode 100644 src/NATS.Client.JetStream/Models/ConsumerCreateResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/ConsumerDeleteResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/ConsumerGetnextRequest.cs create mode 100644 src/NATS.Client.JetStream/Models/ConsumerInfoResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/ConsumerLeaderStepdownResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/ConsumerListRequest.cs create mode 100644 src/NATS.Client.JetStream/Models/ConsumerListResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/ConsumerNamesRequest.cs create mode 100644 src/NATS.Client.JetStream/Models/ConsumerNamesResponse.cs delete mode 100644 src/NATS.Client.JetStream/Models/Error.cs create mode 100644 src/NATS.Client.JetStream/Models/ErrorResponse.cs delete mode 100644 src/NATS.Client.JetStream/Models/External.cs create mode 100644 src/NATS.Client.JetStream/Models/ExternalStreamSource.cs create mode 100644 src/NATS.Client.JetStream/Models/IterableRequest.cs create mode 100644 src/NATS.Client.JetStream/Models/IterableResponse.cs delete mode 100644 src/NATS.Client.JetStream/Models/MessageDeleteRequest.cs delete mode 100644 src/NATS.Client.JetStream/Models/MessageGetRequest.cs delete mode 100644 src/NATS.Client.JetStream/Models/MessageInfo.cs create mode 100644 src/NATS.Client.JetStream/Models/MetaLeaderStepdownRequest.cs create mode 100644 src/NATS.Client.JetStream/Models/MetaLeaderStepdownResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/MetaServerRemoveRequest.cs create mode 100644 src/NATS.Client.JetStream/Models/MetaServerRemoveResponse.cs delete mode 100644 src/NATS.Client.JetStream/Models/Mirror.cs delete mode 100644 src/NATS.Client.JetStream/Models/MirrorInfo.cs create mode 100644 src/NATS.Client.JetStream/Models/PubAckResponse.cs delete mode 100644 src/NATS.Client.JetStream/Models/PublishAck.cs delete mode 100644 src/NATS.Client.JetStream/Models/PublishOptions.cs delete mode 100644 src/NATS.Client.JetStream/Models/PurgeOptions.cs delete mode 100644 src/NATS.Client.JetStream/Models/PurgeResponse.cs delete mode 100644 src/NATS.Client.JetStream/Models/Replica.cs delete mode 100644 src/NATS.Client.JetStream/Models/ServerInfo.cs delete mode 100644 src/NATS.Client.JetStream/Models/Source.cs delete mode 100644 src/NATS.Client.JetStream/Models/SourceInfo.cs create mode 100644 src/NATS.Client.JetStream/Models/StoredMessage.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamAlternate.cs delete mode 100644 src/NATS.Client.JetStream/Models/StreamConfig.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamConfigurationCompression.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamConfigurationDiscard.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamConfigurationRetention.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamConfigurationStorage.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamDeleteResponse.cs delete mode 100644 src/NATS.Client.JetStream/Models/StreamInfoOptions.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamInfoRequest.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamLeaderStepdownResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamListRequest.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamListResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamMsgDeleteRequest.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamMsgDeleteResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamMsgGetRequest.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamMsgGetResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamNamesRequest.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamNamesResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamPurgeRequest.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamPurgeResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamRemovePeerRequest.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamRemovePeerResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamRestoreRequest.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamRestoreResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamSnapshotRequest.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamSnapshotResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamSource.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamSourceInfo.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamTemplateConfiguration.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamTemplateCreateRequest.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamTemplateCreateResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamTemplateDeleteResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamTemplateInfo.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamTemplateInfoResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamTemplateNamesRequest.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamTemplateNamesResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamUpdateRequest.cs create mode 100644 src/NATS.Client.JetStream/Models/StreamUpdateResponse.cs delete mode 100644 src/NATS.Client.JetStream/Models/Subject.cs create mode 100644 src/NATS.Client.JetStream/Models/SubjectTransform.cs delete mode 100644 src/NATS.Client.JetStream/Models/SubscribeOptions.cs delete mode 100644 src/NATS.Client.JetStream/Models/SuccessApiResponse.cs create mode 100644 src/NATS.Client.JetStream/Models/Tier.cs create mode 100644 tools/Schema.Generation/Program.cs create mode 100644 tools/Schema.Generation/README.md create mode 100644 tools/Schema.Generation/Schema.Generation.csproj create mode 100644 tools/Schema.Generation/prepare.js create mode 100644 tools/Schema.Generation/schema/jetstream.api.v1.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/account_info_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/account_purge_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_create_request.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_create_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_delete_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_getnext_request.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_info_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_leader_stepdown_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_list_request.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_list_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_names_request.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_names_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/definitions.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/meta_leader_stepdown_request.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/meta_leader_stepdown_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/meta_server_remove_request.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/meta_server_remove_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/pub_ack_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_create_request.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_create_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_delete_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_info_request.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_info_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_leader_stepdown_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_list_request.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_list_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_msg_delete_request.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_msg_delete_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_msg_get_request.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_msg_get_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_names_request.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_names_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_purge_request.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_purge_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_remove_peer_request.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_remove_peer_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_restore_request.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_restore_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_snapshot_request.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_snapshot_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_configuration.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_create_request.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_create_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_delete_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_info_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_names_request.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_names_response.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_update_request.json create mode 100644 tools/Schema.Generation/schema_source/jetstream/api/v1/stream_update_response.json diff --git a/NATS.Client.sln b/NATS.Client.sln index 5376388a4..b061caa90 100644 --- a/NATS.Client.sln +++ b/NATS.Client.sln @@ -59,6 +59,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NATS.Client.JetStream.Tests EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NATS.Client.TestUtilities", "tests\NATS.Client.TestUtilities\NATS.Client.TestUtilities.csproj", "{90E5BF38-70C1-460A-9177-CE42815BDBF5}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{BD234E2E-F51A-4B18-B8BE-8AF6D546BF87}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Schema.Generation", "tools\Schema.Generation\Schema.Generation.csproj", "{B7DD4A9C-2D24-4772-951E-86A665C59ADF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -145,6 +149,10 @@ Global {90E5BF38-70C1-460A-9177-CE42815BDBF5}.Debug|Any CPU.Build.0 = Debug|Any CPU {90E5BF38-70C1-460A-9177-CE42815BDBF5}.Release|Any CPU.ActiveCfg = Release|Any CPU {90E5BF38-70C1-460A-9177-CE42815BDBF5}.Release|Any CPU.Build.0 = Release|Any CPU + {B7DD4A9C-2D24-4772-951E-86A665C59ADF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B7DD4A9C-2D24-4772-951E-86A665C59ADF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B7DD4A9C-2D24-4772-951E-86A665C59ADF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B7DD4A9C-2D24-4772-951E-86A665C59ADF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -171,6 +179,7 @@ Global {56A9B885-6B7E-4BC6-AED0-ADC67C9A68DB} = {4827B3EC-73D8-436D-AE2A-5E29AC95FD0C} {2D39F649-C512-4EE5-9DFA-7BD4D9E4F145} = {C526E8AB-739A-48D7-8FC4-048978C9B650} {90E5BF38-70C1-460A-9177-CE42815BDBF5} = {C526E8AB-739A-48D7-8FC4-048978C9B650} + {B7DD4A9C-2D24-4772-951E-86A665C59ADF} = {BD234E2E-F51A-4B18-B8BE-8AF6D546BF87} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8CBB7278-D093-448E-B3DE-B5991209A1AA} diff --git a/src/NATS.Client.JetStream/JSContext.cs b/src/NATS.Client.JetStream/JSContext.cs index 13bb22a4f..e35e9ed33 100644 --- a/src/NATS.Client.JetStream/JSContext.cs +++ b/src/NATS.Client.JetStream/JSContext.cs @@ -55,10 +55,10 @@ public record JSOptions public class JSStream { - public StreamCreateResponse Response { get; } - public JSStream(StreamCreateResponse response) { Response = response; } + + public StreamCreateResponse Response { get; } } diff --git a/src/NATS.Client.JetStream/Models/AccountInfoResponse.cs b/src/NATS.Client.JetStream/Models/AccountInfoResponse.cs new file mode 100644 index 000000000..7c6d601cb --- /dev/null +++ b/src/NATS.Client.JetStream/Models/AccountInfoResponse.cs @@ -0,0 +1,9 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.INFO API +/// + +public record AccountInfoResponse : AccountStats +{ +} diff --git a/src/NATS.Client.JetStream/Models/AccountLimits.cs b/src/NATS.Client.JetStream/Models/AccountLimits.cs index cf7677830..aa5e69760 100644 --- a/src/NATS.Client.JetStream/Models/AccountLimits.cs +++ b/src/NATS.Client.JetStream/Models/AccountLimits.cs @@ -1,43 +1,66 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - namespace NATS.Client.JetStream.Models; public record AccountLimits { - [JsonPropertyName("max_memory")] - public long MaxMemory { get; set; } + /// + /// The maximum amount of Memory storage Stream Messages may consume + /// + [System.Text.Json.Serialization.JsonPropertyName("max_memory")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(-1, int.MaxValue)] + public int MaxMemory { get; set; } = default!; - [JsonPropertyName("max_storage")] - public long MaxStorage { get; set; } + /// + /// The maximum amount of File storage Stream Messages may consume + /// + [System.Text.Json.Serialization.JsonPropertyName("max_storage")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(-1, int.MaxValue)] + public int MaxStorage { get; set; } = default!; - [JsonPropertyName("max_streams")] - public long MaxStreams { get; set; } + /// + /// The maximum number of Streams an account can create + /// + [System.Text.Json.Serialization.JsonPropertyName("max_streams")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(-1, int.MaxValue)] + public int MaxStreams { get; set; } = default!; - [JsonPropertyName("max_consumers")] - public long MaxConsumers { get; set; } + /// + /// The maximum number of Consumer an account can create + /// + [System.Text.Json.Serialization.JsonPropertyName("max_consumers")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(-1, int.MaxValue)] + public int MaxConsumers { get; set; } = default!; - [JsonPropertyName("max_ack_pending")] - public long MaxAckPending { get; set; } + /// + /// Indicates if Streams created in this account requires the max_bytes property set + /// + [System.Text.Json.Serialization.JsonPropertyName("max_bytes_required")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool MaxBytesRequired { get; set; } = false; - [JsonPropertyName("memory_max_stream_bytes")] - public long MemoryMaxStreamBytes { get; set; } + /// + /// The maximum number of outstanding ACKs any consumer may configure + /// + [System.Text.Json.Serialization.JsonPropertyName("max_ack_pending")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public int MaxAckPending { get; set; } = default!; - [JsonPropertyName("storage_max_stream_bytes")] - public long StorageMaxStreamBytes { get; set; } + /// + /// The maximum size any single memory stream may be + /// + [System.Text.Json.Serialization.JsonPropertyName("memory_max_stream_bytes")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-1, int.MaxValue)] + public int MemoryMaxStreamBytes { get; set; } = -1; - [JsonPropertyName("max_bytes_required")] - public bool MaxBytesRequired { get; set; } + /// + /// The maximum size any single storage based stream may be + /// + [System.Text.Json.Serialization.JsonPropertyName("storage_max_stream_bytes")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-1, int.MaxValue)] + public int StorageMaxStreamBytes { get; set; } = -1; } diff --git a/src/NATS.Client.JetStream/Models/AccountPurgeResponse.cs b/src/NATS.Client.JetStream/Models/AccountPurgeResponse.cs new file mode 100644 index 000000000..340193f24 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/AccountPurgeResponse.cs @@ -0,0 +1,15 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.ACCOUNT.PURGE API +/// + +public record AccountPurgeResponse +{ + /// + /// If the purge operation was succesfully started + /// + [System.Text.Json.Serialization.JsonPropertyName("initiated")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool Initiated { get; set; } = false; +} diff --git a/src/NATS.Client.JetStream/Models/AccountStatistics.cs b/src/NATS.Client.JetStream/Models/AccountStatistics.cs deleted file mode 100644 index 092ca944d..000000000 --- a/src/NATS.Client.JetStream/Models/AccountStatistics.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record AccountStatistics -{ - [JsonPropertyName("domain")] - public string Domain { get; set; } - - [JsonPropertyName("api")] - public string Api { get; set; } - - [JsonPropertyName("tiers")] - public string Tiers { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/AccountStats.cs b/src/NATS.Client.JetStream/Models/AccountStats.cs new file mode 100644 index 000000000..0c4c9d1b1 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/AccountStats.cs @@ -0,0 +1,57 @@ +namespace NATS.Client.JetStream.Models; + +public record AccountStats +{ + /// + /// Memory Storage being used for Stream Message storage + /// + [System.Text.Json.Serialization.JsonPropertyName("memory")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Memory { get; set; } = default!; + + /// + /// File Storage being used for Stream Message storage + /// + [System.Text.Json.Serialization.JsonPropertyName("storage")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Storage { get; set; } = default!; + + /// + /// Number of active Streams + /// + [System.Text.Json.Serialization.JsonPropertyName("streams")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Streams { get; set; } = default!; + + /// + /// Number of active Consumers + /// + [System.Text.Json.Serialization.JsonPropertyName("consumers")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Consumers { get; set; } = default!; + + /// + /// The JetStream domain this account is in + /// + [System.Text.Json.Serialization.JsonPropertyName("domain")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string Domain { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("limits")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public AccountLimits Limits { get; set; } = new AccountLimits(); + + [System.Text.Json.Serialization.JsonPropertyName("tiers")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.Collections.Generic.IDictionary Tiers { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("api")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public ApiStats Api { get; set; } = new ApiStats(); +} diff --git a/src/NATS.Client.JetStream/Models/AccountTier.cs b/src/NATS.Client.JetStream/Models/AccountTier.cs deleted file mode 100644 index 3ec676b31..000000000 --- a/src/NATS.Client.JetStream/Models/AccountTier.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record AccountTier -{ - [JsonPropertyName("memory")] - public long Memory { get; set; } - - [JsonPropertyName("storage")] - public long Storage { get; set; } - - [JsonPropertyName("streams")] - public long Streams { get; set; } - - [JsonPropertyName("consumers")] - public long Consumers { get; set; } - - [JsonPropertyName("limits")] - public string Limits { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/ApiError.cs b/src/NATS.Client.JetStream/Models/ApiError.cs new file mode 100644 index 000000000..d2815051f --- /dev/null +++ b/src/NATS.Client.JetStream/Models/ApiError.cs @@ -0,0 +1,27 @@ +namespace NATS.Client.JetStream.Models; + +public record ApiError +{ + /// + /// HTTP like error code in the 300 to 500 range + /// + [System.Text.Json.Serialization.JsonPropertyName("code")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(300, 699)] + public int Code { get; set; } = default!; + + /// + /// A human friendly description of the error + /// + [System.Text.Json.Serialization.JsonPropertyName("description")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string Description { get; set; } = default!; + + /// + /// The NATS error code unique to each kind of error + /// + [System.Text.Json.Serialization.JsonPropertyName("err_code")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(0, 65535)] + public int ErrCode { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/ApiResponse.cs b/src/NATS.Client.JetStream/Models/ApiResponse.cs deleted file mode 100644 index 62f9baad0..000000000 --- a/src/NATS.Client.JetStream/Models/ApiResponse.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record ApiResponse -{ - [JsonPropertyName("type")] - public string Type { get; set; } - - [JsonPropertyName("error")] - public string Error { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/ApiStats.cs b/src/NATS.Client.JetStream/Models/ApiStats.cs index ee412f851..ed7b6e480 100644 --- a/src/NATS.Client.JetStream/Models/ApiStats.cs +++ b/src/NATS.Client.JetStream/Models/ApiStats.cs @@ -1,25 +1,20 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - namespace NATS.Client.JetStream.Models; public record ApiStats { - [JsonPropertyName("total")] - public long Total { get; set; } + /// + /// Total number of API requests received for this account + /// + [System.Text.Json.Serialization.JsonPropertyName("total")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Total { get; set; } = default!; - [JsonPropertyName("errors")] - public long Errors { get; set; } + /// + /// API requests that resulted in an error response + /// + [System.Text.Json.Serialization.JsonPropertyName("errors")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Errors { get; set; } = default!; } diff --git a/src/NATS.Client.JetStream/Models/Cluster.cs b/src/NATS.Client.JetStream/Models/Cluster.cs deleted file mode 100644 index 1f5c89116..000000000 --- a/src/NATS.Client.JetStream/Models/Cluster.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record Cluster -{ - [JsonPropertyName("leader")] - public string Leader { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/ClusterInfo.cs b/src/NATS.Client.JetStream/Models/ClusterInfo.cs index 9cfa3e6f8..ba6244f4f 100644 --- a/src/NATS.Client.JetStream/Models/ClusterInfo.cs +++ b/src/NATS.Client.JetStream/Models/ClusterInfo.cs @@ -1,28 +1,25 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - namespace NATS.Client.JetStream.Models; public record ClusterInfo { - [JsonPropertyName("name")] - public string Name { get; set; } + /// + /// The cluster name + /// + [System.Text.Json.Serialization.JsonPropertyName("name")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string Name { get; set; } = default!; - [JsonPropertyName("leader")] - public string Leader { get; set; } + /// + /// The server name of the RAFT leader + /// + [System.Text.Json.Serialization.JsonPropertyName("leader")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string Leader { get; set; } = default!; - [JsonPropertyName("replicas")] - public string Replicas { get; set; } + /// + /// The members of the RAFT cluster + /// + [System.Text.Json.Serialization.JsonPropertyName("replicas")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.Collections.Generic.ICollection Replicas { get; set; } = default!; } diff --git a/src/NATS.Client.JetStream/Models/ConsumerConfiguration.cs b/src/NATS.Client.JetStream/Models/ConsumerConfiguration.cs index 97a7a01f0..b7507b1f2 100644 --- a/src/NATS.Client.JetStream/Models/ConsumerConfiguration.cs +++ b/src/NATS.Client.JetStream/Models/ConsumerConfiguration.cs @@ -1,103 +1,209 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - namespace NATS.Client.JetStream.Models; public record ConsumerConfiguration { - [JsonPropertyName("deliver_policy")] - public string DeliverPolicy { get; set; } - - [JsonPropertyName("ack_policy")] - public string AckPolicy { get; set; } - - [JsonPropertyName("replay_policy")] - public string ReplayPolicy { get; set; } - - [JsonPropertyName("description")] - public string Description { get; set; } - - [JsonPropertyName("durable_name")] - public string DurableName { get; set; } - - [JsonPropertyName("name")] - public string Name { get; set; } - - [JsonPropertyName("deliver_subject")] - public string DeliverSubject { get; set; } - - [JsonPropertyName("deliver_group")] - public string DeliverGroup { get; set; } - - [JsonPropertyName("filter_subject")] - public string FilterSubject { get; set; } - - [JsonPropertyName("sample_freq")] - public string SampleFreq { get; set; } - - [JsonPropertyName("opt_start_time")] - public DateTimeOffset OptStartTime { get; set; } - - [JsonPropertyName("ack_wait")] - public TimeSpan AckWait { get; set; } - - [JsonPropertyName("idle_heartbeat")] - public TimeSpan IdleHeartbeat { get; set; } - - [JsonPropertyName("max_expires")] - public TimeSpan MaxExpires { get; set; } - - [JsonPropertyName("inactive_threshold")] - public TimeSpan InactiveThreshold { get; set; } - - [JsonPropertyName("opt_start_seq")] - public ulong OptStartSeq { get; set; } - - [JsonPropertyName("max_deliver")] - public int MaxDeliver { get; set; } - - [JsonPropertyName("rate_limit_bps")] - public ulong RateLimitBps { get; set; } - - [JsonPropertyName("max_ack_pending")] - public int MaxAckPending { get; set; } - - [JsonPropertyName("max_waiting")] - public int MaxWaiting { get; set; } - - [JsonPropertyName("max_batch")] - public int MaxBatch { get; set; } - - [JsonPropertyName("max_bytes")] - public int MaxBytes { get; set; } - - [JsonPropertyName("num_replicas")] - public int NumReplicas { get; set; } - - [JsonPropertyName("flow_control")] - public bool FlowControl { get; set; } - - [JsonPropertyName("headers_only")] - public bool HeadersOnly { get; set; } - - [JsonPropertyName("mem_storage")] - public bool MemStorage { get; set; } - - [JsonPropertyName("backoff")] - public string Backoff { get; set; } - - [JsonPropertyName("metadata")] - public string Metadata { get; set; } + [System.Text.Json.Serialization.JsonPropertyName("deliver_policy")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] + public ConsumerConfigurationDeliverPolicy DeliverPolicy { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("opt_start_seq")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long OptStartSeq { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("opt_start_time")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.DateTimeOffset OptStartTime { get; set; } = default!; + + /// + /// A unique name for a durable consumer + /// + [System.Text.Json.Serialization.JsonPropertyName("durable_name")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.StringLength(int.MaxValue, MinimumLength = 1)] + [System.ComponentModel.DataAnnotations.RegularExpression(@"^[^.*>]+$")] + public string DurableName { get; set; } = default!; + + /// + /// A unique name for a consumer + /// + [System.Text.Json.Serialization.JsonPropertyName("name")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.StringLength(int.MaxValue, MinimumLength = 1)] + [System.ComponentModel.DataAnnotations.RegularExpression(@"^[^.*>]+$")] + public string Name { get; set; } = default!; + + /// + /// A short description of the purpose of this consumer + /// + [System.Text.Json.Serialization.JsonPropertyName("description")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.StringLength(4096)] + public string Description { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("deliver_subject")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.StringLength(int.MaxValue, MinimumLength = 1)] + public string DeliverSubject { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("ack_policy")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] + public ConsumerConfigurationAckPolicy AckPolicy { get; set; } = NATS.Client.JetStream.Models.ConsumerConfigurationAckPolicy.None; + + /// + /// How long (in nanoseconds) to allow messages to remain un-acknowledged before attempting redelivery + /// + [System.Text.Json.Serialization.JsonPropertyName("ack_wait")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long AckWait { get; set; } = default!; + + /// + /// The number of times a message will be redelivered to consumers if not acknowledged in time + /// + [System.Text.Json.Serialization.JsonPropertyName("max_deliver")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long MaxDeliver { get; set; } = default!; + + /// + /// Filter the stream by a single subjects + /// + [System.Text.Json.Serialization.JsonPropertyName("filter_subject")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string FilterSubject { get; set; } = default!; + + /// + /// Filter the stream by multiple subjects + /// + [System.Text.Json.Serialization.JsonPropertyName("filter_subjects")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.Collections.Generic.ICollection FilterSubjects { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("replay_policy")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] + public ConsumerConfigurationReplayPolicy ReplayPolicy { get; set; } = NATS.Client.JetStream.Models.ConsumerConfigurationReplayPolicy.Instant; + + [System.Text.Json.Serialization.JsonPropertyName("sample_freq")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string SampleFreq { get; set; } = default!; + + /// + /// The rate at which messages will be delivered to clients, expressed in bit per second + /// + [System.Text.Json.Serialization.JsonPropertyName("rate_limit_bps")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long RateLimitBps { get; set; } = default!; + + /// + /// The maximum number of messages without acknowledgement that can be outstanding, once this limit is reached message delivery will be suspended + /// + [System.Text.Json.Serialization.JsonPropertyName("max_ack_pending")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long MaxAckPending { get; set; } = default!; + + /// + /// If the Consumer is idle for more than this many nano seconds a empty message with Status header 100 will be sent indicating the consumer is still alive + /// + [System.Text.Json.Serialization.JsonPropertyName("idle_heartbeat")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long IdleHeartbeat { get; set; } = default!; + + /// + /// For push consumers this will regularly send an empty mess with Status header 100 and a reply subject, consumers must reply to these messages to control the rate of message delivery + /// + [System.Text.Json.Serialization.JsonPropertyName("flow_control")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool FlowControl { get; set; } = default!; + + /// + /// The number of pulls that can be outstanding on a pull consumer, pulls received after this is reached are ignored + /// + [System.Text.Json.Serialization.JsonPropertyName("max_waiting")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long MaxWaiting { get; set; } = default!; + + /// + /// Creates a special consumer that does not touch the Raft layers, not for general use by clients, internal use only + /// + [System.Text.Json.Serialization.JsonPropertyName("direct")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool Direct { get; set; } = false; + + /// + /// Delivers only the headers of messages in the stream and not the bodies. Additionally adds Nats-Msg-Size header to indicate the size of the removed payload + /// + [System.Text.Json.Serialization.JsonPropertyName("headers_only")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool HeadersOnly { get; set; } = false; + + /// + /// The largest batch property that may be specified when doing a pull on a Pull Consumer + /// + [System.Text.Json.Serialization.JsonPropertyName("max_batch")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public int MaxBatch { get; set; } = 0; + + /// + /// The maximum expires value that may be set when doing a pull on a Pull Consumer + /// + [System.Text.Json.Serialization.JsonPropertyName("max_expires")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long MaxExpires { get; set; } = default!; + + /// + /// The maximum bytes value that maybe set when dong a pull on a Pull Consumer + /// + [System.Text.Json.Serialization.JsonPropertyName("max_bytes")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long MaxBytes { get; set; } = default!; + + /// + /// Duration that instructs the server to cleanup ephemeral consumers that are inactive for that long + /// + [System.Text.Json.Serialization.JsonPropertyName("inactive_threshold")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long InactiveThreshold { get; set; } = default!; + + /// + /// List of durations in Go format that represents a retry time scale for NaK'd messages + /// + [System.Text.Json.Serialization.JsonPropertyName("backoff")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.Collections.Generic.ICollection Backoff { get; set; } = default!; + + /// + /// When set do not inherit the replica count from the stream but specifically set it to this amount + /// + [System.Text.Json.Serialization.JsonPropertyName("num_replicas")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long NumReplicas { get; set; } = default!; + + /// + /// Force the consumer state to be kept in memory rather than inherit the setting from the stream + /// + [System.Text.Json.Serialization.JsonPropertyName("mem_storage")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool MemStorage { get; set; } = false; + + /// + /// Additional metadata for the Consumer + /// + [System.Text.Json.Serialization.JsonPropertyName("metadata")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.Collections.Generic.IDictionary Metadata { get; set; } = default!; } diff --git a/src/NATS.Client.JetStream/Models/ConsumerConfigurationAckPolicy.cs b/src/NATS.Client.JetStream/Models/ConsumerConfigurationAckPolicy.cs new file mode 100644 index 000000000..db26693cf --- /dev/null +++ b/src/NATS.Client.JetStream/Models/ConsumerConfigurationAckPolicy.cs @@ -0,0 +1,13 @@ +namespace NATS.Client.JetStream.Models; + +public enum ConsumerConfigurationAckPolicy +{ + [System.Runtime.Serialization.EnumMember(Value = @"none")] + None = 0, + + [System.Runtime.Serialization.EnumMember(Value = @"all")] + All = 1, + + [System.Runtime.Serialization.EnumMember(Value = @"explicit")] + Explicit = 2, +} diff --git a/src/NATS.Client.JetStream/Models/ConsumerConfigurationDeliverPolicy.cs b/src/NATS.Client.JetStream/Models/ConsumerConfigurationDeliverPolicy.cs new file mode 100644 index 000000000..d1f807fab --- /dev/null +++ b/src/NATS.Client.JetStream/Models/ConsumerConfigurationDeliverPolicy.cs @@ -0,0 +1,22 @@ +namespace NATS.Client.JetStream.Models; + +public enum ConsumerConfigurationDeliverPolicy +{ + [System.Runtime.Serialization.EnumMember(Value = @"all")] + All = 0, + + [System.Runtime.Serialization.EnumMember(Value = @"last")] + Last = 1, + + [System.Runtime.Serialization.EnumMember(Value = @"new")] + New = 2, + + [System.Runtime.Serialization.EnumMember(Value = @"by_start_sequence")] + ByStartSequence = 3, + + [System.Runtime.Serialization.EnumMember(Value = @"by_start_time")] + ByStartTime = 4, + + [System.Runtime.Serialization.EnumMember(Value = @"last_per_subject")] + LastPerSubject = 5, +} diff --git a/src/NATS.Client.JetStream/Models/ConsumerConfigurationReplayPolicy.cs b/src/NATS.Client.JetStream/Models/ConsumerConfigurationReplayPolicy.cs new file mode 100644 index 000000000..ff6653953 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/ConsumerConfigurationReplayPolicy.cs @@ -0,0 +1,10 @@ +namespace NATS.Client.JetStream.Models; + +public enum ConsumerConfigurationReplayPolicy +{ + [System.Runtime.Serialization.EnumMember(Value = @"instant")] + Instant = 0, + + [System.Runtime.Serialization.EnumMember(Value = @"original")] + Original = 1, +} diff --git a/src/NATS.Client.JetStream/Models/ConsumerCreateRequest.cs b/src/NATS.Client.JetStream/Models/ConsumerCreateRequest.cs index d2fc2b067..f6a84a73f 100644 --- a/src/NATS.Client.JetStream/Models/ConsumerCreateRequest.cs +++ b/src/NATS.Client.JetStream/Models/ConsumerCreateRequest.cs @@ -1,25 +1,23 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - namespace NATS.Client.JetStream.Models; +/// +/// A request to the JetStream $JS.API.CONSUMER.CREATE and $JS.API.CONSUMER.DURABLE.CREATE APIs +/// + public record ConsumerCreateRequest { - [JsonPropertyName("stream_name")] - public string StreamName { get; set; } + /// + /// The name of the stream to create the consumer in + /// + [System.Text.Json.Serialization.JsonPropertyName("stream_name")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string StreamName { get; set; } = default!; - [JsonPropertyName("config")] - public string Config { get; set; } + /// + /// The consumer configuration + /// + [System.Text.Json.Serialization.JsonPropertyName("config")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + public ConsumerConfiguration Config { get; set; } = default!; } diff --git a/src/NATS.Client.JetStream/Models/ConsumerCreateResponse.cs b/src/NATS.Client.JetStream/Models/ConsumerCreateResponse.cs new file mode 100644 index 000000000..e21579972 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/ConsumerCreateResponse.cs @@ -0,0 +1,9 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.CONSUMER.CREATE API +/// + +public record ConsumerCreateResponse : ConsumerInfo +{ +} diff --git a/src/NATS.Client.JetStream/Models/ConsumerDeleteResponse.cs b/src/NATS.Client.JetStream/Models/ConsumerDeleteResponse.cs new file mode 100644 index 000000000..067c0b0f0 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/ConsumerDeleteResponse.cs @@ -0,0 +1,12 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.CONSUMER.DELETE API +/// + +public record ConsumerDeleteResponse +{ + [System.Text.Json.Serialization.JsonPropertyName("success")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + public bool Success { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/ConsumerGetnextRequest.cs b/src/NATS.Client.JetStream/Models/ConsumerGetnextRequest.cs new file mode 100644 index 000000000..588259513 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/ConsumerGetnextRequest.cs @@ -0,0 +1,47 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A request to the JetStream $JS.API.CONSUMER.MSG.NEXT API +/// + +public record ConsumerGetnextRequest +{ + /// + /// A duration from now when the pull should expire, stated in nanoseconds, 0 for no expiry + /// + [System.Text.Json.Serialization.JsonPropertyName("expires")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long Expires { get; set; } = default!; + + /// + /// How many messages the server should deliver to the requestor + /// + [System.Text.Json.Serialization.JsonPropertyName("batch")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long Batch { get; set; } = default!; + + /// + /// Sends at most this many bytes to the requestor, limited by consumer configuration max_bytes + /// + [System.Text.Json.Serialization.JsonPropertyName("max_bytes")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long MaxBytes { get; set; } = default!; + + /// + /// When true a response with a 404 status header will be returned when no messages are available + /// + [System.Text.Json.Serialization.JsonPropertyName("no_wait")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool NoWait { get; set; } = default!; + + /// + /// When not 0 idle heartbeats will be sent on this interval + /// + [System.Text.Json.Serialization.JsonPropertyName("idle_heartbeat")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long IdleHeartbeat { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/ConsumerInfo.cs b/src/NATS.Client.JetStream/Models/ConsumerInfo.cs index 27b546d14..b6848f1b1 100644 --- a/src/NATS.Client.JetStream/Models/ConsumerInfo.cs +++ b/src/NATS.Client.JetStream/Models/ConsumerInfo.cs @@ -1,55 +1,98 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - namespace NATS.Client.JetStream.Models; public record ConsumerInfo { - [JsonPropertyName("stream_name")] - public string StreamName { get; set; } + /// + /// The Stream the consumer belongs to + /// + [System.Text.Json.Serialization.JsonPropertyName("stream_name")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string StreamName { get; set; } = default!; + + /// + /// A unique name for the consumer, either machine generated or the durable name + /// + [System.Text.Json.Serialization.JsonPropertyName("name")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Name { get; set; } = default!; - [JsonPropertyName("config")] - public string Config { get; set; } + /// + /// The server time the consumer info was created + /// + [System.Text.Json.Serialization.JsonPropertyName("ts")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.DateTimeOffset Ts { get; set; } = default!; - [JsonPropertyName("name")] - public string Name { get; set; } + [System.Text.Json.Serialization.JsonPropertyName("config")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + public ConsumerConfiguration Config { get; set; } = default!; - [JsonPropertyName("created")] - public DateTimeOffset Created { get; set; } + /// + /// The time the Consumer was created + /// + [System.Text.Json.Serialization.JsonPropertyName("created")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public System.DateTimeOffset Created { get; set; } = default!; - [JsonPropertyName("delivered")] - public string Delivered { get; set; } + /// + /// The last message delivered from this Consumer + /// + [System.Text.Json.Serialization.JsonPropertyName("delivered")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public SequenceInfo Delivered { get; set; } = new SequenceInfo(); - [JsonPropertyName("ack_floor")] - public string AckFloor { get; set; } + /// + /// The highest contiguous acknowledged message + /// + [System.Text.Json.Serialization.JsonPropertyName("ack_floor")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public SequenceInfo AckFloor { get; set; } = new SequenceInfo(); - [JsonPropertyName("num_pending")] - public ulong NumPending { get; set; } + /// + /// The number of messages pending acknowledgement + /// + [System.Text.Json.Serialization.JsonPropertyName("num_ack_pending")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long NumAckPending { get; set; } = default!; - [JsonPropertyName("num_waiting")] - public long NumWaiting { get; set; } + /// + /// The number of redeliveries that have been performed + /// + [System.Text.Json.Serialization.JsonPropertyName("num_redelivered")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long NumRedelivered { get; set; } = default!; - [JsonPropertyName("num_ack_pending")] - public long NumAckPending { get; set; } + /// + /// The number of pull consumers waiting for messages + /// + [System.Text.Json.Serialization.JsonPropertyName("num_waiting")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long NumWaiting { get; set; } = default!; - [JsonPropertyName("num_redelivered")] - public long NumRedelivered { get; set; } + /// + /// The number of messages left unconsumed in this Consumer + /// + [System.Text.Json.Serialization.JsonPropertyName("num_pending")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long NumPending { get; set; } = default!; - [JsonPropertyName("cluster")] - public string Cluster { get; set; } + [System.Text.Json.Serialization.JsonPropertyName("cluster")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public ClusterInfo Cluster { get; set; } = default!; - [JsonPropertyName("push_bound")] - public bool PushBound { get; set; } + /// + /// Indicates if any client is connected and receiving messages from a push consumer + /// + [System.Text.Json.Serialization.JsonPropertyName("push_bound")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool PushBound { get; set; } = default!; } diff --git a/src/NATS.Client.JetStream/Models/ConsumerInfoResponse.cs b/src/NATS.Client.JetStream/Models/ConsumerInfoResponse.cs new file mode 100644 index 000000000..32dcbb40a --- /dev/null +++ b/src/NATS.Client.JetStream/Models/ConsumerInfoResponse.cs @@ -0,0 +1,9 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.CONSUMER.INFO API +/// + +public record ConsumerInfoResponse : ConsumerInfo +{ +} diff --git a/src/NATS.Client.JetStream/Models/ConsumerLeaderStepdownResponse.cs b/src/NATS.Client.JetStream/Models/ConsumerLeaderStepdownResponse.cs new file mode 100644 index 000000000..dbd0aa4f5 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/ConsumerLeaderStepdownResponse.cs @@ -0,0 +1,15 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.CONSUMER.LEADER.STEPDOWN API +/// + +public record ConsumerLeaderStepdownResponse +{ + /// + /// If the leader successfully stood down + /// + [System.Text.Json.Serialization.JsonPropertyName("success")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + public bool Success { get; set; } = false; +} diff --git a/src/NATS.Client.JetStream/Models/ConsumerListRequest.cs b/src/NATS.Client.JetStream/Models/ConsumerListRequest.cs new file mode 100644 index 000000000..3b86627b3 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/ConsumerListRequest.cs @@ -0,0 +1,9 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A request to the JetStream $JS.API.CONSUMER.LIST API +/// + +public record ConsumerListRequest : IterableRequest +{ +} diff --git a/src/NATS.Client.JetStream/Models/ConsumerListResponse.cs b/src/NATS.Client.JetStream/Models/ConsumerListResponse.cs new file mode 100644 index 000000000..7261e3bd7 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/ConsumerListResponse.cs @@ -0,0 +1,16 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.CONSUMER.LIST API +/// + +public record ConsumerListResponse : IterableResponse +{ + /// + /// Full Consumer information for each known Consumer + /// + [System.Text.Json.Serialization.JsonPropertyName("consumers")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public System.Collections.Generic.ICollection Consumers { get; set; } = new System.Collections.ObjectModel.Collection(); +} diff --git a/src/NATS.Client.JetStream/Models/ConsumerNamesRequest.cs b/src/NATS.Client.JetStream/Models/ConsumerNamesRequest.cs new file mode 100644 index 000000000..07ca351dc --- /dev/null +++ b/src/NATS.Client.JetStream/Models/ConsumerNamesRequest.cs @@ -0,0 +1,15 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A request to the JetStream $JS.API.CONSUMER.NAMES API +/// + +public record ConsumerNamesRequest : IterableRequest +{ + /// + /// Filter the names to those consuming messages matching this subject or wildcard + /// + [System.Text.Json.Serialization.JsonPropertyName("subject")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string Subject { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/ConsumerNamesResponse.cs b/src/NATS.Client.JetStream/Models/ConsumerNamesResponse.cs new file mode 100644 index 000000000..70beb4ac2 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/ConsumerNamesResponse.cs @@ -0,0 +1,13 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.CONSUMER.NAMES API +/// + +public record ConsumerNamesResponse : IterableResponse +{ + [System.Text.Json.Serialization.JsonPropertyName("consumers")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public System.Collections.Generic.ICollection Consumers { get; set; } = new System.Collections.ObjectModel.Collection(); +} diff --git a/src/NATS.Client.JetStream/Models/Error.cs b/src/NATS.Client.JetStream/Models/Error.cs deleted file mode 100644 index a3e3e2bf7..000000000 --- a/src/NATS.Client.JetStream/Models/Error.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record Error -{ - [JsonPropertyName("code")] - public int Code { get; set; } - - [JsonPropertyName("err_code")] - public int ErrCode { get; set; } - - [JsonPropertyName("description")] - public string Description { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/ErrorResponse.cs b/src/NATS.Client.JetStream/Models/ErrorResponse.cs new file mode 100644 index 000000000..71b3b1e65 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/ErrorResponse.cs @@ -0,0 +1,9 @@ +namespace NATS.Client.JetStream.Models; + +public record ErrorResponse +{ + [System.Text.Json.Serialization.JsonPropertyName("error")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public ApiError Error { get; set; } = new ApiError(); +} diff --git a/src/NATS.Client.JetStream/Models/External.cs b/src/NATS.Client.JetStream/Models/External.cs deleted file mode 100644 index f2e2022cb..000000000 --- a/src/NATS.Client.JetStream/Models/External.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record External -{ - [JsonPropertyName("api")] - public string Api { get; set; } - - [JsonPropertyName("deliver")] - public string Deliver { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/ExternalStreamSource.cs b/src/NATS.Client.JetStream/Models/ExternalStreamSource.cs new file mode 100644 index 000000000..62b94ddf2 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/ExternalStreamSource.cs @@ -0,0 +1,23 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// Configuration referencing a stream source in another account or JetStream domain +/// + +public record ExternalStreamSource +{ + /// + /// The subject prefix that imports the other account/domain $JS.API.CONSUMER.> subjects + /// + [System.Text.Json.Serialization.JsonPropertyName("api")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Api { get; set; } = default!; + + /// + /// The delivery subject to use for the push consumer + /// + [System.Text.Json.Serialization.JsonPropertyName("deliver")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string Deliver { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/IterableRequest.cs b/src/NATS.Client.JetStream/Models/IterableRequest.cs new file mode 100644 index 000000000..3e8296388 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/IterableRequest.cs @@ -0,0 +1,9 @@ +namespace NATS.Client.JetStream.Models; + +public record IterableRequest +{ + [System.Text.Json.Serialization.JsonPropertyName("offset")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Offset { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/IterableResponse.cs b/src/NATS.Client.JetStream/Models/IterableResponse.cs new file mode 100644 index 000000000..ef2c3f660 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/IterableResponse.cs @@ -0,0 +1,19 @@ +namespace NATS.Client.JetStream.Models; + +public record IterableResponse +{ + [System.Text.Json.Serialization.JsonPropertyName("total")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Total { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("offset")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Offset { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("limit")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Limit { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/LostStreamData.cs b/src/NATS.Client.JetStream/Models/LostStreamData.cs index deefa7ca8..af4910452 100644 --- a/src/NATS.Client.JetStream/Models/LostStreamData.cs +++ b/src/NATS.Client.JetStream/Models/LostStreamData.cs @@ -1,25 +1,23 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - namespace NATS.Client.JetStream.Models; +/// +/// Records messages that were damaged and unrecoverable +/// + public record LostStreamData { - [JsonPropertyName("msgs")] - public string Msgs { get; set; } + /// + /// The messages that were lost + /// + [System.Text.Json.Serialization.JsonPropertyName("msgs")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.Collections.Generic.ICollection? Msgs { get; set; } = default!; - [JsonPropertyName("bytes")] - public ulong Bytes { get; set; } + /// + /// The number of bytes that were lost + /// + [System.Text.Json.Serialization.JsonPropertyName("bytes")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long Bytes { get; set; } = default!; } diff --git a/src/NATS.Client.JetStream/Models/MessageDeleteRequest.cs b/src/NATS.Client.JetStream/Models/MessageDeleteRequest.cs deleted file mode 100644 index f791e64ff..000000000 --- a/src/NATS.Client.JetStream/Models/MessageDeleteRequest.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record MessageDeleteRequest -{ - [JsonPropertyName("seq")] - public string Seq { get; set; } - - [JsonPropertyName("no_erase")] - public string NoErase { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/MessageGetRequest.cs b/src/NATS.Client.JetStream/Models/MessageGetRequest.cs deleted file mode 100644 index 2d6808e85..000000000 --- a/src/NATS.Client.JetStream/Models/MessageGetRequest.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record MessageGetRequest -{ - [JsonPropertyName("seq")] - public string Seq { get; set; } - - [JsonPropertyName("last_by_subj")] - public string LastBySubject { get; set; } - - [JsonPropertyName("next_by_subj")] - public string NextBySubject { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/MessageInfo.cs b/src/NATS.Client.JetStream/Models/MessageInfo.cs deleted file mode 100644 index df007341c..000000000 --- a/src/NATS.Client.JetStream/Models/MessageInfo.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record MessageInfo -{ - [JsonPropertyName("message")] - public string Message { get; set; } - - [JsonPropertyName("subject")] - public string Subject { get; set; } - - [JsonPropertyName("seq")] - public ulong Seq { get; set; } - - [JsonPropertyName("time")] - public DateTimeOffset Time { get; set; } - - [JsonPropertyName("data")] - public string Data { get; set; } - - [JsonPropertyName("hdrs")] - public string Hdrs { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/MetaLeaderStepdownRequest.cs b/src/NATS.Client.JetStream/Models/MetaLeaderStepdownRequest.cs new file mode 100644 index 000000000..6a0bbc7b5 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/MetaLeaderStepdownRequest.cs @@ -0,0 +1,12 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A request to the JetStream $JS.API.META.LEADER.STEPDOWN API +/// + +public record MetaLeaderStepdownRequest +{ + [System.Text.Json.Serialization.JsonPropertyName("placement")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public Placement Placement { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/MetaLeaderStepdownResponse.cs b/src/NATS.Client.JetStream/Models/MetaLeaderStepdownResponse.cs new file mode 100644 index 000000000..ca795219e --- /dev/null +++ b/src/NATS.Client.JetStream/Models/MetaLeaderStepdownResponse.cs @@ -0,0 +1,15 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.META.LEADER.STEPDOWN API +/// + +public record MetaLeaderStepdownResponse +{ + /// + /// If the leader successfully stood down + /// + [System.Text.Json.Serialization.JsonPropertyName("success")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + public bool Success { get; set; } = false; +} diff --git a/src/NATS.Client.JetStream/Models/MetaServerRemoveRequest.cs b/src/NATS.Client.JetStream/Models/MetaServerRemoveRequest.cs new file mode 100644 index 000000000..a61acd89c --- /dev/null +++ b/src/NATS.Client.JetStream/Models/MetaServerRemoveRequest.cs @@ -0,0 +1,22 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A request to the JetStream $JS.API.SERVER.REMOVE API +/// + +public record MetaServerRemoveRequest +{ + /// + /// The Name of the server to remove from the meta group + /// + [System.Text.Json.Serialization.JsonPropertyName("peer")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string Peer { get; set; } = default!; + + /// + /// Peer ID of the peer to be removed. If specified this is used instead of the server name + /// + [System.Text.Json.Serialization.JsonPropertyName("peer_id")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string PeerId { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/MetaServerRemoveResponse.cs b/src/NATS.Client.JetStream/Models/MetaServerRemoveResponse.cs new file mode 100644 index 000000000..ca176a4f4 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/MetaServerRemoveResponse.cs @@ -0,0 +1,15 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.SERVER.REMOVE API +/// + +public record MetaServerRemoveResponse +{ + /// + /// If the peer was successfully removed + /// + [System.Text.Json.Serialization.JsonPropertyName("success")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + public bool Success { get; set; } = false; +} diff --git a/src/NATS.Client.JetStream/Models/Mirror.cs b/src/NATS.Client.JetStream/Models/Mirror.cs deleted file mode 100644 index ed27dac90..000000000 --- a/src/NATS.Client.JetStream/Models/Mirror.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record Mirror -{ - [JsonPropertyName("name")] - public string Name { get; set; } - - [JsonPropertyName("opt_start_seq")] - public ulong OptStartSeq { get; set; } - - [JsonPropertyName("opt_start_time")] - public DateTimeOffset OptStartTime { get; set; } - - [JsonPropertyName("filter_subject")] - public string FilterSubject { get; set; } - - [JsonPropertyName("external")] - public string External { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/MirrorInfo.cs b/src/NATS.Client.JetStream/Models/MirrorInfo.cs deleted file mode 100644 index 7f9ec3b2f..000000000 --- a/src/NATS.Client.JetStream/Models/MirrorInfo.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record MirrorInfo -{ - [JsonPropertyName("name")] - public string Name { get; set; } - - [JsonPropertyName("lag")] - public string Lag { get; set; } - - [JsonPropertyName("active")] - public TimeSpan Active { get; set; } - - [JsonPropertyName("error")] - public string Error { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/PeerInfo.cs b/src/NATS.Client.JetStream/Models/PeerInfo.cs index bc512ad1f..896832f82 100644 --- a/src/NATS.Client.JetStream/Models/PeerInfo.cs +++ b/src/NATS.Client.JetStream/Models/PeerInfo.cs @@ -1,34 +1,41 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - namespace NATS.Client.JetStream.Models; public record PeerInfo { - [JsonPropertyName("name")] - public string Name { get; set; } + /// + /// The server name of the peer + /// + [System.Text.Json.Serialization.JsonPropertyName("name")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Name { get; set; } = default!; - [JsonPropertyName("current")] - public bool Current { get; set; } + /// + /// Indicates if the server is up to date and synchronised + /// + [System.Text.Json.Serialization.JsonPropertyName("current")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + public bool Current { get; set; } = false; - [JsonPropertyName("offline")] - public bool Offline { get; set; } + /// + /// Nanoseconds since this peer was last seen + /// + [System.Text.Json.Serialization.JsonPropertyName("active")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + public double Active { get; set; } = default!; - [JsonPropertyName("active")] - public TimeSpan Active { get; set; } + /// + /// Indicates the node is considered offline by the group + /// + [System.Text.Json.Serialization.JsonPropertyName("offline")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool Offline { get; set; } = false; - [JsonPropertyName("lag")] - public long Lag { get; set; } + /// + /// How many uncommitted operations this peer is behind the leader + /// + [System.Text.Json.Serialization.JsonPropertyName("lag")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Lag { get; set; } = default!; } diff --git a/src/NATS.Client.JetStream/Models/Placement.cs b/src/NATS.Client.JetStream/Models/Placement.cs index b42b80110..6ce0f3d9e 100644 --- a/src/NATS.Client.JetStream/Models/Placement.cs +++ b/src/NATS.Client.JetStream/Models/Placement.cs @@ -1,25 +1,23 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - namespace NATS.Client.JetStream.Models; +/// +/// Placement requirements for a stream +/// + public record Placement { - [JsonPropertyName("cluster")] - public string Cluster { get; set; } + /// + /// The desired cluster name to place the stream + /// + [System.Text.Json.Serialization.JsonPropertyName("cluster")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Cluster { get; set; } = default!; - [JsonPropertyName("tags")] - public string Tags { get; set; } + /// + /// Tags required on servers hosting this stream + /// + [System.Text.Json.Serialization.JsonPropertyName("tags")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.Collections.Generic.ICollection Tags { get; set; } = default!; } diff --git a/src/NATS.Client.JetStream/Models/PubAckResponse.cs b/src/NATS.Client.JetStream/Models/PubAckResponse.cs new file mode 100644 index 000000000..17fc37019 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/PubAckResponse.cs @@ -0,0 +1,42 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response received when publishing a message +/// + +public record PubAckResponse +{ + [System.Text.Json.Serialization.JsonPropertyName("error")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public ApiError Error { get; set; } = default!; + + /// + /// The name of the stream that received the message + /// + [System.Text.Json.Serialization.JsonPropertyName("stream")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public string Stream { get; set; } = default!; + + /// + /// If successful this will be the sequence the message is stored at + /// + [System.Text.Json.Serialization.JsonPropertyName("seq")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long Seq { get; set; } = default!; + + /// + /// Indicates that the message was not stored due to the Nats-Msg-Id header and duplicate tracking + /// + [System.Text.Json.Serialization.JsonPropertyName("duplicate")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool Duplicate { get; set; } = false; + + /// + /// If the Stream accepting the message is in a JetStream server configured for a domain this would be that domain + /// + [System.Text.Json.Serialization.JsonPropertyName("domain")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string Domain { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/PublishAck.cs b/src/NATS.Client.JetStream/Models/PublishAck.cs deleted file mode 100644 index 10011bb75..000000000 --- a/src/NATS.Client.JetStream/Models/PublishAck.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record PublishAck -{ - [JsonPropertyName("stream")] - public string Stream { get; set; } - - [JsonPropertyName("domain")] - public string Domain { get; set; } - - [JsonPropertyName("seq")] - public ulong Seq { get; set; } - - [JsonPropertyName("duplicate")] - public bool Duplicate { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/PublishOptions.cs b/src/NATS.Client.JetStream/Models/PublishOptions.cs deleted file mode 100644 index b2633be01..000000000 --- a/src/NATS.Client.JetStream/Models/PublishOptions.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record PublishOptions -{} diff --git a/src/NATS.Client.JetStream/Models/PurgeOptions.cs b/src/NATS.Client.JetStream/Models/PurgeOptions.cs deleted file mode 100644 index 1ca33cdaf..000000000 --- a/src/NATS.Client.JetStream/Models/PurgeOptions.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record PurgeOptions -{ - [JsonPropertyName("filter")] - public string Filter { get; set; } - - [JsonPropertyName("seq")] - public string Seq { get; set; } - - [JsonPropertyName("keep")] - public string Keep { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/PurgeResponse.cs b/src/NATS.Client.JetStream/Models/PurgeResponse.cs deleted file mode 100644 index 6f144fb6e..000000000 --- a/src/NATS.Client.JetStream/Models/PurgeResponse.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record PurgeResponse -{ - [JsonPropertyName("success")] - public bool Success { get; set; } - - [JsonPropertyName("purged")] - public ulong Purged { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/Replica.cs b/src/NATS.Client.JetStream/Models/Replica.cs deleted file mode 100644 index 74263327a..000000000 --- a/src/NATS.Client.JetStream/Models/Replica.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record Replica -{ - [JsonPropertyName("name")] - public string Name { get; set; } - - [JsonPropertyName("current")] - public bool Current { get; set; } - - [JsonPropertyName("offline")] - public bool Offline { get; set; } - - [JsonPropertyName("active")] - public TimeSpan Active { get; set; } - - [JsonPropertyName("lag")] - public string Lag { get; set; } -} - diff --git a/src/NATS.Client.JetStream/Models/Republish.cs b/src/NATS.Client.JetStream/Models/Republish.cs index d669b9dfc..53276e08e 100644 --- a/src/NATS.Client.JetStream/Models/Republish.cs +++ b/src/NATS.Client.JetStream/Models/Republish.cs @@ -1,28 +1,31 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - namespace NATS.Client.JetStream.Models; +/// +/// Rules for republishing messages from a stream with subject mapping onto new subjects for partitioning and more +/// + public record Republish { - [JsonPropertyName("src")] - public string Src { get; set; } + /// + /// The source subject to republish + /// + [System.Text.Json.Serialization.JsonPropertyName("src")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Src { get; set; } = default!; - [JsonPropertyName("dest")] - public string Dest { get; set; } + /// + /// The destination to publish to + /// + [System.Text.Json.Serialization.JsonPropertyName("dest")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Dest { get; set; } = default!; - [JsonPropertyName("headers_only")] - public bool HeadersOnly { get; set; } + /// + /// Only send message headers, no bodies + /// + [System.Text.Json.Serialization.JsonPropertyName("headers_only")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool HeadersOnly { get; set; } = false; } diff --git a/src/NATS.Client.JetStream/Models/SequenceInfo.cs b/src/NATS.Client.JetStream/Models/SequenceInfo.cs index 31cd8be78..08f0e01f8 100644 --- a/src/NATS.Client.JetStream/Models/SequenceInfo.cs +++ b/src/NATS.Client.JetStream/Models/SequenceInfo.cs @@ -1,22 +1,27 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - namespace NATS.Client.JetStream.Models; public record SequenceInfo { - [JsonPropertyName("last_active")] - public DateTimeOffset LastActive { get; set; } + /// + /// The sequence number of the Consumer + /// + [System.Text.Json.Serialization.JsonPropertyName("consumer_seq")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long ConsumerSeq { get; set; } = default!; + + /// + /// The sequence number of the Stream + /// + [System.Text.Json.Serialization.JsonPropertyName("stream_seq")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long StreamSeq { get; set; } = default!; + + /// + /// The last time a message was delivered or acknowledged (for ack_floor) + /// + [System.Text.Json.Serialization.JsonPropertyName("last_active")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.DateTimeOffset LastActive { get; set; } = default!; } diff --git a/src/NATS.Client.JetStream/Models/SequencePair.cs b/src/NATS.Client.JetStream/Models/SequencePair.cs index dfa9a6f18..8e25ad615 100644 --- a/src/NATS.Client.JetStream/Models/SequencePair.cs +++ b/src/NATS.Client.JetStream/Models/SequencePair.cs @@ -1,25 +1,20 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - namespace NATS.Client.JetStream.Models; public record SequencePair { - [JsonPropertyName("consumer_seq")] - public ulong ConsumerSeq { get; set; } + /// + /// The sequence number of the Consumer + /// + [System.Text.Json.Serialization.JsonPropertyName("consumer_seq")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long ConsumerSeq { get; set; } = default!; - [JsonPropertyName("stream_seq")] - public ulong StreamSeq { get; set; } + /// + /// The sequence number of the Stream + /// + [System.Text.Json.Serialization.JsonPropertyName("stream_seq")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long StreamSeq { get; set; } = default!; } diff --git a/src/NATS.Client.JetStream/Models/ServerInfo.cs b/src/NATS.Client.JetStream/Models/ServerInfo.cs deleted file mode 100644 index 3bc534f4f..000000000 --- a/src/NATS.Client.JetStream/Models/ServerInfo.cs +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record ServerInfo -{ - [JsonPropertyName("server_id")] - public string ServerId { get; set; } - - [JsonPropertyName("server_name")] - public string ServerName { get; set; } - - [JsonPropertyName("version")] - public string Version { get; set; } - - [JsonPropertyName("go")] - public string Go { get; set; } - - [JsonPropertyName("host")] - public string Host { get; set; } - - [JsonPropertyName("headers")] - public bool Headers { get; set; } - - [JsonPropertyName("auth_required")] - public bool AuthRequired { get; set; } - - [JsonPropertyName("nonce")] - public string Nonce { get; set; } - - [JsonPropertyName("tls_required")] - public bool Tls { get; set; } - - [JsonPropertyName("ldm")] - public bool LameDuckMode { get; set; } - - [JsonPropertyName("jetstream")] - public bool Jetstream { get; set; } - - [JsonPropertyName("port")] - public int Port { get; set; } - - [JsonPropertyName("proto")] - public int Proto { get; set; } - - [JsonPropertyName("max_payload")] - public long MaxPayload { get; set; } - - [JsonPropertyName("client_id")] - public int ClientId { get; set; } - - [JsonPropertyName("client_ip")] - public string ClientIp { get; set; } - - [JsonPropertyName("cluster")] - public string Cluster { get; set; } - - [JsonPropertyName("connect_urls")] - public string ConnectUrls { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/Source.cs b/src/NATS.Client.JetStream/Models/Source.cs deleted file mode 100644 index cdb052775..000000000 --- a/src/NATS.Client.JetStream/Models/Source.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record Source -{ - [JsonPropertyName("name")] - public string Name { get; set; } - - [JsonPropertyName("opt_start_seq")] - public ulong OptStartSeq { get; set; } - - [JsonPropertyName("opt_start_time")] - public DateTimeOffset OptStartTime { get; set; } - - [JsonPropertyName("filter_subject")] - public string FilterSubject { get; set; } - - [JsonPropertyName("external")] - public string External { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/SourceInfo.cs b/src/NATS.Client.JetStream/Models/SourceInfo.cs deleted file mode 100644 index 647e387c2..000000000 --- a/src/NATS.Client.JetStream/Models/SourceInfo.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record SourceInfo -{ - [JsonPropertyName("name")] - public string Name { get; set; } - - [JsonPropertyName("lag")] - public string Lag { get; set; } - - [JsonPropertyName("active")] - public TimeSpan Active { get; set; } - - [JsonPropertyName("error")] - public string Error { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/StoredMessage.cs b/src/NATS.Client.JetStream/Models/StoredMessage.cs new file mode 100644 index 000000000..296a14e90 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StoredMessage.cs @@ -0,0 +1,43 @@ +namespace NATS.Client.JetStream.Models; + +public record StoredMessage +{ + /// + /// The subject the message was originally received on + /// + [System.Text.Json.Serialization.JsonPropertyName("subject")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public string Subject { get; set; } = default!; + + /// + /// The sequence number of the message in the Stream + /// + [System.Text.Json.Serialization.JsonPropertyName("seq")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long Seq { get; set; } = default!; + + /// + /// The base64 encoded payload of the message body + /// + [System.Text.Json.Serialization.JsonPropertyName("data")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.StringLength(int.MaxValue)] + public string Data { get; set; } = default!; + + /// + /// The time the message was received + /// + [System.Text.Json.Serialization.JsonPropertyName("time")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Time { get; set; } = default!; + + /// + /// Base64 encoded headers for the message + /// + [System.Text.Json.Serialization.JsonPropertyName("hdrs")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string Hdrs { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/StreamAlternate.cs b/src/NATS.Client.JetStream/Models/StreamAlternate.cs new file mode 100644 index 000000000..5e9698e1b --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamAlternate.cs @@ -0,0 +1,31 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// An alternate location to read mirrored data +/// + +public record StreamAlternate +{ + /// + /// The mirror stream name + /// + [System.Text.Json.Serialization.JsonPropertyName("name")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Name { get; set; } = default!; + + /// + /// The name of the cluster holding the stream + /// + [System.Text.Json.Serialization.JsonPropertyName("cluster")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Cluster { get; set; } = default!; + + /// + /// The domain holding the string + /// + [System.Text.Json.Serialization.JsonPropertyName("domain")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string Domain { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/StreamConfig.cs b/src/NATS.Client.JetStream/Models/StreamConfig.cs deleted file mode 100644 index b6eb132f4..000000000 --- a/src/NATS.Client.JetStream/Models/StreamConfig.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record StreamConfig -{ - [JsonPropertyName("name")] - public string Name { get; set; } - - [JsonPropertyName("subjects")] - public string[] Subjects { get; set; } - - [JsonPropertyName("retention")] - public string Retention { get; set; } - - [JsonPropertyName("max_consumers")] - public long MaxConsumers { get; set; } - - [JsonPropertyName("max_msgs")] - public long MaxMsgs { get; set; } - - [JsonPropertyName("max_bytes")] - public long MaxBytes { get; set; } - - [JsonPropertyName("max_age")] - public long MaxAge { get; set; } - - [JsonPropertyName("max_msgs_per_subject")] - public long MaxMsgsPerSubject { get; set; } - - [JsonPropertyName("max_msg_size")] - public long MaxMsgSize { get; set; } - - [JsonPropertyName("discard")] - public string Discard { get; set; } - - [JsonPropertyName("storage")] - public string Storage { get; set; } - - [JsonPropertyName("num_replicas")] - public long NumReplicas { get; set; } - - [JsonPropertyName("duplicate_window")] - public long DuplicateWindow { get; set; } - - [JsonPropertyName("allow_direct")] - public bool AllowDirect { get; set; } - - [JsonPropertyName("mirror_direct")] - public bool MirrorDirect { get; set; } - - [JsonPropertyName("sealed")] - public bool Sealed { get; set; } - - [JsonPropertyName("deny_delete")] - public bool DenyDelete { get; set; } - - [JsonPropertyName("deny_purge")] - public bool DenyPurge { get; set; } - - [JsonPropertyName("allow_rollup_hdrs")] - public bool AllowRollupHdrs { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/StreamConfiguration.cs b/src/NATS.Client.JetStream/Models/StreamConfiguration.cs index 9d68654ee..ea4b50640 100644 --- a/src/NATS.Client.JetStream/Models/StreamConfiguration.cs +++ b/src/NATS.Client.JetStream/Models/StreamConfiguration.cs @@ -1,103 +1,228 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - namespace NATS.Client.JetStream.Models; public record StreamConfiguration { - [JsonPropertyName("retention")] - public string Retention { get; set; } - - [JsonPropertyName("storage")] - public string Storage { get; set; } - - [JsonPropertyName("discard")] - public string Discard { get; set; } - - [JsonPropertyName("name")] - public string Name { get; set; } - - [JsonPropertyName("description")] - public string Description { get; set; } - - [JsonPropertyName("subjects")] - public string Subjects { get; set; } - - [JsonPropertyName("max_consumers")] - public long MaxConsumers { get; set; } - - [JsonPropertyName("max_msgs")] - public long MaxMsgs { get; set; } - - [JsonPropertyName("max_msgs_per_subject")] - public long MaxMsgsPerSubject { get; set; } - - [JsonPropertyName("max_bytes")] - public long MaxBytes { get; set; } - - [JsonPropertyName("max_age")] - public TimeSpan MaxAge { get; set; } - - [JsonPropertyName("max_msg_size")] - public long MaxMsgSize { get; set; } - - [JsonPropertyName("num_replicas")] - public int NumReplicas { get; set; } - - [JsonPropertyName("no_ack")] - public bool NoAck { get; set; } - - [JsonPropertyName("template_owner")] - public string TemplateOwner { get; set; } - - [JsonPropertyName("duplicate_window")] - public TimeSpan DuplicateWindow { get; set; } - - [JsonPropertyName("placement")] - public string Placement { get; set; } - - [JsonPropertyName("republish")] - public string Republish { get; set; } - - [JsonPropertyName("mirror")] - public string Mirror { get; set; } - - [JsonPropertyName("sources")] - public string Sources { get; set; } - - [JsonPropertyName("sealed")] - public bool Sealed { get; set; } - - [JsonPropertyName("allow_rollup_hdrs")] - public bool AllowRollupHdrs { get; set; } - - [JsonPropertyName("allow_direct")] - public bool AllowDirect { get; set; } - - [JsonPropertyName("mirror_direct")] - public bool MirrorDirect { get; set; } - - [JsonPropertyName("deny_delete")] - public bool DenyDelete { get; set; } - - [JsonPropertyName("deny_purge")] - public bool DenyPurge { get; set; } - - [JsonPropertyName("discard_new_per_subject")] - public bool DiscardNewPerSubject { get; set; } - - [JsonPropertyName("metadata")] - public string Metadata { get; set; } + /// + /// A unique name for the Stream, empty for Stream Templates. + /// + [System.Text.Json.Serialization.JsonPropertyName("name")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.StringLength(int.MaxValue)] + [System.ComponentModel.DataAnnotations.RegularExpression(@"^[^.*>]*$")] + public string Name { get; set; } = default!; + + /// + /// A short description of the purpose of this stream + /// + [System.Text.Json.Serialization.JsonPropertyName("description")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.StringLength(4096)] + public string Description { get; set; } = default!; + + /// + /// A list of subjects to consume, supports wildcards. Must be empty when a mirror is configured. May be empty when sources are configured. + /// + [System.Text.Json.Serialization.JsonPropertyName("subjects")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.Collections.Generic.ICollection Subjects { get; set; } = default!; + + /// + /// Subject transform to apply to matching messages + /// + [System.Text.Json.Serialization.JsonPropertyName("subject_transform")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public SubjectTransform SubjectTransform { get; set; } = default!; + + /// + /// How messages are retained in the Stream, once this is exceeded old messages are removed. + /// + [System.Text.Json.Serialization.JsonPropertyName("retention")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] + public StreamConfigurationRetention Retention { get; set; } = NATS.Client.JetStream.Models.StreamConfigurationRetention.Limits; + + /// + /// How many Consumers can be defined for a given Stream. -1 for unlimited. + /// + [System.Text.Json.Serialization.JsonPropertyName("max_consumers")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long MaxConsumers { get; set; } = default!; + + /// + /// How many messages may be in a Stream, oldest messages will be removed if the Stream exceeds this size. -1 for unlimited. + /// + [System.Text.Json.Serialization.JsonPropertyName("max_msgs")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long MaxMsgs { get; set; } = default!; + + /// + /// For wildcard streams ensure that for every unique subject this many messages are kept - a per subject retention limit + /// + [System.Text.Json.Serialization.JsonPropertyName("max_msgs_per_subject")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long MaxMsgsPerSubject { get; set; } = default!; + + /// + /// How big the Stream may be, when the combined stream size exceeds this old messages are removed. -1 for unlimited. + /// + [System.Text.Json.Serialization.JsonPropertyName("max_bytes")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long MaxBytes { get; set; } = default!; + + /// + /// Maximum age of any message in the stream, expressed in nanoseconds. 0 for unlimited. + /// + [System.Text.Json.Serialization.JsonPropertyName("max_age")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long MaxAge { get; set; } = default!; + + /// + /// The largest message that will be accepted by the Stream. -1 for unlimited. + /// + [System.Text.Json.Serialization.JsonPropertyName("max_msg_size")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-2147483648, 2147483647)] + public int MaxMsgSize { get; set; } = default!; + + /// + /// The storage backend to use for the Stream. + /// + [System.Text.Json.Serialization.JsonPropertyName("storage")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] + public StreamConfigurationStorage Storage { get; set; } = NATS.Client.JetStream.Models.StreamConfigurationStorage.File; + + /// + /// Optional compression algorithm used for the Stream. + /// + [System.Text.Json.Serialization.JsonPropertyName("compression")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] + public StreamConfigurationCompression Compression { get; set; } = NATS.Client.JetStream.Models.StreamConfigurationCompression.None; + + /// + /// How many replicas to keep for each message. + /// + [System.Text.Json.Serialization.JsonPropertyName("num_replicas")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long NumReplicas { get; set; } = default!; + + /// + /// Disables acknowledging messages that are received by the Stream. + /// + [System.Text.Json.Serialization.JsonPropertyName("no_ack")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool NoAck { get; set; } = false; + + /// + /// When the Stream is managed by a Stream Template this identifies the template that manages the Stream. + /// + [System.Text.Json.Serialization.JsonPropertyName("template_owner")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string TemplateOwner { get; set; } = default!; + + /// + /// When a Stream reach it's limits either old messages are deleted or new ones are denied + /// + [System.Text.Json.Serialization.JsonPropertyName("discard")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))] + public StreamConfigurationDiscard Discard { get; set; } = NATS.Client.JetStream.Models.StreamConfigurationDiscard.Old; + + /// + /// The time window to track duplicate messages for, expressed in nanoseconds. 0 for default + /// + [System.Text.Json.Serialization.JsonPropertyName("duplicate_window")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long DuplicateWindow { get; set; } = default!; + + /// + /// Placement directives to consider when placing replicas of this stream, random placement when unset + /// + [System.Text.Json.Serialization.JsonPropertyName("placement")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public Placement Placement { get; set; } = default!; + + /// + /// Maintains a 1:1 mirror of another stream with name matching this property. When a mirror is configured subjects and sources must be empty. + /// + [System.Text.Json.Serialization.JsonPropertyName("mirror")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public StreamSource Mirror { get; set; } = default!; + + /// + /// List of Stream names to replicate into this Stream + /// + [System.Text.Json.Serialization.JsonPropertyName("sources")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.Collections.Generic.ICollection Sources { get; set; } = default!; + + /// + /// Sealed streams do not allow messages to be deleted via limits or API, sealed streams can not be unsealed via configuration update. Can only be set on already created streams via the Update API + /// + [System.Text.Json.Serialization.JsonPropertyName("sealed")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool Sealed { get; set; } = false; + + /// + /// Restricts the ability to delete messages from a stream via the API. Cannot be changed once set to true + /// + [System.Text.Json.Serialization.JsonPropertyName("deny_delete")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool DenyDelete { get; set; } = false; + + /// + /// Restricts the ability to purge messages from a stream via the API. Cannot be change once set to true + /// + [System.Text.Json.Serialization.JsonPropertyName("deny_purge")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool DenyPurge { get; set; } = false; + + /// + /// Allows the use of the Nats-Rollup header to replace all contents of a stream, or subject in a stream, with a single new message + /// + [System.Text.Json.Serialization.JsonPropertyName("allow_rollup_hdrs")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool AllowRollupHdrs { get; set; } = false; + + /// + /// Allow higher performance, direct access to get individual messages + /// + [System.Text.Json.Serialization.JsonPropertyName("allow_direct")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool AllowDirect { get; set; } = false; + + /// + /// Allow higher performance, direct access for mirrors as well + /// + [System.Text.Json.Serialization.JsonPropertyName("mirror_direct")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool MirrorDirect { get; set; } = false; + + [System.Text.Json.Serialization.JsonPropertyName("republish")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public Republish Republish { get; set; } = default!; + + /// + /// When discard policy is new and the stream is one with max messages per subject set, this will apply the new behavior to every subject. Essentially turning discard new from maximum number of subjects into maximum number of messages in a subject. + /// + [System.Text.Json.Serialization.JsonPropertyName("discard_new_per_subject")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool DiscardNewPerSubject { get; set; } = false; + + /// + /// Additional metadata for the Stream + /// + [System.Text.Json.Serialization.JsonPropertyName("metadata")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.Collections.Generic.IDictionary Metadata { get; set; } = default!; } diff --git a/src/NATS.Client.JetStream/Models/StreamConfigurationCompression.cs b/src/NATS.Client.JetStream/Models/StreamConfigurationCompression.cs new file mode 100644 index 000000000..3abbbbc7c --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamConfigurationCompression.cs @@ -0,0 +1,10 @@ +namespace NATS.Client.JetStream.Models; + +public enum StreamConfigurationCompression +{ + [System.Runtime.Serialization.EnumMember(Value = @"none")] + None = 0, + + [System.Runtime.Serialization.EnumMember(Value = @"s2")] + S2 = 1, +} diff --git a/src/NATS.Client.JetStream/Models/StreamConfigurationDiscard.cs b/src/NATS.Client.JetStream/Models/StreamConfigurationDiscard.cs new file mode 100644 index 000000000..a9f7159cb --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamConfigurationDiscard.cs @@ -0,0 +1,10 @@ +namespace NATS.Client.JetStream.Models; + +public enum StreamConfigurationDiscard +{ + [System.Runtime.Serialization.EnumMember(Value = @"old")] + Old = 0, + + [System.Runtime.Serialization.EnumMember(Value = @"new")] + New = 1, +} diff --git a/src/NATS.Client.JetStream/Models/StreamConfigurationRetention.cs b/src/NATS.Client.JetStream/Models/StreamConfigurationRetention.cs new file mode 100644 index 000000000..141992c40 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamConfigurationRetention.cs @@ -0,0 +1,13 @@ +namespace NATS.Client.JetStream.Models; + +public enum StreamConfigurationRetention +{ + [System.Runtime.Serialization.EnumMember(Value = @"limits")] + Limits = 0, + + [System.Runtime.Serialization.EnumMember(Value = @"interest")] + Interest = 1, + + [System.Runtime.Serialization.EnumMember(Value = @"workqueue")] + Workqueue = 2, +} diff --git a/src/NATS.Client.JetStream/Models/StreamConfigurationStorage.cs b/src/NATS.Client.JetStream/Models/StreamConfigurationStorage.cs new file mode 100644 index 000000000..b326b5bec --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamConfigurationStorage.cs @@ -0,0 +1,10 @@ +namespace NATS.Client.JetStream.Models; + +public enum StreamConfigurationStorage +{ + [System.Runtime.Serialization.EnumMember(Value = @"file")] + File = 0, + + [System.Runtime.Serialization.EnumMember(Value = @"memory")] + Memory = 1, +} diff --git a/src/NATS.Client.JetStream/Models/StreamCreateRequest.cs b/src/NATS.Client.JetStream/Models/StreamCreateRequest.cs index f9ba2331a..40d3c53b1 100644 --- a/src/NATS.Client.JetStream/Models/StreamCreateRequest.cs +++ b/src/NATS.Client.JetStream/Models/StreamCreateRequest.cs @@ -1,66 +1,9 @@ -using System.ComponentModel.DataAnnotations; -using System.Text.Json.Serialization; - namespace NATS.Client.JetStream.Models; -public record StreamCreateRequest -{ - [Required] - [JsonPropertyName("name")] - public string Name { get; set; } - - [Required] - [JsonPropertyName("subjects")] - public string[] Subjects { get; set; } - - [JsonPropertyName("retention")] - public string Retention { get; set; } = "limits"; - - [JsonPropertyName("max_consumers")] - public long MaxConsumers { get; set; } - - [JsonPropertyName("max_msgs_per_subject")] - public long MaxMsgsPerSubject { get; set; } - - [JsonPropertyName("max_msgs")] - public long MaxMsgs { get; set; } - - [JsonPropertyName("max_bytes")] - public long MaxBytes { get; set; } - - [JsonPropertyName("max_age")] - public long MaxAge { get; set; } - - [JsonPropertyName("max_msg_size")] - public long MaxMsgSize { get; set; } +/// +/// A request to the JetStream $JS.API.STREAM.CREATE API +/// - [JsonPropertyName("storage")] - public string Storage { get; set; } = "file"; - - [JsonPropertyName("discard")] - public string Discard { get; set; } = "old"; - - [JsonPropertyName("num_replicas")] - public long NumReplicas { get; set; } - - [JsonPropertyName("duplicate_window")] - public long DuplicateWindow { get; set; } - - [JsonPropertyName("sealed")] - public bool Sealed { get; set; } - - [JsonPropertyName("deny_delete")] - public bool DenyDelete { get; set; } - - [JsonPropertyName("deny_purge")] - public bool DenyPurge { get; set; } - - [JsonPropertyName("allow_rollup_hdrs")] - public bool AllowRollupHdrs { get; set; } - - [JsonPropertyName("allow_direct")] - public bool AllowDirect { get; set; } - - [JsonPropertyName("mirror_direct")] - public bool MirrorDirect { get; set; } +public record StreamCreateRequest : StreamConfiguration +{ } diff --git a/src/NATS.Client.JetStream/Models/StreamCreateResponse.cs b/src/NATS.Client.JetStream/Models/StreamCreateResponse.cs index 76b8d1183..9ab475b19 100644 --- a/src/NATS.Client.JetStream/Models/StreamCreateResponse.cs +++ b/src/NATS.Client.JetStream/Models/StreamCreateResponse.cs @@ -1,21 +1,9 @@ -using System.Text.Json.Serialization; - namespace NATS.Client.JetStream.Models; -public record StreamCreateResponse -{ - [JsonPropertyName("type")] - public string Type { get; set; } - - [JsonPropertyName("config")] - public StreamConfig Config { get; set; } +/// +/// A response from the JetStream $JS.API.STREAM.CREATE API +/// - [JsonPropertyName("created")] - public DateTimeOffset Created { get; set; } - - [JsonPropertyName("state")] - public StreamState State { get; set; } - - [JsonPropertyName("did_create")] - public bool DidCreate { get; set; } +public record StreamCreateResponse : StreamInfo +{ } diff --git a/src/NATS.Client.JetStream/Models/StreamDeleteResponse.cs b/src/NATS.Client.JetStream/Models/StreamDeleteResponse.cs new file mode 100644 index 000000000..c7687a56b --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamDeleteResponse.cs @@ -0,0 +1,12 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.STREAM.DELETE API +/// + +public record StreamDeleteResponse +{ + [System.Text.Json.Serialization.JsonPropertyName("success")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + public bool Success { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/StreamInfo.cs b/src/NATS.Client.JetStream/Models/StreamInfo.cs index cb05cd649..885b29be4 100644 --- a/src/NATS.Client.JetStream/Models/StreamInfo.cs +++ b/src/NATS.Client.JetStream/Models/StreamInfo.cs @@ -1,37 +1,57 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - namespace NATS.Client.JetStream.Models; public record StreamInfo { - [JsonPropertyName("created")] - public DateTimeOffset Created { get; set; } - - [JsonPropertyName("config")] - public string Config { get; set; } - - [JsonPropertyName("state")] - public string State { get; set; } - - [JsonPropertyName("cluster")] - public string Cluster { get; set; } - - [JsonPropertyName("mirror")] - public string Mirror { get; set; } - - [JsonPropertyName("sources")] - public string Sources { get; set; } + /// + /// The active configuration for the Stream + /// + [System.Text.Json.Serialization.JsonPropertyName("config")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public StreamConfiguration Config { get; set; } = new StreamConfiguration(); + + /// + /// Detail about the current State of the Stream + /// + [System.Text.Json.Serialization.JsonPropertyName("state")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public StreamState State { get; set; } = new StreamState(); + + /// + /// Timestamp when the stream was created + /// + [System.Text.Json.Serialization.JsonPropertyName("created")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public System.DateTimeOffset Created { get; set; } = default!; + + /// + /// The server time the stream info was created + /// + [System.Text.Json.Serialization.JsonPropertyName("ts")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.DateTimeOffset Ts { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("cluster")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public ClusterInfo Cluster { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("mirror")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public StreamSourceInfo Mirror { get; set; } = default!; + + /// + /// Streams being sourced into this Stream + /// + [System.Text.Json.Serialization.JsonPropertyName("sources")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.Collections.Generic.ICollection Sources { get; set; } = default!; + + /// + /// List of mirrors sorted by priority + /// + [System.Text.Json.Serialization.JsonPropertyName("alternates")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.Collections.Generic.ICollection Alternates { get; set; } = default!; } diff --git a/src/NATS.Client.JetStream/Models/StreamInfoOptions.cs b/src/NATS.Client.JetStream/Models/StreamInfoOptions.cs deleted file mode 100644 index e5cc9f3ce..000000000 --- a/src/NATS.Client.JetStream/Models/StreamInfoOptions.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record StreamInfoOptions -{ - [JsonPropertyName("subjects_filter")] - public string SubjectsFilter { get; set; } - - [JsonPropertyName("deleted_details")] - public string DeletedDetails { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/StreamInfoRequest.cs b/src/NATS.Client.JetStream/Models/StreamInfoRequest.cs new file mode 100644 index 000000000..35958c167 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamInfoRequest.cs @@ -0,0 +1,30 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A request to the JetStream $JS.API.STREAM.INFO API +/// + +public record StreamInfoRequest +{ + /// + /// When true will result in a full list of deleted message IDs being returned in the info response + /// + [System.Text.Json.Serialization.JsonPropertyName("deleted_details")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool DeletedDetails { get; set; } = default!; + + /// + /// When set will return a list of subjects and how many messages they hold for all matching subjects. Filter is a standard NATS subject wildcard pattern. + /// + [System.Text.Json.Serialization.JsonPropertyName("subjects_filter")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string SubjectsFilter { get; set; } = default!; + + /// + /// Paging offset when retrieving pages of subjet details + /// + [System.Text.Json.Serialization.JsonPropertyName("offset")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Offset { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/StreamInfoResponse.cs b/src/NATS.Client.JetStream/Models/StreamInfoResponse.cs index 5ee35398e..da3342c79 100644 --- a/src/NATS.Client.JetStream/Models/StreamInfoResponse.cs +++ b/src/NATS.Client.JetStream/Models/StreamInfoResponse.cs @@ -1,30 +1,23 @@ -using System.Text.Json.Serialization; - namespace NATS.Client.JetStream.Models; -public record StreamInfoResponse -{ - [JsonPropertyName("type")] - public string Type { get; set; } - - [JsonPropertyName("total")] - public long Total { get; set; } - - [JsonPropertyName("offset")] - public long Offset { get; set; } - - [JsonPropertyName("limit")] - public long Limit { get; set; } +/// +/// A response from the JetStream $JS.API.STREAM.INFO API +/// - [JsonPropertyName("config")] - public StreamConfig Config { get; set; } - - [JsonPropertyName("created")] - public DateTimeOffset Created { get; set; } - - [JsonPropertyName("state")] - public StreamState State { get; set; } - - [JsonPropertyName("cluster")] - public Cluster Cluster { get; set; } +public record StreamInfoResponse : StreamInfo +{ + [System.Text.Json.Serialization.JsonPropertyName("total")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Total { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("offset")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Offset { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("limit")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Limit { get; set; } = default!; } diff --git a/src/NATS.Client.JetStream/Models/StreamLeaderStepdownResponse.cs b/src/NATS.Client.JetStream/Models/StreamLeaderStepdownResponse.cs new file mode 100644 index 000000000..3dc786726 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamLeaderStepdownResponse.cs @@ -0,0 +1,15 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.STREAM.LEADER.STEPDOWN API +/// + +public record StreamLeaderStepdownResponse +{ + /// + /// If the leader successfully stood down + /// + [System.Text.Json.Serialization.JsonPropertyName("success")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + public bool Success { get; set; } = false; +} diff --git a/src/NATS.Client.JetStream/Models/StreamListRequest.cs b/src/NATS.Client.JetStream/Models/StreamListRequest.cs new file mode 100644 index 000000000..5b3976fa5 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamListRequest.cs @@ -0,0 +1,20 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A request to the JetStream $JS.API.STREAM.LIST API +/// + +public record StreamListRequest +{ + /// + /// Limit the list to streams matching this subject filter + /// + [System.Text.Json.Serialization.JsonPropertyName("subject")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string Subject { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("offset")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Offset { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/StreamListResponse.cs b/src/NATS.Client.JetStream/Models/StreamListResponse.cs new file mode 100644 index 000000000..297c4767b --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamListResponse.cs @@ -0,0 +1,23 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.STREAM.LIST API +/// + +public record StreamListResponse : IterableResponse +{ + /// + /// Full Stream information for each known Stream + /// + [System.Text.Json.Serialization.JsonPropertyName("streams")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public System.Collections.Generic.ICollection Streams { get; set; } = new System.Collections.ObjectModel.Collection(); + + /// + /// In clustered environments gathering Stream info might time out, this list would be a list of Streams for which information was not obtainable + /// + [System.Text.Json.Serialization.JsonPropertyName("missing")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.Collections.Generic.ICollection Missing { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/StreamMsgDeleteRequest.cs b/src/NATS.Client.JetStream/Models/StreamMsgDeleteRequest.cs new file mode 100644 index 000000000..27fba40cd --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamMsgDeleteRequest.cs @@ -0,0 +1,23 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A request to the JetStream $JS.API.STREAM.MSG.DELETE API +/// + +public record StreamMsgDeleteRequest +{ + /// + /// Stream sequence number of the message to delete + /// + [System.Text.Json.Serialization.JsonPropertyName("seq")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long Seq { get; set; } = default!; + + /// + /// Default will securely remove a message and rewrite the data with random data, set this to true to only remove the message + /// + [System.Text.Json.Serialization.JsonPropertyName("no_erase")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool NoErase { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/StreamMsgDeleteResponse.cs b/src/NATS.Client.JetStream/Models/StreamMsgDeleteResponse.cs new file mode 100644 index 000000000..a616ac796 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamMsgDeleteResponse.cs @@ -0,0 +1,12 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.STREAM.MSG.DELETE API +/// + +public record StreamMsgDeleteResponse +{ + [System.Text.Json.Serialization.JsonPropertyName("success")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + public bool Success { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/StreamMsgGetRequest.cs b/src/NATS.Client.JetStream/Models/StreamMsgGetRequest.cs new file mode 100644 index 000000000..ebea7845a --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamMsgGetRequest.cs @@ -0,0 +1,29 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A request to the JetStream $JS.API.STREAM.MSG.GET API +/// + +public record StreamMsgGetRequest +{ + /// + /// Stream sequence number of the message to retrieve, cannot be combined with last_by_subj + /// + [System.Text.Json.Serialization.JsonPropertyName("seq")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public int Seq { get; set; } = default!; + + /// + /// Retrieves the last message for a given subject, cannot be combined with seq + /// + [System.Text.Json.Serialization.JsonPropertyName("last_by_subj")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string LastBySubj { get; set; } = default!; + + /// + /// Combined with sequence gets the next message for a subject with the given sequence or higher + /// + [System.Text.Json.Serialization.JsonPropertyName("next_by_subj")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string NextBySubj { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/StreamMsgGetResponse.cs b/src/NATS.Client.JetStream/Models/StreamMsgGetResponse.cs new file mode 100644 index 000000000..66c0073b5 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamMsgGetResponse.cs @@ -0,0 +1,13 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.STREAM.MSG.GET API +/// + +public record StreamMsgGetResponse +{ + [System.Text.Json.Serialization.JsonPropertyName("message")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public StoredMessage Message { get; set; } = new StoredMessage(); +} diff --git a/src/NATS.Client.JetStream/Models/StreamNamesRequest.cs b/src/NATS.Client.JetStream/Models/StreamNamesRequest.cs new file mode 100644 index 000000000..ebf2d6223 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamNamesRequest.cs @@ -0,0 +1,20 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A request to the JetStream $JS.API.STREAM.NAMES API +/// + +public record StreamNamesRequest +{ + /// + /// Limit the list to streams matching this subject filter + /// + [System.Text.Json.Serialization.JsonPropertyName("subject")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string Subject { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("offset")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Offset { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/StreamNamesResponse.cs b/src/NATS.Client.JetStream/Models/StreamNamesResponse.cs new file mode 100644 index 000000000..d8bc87fc5 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamNamesResponse.cs @@ -0,0 +1,12 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.STREAM.NAMES API +/// + +public record StreamNamesResponse : IterableResponse +{ + [System.Text.Json.Serialization.JsonPropertyName("consumers")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.Collections.Generic.ICollection Consumers { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/StreamPurgeRequest.cs b/src/NATS.Client.JetStream/Models/StreamPurgeRequest.cs new file mode 100644 index 000000000..bd1f37303 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamPurgeRequest.cs @@ -0,0 +1,31 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A request to the JetStream $JS.API.STREAM.PURGE API +/// + +public record StreamPurgeRequest +{ + /// + /// Restrict purging to messages that match this subject + /// + [System.Text.Json.Serialization.JsonPropertyName("filter")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string Filter { get; set; } = default!; + + /// + /// Purge all messages up to but not including the message with this sequence. Can be combined with subject filter but not the keep option + /// + [System.Text.Json.Serialization.JsonPropertyName("seq")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long Seq { get; set; } = default!; + + /// + /// Ensures this many messages are present after the purge. Can be combined with the subject filter but not the sequence + /// + [System.Text.Json.Serialization.JsonPropertyName("keep")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long Keep { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/StreamPurgeResponse.cs b/src/NATS.Client.JetStream/Models/StreamPurgeResponse.cs new file mode 100644 index 000000000..f7f36c5d7 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamPurgeResponse.cs @@ -0,0 +1,20 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.STREAM.PURGE API +/// + +public record StreamPurgeResponse +{ + [System.Text.Json.Serialization.JsonPropertyName("success")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + public bool Success { get; set; } = default!; + + /// + /// Number of messages purged from the Stream + /// + [System.Text.Json.Serialization.JsonPropertyName("purged")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long Purged { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/StreamRemovePeerRequest.cs b/src/NATS.Client.JetStream/Models/StreamRemovePeerRequest.cs new file mode 100644 index 000000000..f83345aa0 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamRemovePeerRequest.cs @@ -0,0 +1,16 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A request to the JetStream $JS.API.STREAM.PEER.REMOVE API +/// + +public record StreamRemovePeerRequest +{ + /// + /// Server name of the peer to remove + /// + [System.Text.Json.Serialization.JsonPropertyName("peer")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public string Peer { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/StreamRemovePeerResponse.cs b/src/NATS.Client.JetStream/Models/StreamRemovePeerResponse.cs new file mode 100644 index 000000000..c7a9094e6 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamRemovePeerResponse.cs @@ -0,0 +1,15 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.STREAM.PEER.REMOVE API +/// + +public record StreamRemovePeerResponse +{ + /// + /// If the peer was successfully removed + /// + [System.Text.Json.Serialization.JsonPropertyName("success")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + public bool Success { get; set; } = false; +} diff --git a/src/NATS.Client.JetStream/Models/StreamRestoreRequest.cs b/src/NATS.Client.JetStream/Models/StreamRestoreRequest.cs new file mode 100644 index 000000000..eee273909 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamRestoreRequest.cs @@ -0,0 +1,18 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.STREAM.RESTORE API +/// + +public record StreamRestoreRequest +{ + [System.Text.Json.Serialization.JsonPropertyName("config")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public StreamConfiguration Config { get; set; } = new StreamConfiguration(); + + [System.Text.Json.Serialization.JsonPropertyName("state")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public StreamState State { get; set; } = new StreamState(); +} diff --git a/src/NATS.Client.JetStream/Models/StreamRestoreResponse.cs b/src/NATS.Client.JetStream/Models/StreamRestoreResponse.cs new file mode 100644 index 000000000..860af8f1a --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamRestoreResponse.cs @@ -0,0 +1,16 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.STREAM.RESTORE API +/// + +public record StreamRestoreResponse +{ + /// + /// The Subject to send restore chunks to + /// + [System.Text.Json.Serialization.JsonPropertyName("deliver_subject")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public string DeliverSubject { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/StreamSnapshotRequest.cs b/src/NATS.Client.JetStream/Models/StreamSnapshotRequest.cs new file mode 100644 index 000000000..2f693faf9 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamSnapshotRequest.cs @@ -0,0 +1,38 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A request to the JetStream $JS.API.STREAM.SNAPSHOT API +/// + +public record StreamSnapshotRequest +{ + /// + /// The NATS subject where the snapshot will be delivered + /// + [System.Text.Json.Serialization.JsonPropertyName("deliver_subject")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public string DeliverSubject { get; set; } = default!; + + /// + /// When true consumer states and configurations will not be present in the snapshot + /// + [System.Text.Json.Serialization.JsonPropertyName("no_consumers")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool NoConsumers { get; set; } = default!; + + /// + /// The size of data chunks to send to deliver_subject + /// + [System.Text.Json.Serialization.JsonPropertyName("chunk_size")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long ChunkSize { get; set; } = default!; + + /// + /// Check all message's checksums prior to snapshot + /// + [System.Text.Json.Serialization.JsonPropertyName("jsck")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public bool Jsck { get; set; } = false; +} diff --git a/src/NATS.Client.JetStream/Models/StreamSnapshotResponse.cs b/src/NATS.Client.JetStream/Models/StreamSnapshotResponse.cs new file mode 100644 index 000000000..2e31a5fed --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamSnapshotResponse.cs @@ -0,0 +1,18 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.STREAM.SNAPSHOT API +/// + +public record StreamSnapshotResponse +{ + [System.Text.Json.Serialization.JsonPropertyName("config")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public StreamConfiguration Config { get; set; } = new StreamConfiguration(); + + [System.Text.Json.Serialization.JsonPropertyName("state")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public StreamState State { get; set; } = new StreamState(); +} diff --git a/src/NATS.Client.JetStream/Models/StreamSource.cs b/src/NATS.Client.JetStream/Models/StreamSource.cs new file mode 100644 index 000000000..5c84a38da --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamSource.cs @@ -0,0 +1,51 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// Defines a source where streams should be replicated from +/// + +public record StreamSource +{ + /// + /// Stream name + /// + [System.Text.Json.Serialization.JsonPropertyName("name")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + [System.ComponentModel.DataAnnotations.StringLength(int.MaxValue, MinimumLength = 1)] + [System.ComponentModel.DataAnnotations.RegularExpression(@"^[^.*>]+$")] + public string Name { get; set; } = default!; + + /// + /// Sequence to start replicating from + /// + [System.Text.Json.Serialization.JsonPropertyName("opt_start_seq")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long OptStartSeq { get; set; } = default!; + + /// + /// Time stamp to start replicating from + /// + [System.Text.Json.Serialization.JsonPropertyName("opt_start_time")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.DateTimeOffset OptStartTime { get; set; } = default!; + + /// + /// Replicate only a subset of messages based on filter + /// + [System.Text.Json.Serialization.JsonPropertyName("filter_subject")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string FilterSubject { get; set; } = default!; + + /// + /// Map matching subjects according to this transform destination + /// + [System.Text.Json.Serialization.JsonPropertyName("subject_transform_dest")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string SubjectTransformDest { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("external")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public ExternalStreamSource External { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/StreamSourceInfo.cs b/src/NATS.Client.JetStream/Models/StreamSourceInfo.cs new file mode 100644 index 000000000..e2048e0ab --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamSourceInfo.cs @@ -0,0 +1,54 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// Information about an upstream stream source in a mirror +/// + +public record StreamSourceInfo +{ + /// + /// The name of the Stream being replicated + /// + [System.Text.Json.Serialization.JsonPropertyName("name")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Name { get; set; } = default!; + + /// + /// The subject filter to apply to the messages + /// + [System.Text.Json.Serialization.JsonPropertyName("filter_subject")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string FilterSubject { get; set; } = default!; + + /// + /// The subject transform destination to apply to the messages + /// + [System.Text.Json.Serialization.JsonPropertyName("subject_transform_dest")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string SubjectTransformDest { get; set; } = default!; + + /// + /// How many messages behind the mirror operation is + /// + [System.Text.Json.Serialization.JsonPropertyName("lag")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long Lag { get; set; } = default!; + + /// + /// When last the mirror had activity, in nanoseconds. Value will be -1 when there has been no activity. + /// + [System.Text.Json.Serialization.JsonPropertyName("active")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long Active { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("external")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public ExternalStreamSource External { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("error")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public ApiError Error { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/StreamState.cs b/src/NATS.Client.JetStream/Models/StreamState.cs index 528b708d4..0dea24174 100644 --- a/src/NATS.Client.JetStream/Models/StreamState.cs +++ b/src/NATS.Client.JetStream/Models/StreamState.cs @@ -1,55 +1,92 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - namespace NATS.Client.JetStream.Models; public record StreamState { - [JsonPropertyName("messages")] - public ulong Messages { get; set; } + /// + /// Number of messages stored in the Stream + /// + [System.Text.Json.Serialization.JsonPropertyName("messages")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long Messages { get; set; } = default!; - [JsonPropertyName("bytes")] - public ulong Bytes { get; set; } + /// + /// Combined size of all messages in the Stream + /// + [System.Text.Json.Serialization.JsonPropertyName("bytes")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long Bytes { get; set; } = default!; - [JsonPropertyName("first_seq")] - public ulong FirstSeq { get; set; } + /// + /// Sequence number of the first message in the Stream + /// + [System.Text.Json.Serialization.JsonPropertyName("first_seq")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long FirstSeq { get; set; } = default!; - [JsonPropertyName("last_seq")] - public ulong LastSeq { get; set; } + /// + /// The timestamp of the first message in the Stream + /// + [System.Text.Json.Serialization.JsonPropertyName("first_ts")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string FirstTs { get; set; } = default!; - [JsonPropertyName("consumer_count")] - public long ConsumerCount { get; set; } + /// + /// Sequence number of the last message in the Stream + /// + [System.Text.Json.Serialization.JsonPropertyName("last_seq")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0D, 18446744073709552000D)] + public long LastSeq { get; set; } = default!; - [JsonPropertyName("num_subjects")] - public long NumSubjects { get; set; } + /// + /// The timestamp of the last message in the Stream + /// + [System.Text.Json.Serialization.JsonPropertyName("last_ts")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string LastTs { get; set; } = default!; - [JsonPropertyName("num_deleted")] - public long NumDeleted { get; set; } + /// + /// IDs of messages that were deleted using the Message Delete API or Interest based streams removing messages out of order + /// + [System.Text.Json.Serialization.JsonPropertyName("deleted")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.Collections.Generic.ICollection Deleted { get; set; } = default!; - [JsonPropertyName("first_ts")] - public DateTimeOffset FirstTs { get; set; } + /// + /// Subjects and their message counts when a subjects_filter was set + /// + [System.Text.Json.Serialization.JsonPropertyName("subjects")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.Collections.Generic.IDictionary Subjects { get; set; } = default!; - [JsonPropertyName("last_ts")] - public DateTimeOffset LastTs { get; set; } + /// + /// The number of unique subjects held in the stream + /// + [System.Text.Json.Serialization.JsonPropertyName("num_subjects")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long NumSubjects { get; set; } = default!; - [JsonPropertyName("subjects")] - public string Subjects { get; set; } + /// + /// The number of deleted messages + /// + [System.Text.Json.Serialization.JsonPropertyName("num_deleted")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long NumDeleted { get; set; } = default!; - [JsonPropertyName("deleted")] - public string Deleted { get; set; } + [System.Text.Json.Serialization.JsonPropertyName("lost")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public LostStreamData Lost { get; set; } = default!; - [JsonPropertyName("lost")] - public string Lost { get; set; } + /// + /// Number of Consumers attached to the Stream + /// + [System.Text.Json.Serialization.JsonPropertyName("consumer_count")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(-9223372036854776000D, 9223372036854776000D)] + public long ConsumerCount { get; set; } = default!; } diff --git a/src/NATS.Client.JetStream/Models/StreamTemplateConfiguration.cs b/src/NATS.Client.JetStream/Models/StreamTemplateConfiguration.cs new file mode 100644 index 000000000..8a9a7feee --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamTemplateConfiguration.cs @@ -0,0 +1,31 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// The data structure that describe the configuration of a NATS JetStream Stream Template +/// + +public record StreamTemplateConfiguration +{ + /// + /// A unique name for the Stream Template. + /// + [System.Text.Json.Serialization.JsonPropertyName("name")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + [System.ComponentModel.DataAnnotations.StringLength(int.MaxValue, MinimumLength = 1)] + [System.ComponentModel.DataAnnotations.RegularExpression(@"^[^.*>]+$")] + public string Name { get; set; } = default!; + + /// + /// The maximum number of Streams this Template can create, -1 for unlimited. + /// + [System.Text.Json.Serialization.JsonPropertyName("max_streams")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(-2147483648, 2147483647)] + public int MaxStreams { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("config")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public StreamConfiguration Config { get; set; } = new StreamConfiguration(); +} diff --git a/src/NATS.Client.JetStream/Models/StreamTemplateCreateRequest.cs b/src/NATS.Client.JetStream/Models/StreamTemplateCreateRequest.cs new file mode 100644 index 000000000..a960454ab --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamTemplateCreateRequest.cs @@ -0,0 +1,9 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A request to the JetStream $JS.API.STREAM.TEMPLATE.CREATE API +/// + +public record StreamTemplateCreateRequest : StreamTemplateConfiguration +{ +} diff --git a/src/NATS.Client.JetStream/Models/StreamTemplateCreateResponse.cs b/src/NATS.Client.JetStream/Models/StreamTemplateCreateResponse.cs new file mode 100644 index 000000000..a1cc9dc9f --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamTemplateCreateResponse.cs @@ -0,0 +1,9 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.STREAM.TEMPLATE.CREATE API +/// + +public record StreamTemplateCreateResponse : StreamTemplateInfo +{ +} diff --git a/src/NATS.Client.JetStream/Models/StreamTemplateDeleteResponse.cs b/src/NATS.Client.JetStream/Models/StreamTemplateDeleteResponse.cs new file mode 100644 index 000000000..a6eec13ef --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamTemplateDeleteResponse.cs @@ -0,0 +1,12 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.STREAM.TEMPLATE.DELETE API +/// + +public record StreamTemplateDeleteResponse +{ + [System.Text.Json.Serialization.JsonPropertyName("success")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + public bool Success { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/StreamTemplateInfo.cs b/src/NATS.Client.JetStream/Models/StreamTemplateInfo.cs new file mode 100644 index 000000000..9c0b8d1cd --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamTemplateInfo.cs @@ -0,0 +1,17 @@ +namespace NATS.Client.JetStream.Models; + +public record StreamTemplateInfo +{ + [System.Text.Json.Serialization.JsonPropertyName("config")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public StreamTemplateConfiguration Config { get; set; } = new StreamTemplateConfiguration(); + + /// + /// List of Streams managed by this Template + /// + [System.Text.Json.Serialization.JsonPropertyName("streams")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public System.Collections.Generic.ICollection Streams { get; set; } = new System.Collections.ObjectModel.Collection(); +} diff --git a/src/NATS.Client.JetStream/Models/StreamTemplateInfoResponse.cs b/src/NATS.Client.JetStream/Models/StreamTemplateInfoResponse.cs new file mode 100644 index 000000000..c04c35466 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamTemplateInfoResponse.cs @@ -0,0 +1,9 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.STREAM.TEMPLATE.INFO API +/// + +public record StreamTemplateInfoResponse : StreamTemplateInfo +{ +} diff --git a/src/NATS.Client.JetStream/Models/StreamTemplateNamesRequest.cs b/src/NATS.Client.JetStream/Models/StreamTemplateNamesRequest.cs new file mode 100644 index 000000000..25e44c108 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamTemplateNamesRequest.cs @@ -0,0 +1,9 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A request to the JetStream $JS.API.CONSUMER.LIST API +/// + +public record StreamTemplateNamesRequest : IterableRequest +{ +} diff --git a/src/NATS.Client.JetStream/Models/StreamTemplateNamesResponse.cs b/src/NATS.Client.JetStream/Models/StreamTemplateNamesResponse.cs new file mode 100644 index 000000000..285490416 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamTemplateNamesResponse.cs @@ -0,0 +1,12 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.STREAM.TEMPLATE.NAMES API +/// + +public record StreamTemplateNamesResponse : IterableResponse +{ + [System.Text.Json.Serialization.JsonPropertyName("consumers")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public System.Collections.Generic.ICollection Consumers { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/StreamUpdateRequest.cs b/src/NATS.Client.JetStream/Models/StreamUpdateRequest.cs new file mode 100644 index 000000000..6eb0b995c --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamUpdateRequest.cs @@ -0,0 +1,9 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A request to the JetStream $JS.API.STREAM.UPDATE API +/// + +public record StreamUpdateRequest : StreamConfiguration +{ +} diff --git a/src/NATS.Client.JetStream/Models/StreamUpdateResponse.cs b/src/NATS.Client.JetStream/Models/StreamUpdateResponse.cs new file mode 100644 index 000000000..ff46a3bf0 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/StreamUpdateResponse.cs @@ -0,0 +1,9 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// A response from the JetStream $JS.API.STREAM.UPDATE API +/// + +public record StreamUpdateResponse : StreamInfo +{ +} diff --git a/src/NATS.Client.JetStream/Models/Subject.cs b/src/NATS.Client.JetStream/Models/Subject.cs deleted file mode 100644 index df57396ac..000000000 --- a/src/NATS.Client.JetStream/Models/Subject.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record Subject -{} diff --git a/src/NATS.Client.JetStream/Models/SubjectTransform.cs b/src/NATS.Client.JetStream/Models/SubjectTransform.cs new file mode 100644 index 000000000..ba5034db5 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/SubjectTransform.cs @@ -0,0 +1,23 @@ +namespace NATS.Client.JetStream.Models; + +/// +/// Subject transform to apply to matching messages going into the stream +/// + +public record SubjectTransform +{ + /// + /// The subject transform source + /// + [System.Text.Json.Serialization.JsonPropertyName("src")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] + public string Src { get; set; } = default!; + + /// + /// The subject transform destination + /// + [System.Text.Json.Serialization.JsonPropertyName("dest")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Dest { get; set; } = default!; +} diff --git a/src/NATS.Client.JetStream/Models/SubscribeOptions.cs b/src/NATS.Client.JetStream/Models/SubscribeOptions.cs deleted file mode 100644 index 666b3527f..000000000 --- a/src/NATS.Client.JetStream/Models/SubscribeOptions.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record SubscribeOptions -{} diff --git a/src/NATS.Client.JetStream/Models/SuccessApiResponse.cs b/src/NATS.Client.JetStream/Models/SuccessApiResponse.cs deleted file mode 100644 index 886f0d321..000000000 --- a/src/NATS.Client.JetStream/Models/SuccessApiResponse.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2023 The NATS Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System.Text.Json.Serialization; - -namespace NATS.Client.JetStream.Models; - -public record SuccessApiResponse -{ - [JsonPropertyName("success")] - public string Success { get; set; } -} diff --git a/src/NATS.Client.JetStream/Models/Tier.cs b/src/NATS.Client.JetStream/Models/Tier.cs new file mode 100644 index 000000000..a05ce7a56 --- /dev/null +++ b/src/NATS.Client.JetStream/Models/Tier.cs @@ -0,0 +1,41 @@ +namespace NATS.Client.JetStream.Models; + +public record Tier +{ + /// + /// Memory Storage being used for Stream Message storage + /// + [System.Text.Json.Serialization.JsonPropertyName("memory")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Memory { get; set; } = default!; + + /// + /// File Storage being used for Stream Message storage + /// + [System.Text.Json.Serialization.JsonPropertyName("storage")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Storage { get; set; } = default!; + + /// + /// Number of active Streams + /// + [System.Text.Json.Serialization.JsonPropertyName("streams")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Streams { get; set; } = default!; + + /// + /// Number of active Consumers + /// + [System.Text.Json.Serialization.JsonPropertyName("consumers")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Range(0, int.MaxValue)] + public int Consumers { get; set; } = default!; + + [System.Text.Json.Serialization.JsonPropertyName("limits")] + [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.Never)] + [System.ComponentModel.DataAnnotations.Required] + public AccountLimits Limits { get; set; } = new AccountLimits(); +} diff --git a/tools/Schema.Generation/Program.cs b/tools/Schema.Generation/Program.cs new file mode 100644 index 000000000..8ed4a2751 --- /dev/null +++ b/tools/Schema.Generation/Program.cs @@ -0,0 +1,97 @@ +using System.Text.RegularExpressions; +using NJsonSchema; +using NJsonSchema.CodeGeneration; +using NJsonSchema.CodeGeneration.CSharp; + +var enumNameGenerator = new ProperCaseEnumNameGenerator(); +var propertyNameGenerator = new ProperCasePropertyNameGenerator(); +var typeNameGenerator = new ProperCaseTypeNameGenerator(); + +var generatorSettings = new CSharpGeneratorSettings +{ + JsonLibrary = CSharpJsonLibrary.SystemTextJson, + GenerateNativeRecords = true, + Namespace = "NATS.Client.JetStream.Models", + GenerateNullableReferenceTypes = true, + EnumNameGenerator = enumNameGenerator, + TypeNameGenerator = typeNameGenerator, + PropertyNameGenerator = propertyNameGenerator, +}; + +var slnDirInfo = new DirectoryInfo(Directory.GetCurrentDirectory()); +while (!File.Exists(Path.Combine(slnDirInfo.FullName, "NATS.Client.sln"))) +{ + if (slnDirInfo.Parent == default) + throw new Exception("could not locate solution root"); + + slnDirInfo = new DirectoryInfo(slnDirInfo.Parent.FullName); +} + +var slnDir = slnDirInfo.FullName; +var schemaProjDir = Path.Combine(slnDir, "tools", "Schema.Generation"); +var jsProjDir = Path.Combine(slnDir, "src", "NATS.Client.JetStream"); + +var jsDefinition = Path.Combine(schemaProjDir, "schema", "jetstream.api.v1.json"); +var jsModels = Path.Combine(jsProjDir, "Models"); + +// start with definitions +var schema = await JsonSchema.FromFileAsync(jsDefinition); + +// create an "Unknown" type containing all of the definitions at the root level +// so that all definitions will be created +foreach (var (typeName, typeDef) in schema.Definitions) +{ + // default behavior is to allow additional properties + // but if no additional property schema is defined we don't want them + if (typeDef.AdditionalPropertiesSchema == default) + typeDef.AllowAdditionalProperties = false; + + schema.Properties[typeName] = new JsonSchemaProperty { Reference = typeDef, }; +} + +// generate +var generator = new CSharpGenerator(schema, generatorSettings); +generator.GenerateFile(); + +var removeGeneratedCodeLine = new Regex(@"^\[System.CodeDom.Compiler.GeneratedCode.*$", RegexOptions.Multiline); +var removeExtraLineAfterAnnotation = new Regex(@"(\[System.Text.Json.Serialization.JsonPropertyName\(""\w+""\)])\n\n"); + +// loop through each type and write a model +foreach (var type in generator.GenerateTypes()) +{ + if (type.TypeName == "Unknown") + continue; + + var code = type.Code; + code = removeGeneratedCodeLine.Replace(code, string.Empty); + code = removeExtraLineAfterAnnotation.Replace(code, "$1\n"); + code = code.Replace("public partial record", "public record"); + code = $"namespace {generatorSettings.Namespace};\n\n{code}"; + + var fileName = $"{type.TypeName}.cs"; + Console.WriteLine($"writing {fileName}"); + await File.WriteAllTextAsync(Path.Combine(jsModels, fileName), code); +} + +public static class Utils +{ + public static string ProperCase(string str) => + string.IsNullOrEmpty(str) + ? str + : string.Concat(str.Split("_").Select(s => string.Concat(s[0].ToString().ToUpper(), s.AsSpan(1)))); +} + +public class ProperCaseEnumNameGenerator : IEnumNameGenerator +{ + public string Generate(int index, string name, object value, JsonSchema schema) => Utils.ProperCase(name); +} + +public class ProperCasePropertyNameGenerator : IPropertyNameGenerator +{ + public string Generate(JsonSchemaProperty property) => Utils.ProperCase(property.Name); +} + +public class ProperCaseTypeNameGenerator : ITypeNameGenerator +{ + public string Generate(JsonSchema schema, string typeNameHint, IEnumerable reservedTypeNames) => string.IsNullOrEmpty(typeNameHint) ? "Unknown" : Utils.ProperCase(typeNameHint); +} diff --git a/tools/Schema.Generation/README.md b/tools/Schema.Generation/README.md new file mode 100644 index 000000000..faa2e1458 --- /dev/null +++ b/tools/Schema.Generation/README.md @@ -0,0 +1,13 @@ +# Schema.Generation + +Console App to generate Models for JetStream + +Requires `node` (current LTS release is fine) for preparing JSON Schema + +1. Copy relevant files from https://github.com/nats-io/jsm.go/tree/main/schema_source + - `request` and `response` models have been edited to make use of `allOf` for cleaner inheritance + - `response` models have `oneOf` with error types removed + - in `definitions.json`: `allOf` references in 3 places have been simplified to enable cleaner model generation +2. Run `node prepare.js` to bundle the `schema_source` files into a single file in `schema` +3. Run `dotnet run` to generate models +4. Run `dotnet format ../../src/NATS.Client.JetStream` to format the generated models diff --git a/tools/Schema.Generation/Schema.Generation.csproj b/tools/Schema.Generation/Schema.Generation.csproj new file mode 100644 index 000000000..03a0db923 --- /dev/null +++ b/tools/Schema.Generation/Schema.Generation.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + enable + enable + false + + + + + + + diff --git a/tools/Schema.Generation/prepare.js b/tools/Schema.Generation/prepare.js new file mode 100644 index 000000000..ff0d86758 --- /dev/null +++ b/tools/Schema.Generation/prepare.js @@ -0,0 +1,22 @@ +const fs = require('fs') +const path = require('path') + +const source = path.join(__dirname, 'schema_source', 'jetstream', 'api', 'v1') +const dest = path.join(__dirname, 'schema', 'jetstream.api.v1.json') +const defs = JSON.parse(fs.readFileSync(path.join(source, 'definitions.json'), 'utf-8')) + +for (const f of fs.readdirSync(source)) { + if (f == 'definitions.json') { + continue + } + const typeName = f.split('.json')[0] + console.log(`merging ${typeName}`) + const schema = JSON.parse(fs.readFileSync(path.join(source, f), 'utf-8')) + delete schema['$id'] + delete schema['$schema'] + defs.definitions[typeName] = schema +} + +let contents = JSON.stringify(defs, null, 2).replaceAll() +console.log(`writing ${dest}`) +fs.writeFileSync(dest, JSON.stringify(defs, null, 2).replaceAll("definitions.json#/definitions", "#/definitions"), 'utf-8') diff --git a/tools/Schema.Generation/schema/jetstream.api.v1.json b/tools/Schema.Generation/schema/jetstream.api.v1.json new file mode 100644 index 000000000..26d799bc9 --- /dev/null +++ b/tools/Schema.Generation/schema/jetstream.api.v1.json @@ -0,0 +1,1984 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/definitions.json", + "title": "io.nats.jetstream.api.v1.definitions", + "description": "Shared definitions for the JetStream API", + "type": "object", + "definitions": { + "golang_duration_nanos": { + "$comment": "nanoseconds depicting a duration in time, signed 64 bit integer", + "$ref": "#/definitions/golang_int64" + }, + "golang_int": { + "$comment": "integer with a dynamic bit size depending on the platform the cluster runs on, can be up to 64bit", + "$ref": "#/definitions/golang_int64" + }, + "golang_uint64": { + "$comment": "unsigned 64 bit integer", + "type": "integer", + "minimum": 0, + "maximum": 18446744073709552000 + }, + "golang_int32": { + "$comment": "signed 32 bit integer", + "type": "integer", + "maximum": 2147483647, + "minimum": -2147483648 + }, + "golang_int64": { + "$comment": "signed 64 bit integer", + "type": "integer", + "maximum": 9223372036854776000, + "minimum": -9223372036854776000 + }, + "golang_time": { + "$comment": "A point in time in RFC3339 format including timezone, though typically in UTC", + "type": "string", + "format": "date-time" + }, + "stream_source": { + "type": "object", + "description": "Defines a source where streams should be replicated from", + "required": [ + "name" + ], + "properties": { + "name": { + "description": "Stream name", + "$ref": "#/definitions/basic_name" + }, + "opt_start_seq": { + "description": "Sequence to start replicating from", + "$ref": "#/definitions/golang_uint64" + }, + "opt_start_time": { + "description": "Time stamp to start replicating from", + "$ref": "#/definitions/golang_time" + }, + "filter_subject": { + "description": "Replicate only a subset of messages based on filter", + "type": "string" + }, + "subject_transform_dest": { + "description": "Map matching subjects according to this transform destination", + "type": "string" + }, + "external": { + "$ref": "#/definitions/external_stream_source" + } + } + }, + "external_stream_source": { + "required": [ + "api" + ], + "type": "object", + "description": "Configuration referencing a stream source in another account or JetStream domain", + "properties": { + "api": { + "type": "string", + "description": "The subject prefix that imports the other account/domain $JS.API.CONSUMER.> subjects" + }, + "deliver": { + "type": "string", + "description": "The delivery subject to use for the push consumer" + } + } + }, + "stream_source_info": { + "required": [ + "name", + "lag", + "active" + ], + "type": "object", + "description": "Information about an upstream stream source in a mirror", + "properties": { + "name": { + "type": "string", + "description": "The name of the Stream being replicated" + }, + "filter_subject": { + "type": "string", + "description": "The subject filter to apply to the messages" + }, + "subject_transform_dest": { + "type": "string", + "description": "The subject transform destination to apply to the messages" + }, + "lag": { + "$ref": "#/definitions/golang_uint64", + "description": "How many messages behind the mirror operation is", + "minimum": 0 + }, + "active": { + "description": "When last the mirror had activity, in nanoseconds. Value will be -1 when there has been no activity.", + "$ref": "#/definitions/golang_duration_nanos", + "minimum": -1 + }, + "external": { + "$ref": "#/definitions/external_stream_source" + }, + "error": { + "$ref": "#/definitions/api_error" + } + } + }, + "lost_stream_data": { + "type": "object", + "description": "Records messages that were damaged and unrecoverable", + "properties": { + "msgs": { + "type": [ + "array", + "null" + ], + "description": "The messages that were lost", + "items": { + "$ref": "#/definitions/golang_uint64", + "minimum": 0 + } + }, + "bytes": { + "description": "The number of bytes that were lost", + "$ref": "#/definitions/golang_uint64" + } + } + }, + "placement": { + "type": "object", + "description": "Placement requirements for a stream", + "required": [ + "cluster" + ], + "properties": { + "cluster": { + "type": "string", + "description": "The desired cluster name to place the stream" + }, + "tags": { + "description": "Tags required on servers hosting this stream", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "peer_info": { + "type": "object", + "required": [ + "name", + "current", + "active" + ], + "properties": { + "name": { + "description": "The server name of the peer", + "type": "string", + "minimum": 1 + }, + "current": { + "description": "Indicates if the server is up to date and synchronised", + "type": "boolean", + "default": false + }, + "active": { + "description": "Nanoseconds since this peer was last seen", + "type": "number" + }, + "offline": { + "description": "Indicates the node is considered offline by the group", + "type": "boolean", + "default": false + }, + "lag": { + "description": "How many uncommitted operations this peer is behind the leader", + "type": "integer", + "minimum": 0 + } + } + }, + "cluster_info": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The cluster name" + }, + "leader": { + "type": "string", + "description": "The server name of the RAFT leader" + }, + "replicas": { + "type": "array", + "description": "The members of the RAFT cluster", + "items": { + "$ref": "#/definitions/peer_info" + } + } + } + }, + "api_stats": { + "type": "object", + "required": [ + "total", + "errors" + ], + "properties": { + "total": { + "description": "Total number of API requests received for this account", + "minimum": 0, + "type": "integer" + }, + "errors": { + "description": "API requests that resulted in an error response", + "minimum": 0, + "type": "integer" + } + } + }, + "tier": { + "type": "object", + "required": [ + "memory", + "storage", + "streams", + "limits", + "consumers" + ], + "properties": { + "memory": { + "description": "Memory Storage being used for Stream Message storage", + "type": "integer", + "minimum": 0 + }, + "storage": { + "description": "File Storage being used for Stream Message storage", + "type": "integer", + "minimum": 0 + }, + "streams": { + "description": "Number of active Streams", + "type": "integer", + "minimum": 0 + }, + "consumers": { + "description": "Number of active Consumers", + "type": "integer", + "minimum": 0 + }, + "limits": { + "$ref": "#/definitions/account_limits" + } + } + }, + "account_stats": { + "type": "object", + "required": [ + "memory", + "storage", + "streams", + "limits", + "api", + "consumers" + ], + "properties": { + "memory": { + "description": "Memory Storage being used for Stream Message storage", + "type": "integer", + "minimum": 0 + }, + "storage": { + "description": "File Storage being used for Stream Message storage", + "type": "integer", + "minimum": 0 + }, + "streams": { + "description": "Number of active Streams", + "type": "integer", + "minimum": 0 + }, + "consumers": { + "description": "Number of active Consumers", + "type": "integer", + "minimum": 0 + }, + "domain": { + "description": "The JetStream domain this account is in", + "type": "string" + }, + "limits": { + "$ref": "#/definitions/account_limits" + }, + "tiers": { + "type": "object", + "patternProperties": { + ".*": { + "$ref": "#/definitions/tier" + } + } + }, + "api": { + "$ref": "#/definitions/api_stats" + } + } + }, + "account_limits": { + "type": "object", + "additionalProperties": false, + "required": [ + "max_consumers", + "max_memory", + "max_storage", + "max_streams" + ], + "properties": { + "max_memory": { + "type": "integer", + "description": "The maximum amount of Memory storage Stream Messages may consume", + "minimum": -1 + }, + "max_storage": { + "type": "integer", + "description": "The maximum amount of File storage Stream Messages may consume", + "minimum": -1 + }, + "max_streams": { + "type": "integer", + "description": "The maximum number of Streams an account can create", + "minimum": -1 + }, + "max_consumers": { + "type": "integer", + "description": "The maximum number of Consumer an account can create", + "minimum": -1 + }, + "max_bytes_required": { + "type": "boolean", + "description": "Indicates if Streams created in this account requires the max_bytes property set", + "default": false + }, + "max_ack_pending": { + "type": "integer", + "description": "The maximum number of outstanding ACKs any consumer may configure" + }, + "memory_max_stream_bytes": { + "type": "integer", + "description": "The maximum size any single memory stream may be", + "minimum": -1, + "default": -1 + }, + "storage_max_stream_bytes": { + "type": "integer", + "description": "The maximum size any single storage based stream may be", + "minimum": -1, + "default": -1 + } + } + }, + "stored_message": { + "type": "object", + "additionalProperties": false, + "required": [ + "subject", + "seq", + "time" + ], + "properties": { + "subject": { + "type": "string", + "description": "The subject the message was originally received on", + "minLength": 1 + }, + "seq": { + "description": "The sequence number of the message in the Stream", + "$ref": "#/definitions/golang_uint64" + }, + "data": { + "type": "string", + "description": "The base64 encoded payload of the message body", + "minLength": 0 + }, + "time": { + "type": "string", + "description": "The time the message was received" + }, + "hdrs": { + "type": "string", + "description": "Base64 encoded headers for the message" + } + } + }, + "iterable_request": { + "type": "object", + "additionalProperties": false, + "required": [ + "offset" + ], + "properties": { + "offset": { + "type": "integer", + "minimum": 0 + } + } + }, + "iterable_response": { + "type": "object", + "required": [ + "total", + "offset", + "limit" + ], + "properties": { + "total": { + "type": "integer", + "minimum": 0 + }, + "offset": { + "type": "integer", + "minimum": 0 + }, + "limit": { + "type": "integer", + "minimum": 0 + } + } + }, + "error_response": { + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "$ref": "#/definitions/api_error" + } + } + }, + "api_error": { + "type": "object", + "required": [ + "code" + ], + "properties": { + "code": { + "type": "integer", + "description": "HTTP like error code in the 300 to 500 range", + "minimum": 300, + "maximum": 699 + }, + "description": { + "type": "string", + "description": "A human friendly description of the error" + }, + "err_code": { + "type": "integer", + "description": "The NATS error code unique to each kind of error", + "minimum": 0, + "maximum": 65535 + } + } + }, + "basic_name": { + "type": "string", + "pattern": "^[^.*>]+$", + "minLength": 1 + }, + "sequence_info": { + "type": "object", + "additionalProperties": false, + "required": [ + "consumer_seq", + "stream_seq" + ], + "properties": { + "consumer_seq": { + "$ref": "#/definitions/golang_uint64", + "description": "The sequence number of the Consumer" + }, + "stream_seq": { + "$ref": "#/definitions/golang_uint64", + "description": "The sequence number of the Stream" + }, + "last_active": { + "description": "The last time a message was delivered or acknowledged (for ack_floor)", + "$ref": "#/definitions/golang_time" + } + } + }, + "sequence_pair": { + "type": "object", + "additionalProperties": false, + "required": [ + "consumer_seq", + "stream_seq" + ], + "properties": { + "consumer_seq": { + "$ref": "#/definitions/golang_uint64", + "description": "The sequence number of the Consumer" + }, + "stream_seq": { + "$ref": "#/definitions/golang_uint64", + "description": "The sequence number of the Stream" + } + } + }, + "consumer_info": { + "required": [ + "stream_name", + "name", + "config", + "created", + "delivered", + "ack_floor", + "num_ack_pending", + "num_redelivered", + "num_waiting", + "num_pending" + ], + "type": "object", + "properties": { + "stream_name": { + "type": "string", + "description": "The Stream the consumer belongs to" + }, + "name": { + "type": "string", + "description": "A unique name for the consumer, either machine generated or the durable name" + }, + "ts": { + "description": "The server time the consumer info was created", + "$ref": "#/definitions/golang_time" + }, + "config": { + "$ref": "#/definitions/consumer_configuration" + }, + "created": { + "description": "The time the Consumer was created", + "$ref": "#/definitions/golang_time" + }, + "delivered": { + "description": "The last message delivered from this Consumer", + "$ref": "#/definitions/sequence_info" + }, + "ack_floor": { + "description": "The highest contiguous acknowledged message", + "$ref": "#/definitions/sequence_info" + }, + "num_ack_pending": { + "description": "The number of messages pending acknowledgement", + "$ref": "#/definitions/golang_int", + "minimum": 0 + }, + "num_redelivered": { + "description": "The number of redeliveries that have been performed", + "$ref": "#/definitions/golang_int", + "minimum": 0 + }, + "num_waiting": { + "description": "The number of pull consumers waiting for messages", + "$ref": "#/definitions/golang_int", + "minimum": 0 + }, + "num_pending": { + "description": "The number of messages left unconsumed in this Consumer", + "$ref": "#/definitions/golang_uint64", + "minimum": 0 + }, + "cluster": { + "$ref": "#/definitions/cluster_info" + }, + "push_bound": { + "description": "Indicates if any client is connected and receiving messages from a push consumer", + "type": "boolean" + } + } + }, + "consumer_configuration": { + "required": [ + "deliver_policy", + "ack_policy", + "replay_policy" + ], + "properties": { + "deliver_policy": { + "type": "string", + "enum": [ + "all", + "last", + "new", + "by_start_sequence", + "by_start_time", + "last_per_subject" + ] + }, + "opt_start_seq": { + "$ref": "#/definitions/golang_uint64", + "minimum": 0 + }, + "opt_start_time": { + "$ref": "#/definitions/golang_time" + }, + "durable_name": { + "description": "A unique name for a durable consumer", + "deprecationMessage": "Durable is deprecated. All consumers will have names. picked by clients.", + "$ref": "#/definitions/basic_name" + }, + "name": { + "description": "A unique name for a consumer", + "$ref": "#/definitions/basic_name" + }, + "description": { + "description": "A short description of the purpose of this consumer", + "type": "string", + "maxLength": 4096 + }, + "deliver_subject": { + "type": "string", + "minLength": 1 + }, + "ack_policy": { + "type": "string", + "enum": [ + "none", + "all", + "explicit" + ], + "default": "none" + }, + "ack_wait": { + "description": "How long (in nanoseconds) to allow messages to remain un-acknowledged before attempting redelivery", + "$ref": "#/definitions/golang_duration_nanos", + "minimum": 1, + "default": "30000000000" + }, + "max_deliver": { + "$ref": "#/definitions/golang_int", + "description": "The number of times a message will be redelivered to consumers if not acknowledged in time", + "default": -1 + }, + "filter_subject": { + "description": "Filter the stream by a single subjects", + "type": "string" + }, + "filter_subjects": { + "description": "Filter the stream by multiple subjects", + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + }, + "replay_policy": { + "type": "string", + "enum": [ + "instant", + "original" + ], + "default": "instant" + }, + "sample_freq": { + "type": "string" + }, + "rate_limit_bps": { + "$ref": "#/definitions/golang_uint64", + "description": "The rate at which messages will be delivered to clients, expressed in bit per second", + "minimum": 0 + }, + "max_ack_pending": { + "$ref": "#/definitions/golang_int", + "description": "The maximum number of messages without acknowledgement that can be outstanding, once this limit is reached message delivery will be suspended", + "default": 1000 + }, + "idle_heartbeat": { + "$ref": "#/definitions/golang_duration_nanos", + "minimum": 0, + "description": "If the Consumer is idle for more than this many nano seconds a empty message with Status header 100 will be sent indicating the consumer is still alive" + }, + "flow_control": { + "type": "boolean", + "description": "For push consumers this will regularly send an empty mess with Status header 100 and a reply subject, consumers must reply to these messages to control the rate of message delivery" + }, + "max_waiting": { + "$ref": "#/definitions/golang_int", + "description": "The number of pulls that can be outstanding on a pull consumer, pulls received after this is reached are ignored", + "minimum": 0, + "default": 512 + }, + "direct": { + "type": "boolean", + "description": "Creates a special consumer that does not touch the Raft layers, not for general use by clients, internal use only", + "default": false + }, + "headers_only": { + "type": "boolean", + "default": false, + "description": "Delivers only the headers of messages in the stream and not the bodies. Additionally adds Nats-Msg-Size header to indicate the size of the removed payload" + }, + "max_batch": { + "type": "integer", + "description": "The largest batch property that may be specified when doing a pull on a Pull Consumer", + "default": 0 + }, + "max_expires": { + "description": "The maximum expires value that may be set when doing a pull on a Pull Consumer", + "$ref": "#/definitions/golang_duration_nanos", + "default": 0 + }, + "max_bytes": { + "description": "The maximum bytes value that maybe set when dong a pull on a Pull Consumer", + "$ref": "#/definitions/golang_int", + "minimum": 0, + "default": 0 + }, + "inactive_threshold": { + "description": "Duration that instructs the server to cleanup ephemeral consumers that are inactive for that long", + "$ref": "#/definitions/golang_duration_nanos", + "default": 0 + }, + "backoff": { + "description": "List of durations in Go format that represents a retry time scale for NaK'd messages", + "type": "array", + "items": { + "$ref": "#/definitions/golang_duration_nanos" + } + }, + "num_replicas": { + "description": "When set do not inherit the replica count from the stream but specifically set it to this amount", + "type": "integer", + "$ref": "#/definitions/golang_int", + "minimum": 0, + "maximum": 5 + }, + "mem_storage": { + "description": "Force the consumer state to be kept in memory rather than inherit the setting from the stream", + "type": "boolean", + "default": false + }, + "metadata": { + "description": "Additional metadata for the Consumer", + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "anyOf": [ + { + "if": { + "properties": { + "deliver_policy": { + "const": "by_start_sequence" + } + } + }, + "then": { + "required": [ + "opt_start_seq" + ] + } + }, + { + "if": { + "properties": { + "deliver_policy": { + "const": "opt_start_time" + } + } + }, + "then": { + "required": [ + "opt_start_seq" + ] + } + } + ] + }, + "stream_info": { + "type": "object", + "required": [ + "config", + "state", + "created" + ], + "properties": { + "config": { + "type": "object", + "description": "The active configuration for the Stream", + "$ref": "#/definitions/stream_configuration" + }, + "state": { + "type": "object", + "description": "Detail about the current State of the Stream", + "$ref": "#/definitions/stream_state" + }, + "created": { + "description": "Timestamp when the stream was created", + "$ref": "#/definitions/golang_time" + }, + "ts": { + "description": "The server time the stream info was created", + "$ref": "#/definitions/golang_time" + }, + "cluster": { + "$ref": "#/definitions/cluster_info" + }, + "mirror": { + "$ref": "#/definitions/stream_source_info" + }, + "sources": { + "type": "array", + "description": "Streams being sourced into this Stream", + "items": { + "$ref": "#/definitions/stream_source_info" + } + }, + "alternates": { + "type": "array", + "description": "List of mirrors sorted by priority", + "items": { + "$ref": "#/definitions/stream_alternate" + } + } + } + }, + "stream_alternate": { + "type": "object", + "description": "An alternate location to read mirrored data", + "required": [ + "name", + "cluster" + ], + "properties": { + "name": { + "type": "string", + "description": "The mirror stream name" + }, + "cluster": { + "type": "string", + "description": "The name of the cluster holding the stream" + }, + "domain": { + "type": "string", + "description": "The domain holding the string" + } + } + }, + "stream_state": { + "type": "object", + "additionalProperties": false, + "required": [ + "messages", + "bytes", + "first_seq", + "last_seq", + "consumer_count" + ], + "properties": { + "messages": { + "$ref": "#/definitions/golang_uint64", + "description": "Number of messages stored in the Stream", + "minimum": 0 + }, + "bytes": { + "$ref": "#/definitions/golang_uint64", + "description": "Combined size of all messages in the Stream", + "minimum": 0 + }, + "first_seq": { + "$ref": "#/definitions/golang_uint64", + "description": "Sequence number of the first message in the Stream", + "minimum": 0 + }, + "first_ts": { + "type": "string", + "description": "The timestamp of the first message in the Stream" + }, + "last_seq": { + "$ref": "#/definitions/golang_uint64", + "description": "Sequence number of the last message in the Stream", + "minimum": 0 + }, + "last_ts": { + "type": "string", + "description": "The timestamp of the last message in the Stream" + }, + "deleted": { + "description": "IDs of messages that were deleted using the Message Delete API or Interest based streams removing messages out of order", + "type": "array", + "minLength": 0, + "items": { + "$ref": "#/definitions/golang_uint64", + "minimum": 0 + } + }, + "subjects": { + "description": "Subjects and their message counts when a subjects_filter was set", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/golang_uint64" + } + }, + "num_subjects": { + "description": "The number of unique subjects held in the stream", + "$ref": "#/definitions/golang_int", + "minimum": 0 + }, + "num_deleted": { + "description": "The number of deleted messages", + "$ref": "#/definitions/golang_int", + "minimum": 0 + }, + "lost": { + "$ref": "#/definitions/lost_stream_data" + }, + "consumer_count": { + "$ref": "#/definitions/golang_int", + "description": "Number of Consumers attached to the Stream", + "minimum": 0 + } + } + }, + "subject_transform": { + "type": "object", + "description": "Subject transform to apply to matching messages going into the stream", + "required": [ + "dest" + ], + "properties": { + "src": { + "type": "string", + "description": "The subject transform source" + }, + "dest": { + "type": "string", + "description": "The subject transform destination" + } + } + }, + "republish": { + "type": "object", + "description": "Rules for republishing messages from a stream with subject mapping onto new subjects for partitioning and more", + "required": [ + "src", + "dest" + ], + "properties": { + "src": { + "type": "string", + "description": "The source subject to republish" + }, + "dest": { + "type": "string", + "description": "The destination to publish to" + }, + "headers_only": { + "type": "boolean", + "description": "Only send message headers, no bodies", + "default": false + } + } + }, + "stream_configuration": { + "type": "object", + "required": [ + "retention", + "max_consumers", + "max_msgs", + "max_bytes", + "max_age", + "storage", + "num_replicas" + ], + "additionalProperties": false, + "properties": { + "name": { + "description": "A unique name for the Stream, empty for Stream Templates.", + "type": "string", + "pattern": "^[^.*>]*$", + "minLength": 0 + }, + "description": { + "description": "A short description of the purpose of this stream", + "type": "string", + "maxLength": 4096 + }, + "subjects": { + "description": "A list of subjects to consume, supports wildcards. Must be empty when a mirror is configured. May be empty when sources are configured.", + "type": "array", + "minLength": 0, + "items": { + "type": "string" + } + }, + "subject_transform": { + "description": "Subject transform to apply to matching messages", + "$ref": "#/definitions/subject_transform" + }, + "retention": { + "description": "How messages are retained in the Stream, once this is exceeded old messages are removed.", + "type": "string", + "enum": [ + "limits", + "interest", + "workqueue" + ], + "default": "limits" + }, + "max_consumers": { + "description": "How many Consumers can be defined for a given Stream. -1 for unlimited.", + "$ref": "#/definitions/golang_int", + "minimum": -1, + "default": -1 + }, + "max_msgs": { + "description": "How many messages may be in a Stream, oldest messages will be removed if the Stream exceeds this size. -1 for unlimited.", + "$ref": "#/definitions/golang_int64", + "minimum": -1, + "default": -1 + }, + "max_msgs_per_subject": { + "description": "For wildcard streams ensure that for every unique subject this many messages are kept - a per subject retention limit", + "$ref": "#/definitions/golang_int64", + "minimum": -1, + "default": -1 + }, + "max_bytes": { + "description": "How big the Stream may be, when the combined stream size exceeds this old messages are removed. -1 for unlimited.", + "$ref": "#/definitions/golang_int64", + "minimum": -1, + "default": -1 + }, + "max_age": { + "description": "Maximum age of any message in the stream, expressed in nanoseconds. 0 for unlimited.", + "$ref": "#/definitions/golang_duration_nanos", + "minimum": 0, + "default": 0 + }, + "max_msg_size": { + "description": "The largest message that will be accepted by the Stream. -1 for unlimited.", + "$ref": "#/definitions/golang_int32", + "minimum": -1, + "default": -1 + }, + "storage": { + "description": "The storage backend to use for the Stream.", + "type": "string", + "enum": [ + "file", + "memory" + ], + "default": "file" + }, + "compression": { + "description": "Optional compression algorithm used for the Stream.", + "type": "string", + "enum": [ + "none", + "s2" + ], + "default": "none" + }, + "num_replicas": { + "description": "How many replicas to keep for each message.", + "$ref": "#/definitions/golang_int", + "minimum": 1, + "default": 1, + "maximum": 5 + }, + "no_ack": { + "description": "Disables acknowledging messages that are received by the Stream.", + "type": "boolean", + "default": false + }, + "template_owner": { + "description": "When the Stream is managed by a Stream Template this identifies the template that manages the Stream.", + "type": "string" + }, + "discard": { + "description": "When a Stream reach it's limits either old messages are deleted or new ones are denied", + "type": "string", + "enum": [ + "old", + "new" + ], + "default": "old" + }, + "duplicate_window": { + "description": "The time window to track duplicate messages for, expressed in nanoseconds. 0 for default", + "$ref": "#/definitions/golang_duration_nanos", + "minimum": 0, + "default": 0 + }, + "placement": { + "description": "Placement directives to consider when placing replicas of this stream, random placement when unset", + "$ref": "#/definitions/placement" + }, + "mirror": { + "description": "Maintains a 1:1 mirror of another stream with name matching this property. When a mirror is configured subjects and sources must be empty.", + "$ref": "#/definitions/stream_source" + }, + "sources": { + "type": "array", + "description": "List of Stream names to replicate into this Stream", + "items": { + "$ref": "#/definitions/stream_source" + } + }, + "sealed": { + "type": "boolean", + "default": false, + "description": "Sealed streams do not allow messages to be deleted via limits or API, sealed streams can not be unsealed via configuration update. Can only be set on already created streams via the Update API" + }, + "deny_delete": { + "type": "boolean", + "default": false, + "description": "Restricts the ability to delete messages from a stream via the API. Cannot be changed once set to true" + }, + "deny_purge": { + "type": "boolean", + "default": false, + "description": "Restricts the ability to purge messages from a stream via the API. Cannot be change once set to true" + }, + "allow_rollup_hdrs": { + "type": "boolean", + "default": false, + "description": "Allows the use of the Nats-Rollup header to replace all contents of a stream, or subject in a stream, with a single new message" + }, + "allow_direct": { + "type": "boolean", + "default": false, + "description": "Allow higher performance, direct access to get individual messages" + }, + "mirror_direct": { + "type": "boolean", + "default": false, + "description": "Allow higher performance, direct access for mirrors as well" + }, + "republish": { + "$ref": "#/definitions/republish" + }, + "discard_new_per_subject": { + "type": "boolean", + "description": "When discard policy is new and the stream is one with max messages per subject set, this will apply the new behavior to every subject. Essentially turning discard new from maximum number of subjects into maximum number of messages in a subject.", + "default": false + }, + "metadata": { + "description": "Additional metadata for the Stream", + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, + "stream_template_info": { + "type": "object", + "required": [ + "config", + "streams" + ], + "properties": { + "config": { + "$ref": "#/definitions/stream_template_configuration" + }, + "streams": { + "description": "List of Streams managed by this Template", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "stream_template_configuration": { + "description": "The data structure that describe the configuration of a NATS JetStream Stream Template", + "title": "io.nats.jetstream.api.v1.stream_template_configuration", + "type": "object", + "required": [ + "name", + "config", + "max_streams" + ], + "additionalProperties": false, + "properties": { + "name": { + "description": "A unique name for the Stream Template.", + "$ref": "#/definitions/basic_name" + }, + "max_streams": { + "description": "The maximum number of Streams this Template can create, -1 for unlimited.", + "minimum": -1, + "default": -1, + "$ref": "#/definitions/golang_int32" + }, + "config": { + "$ref": "#/definitions/stream_configuration" + } + } + }, + "account_info_response": { + "description": "A response from the JetStream $JS.API.INFO API", + "title": "io.nats.jetstream.api.v1.account_info_response", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/account_stats" + } + ] + }, + "account_purge_response": { + "description": "A response from the JetStream $JS.API.ACCOUNT.PURGE API", + "title": "io.nats.jetstream.api.v1.account_purge_response", + "type": "object", + "properties": { + "initiated": { + "type": "boolean", + "description": "If the purge operation was succesfully started", + "default": false + } + } + }, + "consumer_create_request": { + "description": "A request to the JetStream $JS.API.CONSUMER.CREATE and $JS.API.CONSUMER.DURABLE.CREATE APIs", + "title": "io.nats.jetstream.api.v1.consumer_create_request", + "type": "object", + "required": [ + "stream_name", + "config" + ], + "properties": { + "stream_name": { + "type": "string", + "description": "The name of the stream to create the consumer in" + }, + "config": { + "type": "object", + "description": "The consumer configuration", + "$ref": "#/definitions/consumer_configuration" + } + } + }, + "consumer_create_response": { + "description": "A response from the JetStream $JS.API.CONSUMER.CREATE API", + "title": "io.nats.jetstream.api.v1.consumer_create_response", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/consumer_info" + } + ] + }, + "consumer_delete_response": { + "description": "A response from the JetStream $JS.API.CONSUMER.DELETE API", + "title": "io.nats.jetstream.api.v1.consumer_delete_response", + "type": "object", + "required": [ + "success" + ], + "properties": { + "success": { + "type": "boolean" + } + } + }, + "consumer_getnext_request": { + "description": "A request to the JetStream $JS.API.CONSUMER.MSG.NEXT API", + "title": "io.nats.jetstream.api.v1.consumer_getnext_request", + "type": "object", + "properties": { + "expires": { + "$ref": "#/definitions/golang_duration_nanos", + "description": "A duration from now when the pull should expire, stated in nanoseconds, 0 for no expiry" + }, + "batch": { + "$ref": "#/definitions/golang_int", + "description": "How many messages the server should deliver to the requestor", + "minimum": 0, + "maximum": 256 + }, + "max_bytes": { + "$ref": "#/definitions/golang_int", + "description": "Sends at most this many bytes to the requestor, limited by consumer configuration max_bytes", + "minimum": 0 + }, + "no_wait": { + "type": "boolean", + "description": "When true a response with a 404 status header will be returned when no messages are available" + }, + "idle_heartbeat": { + "$ref": "#/definitions/golang_duration_nanos", + "description": "When not 0 idle heartbeats will be sent on this interval" + } + } + }, + "consumer_info_response": { + "description": "A response from the JetStream $JS.API.CONSUMER.INFO API", + "title": "io.nats.jetstream.api.v1.consumer_info_response", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/consumer_info" + } + ] + }, + "consumer_leader_stepdown_response": { + "description": "A response from the JetStream $JS.API.CONSUMER.LEADER.STEPDOWN API", + "title": "io.nats.jetstream.api.v1.consumer_leader_stepdown_response", + "type": "object", + "required": [ + "success" + ], + "properties": { + "success": { + "type": "boolean", + "description": "If the leader successfully stood down", + "default": false + } + } + }, + "consumer_list_request": { + "description": "A request to the JetStream $JS.API.CONSUMER.LIST API", + "title": "io.nats.jetstream.api.v1.consumer_list_request", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/iterable_request" + } + ] + }, + "consumer_list_response": { + "description": "A response from the JetStream $JS.API.CONSUMER.LIST API", + "title": "io.nats.jetstream.api.v1.consumer_list_response", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/iterable_response" + } + ], + "required": [ + "consumers" + ], + "properties": { + "consumers": { + "description": "Full Consumer information for each known Consumer", + "type": "array", + "items": { + "$ref": "#/definitions/consumer_info" + }, + "missing": { + "description": "In clustered environments gathering Consumer info might time out, this list would be a list of Consumers for which information was not obtainable", + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, + "consumer_names_request": { + "description": "A request to the JetStream $JS.API.CONSUMER.NAMES API", + "title": "io.nats.jetstream.api.v1.consumer_names_request", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/iterable_request" + } + ], + "properties": { + "subject": { + "type": "string", + "description": "Filter the names to those consuming messages matching this subject or wildcard" + } + } + }, + "consumer_names_response": { + "description": "A response from the JetStream $JS.API.CONSUMER.NAMES API", + "title": "io.nats.jetstream.api.v1.consumer_names_response", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/iterable_response" + } + ], + "required": [ + "consumers" + ], + "properties": { + "consumers": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "meta_leader_stepdown_request": { + "description": "A request to the JetStream $JS.API.META.LEADER.STEPDOWN API", + "title": "io.nats.jetstream.api.v1.meta_leader_stepdown_request", + "type": "object", + "properties": { + "placement": { + "$ref": "#/definitions/placement" + } + } + }, + "meta_leader_stepdown_response": { + "description": "A response from the JetStream $JS.API.META.LEADER.STEPDOWN API", + "title": "io.nats.jetstream.api.v1.meta_leader_stepdown_response", + "type": "object", + "required": [ + "success" + ], + "properties": { + "success": { + "type": "boolean", + "description": "If the leader successfully stood down", + "default": false + } + } + }, + "meta_server_remove_request": { + "description": "A request to the JetStream $JS.API.SERVER.REMOVE API", + "title": "io.nats.jetstream.api.v1.meta_server_remove_request", + "type": "object", + "properties": { + "peer": { + "type": "string", + "description": "The Name of the server to remove from the meta group" + }, + "peer_id": { + "type": "string", + "description": "Peer ID of the peer to be removed. If specified this is used instead of the server name" + } + } + }, + "meta_server_remove_response": { + "description": "A response from the JetStream $JS.API.SERVER.REMOVE API", + "title": "io.nats.jetstream.api.v1.meta_server_remove_response", + "required": [ + "success" + ], + "type": "object", + "properties": { + "success": { + "type": "boolean", + "description": "If the peer was successfully removed", + "default": false + } + } + }, + "pub_ack_response": { + "description": "A response received when publishing a message", + "title": "io.nats.jetstream.api.v1.pub_ack_response", + "type": "object", + "required": [ + "stream" + ], + "additionalProperties": false, + "properties": { + "error": { + "$ref": "#/definitions/api_error" + }, + "stream": { + "type": "string", + "description": "The name of the stream that received the message", + "minLength": 1 + }, + "seq": { + "type": "integer", + "description": "If successful this will be the sequence the message is stored at", + "$ref": "#/definitions/golang_uint64" + }, + "duplicate": { + "type": "boolean", + "description": "Indicates that the message was not stored due to the Nats-Msg-Id header and duplicate tracking", + "default": false + }, + "domain": { + "type": "string", + "description": "If the Stream accepting the message is in a JetStream server configured for a domain this would be that domain" + } + } + }, + "stream_create_request": { + "description": "A request to the JetStream $JS.API.STREAM.CREATE API", + "title": "io.nats.jetstream.api.v1.stream_create_request", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/stream_configuration" + } + ] + }, + "stream_create_response": { + "description": "A response from the JetStream $JS.API.STREAM.CREATE API", + "title": "io.nats.jetstream.api.v1.stream_create_response", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/stream_info" + } + ] + }, + "stream_delete_response": { + "description": "A response from the JetStream $JS.API.STREAM.DELETE API", + "title": "io.nats.jetstream.api.v1.stream_delete_response", + "type": "object", + "required": [ + "success" + ], + "properties": { + "success": { + "type": "boolean" + } + } + }, + "stream_info_request": { + "description": "A request to the JetStream $JS.API.STREAM.INFO API", + "title": "io.nats.jetstream.api.v1.stream_info_request", + "type": "object", + "properties": { + "deleted_details": { + "type": "boolean", + "description": "When true will result in a full list of deleted message IDs being returned in the info response" + }, + "subjects_filter": { + "type": "string", + "description": "When set will return a list of subjects and how many messages they hold for all matching subjects. Filter is a standard NATS subject wildcard pattern." + }, + "offset": { + "type": "integer", + "minimum": 0, + "description": "Paging offset when retrieving pages of subjet details" + } + } + }, + "stream_info_response": { + "description": "A response from the JetStream $JS.API.STREAM.INFO API", + "title": "io.nats.jetstream.api.v1.stream_info_response", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/stream_info" + } + ], + "properties": { + "total": { + "type": "integer", + "minimum": 0 + }, + "offset": { + "type": "integer", + "minimum": 0 + }, + "limit": { + "type": "integer", + "minimum": 0 + } + } + }, + "stream_leader_stepdown_response": { + "description": "A response from the JetStream $JS.API.STREAM.LEADER.STEPDOWN API", + "title": "io.nats.jetstream.api.v1.stream_leader_stepdown_response", + "type": "object", + "required": [ + "success" + ], + "properties": { + "success": { + "type": "boolean", + "description": "If the leader successfully stood down", + "default": false + } + } + }, + "stream_list_request": { + "description": "A request to the JetStream $JS.API.STREAM.LIST API", + "title": "io.nats.jetstream.api.v1.stream_list_request", + "type": "object", + "properties": { + "subject": { + "type": "string", + "description": "Limit the list to streams matching this subject filter" + }, + "offset": { + "type": "integer", + "minimum": 0 + } + } + }, + "stream_list_response": { + "description": "A response from the JetStream $JS.API.STREAM.LIST API", + "title": "io.nats.jetstream.api.v1.stream_list_response", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/iterable_response" + } + ], + "required": [ + "streams" + ], + "properties": { + "streams": { + "description": "Full Stream information for each known Stream", + "type": "array", + "items": { + "$ref": "#/definitions/stream_info" + } + }, + "missing": { + "description": "In clustered environments gathering Stream info might time out, this list would be a list of Streams for which information was not obtainable", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "stream_msg_delete_request": { + "description": "A request to the JetStream $JS.API.STREAM.MSG.DELETE API", + "title": "io.nats.jetstream.api.v1.stream_msg_delete_request", + "type": "object", + "required": [ + "seq" + ], + "properties": { + "seq": { + "description": "Stream sequence number of the message to delete", + "$ref": "#/definitions/golang_uint64" + }, + "no_erase": { + "type": "boolean", + "description": "Default will securely remove a message and rewrite the data with random data, set this to true to only remove the message" + } + } + }, + "stream_msg_delete_response": { + "description": "A response from the JetStream $JS.API.STREAM.MSG.DELETE API", + "title": "io.nats.jetstream.api.v1.stream_msg_delete_response", + "type": "object", + "required": [ + "success" + ], + "properties": { + "success": { + "type": "boolean" + } + } + }, + "stream_msg_get_request": { + "description": "A request to the JetStream $JS.API.STREAM.MSG.GET API", + "title": "io.nats.jetstream.api.v1.stream_msg_get_request", + "type": "object", + "properties": { + "seq": { + "type": "integer", + "description": "Stream sequence number of the message to retrieve, cannot be combined with last_by_subj" + }, + "last_by_subj": { + "type": "string", + "description": "Retrieves the last message for a given subject, cannot be combined with seq" + }, + "next_by_subj": { + "type": "string", + "description": "Combined with sequence gets the next message for a subject with the given sequence or higher" + } + } + }, + "stream_msg_get_response": { + "description": "A response from the JetStream $JS.API.STREAM.MSG.GET API", + "title": "io.nats.jetstream.api.v1.stream_msg_get_response", + "type": "object", + "required": [ + "message" + ], + "properties": { + "message": { + "$ref": "#/definitions/stored_message" + } + } + }, + "stream_names_request": { + "description": "A request to the JetStream $JS.API.STREAM.NAMES API", + "title": "io.nats.jetstream.api.v1.stream_names_request", + "type": "object", + "properties": { + "subject": { + "type": "string", + "description": "Limit the list to streams matching this subject filter" + }, + "offset": { + "type": "integer", + "minimum": 0 + } + } + }, + "stream_names_response": { + "description": "A response from the JetStream $JS.API.STREAM.NAMES API", + "title": "io.nats.jetstream.api.v1.stream_names_response", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/iterable_response" + } + ], + "required": [ + "streams" + ], + "properties": { + "consumers": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "stream_purge_request": { + "description": "A request to the JetStream $JS.API.STREAM.PURGE API", + "title": "io.nats.jetstream.api.v1.stream_purge_request", + "type": "object", + "properties": { + "filter": { + "type": "string", + "description": "Restrict purging to messages that match this subject" + }, + "seq": { + "description": "Purge all messages up to but not including the message with this sequence. Can be combined with subject filter but not the keep option", + "$ref": "#/definitions/golang_uint64" + }, + "keep": { + "description": "Ensures this many messages are present after the purge. Can be combined with the subject filter but not the sequence", + "$ref": "#/definitions/golang_uint64" + } + } + }, + "stream_purge_response": { + "description": "A response from the JetStream $JS.API.STREAM.PURGE API", + "title": "io.nats.jetstream.api.v1.stream_purge_response", + "type": "object", + "required": [ + "success", + "purged" + ], + "properties": { + "success": { + "type": "boolean" + }, + "purged": { + "description": "Number of messages purged from the Stream", + "$ref": "#/definitions/golang_uint64" + } + } + }, + "stream_remove_peer_request": { + "description": "A request to the JetStream $JS.API.STREAM.PEER.REMOVE API", + "title": "io.nats.jetstream.api.v1.stream_remove_peer_request", + "type": "object", + "required": [ + "peer" + ], + "additionalProperties": false, + "properties": { + "peer": { + "type": "string", + "description": "Server name of the peer to remove", + "minLength": 1 + } + } + }, + "stream_remove_peer_response": { + "description": "A response from the JetStream $JS.API.STREAM.PEER.REMOVE API", + "title": "io.nats.jetstream.api.v1.stream_remove_peer_response", + "type": "object", + "required": [ + "success" + ], + "properties": { + "success": { + "type": "boolean", + "description": "If the peer was successfully removed", + "default": false + } + } + }, + "stream_restore_request": { + "description": "A response from the JetStream $JS.API.STREAM.RESTORE API", + "title": "io.nats.jetstream.api.v1.stream_restore_request", + "type": "object", + "required": [ + "config", + "state" + ], + "properties": { + "config": { + "$ref": "#/definitions/stream_configuration" + }, + "state": { + "$ref": "#/definitions/stream_state" + } + } + }, + "stream_restore_response": { + "description": "A response from the JetStream $JS.API.STREAM.RESTORE API", + "title": "io.nats.jetstream.api.v1.stream_restore_response", + "type": "object", + "required": [ + "deliver_subject" + ], + "properties": { + "deliver_subject": { + "type": "string", + "description": "The Subject to send restore chunks to", + "minLength": 1 + } + } + }, + "stream_snapshot_request": { + "description": "A request to the JetStream $JS.API.STREAM.SNAPSHOT API", + "title": "io.nats.jetstream.api.v1.stream_snapshot_request", + "type": "object", + "required": [ + "deliver_subject" + ], + "additionalProperties": false, + "properties": { + "deliver_subject": { + "type": "string", + "description": "The NATS subject where the snapshot will be delivered", + "minLength": 1 + }, + "no_consumers": { + "type": "boolean", + "description": "When true consumer states and configurations will not be present in the snapshot" + }, + "chunk_size": { + "type": "integer", + "description": "The size of data chunks to send to deliver_subject", + "minimum": 1024, + "$ref": "#/definitions/golang_int" + }, + "jsck": { + "type": "boolean", + "description": "Check all message's checksums prior to snapshot", + "default": false + } + } + }, + "stream_snapshot_response": { + "description": "A response from the JetStream $JS.API.STREAM.SNAPSHOT API", + "title": "io.nats.jetstream.api.v1.stream_snapshot_response", + "type": "object", + "required": [ + "config", + "state" + ], + "properties": { + "config": { + "$ref": "#/definitions/stream_configuration" + }, + "state": { + "$ref": "#/definitions/stream_state" + } + } + }, + "stream_template_create_request": { + "description": "A request to the JetStream $JS.API.STREAM.TEMPLATE.CREATE API", + "title": "io.nats.jetstream.api.v1.stream_template_create_request", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/stream_template_configuration" + } + ] + }, + "stream_template_create_response": { + "description": "A response from the JetStream $JS.API.STREAM.TEMPLATE.CREATE API", + "title": "io.nats.jetstream.api.v1.stream_template_create_response", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/stream_template_info" + } + ] + }, + "stream_template_delete_response": { + "description": "A response from the JetStream $JS.API.STREAM.TEMPLATE.DELETE API", + "title": "io.nats.jetstream.api.v1.stream_template_delete_response", + "type": "object", + "required": [ + "success" + ], + "properties": { + "success": { + "type": "boolean" + } + } + }, + "stream_template_info_response": { + "description": "A response from the JetStream $JS.API.STREAM.TEMPLATE.INFO API", + "title": "io.nats.jetstream.api.v1.stream_template_info_response", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/stream_template_info" + } + ] + }, + "stream_template_names_request": { + "description": "A request to the JetStream $JS.API.CONSUMER.LIST API", + "title": "io.nats.jetstream.api.v1.stream_template_names_request", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/iterable_request" + } + ] + }, + "stream_template_names_response": { + "description": "A response from the JetStream $JS.API.STREAM.TEMPLATE.NAMES API", + "title": "io.nats.jetstream.api.v1.stream_template_names_response", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/iterable_response" + } + ], + "required": [ + "streams" + ], + "properties": { + "consumers": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "stream_update_request": { + "description": "A request to the JetStream $JS.API.STREAM.UPDATE API", + "title": "io.nats.jetstream.api.v1.stream_update_request", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/stream_configuration" + } + ] + }, + "stream_update_response": { + "description": "A response from the JetStream $JS.API.STREAM.UPDATE API", + "title": "io.nats.jetstream.api.v1.stream_update_response", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/stream_info" + } + ] + } + } +} \ No newline at end of file diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/account_info_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/account_info_response.json new file mode 100644 index 000000000..babc7c7d6 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/account_info_response.json @@ -0,0 +1,10 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/account_info_response.json", + "description": "A response from the JetStream $JS.API.INFO API", + "title": "io.nats.jetstream.api.v1.account_info_response", + "type": "object", + "allOf": [{ + "$ref": "definitions.json#/definitions/account_stats" + }] +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/account_purge_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/account_purge_response.json new file mode 100644 index 000000000..4a6887c6b --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/account_purge_response.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/meta_account_purge_response.json", + "description": "A response from the JetStream $JS.API.ACCOUNT.PURGE API", + "title": "io.nats.jetstream.api.v1.account_purge_response", + "type": "object", + "properties": { + "initiated": { + "type": "boolean", + "description": "If the purge operation was succesfully started", + "default": false + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_create_request.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_create_request.json new file mode 100644 index 000000000..f56bae0b6 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_create_request.json @@ -0,0 +1,22 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/consumer_create_request.json", + "description": "A request to the JetStream $JS.API.CONSUMER.CREATE and $JS.API.CONSUMER.DURABLE.CREATE APIs", + "title": "io.nats.jetstream.api.v1.consumer_create_request", + "type": "object", + "required": [ + "stream_name", + "config" + ], + "properties": { + "stream_name": { + "type": "string", + "description": "The name of the stream to create the consumer in" + }, + "config": { + "type": "object", + "description": "The consumer configuration", + "$ref": "definitions.json#/definitions/consumer_configuration" + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_create_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_create_response.json new file mode 100644 index 000000000..a5d9235c3 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_create_response.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/consumer_create_response.json", + "description": "A response from the JetStream $JS.API.CONSUMER.CREATE API", + "title": "io.nats.jetstream.api.v1.consumer_create_response", + "type": "object", + "allOf": [ + { + "$ref": "definitions.json#/definitions/consumer_info" + } + ] +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_delete_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_delete_response.json new file mode 100644 index 000000000..602b7b8a6 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_delete_response.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/consumer_delete_response.json", + "description": "A response from the JetStream $JS.API.CONSUMER.DELETE API", + "title": "io.nats.jetstream.api.v1.consumer_delete_response", + "type": "object", + "required": ["success"], + "properties": { + "success": { + "type": "boolean" + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_getnext_request.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_getnext_request.json new file mode 100644 index 000000000..214f9fd8c --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_getnext_request.json @@ -0,0 +1,32 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/consumer_getnext_request.json", + "description": "A request to the JetStream $JS.API.CONSUMER.MSG.NEXT API", + "title": "io.nats.jetstream.api.v1.consumer_getnext_request", + "type": "object", + "properties": { + "expires": { + "$ref": "definitions.json#/definitions/golang_duration_nanos", + "description": "A duration from now when the pull should expire, stated in nanoseconds, 0 for no expiry" + }, + "batch": { + "$ref": "definitions.json#/definitions/golang_int", + "description": "How many messages the server should deliver to the requestor", + "minimum": 0, + "maximum": 256 + }, + "max_bytes": { + "$ref": "definitions.json#/definitions/golang_int", + "description": "Sends at most this many bytes to the requestor, limited by consumer configuration max_bytes", + "minimum": 0 + }, + "no_wait": { + "type": "boolean", + "description": "When true a response with a 404 status header will be returned when no messages are available" + }, + "idle_heartbeat": { + "$ref": "definitions.json#/definitions/golang_duration_nanos", + "description": "When not 0 idle heartbeats will be sent on this interval" + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_info_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_info_response.json new file mode 100644 index 000000000..5996e5617 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_info_response.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/consumer_info_response.json", + "description": "A response from the JetStream $JS.API.CONSUMER.INFO API", + "title": "io.nats.jetstream.api.v1.consumer_info_response", + "type": "object", + "allOf": [ + { + "$ref": "definitions.json#/definitions/consumer_info" + } + ] +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_leader_stepdown_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_leader_stepdown_response.json new file mode 100644 index 000000000..f76970da7 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_leader_stepdown_response.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/consumer_leader_stepdown_response.json", + "description": "A response from the JetStream $JS.API.CONSUMER.LEADER.STEPDOWN API", + "title": "io.nats.jetstream.api.v1.consumer_leader_stepdown_response", + "type": "object", + "required": ["success"], + "properties": { + "success": { + "type": "boolean", + "description": "If the leader successfully stood down", + "default": false + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_list_request.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_list_request.json new file mode 100644 index 000000000..440c8b1c7 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_list_request.json @@ -0,0 +1,10 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/consumer_list_request.json", + "description": "A request to the JetStream $JS.API.CONSUMER.LIST API", + "title": "io.nats.jetstream.api.v1.consumer_list_request", + "type": "object", + "allOf": [{ + "$ref": "definitions.json#/definitions/iterable_request" + }] +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_list_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_list_response.json new file mode 100644 index 000000000..7bdfb2d6c --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_list_response.json @@ -0,0 +1,29 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/consumer_list_response.json", + "description": "A response from the JetStream $JS.API.CONSUMER.LIST API", + "title": "io.nats.jetstream.api.v1.consumer_list_response", + "type": "object", + "allOf": [ + { + "$ref": "definitions.json#/definitions/iterable_response" + } + ], + "required": ["consumers"], + "properties": { + "consumers": { + "description": "Full Consumer information for each known Consumer", + "type": "array", + "items": { + "$ref": "definitions.json#/definitions/consumer_info" + }, + "missing": { + "description": "In clustered environments gathering Consumer info might time out, this list would be a list of Consumers for which information was not obtainable", + "type": "array", + "items": { + "type": "string" + } + } + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_names_request.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_names_request.json new file mode 100644 index 000000000..6ca9ac5d3 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_names_request.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/consumer_names_request.json", + "description": "A request to the JetStream $JS.API.CONSUMER.NAMES API", + "title": "io.nats.jetstream.api.v1.consumer_names_request", + "type": "object", + "allOf": [ + { + "$ref": "definitions.json#/definitions/iterable_request" + } + ], + "properties": { + "subject": { + "type": "string", + "description": "Filter the names to those consuming messages matching this subject or wildcard" + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_names_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_names_response.json new file mode 100644 index 000000000..02976f285 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/consumer_names_response.json @@ -0,0 +1,21 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/consumer_names_response.json", + "description": "A response from the JetStream $JS.API.CONSUMER.NAMES API", + "title": "io.nats.jetstream.api.v1.consumer_names_response", + "type": "object", + "allOf": [ + { + "$ref": "definitions.json#/definitions/iterable_response" + } + ], + "required": ["consumers"], + "properties": { + "consumers": { + "type": "array", + "items": { + "type": "string" + } + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/definitions.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/definitions.json new file mode 100644 index 000000000..3542fbe17 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/definitions.json @@ -0,0 +1,1097 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/definitions.json", + "title": "io.nats.jetstream.api.v1.definitions", + "description": "Shared definitions for the JetStream API", + "type": "object", + "definitions": { + "golang_duration_nanos": { + "$comment": "nanoseconds depicting a duration in time, signed 64 bit integer", + "$ref": "#/definitions/golang_int64" + }, + "golang_int": { + "$comment": "integer with a dynamic bit size depending on the platform the cluster runs on, can be up to 64bit", + "$ref": "#/definitions/golang_int64" + }, + "golang_uint64": { + "$comment": "unsigned 64 bit integer", + "type": "integer", + "minimum": 0, + "maximum": 18446744073709551615 + }, + "golang_int32": { + "$comment": "signed 32 bit integer", + "type": "integer", + "maximum": 2147483647, + "minimum": -2147483648 + }, + "golang_int64": { + "$comment": "signed 64 bit integer", + "type": "integer", + "maximum": 9223372036854775807, + "minimum": -9223372036854775808 + }, + "golang_time": { + "$comment": "A point in time in RFC3339 format including timezone, though typically in UTC", + "type": "string", + "format": "date-time" + }, + "stream_source": { + "type": "object", + "description": "Defines a source where streams should be replicated from", + "required": ["name"], + "properties": { + "name": { + "description": "Stream name", + "$ref": "#/definitions/basic_name" + }, + "opt_start_seq": { + "description": "Sequence to start replicating from", + "$ref": "#/definitions/golang_uint64" + }, + "opt_start_time": { + "description": "Time stamp to start replicating from", + "$ref": "#/definitions/golang_time" + }, + "filter_subject": { + "description": "Replicate only a subset of messages based on filter", + "type": "string" + }, + "subject_transform_dest" : { + "description": "Map matching subjects according to this transform destination", + "type": "string" + }, + "external": { + "$ref": "#/definitions/external_stream_source" + } + } + }, + "external_stream_source": { + "required": ["api"], + "type": "object", + "description": "Configuration referencing a stream source in another account or JetStream domain", + "properties": { + "api": { + "type": "string", + "description": "The subject prefix that imports the other account/domain $JS.API.CONSUMER.> subjects" + }, + "deliver": { + "type": "string", + "description": "The delivery subject to use for the push consumer" + } + } + }, + "stream_source_info": { + "required": ["name","lag","active"], + "type": "object", + "description": "Information about an upstream stream source in a mirror", + "properties": { + "name": { + "type": "string", + "description": "The name of the Stream being replicated" + }, + "filter_subject": { + "type": "string", + "description": "The subject filter to apply to the messages" + }, + "subject_transform_dest": { + "type": "string", + "description": "The subject transform destination to apply to the messages" + }, + "lag": { + "$ref": "#/definitions/golang_uint64", + "description": "How many messages behind the mirror operation is", + "minimum": 0 + }, + "active": { + "description": "When last the mirror had activity, in nanoseconds. Value will be -1 when there has been no activity.", + "$ref": "#/definitions/golang_duration_nanos", + "minimum": -1 + }, + "external": { + "$ref": "#/definitions/external_stream_source" + }, + "error": { + "$ref": "#/definitions/api_error" + } + } + }, + "lost_stream_data": { + "type": "object", + "description": "Records messages that were damaged and unrecoverable", + "properties": { + "msgs": { + "type": ["array","null"], + "description": "The messages that were lost", + "items": { + "$ref": "#/definitions/golang_uint64", + "minimum": 0 + } + }, + "bytes": { + "description": "The number of bytes that were lost", + "$ref": "#/definitions/golang_uint64" + } + } + }, + "placement": { + "type": "object", + "description": "Placement requirements for a stream", + "required": ["cluster"], + "properties": { + "cluster": { + "type": "string", + "description": "The desired cluster name to place the stream" + }, + "tags": { + "description": "Tags required on servers hosting this stream", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "peer_info": { + "type": "object", + "required": ["name", "current", "active"], + "properties": { + "name": { + "description": "The server name of the peer", + "type": "string", + "minimum": 1 + }, + "current": { + "description": "Indicates if the server is up to date and synchronised", + "type": "boolean", + "default": false + }, + "active": { + "description": "Nanoseconds since this peer was last seen", + "type": "number" + }, + "offline": { + "description": "Indicates the node is considered offline by the group", + "type": "boolean", + "default": false + }, + "lag": { + "description": "How many uncommitted operations this peer is behind the leader", + "type": "integer", + "minimum": 0 + } + } + }, + "cluster_info": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The cluster name" + }, + "leader": { + "type": "string", + "description": "The server name of the RAFT leader" + }, + "replicas": { + "type": "array", + "description": "The members of the RAFT cluster", + "items": { + "$ref": "#/definitions/peer_info" + } + } + } + }, + "api_stats": { + "type": "object", + "required": ["total", "errors"], + "properties": { + "total": { + "description": "Total number of API requests received for this account", + "minimum": 0, + "type": "integer" + }, + "errors": { + "description": "API requests that resulted in an error response", + "minimum": 0, + "type": "integer" + } + } + }, + "tier": { + "type": "object", + "required": [ + "memory", + "storage", + "streams", + "limits", + "consumers" + ], + "properties": { + "memory": { + "description": "Memory Storage being used for Stream Message storage", + "type": "integer", + "minimum": 0 + }, + "storage": { + "description": "File Storage being used for Stream Message storage", + "type": "integer", + "minimum": 0 + }, + "streams": { + "description": "Number of active Streams", + "type": "integer", + "minimum": 0 + }, + "consumers": { + "description": "Number of active Consumers", + "type": "integer", + "minimum": 0 + }, + "limits": { + "$ref": "#/definitions/account_limits" + } + } + }, + "account_stats": { + "type": "object", + "required": ["memory", "storage", "streams", "limits", "api", "consumers"], + "properties": { + "memory": { + "description": "Memory Storage being used for Stream Message storage", + "type": "integer", + "minimum": 0 + }, + "storage": { + "description": "File Storage being used for Stream Message storage", + "type": "integer", + "minimum": 0 + }, + "streams": { + "description": "Number of active Streams", + "type": "integer", + "minimum": 0 + }, + "consumers": { + "description": "Number of active Consumers", + "type": "integer", + "minimum": 0 + }, + "domain": { + "description": "The JetStream domain this account is in", + "type": "string" + }, + "limits": { + "$ref": "#/definitions/account_limits" + }, + "tiers": { + "type": "object", + "patternProperties": { + ".*": { + "$ref": "#/definitions/tier" + } + } + }, + "api": { + "$ref": "#/definitions/api_stats" + } + } + }, + "account_limits": { + "type": "object", + "additionalProperties": false, + "required": ["max_consumers", "max_memory", "max_storage", "max_streams"], + "properties": { + "max_memory": { + "type": "integer", + "description": "The maximum amount of Memory storage Stream Messages may consume", + "minimum": -1 + }, + "max_storage": { + "type": "integer", + "description": "The maximum amount of File storage Stream Messages may consume", + "minimum": -1 + }, + "max_streams": { + "type": "integer", + "description": "The maximum number of Streams an account can create", + "minimum": -1 + }, + "max_consumers": { + "type": "integer", + "description": "The maximum number of Consumer an account can create", + "minimum": -1 + }, + "max_bytes_required": { + "type": "boolean", + "description": "Indicates if Streams created in this account requires the max_bytes property set", + "default": false + }, + "max_ack_pending": { + "type": "integer", + "description": "The maximum number of outstanding ACKs any consumer may configure" + }, + "memory_max_stream_bytes": { + "type": "integer", + "description": "The maximum size any single memory stream may be", + "minimum": -1, + "default": -1 + }, + "storage_max_stream_bytes": { + "type": "integer", + "description": "The maximum size any single storage based stream may be", + "minimum": -1, + "default": -1 + } + } + }, + "stored_message": { + "type": "object", + "additionalProperties": false, + "required": ["subject", "seq", "time"], + "properties": { + "subject": { + "type": "string", + "description": "The subject the message was originally received on", + "minLength": 1 + }, + "seq": { + "description": "The sequence number of the message in the Stream", + "$ref": "#/definitions/golang_uint64" + }, + "data": { + "type": "string", + "description": "The base64 encoded payload of the message body", + "minLength": 0 + }, + "time": { + "type": "string", + "description": "The time the message was received" + }, + "hdrs": { + "type": "string", + "description": "Base64 encoded headers for the message" + } + } + }, + "iterable_request": { + "type": "object", + "additionalProperties": false, + "required": ["offset"], + "properties": { + "offset": { + "type": "integer", + "minimum": 0 + } + } + }, + "iterable_response": { + "type": "object", + "required": ["total", "offset", "limit"], + "properties": { + "total": { + "type": "integer", + "minimum": 0 + }, + "offset": { + "type": "integer", + "minimum": 0 + }, + "limit": { + "type": "integer", + "minimum": 0 + } + } + }, + "error_response": { + "type": "object", + "required": ["error"], + "properties": { + "error": { + "$ref": "#/definitions/api_error" + } + } + }, + "api_error": { + "type": "object", + "required": ["code"], + "properties": { + "code": { + "type": "integer", + "description": "HTTP like error code in the 300 to 500 range", + "minimum": 300, + "maximum": 699 + }, + "description": { + "type": "string", + "description": "A human friendly description of the error" + }, + "err_code": { + "type": "integer", + "description": "The NATS error code unique to each kind of error", + "minimum": 0, + "maximum": 65535 + } + } + }, + "basic_name": { + "type": "string", + "pattern": "^[^.*>]+$", + "minLength": 1 + }, + "sequence_info": { + "type": "object", + "additionalProperties": false, + "required": ["consumer_seq", "stream_seq"], + "properties": { + "consumer_seq": { + "$ref": "#/definitions/golang_uint64", + "description": "The sequence number of the Consumer" + }, + "stream_seq": { + "$ref": "#/definitions/golang_uint64", + "description": "The sequence number of the Stream" + }, + "last_active": { + "description": "The last time a message was delivered or acknowledged (for ack_floor)", + "$ref": "#/definitions/golang_time" + } + } + }, + "sequence_pair": { + "type": "object", + "additionalProperties": false, + "required": ["consumer_seq", "stream_seq"], + "properties": { + "consumer_seq": { + "$ref": "#/definitions/golang_uint64", + "description": "The sequence number of the Consumer" + }, + "stream_seq": { + "$ref": "#/definitions/golang_uint64", + "description": "The sequence number of the Stream" + } + } + }, + "consumer_info": { + "required": ["stream_name", "name", "config", "created", "delivered", "ack_floor", "num_ack_pending", "num_redelivered", "num_waiting", "num_pending"], + "type": "object", + "properties": { + "stream_name": { + "type": "string", + "description": "The Stream the consumer belongs to" + }, + "name": { + "type": "string", + "description": "A unique name for the consumer, either machine generated or the durable name" + }, + "ts": { + "description": "The server time the consumer info was created", + "$ref": "#/definitions/golang_time" + }, + "config": { + "$ref": "#/definitions/consumer_configuration" + }, + "created": { + "description": "The time the Consumer was created", + "$ref": "#/definitions/golang_time" + }, + "delivered": { + "description": "The last message delivered from this Consumer", + "$ref": "#/definitions/sequence_info" + }, + "ack_floor": { + "description": "The highest contiguous acknowledged message", + "$ref": "#/definitions/sequence_info" + }, + "num_ack_pending": { + "description": "The number of messages pending acknowledgement", + "$ref": "#/definitions/golang_int", + "minimum": 0 + }, + "num_redelivered": { + "description": "The number of redeliveries that have been performed", + "$ref": "#/definitions/golang_int", + "minimum": 0 + }, + "num_waiting": { + "description": "The number of pull consumers waiting for messages", + "$ref": "#/definitions/golang_int", + "minimum": 0 + }, + "num_pending": { + "description": "The number of messages left unconsumed in this Consumer", + "$ref": "#/definitions/golang_uint64", + "minimum": 0 + }, + "cluster": { + "$ref": "#/definitions/cluster_info" + }, + "push_bound": { + "description": "Indicates if any client is connected and receiving messages from a push consumer", + "type": "boolean" + } + } + }, + "consumer_configuration": { + "required":[ + "deliver_policy", + "ack_policy", + "replay_policy" + ], + "properties": { + "deliver_policy": { + "type": "string", + "enum": [ + "all", + "last", + "new", + "by_start_sequence", + "by_start_time", + "last_per_subject" + ] + }, + "opt_start_seq": { + "$ref": "#/definitions/golang_uint64", + "minimum": 0 + }, + "opt_start_time": { + "$ref": "#/definitions/golang_time" + }, + "durable_name": { + "description": "A unique name for a durable consumer", + "deprecationMessage": "Durable is deprecated. All consumers will have names. picked by clients.", + "$ref": "#/definitions/basic_name" + }, + "name": { + "description": "A unique name for a consumer", + "$ref": "#/definitions/basic_name" + }, + "description": { + "description": "A short description of the purpose of this consumer", + "type": "string", + "maxLength": 4096 + }, + "deliver_subject": { + "type": "string", + "minLength": 1 + }, + "ack_policy": { + "type": "string", + "enum": ["none", "all", "explicit"], + "default": "none" + }, + "ack_wait": { + "description": "How long (in nanoseconds) to allow messages to remain un-acknowledged before attempting redelivery", + "$ref": "#/definitions/golang_duration_nanos", + "minimum": 1, + "default": "30000000000" + }, + "max_deliver": { + "$ref": "#/definitions/golang_int", + "description": "The number of times a message will be redelivered to consumers if not acknowledged in time", + "default": -1 + }, + "filter_subject": { + "description": "Filter the stream by a single subjects", + "type": "string" + }, + "filter_subjects": { + "description": "Filter the stream by multiple subjects", + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + }, + "replay_policy": { + "type": "string", + "enum": ["instant", "original"], + "default": "instant" + }, + "sample_freq": { + "type": "string" + }, + "rate_limit_bps": { + "$ref": "#/definitions/golang_uint64", + "description": "The rate at which messages will be delivered to clients, expressed in bit per second", + "minimum": 0 + }, + "max_ack_pending": { + "$ref": "#/definitions/golang_int", + "description": "The maximum number of messages without acknowledgement that can be outstanding, once this limit is reached message delivery will be suspended", + "default": 1000 + }, + "idle_heartbeat": { + "$ref": "#/definitions/golang_duration_nanos", + "minimum": 0, + "description": "If the Consumer is idle for more than this many nano seconds a empty message with Status header 100 will be sent indicating the consumer is still alive" + }, + "flow_control": { + "type": "boolean", + "description": "For push consumers this will regularly send an empty mess with Status header 100 and a reply subject, consumers must reply to these messages to control the rate of message delivery" + }, + "max_waiting": { + "$ref": "#/definitions/golang_int", + "description": "The number of pulls that can be outstanding on a pull consumer, pulls received after this is reached are ignored", + "minimum": 0, + "default": 512 + }, + "direct": { + "type": "boolean", + "description": "Creates a special consumer that does not touch the Raft layers, not for general use by clients, internal use only", + "default": false + }, + "headers_only": { + "type": "boolean", + "default": false, + "description": "Delivers only the headers of messages in the stream and not the bodies. Additionally adds Nats-Msg-Size header to indicate the size of the removed payload" + }, + "max_batch": { + "type": "integer", + "description": "The largest batch property that may be specified when doing a pull on a Pull Consumer", + "default": 0 + }, + "max_expires": { + "description": "The maximum expires value that may be set when doing a pull on a Pull Consumer", + "$ref": "#/definitions/golang_duration_nanos", + "default": 0 + }, + "max_bytes": { + "description": "The maximum bytes value that maybe set when dong a pull on a Pull Consumer", + "$ref": "definitions.json#/definitions/golang_int", + "minimum": 0, + "default": 0 + }, + "inactive_threshold": { + "description": "Duration that instructs the server to cleanup ephemeral consumers that are inactive for that long", + "$ref": "#/definitions/golang_duration_nanos", + "default": 0 + }, + "backoff": { + "description": "List of durations in Go format that represents a retry time scale for NaK'd messages", + "type": "array", + "items": { + "$ref": "#/definitions/golang_duration_nanos" + } + }, + "num_replicas": { + "description": "When set do not inherit the replica count from the stream but specifically set it to this amount", + "type": "integer", + "$ref": "#/definitions/golang_int", + "minimum": 0, + "maximum": 5 + }, + "mem_storage": { + "description": "Force the consumer state to be kept in memory rather than inherit the setting from the stream", + "type": "boolean", + "default": false + }, + "metadata": { + "description": "Additional metadata for the Consumer", + "type": "object", + "additionalProperties": { "type": "string" } + } + }, + "anyOf": [ + { + "if": { + "properties": { + "deliver_policy": { "const": "by_start_sequence" } + } + }, + "then": { "required": ["opt_start_seq"] } + }, + { + "if": { + "properties": { + "deliver_policy": { "const": "opt_start_time" } + } + }, + "then": { "required": ["opt_start_seq"] } + } + ] + }, + "stream_info": { + "type": "object", + "required": ["config", "state", "created"], + "properties": { + "config": { + "type": "object", + "description": "The active configuration for the Stream", + "$ref": "#/definitions/stream_configuration" + }, + "state": { + "type": "object", + "description": "Detail about the current State of the Stream", + "$ref": "#/definitions/stream_state" + }, + "created": { + "description": "Timestamp when the stream was created", + "$ref": "#/definitions/golang_time" + }, + "ts": { + "description": "The server time the stream info was created", + "$ref": "#/definitions/golang_time" + }, + "cluster": { + "$ref": "#/definitions/cluster_info" + }, + "mirror": { + "$ref": "#/definitions/stream_source_info" + }, + "sources": { + "type": "array", + "description": "Streams being sourced into this Stream", + "items": { + "$ref": "#/definitions/stream_source_info" + } + }, + "alternates": { + "type": "array", + "description": "List of mirrors sorted by priority", + "items": { + "$ref": "#/definitions/stream_alternate" + } + } + } + }, + "stream_alternate": { + "type": "object", + "description": "An alternate location to read mirrored data", + "required": ["name", "cluster"], + "properties": { + "name": { + "type": "string", + "description": "The mirror stream name" + }, + "cluster": { + "type": "string", + "description": "The name of the cluster holding the stream" + }, + "domain": { + "type": "string", + "description": "The domain holding the string" + } + } + }, + "stream_state": { + "type": "object", + "additionalProperties": false, + "required": ["messages", "bytes", "first_seq", "last_seq", "consumer_count"], + "properties": { + "messages": { + "$ref": "#/definitions/golang_uint64", + "description": "Number of messages stored in the Stream", + "minimum": 0 + }, + "bytes": { + "$ref": "#/definitions/golang_uint64", + "description": "Combined size of all messages in the Stream", + "minimum": 0 + }, + "first_seq": { + "$ref": "#/definitions/golang_uint64", + "description": "Sequence number of the first message in the Stream", + "minimum": 0 + }, + "first_ts": { + "type": "string", + "description": "The timestamp of the first message in the Stream" + }, + "last_seq": { + "$ref": "#/definitions/golang_uint64", + "description": "Sequence number of the last message in the Stream", + "minimum": 0 + }, + "last_ts": { + "type": "string", + "description": "The timestamp of the last message in the Stream" + }, + "deleted": { + "description": "IDs of messages that were deleted using the Message Delete API or Interest based streams removing messages out of order", + "type": "array", + "minLength": 0, + "items": { + "$ref": "#/definitions/golang_uint64", + "minimum": 0 + } + }, + "subjects": { + "description": "Subjects and their message counts when a subjects_filter was set", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/golang_uint64" + } + }, + "num_subjects": { + "description": "The number of unique subjects held in the stream", + "$ref": "#/definitions/golang_int", + "minimum": 0 + }, + "num_deleted": { + "description": "The number of deleted messages", + "$ref": "#/definitions/golang_int", + "minimum": 0 + }, + "lost": { + "$ref": "#/definitions/lost_stream_data" + }, + "consumer_count": { + "$ref": "#/definitions/golang_int", + "description": "Number of Consumers attached to the Stream", + "minimum": 0 + } + } + }, + "subject_transform" : { + "type": "object", + "description": "Subject transform to apply to matching messages going into the stream", + "required": ["dest"], + "properties": { + "src": { + "type": "string", + "description": "The subject transform source" + }, + "dest": { + "type": "string", + "description": "The subject transform destination" + } + } + }, + "republish": { + "type": "object", + "description": "Rules for republishing messages from a stream with subject mapping onto new subjects for partitioning and more", + "required": ["src","dest"], + "properties": { + "src": { + "type": "string", + "description": "The source subject to republish" + }, + "dest": { + "type": "string", + "description": "The destination to publish to" + }, + "headers_only": { + "type": "boolean", + "description": "Only send message headers, no bodies", + "default": false + } + } + }, + "stream_configuration": { + "type": "object", + "required":[ + "retention", + "max_consumers", + "max_msgs", + "max_bytes", + "max_age", + "storage", + "num_replicas" + ], + "additionalProperties": false, + "properties": { + "name": { + "description": "A unique name for the Stream, empty for Stream Templates.", + "type": "string", + "pattern": "^[^.*>]*$", + "minLength": 0 + }, + "description": { + "description": "A short description of the purpose of this stream", + "type": "string", + "maxLength": 4096 + }, + "subjects": { + "description": "A list of subjects to consume, supports wildcards. Must be empty when a mirror is configured. May be empty when sources are configured.", + "type": "array", + "minLength": 0, + "items": { + "type": "string" + } + }, + "subject_transform" : { + "description": "Subject transform to apply to matching messages", + "$ref": "#/definitions/subject_transform" + }, + "retention": { + "description": "How messages are retained in the Stream, once this is exceeded old messages are removed.", + "type": "string", + "enum": ["limits", "interest", "workqueue"], + "default": "limits" + }, + "max_consumers": { + "description": "How many Consumers can be defined for a given Stream. -1 for unlimited.", + "$ref": "#/definitions/golang_int", + "minimum": -1, + "default": -1 + }, + "max_msgs": { + "description": "How many messages may be in a Stream, oldest messages will be removed if the Stream exceeds this size. -1 for unlimited.", + "$ref": "#/definitions/golang_int64", + "minimum": -1, + "default": -1 + }, + "max_msgs_per_subject": { + "description": "For wildcard streams ensure that for every unique subject this many messages are kept - a per subject retention limit", + "$ref": "#/definitions/golang_int64", + "minimum": -1, + "default": -1 + }, + "max_bytes": { + "description": "How big the Stream may be, when the combined stream size exceeds this old messages are removed. -1 for unlimited.", + "$ref": "#/definitions/golang_int64", + "minimum": -1, + "default": -1 + }, + "max_age": { + "description": "Maximum age of any message in the stream, expressed in nanoseconds. 0 for unlimited.", + "$ref": "#/definitions/golang_duration_nanos", + "minimum": 0, + "default": 0 + }, + "max_msg_size": { + "description": "The largest message that will be accepted by the Stream. -1 for unlimited.", + "$ref": "#/definitions/golang_int32", + "minimum": -1, + "default": -1 + }, + "storage": { + "description": "The storage backend to use for the Stream.", + "type": "string", + "enum": ["file", "memory"], + "default": "file" + }, + "compression": { + "description": "Optional compression algorithm used for the Stream.", + "type": "string", + "enum": ["none", "s2"], + "default": "none" + }, + "num_replicas": { + "description": "How many replicas to keep for each message.", + "$ref": "#/definitions/golang_int", + "minimum": 1, + "default": 1, + "maximum": 5 + }, + "no_ack": { + "description": "Disables acknowledging messages that are received by the Stream.", + "type": "boolean", + "default": false + }, + "template_owner": { + "description": "When the Stream is managed by a Stream Template this identifies the template that manages the Stream.", + "type": "string" + }, + "discard": { + "description": "When a Stream reach it's limits either old messages are deleted or new ones are denied", + "type": "string", + "enum": ["old", "new"], + "default": "old" + }, + "duplicate_window": { + "description": "The time window to track duplicate messages for, expressed in nanoseconds. 0 for default", + "$ref": "#/definitions/golang_duration_nanos", + "minimum": 0, + "default": 0 + }, + "placement": { + "description": "Placement directives to consider when placing replicas of this stream, random placement when unset", + "$ref": "#/definitions/placement" + }, + "mirror": { + "description": "Maintains a 1:1 mirror of another stream with name matching this property. When a mirror is configured subjects and sources must be empty.", + "$ref": "#/definitions/stream_source" + }, + "sources": { + "type": "array", + "description": "List of Stream names to replicate into this Stream", + "items": { + "$ref": "#/definitions/stream_source" + } + }, + "sealed": { + "type": "boolean", + "default": false, + "description": "Sealed streams do not allow messages to be deleted via limits or API, sealed streams can not be unsealed via configuration update. Can only be set on already created streams via the Update API" + }, + "deny_delete": { + "type": "boolean", + "default": false, + "description": "Restricts the ability to delete messages from a stream via the API. Cannot be changed once set to true" + }, + "deny_purge": { + "type": "boolean", + "default": false, + "description": "Restricts the ability to purge messages from a stream via the API. Cannot be change once set to true" + }, + "allow_rollup_hdrs": { + "type": "boolean", + "default": false, + "description": "Allows the use of the Nats-Rollup header to replace all contents of a stream, or subject in a stream, with a single new message" + }, + "allow_direct": { + "type": "boolean", + "default": false, + "description": "Allow higher performance, direct access to get individual messages" + }, + "mirror_direct": { + "type": "boolean", + "default": false, + "description": "Allow higher performance, direct access for mirrors as well" + }, + "republish": { + "$ref": "#/definitions/republish" + }, + "discard_new_per_subject": { + "type": "boolean", + "description": "When discard policy is new and the stream is one with max messages per subject set, this will apply the new behavior to every subject. Essentially turning discard new from maximum number of subjects into maximum number of messages in a subject.", + "default": false + }, + "metadata": { + "description": "Additional metadata for the Stream", + "type": "object", + "additionalProperties": { "type": "string" } + } + } + }, + "stream_template_info": { + "type": "object", + "required": ["config", "streams"], + "properties": { + "config": { + "$ref": "#/definitions/stream_template_configuration" + }, + "streams": { + "description": "List of Streams managed by this Template", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "stream_template_configuration": { + "type": "object", + "additionalProperties": false, + "required": ["name", "config", "max_streams"], + "properties": { + "name": { + "type": "string", + "description": "A unique name for the Template" + }, + "config": { + "description": "The template configuration to create Streams with", + "$ref": "#/definitions/stream_configuration" + }, + "max_streams": { + "type": "integer", + "description": "The maximum number of streams to allow using this Template", + "minimum": -1 + } + } + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/meta_leader_stepdown_request.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/meta_leader_stepdown_request.json new file mode 100644 index 000000000..f6c0f99d5 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/meta_leader_stepdown_request.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/meta_leader_stepdown_request.json", + "description": "A request to the JetStream $JS.API.META.LEADER.STEPDOWN API", + "title": "io.nats.jetstream.api.v1.meta_leader_stepdown_request", + "type": "object", + "properties": { + "placement": { + "$ref": "definitions.json#/definitions/placement" + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/meta_leader_stepdown_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/meta_leader_stepdown_response.json new file mode 100644 index 000000000..0686828d3 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/meta_leader_stepdown_response.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/meta_leader_stepdown_response.json", + "description": "A response from the JetStream $JS.API.META.LEADER.STEPDOWN API", + "title": "io.nats.jetstream.api.v1.meta_leader_stepdown_response", + "type": "object", + "required": ["success"], + "properties": { + "success": { + "type": "boolean", + "description": "If the leader successfully stood down", + "default": false + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/meta_server_remove_request.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/meta_server_remove_request.json new file mode 100644 index 000000000..aa1f61821 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/meta_server_remove_request.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/meta_server_remove_request.json", + "description": "A request to the JetStream $JS.API.SERVER.REMOVE API", + "title": "io.nats.jetstream.api.v1.meta_server_remove_request", + "type": "object", + "properties": { + "peer": { + "type": "string", + "description": "The Name of the server to remove from the meta group" + + }, + "peer_id": { + "type": "string", + "description": "Peer ID of the peer to be removed. If specified this is used instead of the server name" + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/meta_server_remove_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/meta_server_remove_response.json new file mode 100644 index 000000000..eed8df7b9 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/meta_server_remove_response.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/meta_server_remove_response.json", + "description": "A response from the JetStream $JS.API.SERVER.REMOVE API", + "title": "io.nats.jetstream.api.v1.meta_server_remove_response", + "required": ["success"], + "type": "object", + "properties": { + "success": { + "type": "boolean", + "description": "If the peer was successfully removed", + "default": false + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/pub_ack_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/pub_ack_response.json new file mode 100644 index 000000000..0f1a11340 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/pub_ack_response.json @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/pub_ack_response.json", + "description": "A response received when publishing a message", + "title": "io.nats.jetstream.api.v1.pub_ack_response", + "type": "object", + "required": ["stream"], + "additionalProperties": false, + "properties": { + "error": { + "$ref": "definitions.json#/definitions/api_error" + }, + "stream": { + "type": "string", + "description": "The name of the stream that received the message", + "minLength": 1 + }, + "seq": { + "type": "integer", + "description": "If successful this will be the sequence the message is stored at", + "$ref": "definitions.json#/definitions/golang_uint64" + }, + "duplicate":{ + "type": "boolean", + "description": "Indicates that the message was not stored due to the Nats-Msg-Id header and duplicate tracking", + "default": false + }, + "domain": { + "type": "string", + "description": "If the Stream accepting the message is in a JetStream server configured for a domain this would be that domain" + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_create_request.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_create_request.json new file mode 100644 index 000000000..429b0935c --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_create_request.json @@ -0,0 +1,10 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_create_request.json", + "description": "A request to the JetStream $JS.API.STREAM.CREATE API", + "title": "io.nats.jetstream.api.v1.stream_create_request", + "type": "object", + "allOf": [ + {"$ref": "definitions.json#/definitions/stream_configuration"} + ] +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_create_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_create_response.json new file mode 100644 index 000000000..00c7313a5 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_create_response.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_create_response.json", + "description": "A response from the JetStream $JS.API.STREAM.CREATE API", + "title": "io.nats.jetstream.api.v1.stream_create_response", + "type": "object", + "allOf": [ + { + "$ref": "definitions.json#/definitions/stream_info" + } + ] +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_delete_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_delete_response.json new file mode 100644 index 000000000..8f3d4cf9f --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_delete_response.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_delete_response.json", + "description": "A response from the JetStream $JS.API.STREAM.DELETE API", + "title": "io.nats.jetstream.api.v1.stream_delete_response", + "type": "object", + "required": ["success"], + "properties": { + "success": { + "type": "boolean" + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_info_request.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_info_request.json new file mode 100644 index 000000000..00ec4f84c --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_info_request.json @@ -0,0 +1,22 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_info_request.json", + "description": "A request to the JetStream $JS.API.STREAM.INFO API", + "title": "io.nats.jetstream.api.v1.stream_info_request", + "type": "object", + "properties": { + "deleted_details": { + "type": "boolean", + "description": "When true will result in a full list of deleted message IDs being returned in the info response" + }, + "subjects_filter": { + "type": "string", + "description": "When set will return a list of subjects and how many messages they hold for all matching subjects. Filter is a standard NATS subject wildcard pattern." + }, + "offset": { + "type": "integer", + "minimum": 0, + "description": "Paging offset when retrieving pages of subjet details" + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_info_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_info_response.json new file mode 100644 index 000000000..d4debfcd1 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_info_response.json @@ -0,0 +1,26 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_info_response.json", + "description": "A response from the JetStream $JS.API.STREAM.INFO API", + "title": "io.nats.jetstream.api.v1.stream_info_response", + "type": "object", + "allOf": [ + { + "$ref": "definitions.json#/definitions/stream_info" + } + ], + "properties": { + "total": { + "type": "integer", + "minimum": 0 + }, + "offset": { + "type": "integer", + "minimum": 0 + }, + "limit": { + "type": "integer", + "minimum": 0 + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_leader_stepdown_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_leader_stepdown_response.json new file mode 100644 index 000000000..db845b8e1 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_leader_stepdown_response.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_leader_stepdown_response.json", + "description": "A response from the JetStream $JS.API.STREAM.LEADER.STEPDOWN API", + "title": "io.nats.jetstream.api.v1.stream_leader_stepdown_response", + "type": "object", + "required": ["success"], + "properties": { + "success": { + "type": "boolean", + "description": "If the leader successfully stood down", + "default": false + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_list_request.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_list_request.json new file mode 100644 index 000000000..2b3122b9a --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_list_request.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_list_request.json", + "description": "A request to the JetStream $JS.API.STREAM.LIST API", + "title": "io.nats.jetstream.api.v1.stream_list_request", + "type": "object", + "properties": { + "subject": { + "type": "string", + "description": "Limit the list to streams matching this subject filter" + }, + "offset": { + "type": "integer", + "minimum": 0 + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_list_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_list_response.json new file mode 100644 index 000000000..0cb3cf360 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_list_response.json @@ -0,0 +1,29 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_list_response.json", + "description": "A response from the JetStream $JS.API.STREAM.LIST API", + "title": "io.nats.jetstream.api.v1.stream_list_response", + "type": "object", + "allOf": [ + { + "$ref": "definitions.json#/definitions/iterable_response" + } + ], + "required": ["streams"], + "properties": { + "streams": { + "description": "Full Stream information for each known Stream", + "type": "array", + "items": { + "$ref": "definitions.json#/definitions/stream_info" + } + }, + "missing": { + "description": "In clustered environments gathering Stream info might time out, this list would be a list of Streams for which information was not obtainable", + "type": "array", + "items": { + "type": "string" + } + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_msg_delete_request.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_msg_delete_request.json new file mode 100644 index 000000000..703018c85 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_msg_delete_request.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_msg_delete_request.json", + "description": "A request to the JetStream $JS.API.STREAM.MSG.DELETE API", + "title": "io.nats.jetstream.api.v1.stream_msg_delete_request", + "type": "object", + "required": ["seq"], + "properties": { + "seq": { + "description": "Stream sequence number of the message to delete", + "$ref": "definitions.json#/definitions/golang_uint64" + }, + "no_erase": { + "type": "boolean", + "description": "Default will securely remove a message and rewrite the data with random data, set this to true to only remove the message" + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_msg_delete_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_msg_delete_response.json new file mode 100644 index 000000000..e40ef54f5 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_msg_delete_response.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_msg_delete_response.json", + "description": "A response from the JetStream $JS.API.STREAM.MSG.DELETE API", + "title": "io.nats.jetstream.api.v1.stream_msg_delete_response", + "type": "object", + "required": ["success"], + "properties": { + "success": { + "type": "boolean" + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_msg_get_request.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_msg_get_request.json new file mode 100644 index 000000000..bd2c9243f --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_msg_get_request.json @@ -0,0 +1,21 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_msg_get_request.json", + "description": "A request to the JetStream $JS.API.STREAM.MSG.GET API", + "title": "io.nats.jetstream.api.v1.stream_msg_get_request", + "type": "object", + "properties": { + "seq": { + "type": "integer", + "description": "Stream sequence number of the message to retrieve, cannot be combined with last_by_subj" + }, + "last_by_subj": { + "type": "string", + "description": "Retrieves the last message for a given subject, cannot be combined with seq" + }, + "next_by_subj": { + "type": "string", + "description": "Combined with sequence gets the next message for a subject with the given sequence or higher" + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_msg_get_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_msg_get_response.json new file mode 100644 index 000000000..3e9a08c8c --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_msg_get_response.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_msg_get_response.json", + "description": "A response from the JetStream $JS.API.STREAM.MSG.GET API", + "title": "io.nats.jetstream.api.v1.stream_msg_get_response", + "type": "object", + "required": ["message"], + "properties": { + "message": { + "$ref": "definitions.json#/definitions/stored_message" + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_names_request.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_names_request.json new file mode 100644 index 000000000..68cb21556 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_names_request.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_names_request.json", + "description": "A request to the JetStream $JS.API.STREAM.NAMES API", + "title": "io.nats.jetstream.api.v1.stream_names_request", + "type": "object", + "properties": { + "subject": { + "type": "string", + "description": "Limit the list to streams matching this subject filter" + }, + "offset": { + "type": "integer", + "minimum": 0 + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_names_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_names_response.json new file mode 100644 index 000000000..4528c32d5 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_names_response.json @@ -0,0 +1,21 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_names_response.json", + "description": "A response from the JetStream $JS.API.STREAM.NAMES API", + "title": "io.nats.jetstream.api.v1.stream_names_response", + "type": "object", + "allOf": [ + { + "$ref": "definitions.json#/definitions/iterable_response" + } + ], + "required": ["streams"], + "properties": { + "consumers": { + "type": "array", + "items": { + "type": "string" + } + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_purge_request.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_purge_request.json new file mode 100644 index 000000000..a28ffd37f --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_purge_request.json @@ -0,0 +1,21 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_purge_request.json", + "description": "A request to the JetStream $JS.API.STREAM.PURGE API", + "title": "io.nats.jetstream.api.v1.stream_purge_request", + "type": "object", + "properties": { + "filter": { + "type": "string", + "description": "Restrict purging to messages that match this subject" + }, + "seq": { + "description": "Purge all messages up to but not including the message with this sequence. Can be combined with subject filter but not the keep option", + "$ref": "definitions.json#/definitions/golang_uint64" + }, + "keep": { + "description": "Ensures this many messages are present after the purge. Can be combined with the subject filter but not the sequence", + "$ref": "definitions.json#/definitions/golang_uint64" + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_purge_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_purge_response.json new file mode 100644 index 000000000..0a533048c --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_purge_response.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_purge_response.json", + "description": "A response from the JetStream $JS.API.STREAM.PURGE API", + "title": "io.nats.jetstream.api.v1.stream_purge_response", + "type": "object", + "required": ["success", "purged"], + "properties": { + "success": { + "type": "boolean" + }, + "purged": { + "description": "Number of messages purged from the Stream", + "$ref": "definitions.json#/definitions/golang_uint64" + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_remove_peer_request.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_remove_peer_request.json new file mode 100644 index 000000000..f69a25762 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_remove_peer_request.json @@ -0,0 +1,16 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_remove_peer_request.json", + "description": "A request to the JetStream $JS.API.STREAM.PEER.REMOVE API", + "title": "io.nats.jetstream.api.v1.stream_remove_peer_request", + "type": "object", + "required": ["peer"], + "additionalProperties": false, + "properties": { + "peer": { + "type": "string", + "description": "Server name of the peer to remove", + "minLength": 1 + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_remove_peer_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_remove_peer_response.json new file mode 100644 index 000000000..d7282c10b --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_remove_peer_response.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_remove_peer_response.json", + "description": "A response from the JetStream $JS.API.STREAM.PEER.REMOVE API", + "title": "io.nats.jetstream.api.v1.stream_remove_peer_response", + "type": "object", + "required": ["success"], + "properties": { + "success": { + "type": "boolean", + "description": "If the peer was successfully removed", + "default": false + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_restore_request.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_restore_request.json new file mode 100644 index 000000000..f64b319a2 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_restore_request.json @@ -0,0 +1,16 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_restore_request.json", + "description": "A response from the JetStream $JS.API.STREAM.RESTORE API", + "title": "io.nats.jetstream.api.v1.stream_restore_request", + "type": "object", + "required": ["config", "state"], + "properties": { + "config": { + "$ref": "definitions.json#/definitions/stream_configuration" + }, + "state": { + "$ref": "definitions.json#/definitions/stream_state" + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_restore_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_restore_response.json new file mode 100644 index 000000000..c3765f8d3 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_restore_response.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_restore_response.json", + "description": "A response from the JetStream $JS.API.STREAM.RESTORE API", + "title": "io.nats.jetstream.api.v1.stream_restore_response", + "type": "object", + "required": ["deliver_subject"], + "properties": { + "deliver_subject": { + "type": "string", + "description": "The Subject to send restore chunks to", + "minLength": 1 + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_snapshot_request.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_snapshot_request.json new file mode 100644 index 000000000..76f1d9997 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_snapshot_request.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_snapshot_request.json", + "description": "A request to the JetStream $JS.API.STREAM.SNAPSHOT API", + "title": "io.nats.jetstream.api.v1.stream_snapshot_request", + "type": "object", + "required": ["deliver_subject"], + "additionalProperties": false, + "properties": { + "deliver_subject": { + "type": "string", + "description": "The NATS subject where the snapshot will be delivered", + "minLength": 1 + }, + "no_consumers": { + "type": "boolean", + "description": "When true consumer states and configurations will not be present in the snapshot" + }, + "chunk_size": { + "type": "integer", + "description": "The size of data chunks to send to deliver_subject", + "minimum": 1024, + "$ref": "definitions.json#/definitions/golang_int" + }, + "jsck": { + "type": "boolean", + "description": "Check all message's checksums prior to snapshot", + "default": false + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_snapshot_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_snapshot_response.json new file mode 100644 index 000000000..cd8a15f38 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_snapshot_response.json @@ -0,0 +1,16 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_snapshot_response.json", + "description": "A response from the JetStream $JS.API.STREAM.SNAPSHOT API", + "title": "io.nats.jetstream.api.v1.stream_snapshot_response", + "type": "object", + "required": ["config", "state"], + "properties": { + "config": { + "$ref": "definitions.json#/definitions/stream_configuration" + }, + "state": { + "$ref": "definitions.json#/definitions/stream_state" + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_configuration.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_configuration.json new file mode 100644 index 000000000..e6f797036 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_configuration.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_template_configuration.json", + "description": "The data structure that describe the configuration of a NATS JetStream Stream Template", + "title": "io.nats.jetstream.api.v1.stream_template_configuration", + "type":"object", + "required":[ + "name", + "config", + "max_streams" + ], + "additionalProperties": false, + "properties": { + "name": { + "description": "A unique name for the Stream Template.", + "$ref": "definitions.json#/definitions/basic_name" + }, + "max_streams": { + "description": "The maximum number of Streams this Template can create, -1 for unlimited.", + "minimum": -1, + "default": -1, + "$ref": "definitions.json#/definitions/golang_int32" + }, + "config": { + "$ref": "definitions.json#/definitions/stream_configuration" + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_create_request.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_create_request.json new file mode 100644 index 000000000..06041e93d --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_create_request.json @@ -0,0 +1,10 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_template_create_request.json", + "description": "A request to the JetStream $JS.API.STREAM.TEMPLATE.CREATE API", + "title": "io.nats.jetstream.api.v1.stream_template_create_request", + "type": "object", + "allOf": [ + {"$ref": "definitions.json#/definitions/stream_template_configuration"} + ] +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_create_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_create_response.json new file mode 100644 index 000000000..0fd1f8d78 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_create_response.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_template_create_response.json", + "description": "A response from the JetStream $JS.API.STREAM.TEMPLATE.CREATE API", + "title": "io.nats.jetstream.api.v1.stream_template_create_response", + "type": "object", + "allOf": [ + { + "$ref": "definitions.json#/definitions/stream_template_info" + } + ] +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_delete_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_delete_response.json new file mode 100644 index 000000000..39513a34f --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_delete_response.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_template_delete_response.json", + "description": "A response from the JetStream $JS.API.STREAM.TEMPLATE.DELETE API", + "title": "io.nats.jetstream.api.v1.stream_template_delete_response", + "type": "object", + "required": ["success"], + "properties": { + "success": { + "type": "boolean" + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_info_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_info_response.json new file mode 100644 index 000000000..935b232f3 --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_info_response.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_template_info_response.json", + "description": "A response from the JetStream $JS.API.STREAM.TEMPLATE.INFO API", + "title": "io.nats.jetstream.api.v1.stream_template_info_response", + "type": "object", + "allOf": [ + { + "$ref": "definitions.json#/definitions/stream_template_info" + } + ] +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_names_request.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_names_request.json new file mode 100644 index 000000000..afd316e1a --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_names_request.json @@ -0,0 +1,10 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_template_names_request.json", + "description": "A request to the JetStream $JS.API.CONSUMER.LIST API", + "title": "io.nats.jetstream.api.v1.stream_template_names_request", + "type": "object", + "allOf": [ + {"$ref": "definitions.json#/definitions/iterable_request"} + ] +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_names_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_names_response.json new file mode 100644 index 000000000..26048f57d --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_template_names_response.json @@ -0,0 +1,21 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_template_names_response.json", + "description": "A response from the JetStream $JS.API.STREAM.TEMPLATE.NAMES API", + "title": "io.nats.jetstream.api.v1.stream_template_names_response", + "type": "object", + "allOf": [ + { + "$ref": "definitions.json#/definitions/iterable_response" + } + ], + "required": ["streams"], + "properties": { + "consumers": { + "type": "array", + "items": { + "type": "string" + } + } + } +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_update_request.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_update_request.json new file mode 100644 index 000000000..fadecdfba --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_update_request.json @@ -0,0 +1,10 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_update_request.json", + "description": "A request to the JetStream $JS.API.STREAM.UPDATE API", + "title": "io.nats.jetstream.api.v1.stream_update_request", + "type": "object", + "allOf": [ + {"$ref": "definitions.json#/definitions/stream_configuration"} + ] +} diff --git a/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_update_response.json b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_update_response.json new file mode 100644 index 000000000..f9f22d8af --- /dev/null +++ b/tools/Schema.Generation/schema_source/jetstream/api/v1/stream_update_response.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://nats.io/schemas/jetstream/api/v1/stream_update_response.json", + "description": "A response from the JetStream $JS.API.STREAM.UPDATE API", + "title": "io.nats.jetstream.api.v1.stream_update_response", + "type": "object", + "allOf": [ + { + "$ref": "definitions.json#/definitions/stream_info" + } + ] +}