Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DeletePubSubNode.cs
1using System.Threading.Tasks;
2using Waher.Content;
8
10{
12 {
13 public DeletePubSubNode()
14 : base("/DeletePubSubNode")
15 {
16 }
17
18 public override bool HandlesSubPaths => false;
19 public override bool UserSessions => true;
20 public bool AllowsPOST => true;
21
22 public async Task POST(HttpRequest Request, HttpResponse Response)
23 {
24 Gateway.AssertUserAuthenticated(Request, "Admin.Broker.XMPP.PubSub");
25
26 if (!Request.HasData)
27 {
28 await Response.SendResponse(new BadRequestException());
29 return;
30 }
31
32 ContentResponse Content = await Request.DecodeDataAsync();
33 if (Content.HasError || !(Content.Decoded is string NodeName))
34 {
35 await Response.SendResponse(new BadRequestException());
36 return;
37 }
38
39 PubSubNode PubSubNode = await XmppServerModule.GetPubSubNodeAsync(NodeName);
40 if (PubSubNode is null)
41 {
42 await Response.SendResponse(new NotFoundException());
43 return;
44 }
45
46 await XmppServerModule.PubSub.DeleteNode(string.Empty, PubSubNode,
48
49 XmppServerModule.Instance.WebNodeStatus(NodeName, false);
50
51 Response.StatusCode = 200;
52 Response.StatusMessage = "OK";
53 Response.ContentType = PlainTextCodec.DefaultContentType;
54 await Response.Write("1");
55 }
56 }
57}
Contains information about a response to a content request.
bool HasError
If an error occurred.
object Decoded
Decoded object.
Plain text encoder/decoder.
const string DefaultContentType
text/plain
Static class managing the runtime environment of the IoT Gateway.
Definition: Gateway.cs:147
static IUser AssertUserAuthenticated(HttpRequest Request, string Privilege)
Makes sure a request is being made from a session with a successful user login.
Definition: Gateway.cs:3868
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
Represents an HTTP request.
Definition: HttpRequest.cs:22
bool HasData
If the request has data.
Definition: HttpRequest.cs:113
async Task< ContentResponse > DecodeDataAsync()
Decodes data sent in request.
Definition: HttpRequest.cs:139
Represets a response of an HTTP client request.
Definition: HttpResponse.cs:23
async Task SendResponse()
Sends the response back to the client. If the resource is synchronous, there's no need to call this m...
Task Write(byte[] Data)
Returns binary data in the response.
Base class for all synchronous HTTP resources. A synchronous resource responds within the method hand...
The server has not found anything matching the Request-URI. No indication is given of whether the con...
XmppAddress MainDomain
Main/principal domain address
Definition: Component.cs:87
Contains information about one XMPP address.
Definition: XmppAddress.cs:9
CaseInsensitiveString Address
XMPP Address
Definition: XmppAddress.cs:37
Defines a node on which items can be published.
Definition: PubSubNode.cs:19
CaseInsensitiveString Domain
Domain
Definition: PubSubNode.cs:133
bool AllowsPOST
If the POST method is allowed.
async Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
Service Module hosting the XMPP broker and its components.
POST Interface for HTTP resources.