2using System.Collections.Generic;
3using System.Security.Cryptography;
5using System.Threading.Tasks;
19 : base(
"/CreateApiKey")
23 public override bool HandlesSubPaths =>
false;
24 public override bool UserSessions =>
true;
35 if (!(Obj is Dictionary<string, string> Form))
41 if (!Form.ContainsKey(
"Owner") ||
string.IsNullOrEmpty(Owner = Form[
"Owner"]))
44 if (!Form.ContainsKey(
"EMail") ||
string.IsNullOrEmpty(EMail = Form[
"EMail"]))
47 if (!Form.ContainsKey(
"MaxAccounts") || !
long.TryParse(Form[
"MaxAccounts"], out
long MaxAccounts) || MaxAccounts < 1)
56 internal static async Task<ApiKey> Create(
long MaxAccounts,
string Owner,
string EMail,
string RemoteEndpoint)
86 Created = DateTime.Now,
87 MaxAccounts = MaxAccounts
92 StringBuilder Markdown =
new StringBuilder();
93 DateTime Now = DateTime.Now;
95 Markdown.AppendLine(
"API Key created:");
96 Markdown.AppendLine();
97 Markdown.AppendLine(
"| API Key Information ||");
98 Markdown.AppendLine(
"|:-----|:------|");
99 Markdown.Append(
"| Key: | `");
100 Markdown.Append(Key);
101 Markdown.AppendLine(
"` |");
102 Markdown.Append(
"| Owner: | `");
103 Markdown.Append(Owner);
104 Markdown.Append(
"`");
105 Markdown.AppendLine(
" |");
106 Markdown.Append(
"| \\#Accounts: | ");
107 Markdown.Append(MaxAccounts.ToString());
108 Markdown.AppendLine(
" |");
109 Markdown.Append(
"| e-Mail: | <");
110 Markdown.Append(EMail);
111 Markdown.AppendLine(
"> |");
115 Markdown.Append(
"| Date | ");
117 Markdown.AppendLine(
" |");
118 Markdown.Append(
"| Time | ");
120 Markdown.AppendLine(
" |");
Contains a markdown document. This markdown document class supports original markdown,...
static string Encode(string s)
Encodes all special characters in a string so that it can be included in a markdown document without ...
Static class managing the runtime environment of the IoT Gateway.
static IUser AssertUserAuthenticated(HttpRequest Request, string Privilege)
Makes sure a request is being made from a session with a successful user login.
static byte[] NextBytes(int NrBytes)
Generates an array of random bytes.
static Task SendNotification(Graph Graph)
Sends a graph as a notification message to configured notification recipients.
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
Represents an HTTP request.
HttpRequestHeader Header
Request header.
string RemoteEndPoint
Remote end-point.
bool HasData
If the request has data.
async Task< object > DecodeDataAsync()
Decodes data sent in request.
Represets a response of an HTTP client request.
Base class for all synchronous HTTP resources. A synchronous resource responds within the method hand...
The response to the request can be found under a different URI and SHOULD be retrieved using a GET me...
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static Task< IEnumerable< object > > Find(string Collection, params string[] SortOrder)
Finds objects in a given collection.
static async Task Insert(object Object)
Inserts an object into the default collection of the database.
This filter selects objects that have a named field equal to a given value.
Contains methods for simple hash calculations.
static string BinaryToString(byte[] Data)
Converts an array of bytes to a string with their hexadecimal representations (in lower case).
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.
static async Task AppendRemoteEndpointToTable(StringBuilder Markdown, string RemoteEndpoint)
Appends annotated information about a remote endpoint to a Markdown table.
POST Interface for HTTP resources.