Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
WebHookEventSinkNode.cs
2using System.Threading.Tasks;
3using System.Xml;
4using Waher.Content;
7using Waher.Things;
10
12{
17 {
22 : base()
23 {
24 }
25
43 string SinkId, string Url, int MaxSecondsUsed, int MaxSecondsUnused,
46 bool CollectOnModule)
47 : base(Source, Parent, SinkId)
48 {
49 this.Url = Url;
50 this.MaxSecondsUsed = MaxSecondsUsed;
51 this.MaxSecondsUnused = MaxSecondsUnused;
52 this.CollectOnType = CollectOnType;
53 this.CollectOnLevel = CollectOnLevel;
54 this.CollectOnEventId = CollectOnEventId;
55 this.CollectOnObject = CollectOnObject;
56 this.CollectOnActor = CollectOnActor;
57 this.CollectOnFacility = CollectOnFacility;
58 this.CollectOnModule = CollectOnModule;
59 }
60
64 [Page(7, "Configuration")]
65 [Header(185, "Callback URL:")]
66 [ToolTip(186, "URL to call for each event.")]
67 [Required]
68 public string Url { get; set; }
69
73 [Page(7, "Configuration")]
74 [Header(221, "Max collection time (s):")]
75 [ToolTip(222, "Maximum number of seconds events can be cached before being sent.")]
76 public int MaxSecondsUsed { get; set; }
77
81 [Page(7, "Configuration")]
82 [Header(223, "Min collection time (s):")]
83 [ToolTip(224, "Minimum number of seconds events can be cached before being sent.")]
84 public int MaxSecondsUnused { get; set; }
85
89 [Page(7, "Configuration")]
90 [Header(225, "Collect on Type.")]
91 [ToolTip(226, "Collect events having the same event type.")]
92 public bool CollectOnType { get; set; }
93
97 [Page(7, "Configuration")]
98 [Header(227, "Collect on Level.")]
99 [ToolTip(228, "Collect events having the same event level.")]
100 public bool CollectOnLevel { get; set; }
101
105 [Page(7, "Configuration")]
106 [Header(229, "Collect on Level.")]
107 [ToolTip(230, "Collect events having the same event level.")]
108 public bool CollectOnEventId { get; set; }
109
113 [Page(7, "Configuration")]
114 [Header(231, "Collect on Object.")]
115 [ToolTip(232, "Collect events having the same event object.")]
116 public bool CollectOnObject { get; set; }
117
121 [Page(7, "Configuration")]
122 [Header(233, "Collect on Actor.")]
123 [ToolTip(234, "Collect events having the same event actor.")]
124 public bool CollectOnActor { get; set; }
125
129 [Page(7, "Configuration")]
130 [Header(235, "Collect on Facility.")]
131 [ToolTip(236, "Collect events having the same event facility.")]
132 public bool CollectOnFacility { get; set; }
133
137 [Page(7, "Configuration")]
138 [Header(237, "Collect on Module.")]
139 [ToolTip(238, "Collect events having the same event module.")]
140 public bool CollectOnModule { get; set; }
141
146 public override Task<string> GetTypeNameAsync(Language Language)
147 {
148 return Language.GetStringAsync(typeof(GatewayConfigSource), 187, "WebHook Event Sink");
149 }
150
157 public override async Task<IEnumerable<Parameter>> GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
158 {
159 LinkedList<Parameter> Parameters = (LinkedList<Parameter>)await base.GetDisplayableParametersAsync(Language, Caller);
161
162 Parameters.AddLast(new StringParameter("Url", await Namespace.GetStringAsync(188, "URL"), this.Url));
163
164 return Parameters;
165 }
166
171 public override void Export(XmlWriter Output)
172 {
173 Output.WriteStartElement("WebHookEventSink");
174 Output.WriteAttributeString("id", this.SinkId);
175 Output.WriteAttributeString("url", this.Url);
176 Output.WriteAttributeString("maxSecondsUsed", this.MaxSecondsUsed.ToString());
177 Output.WriteAttributeString("maxSecondsUnused", this.MaxSecondsUnused.ToString());
178 Output.WriteAttributeString("collectOnType", CommonTypes.Encode(this.CollectOnType));
179 Output.WriteAttributeString("collectOnLevel", CommonTypes.Encode(this.CollectOnLevel));
180 Output.WriteAttributeString("collectOnEventId", CommonTypes.Encode(this.CollectOnEventId));
181 Output.WriteAttributeString("collectOnObject", CommonTypes.Encode(this.CollectOnObject));
182 Output.WriteAttributeString("collectOnActor", CommonTypes.Encode(this.CollectOnActor));
183 Output.WriteAttributeString("collectOnFacility", CommonTypes.Encode(this.CollectOnFacility));
184 Output.WriteAttributeString("collectOnModule", CommonTypes.Encode(this.CollectOnModule));
185 Output.WriteEndElement();
186 }
187 }
188}
Helps with parsing of commong data types.
Definition: CommonTypes.cs:15
static string Encode(bool x)
Encodes a Boolean for use in XML and other formats.
Definition: CommonTypes.cs:596
Contains information about a language.
Definition: Language.cs:17
Task< string > GetStringAsync(Type Type, int Id, string Default)
Gets the string value of a string ID. If no such string exists, a string is created with the default ...
Definition: Language.cs:209
async Task< Namespace > GetNamespaceAsync(string Name)
Gets the namespace object, given its name, if available.
Definition: Language.cs:99
Contains information about a namespace in a language.
Definition: Namespace.cs:17
Task< LanguageString > GetStringAsync(int Id)
Gets the string object, given its ID, if available.
Definition: Namespace.cs:65
Abstract base class for gateway configuration nodes.
virtual INode Parent
Parent Node, or null if a root node.
GatewayConfigSource Source
Source hosting the node.
Abstract base class for event sink nodes.
WebHookEventSinkNode(GatewayConfigSource Source, ConfigurationNode Parent, string SinkId, string Url, int MaxSecondsUsed, int MaxSecondsUnused, bool CollectOnType, bool CollectOnLevel, bool CollectOnEventId, bool CollectOnObject, bool CollectOnActor, bool CollectOnFacility, bool CollectOnModule)
Representation of a WebHookEventSink
bool CollectOnActor
If events should be collected based on their actor.
override async Task< IEnumerable< Parameter > > GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
Gets displayable parameters.
bool CollectOnObject
If events should be collected based on their object.
int MaxSecondsUnused
Maximum number of seconds events can be cached (if collection key unused) before being sent.
bool CollectOnModule
If events should be collected based on their module.
bool CollectOnFacility
If events should be collected based on their facility.
override Task< string > GetTypeNameAsync(Language Language)
Gets the type name of the node.
bool CollectOnLevel
If events should be collected based on their level.
bool CollectOnEventId
If events should be collected based on their event ID.
int MaxSecondsUsed
Maximum number of seconds events can be cached before being sent.
override void Export(XmlWriter Output)
Exports the event sink definition to XML.
Tokens available in request.
Definition: RequestOrigin.cs:9