NDEVR
API Documentation
ServerActions.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2020, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: NDEVRServerActions
28File: OWLFactory
29Included in API: True
30Author(s): tyler.parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/String.h>
35#include <NDEVR/PasswordString.h>
36#include <NDEVR/DynamicPointer.h>
37#include <NDEVR/TimeSpan.h>
38#include <NDEVR/BinaryFile.h>
39namespace NDEVR
40{
41 class InfoPipe;
42 class StringView;
43 struct NDEVRServerInfo;
44 class TranslatedString;
48 struct ServerCommandReturn
49 {
52 {
53 e_success = 0
54 , e_invalid_packet
55 , e_invalid_credentials
56 , e_user_not_found
57 , e_resource_not_found
58 , e_permission_denied
59 , e_unknown_error
60 , e_too_many_requests
61 , e_already_exists
62 , e_database_error
63 , e_awaiting_approval
64 , e_invalid_resource_id
65 , e_retry_soon
66 , e_not_supported
67 , e_server_too_new
68 , e_server_too_old
69 , e_client_too_new
70 , e_client_too_old
71 , e_timeout
72 };
74 : return_code(code)
75 {
76 }
77 ServerCommandReturn(ReturnCode code, const StringView& msg)
78 : return_code(code)
79 , return_message(msg)
80 {}
81 bool success() const
82 {
83 return return_code == e_success;
84 }
85 NDEVRSERVERCLIENT_API TranslatedString returnMessage() const;
88 };
89
99 class PublicPrivateKey;
111
115 {
117 sint04 resource_id = Constant<sint04>::Invalid;
118 sint04 resource_owner = Constant<sint04>::Invalid;
119 sint04 resource_version = Constant<sint04>::Invalid;
120 };
121
140
144 {
145 sint04 user_id = Constant<sint04>::Invalid;
146 sint04 resource_id = Constant<sint04>::Invalid;
147 sint04 version_id = Constant<sint04>::Invalid;
148 HighCapacityBuffer<uint01> header;
149 HighCapacityBuffer<uint01> message;
151 };
152
156 {
159 UUID link_password = Constant<UUID>::Invalid;
160 HighCapacityBuffer<uint01> encoded_resource_password;
161 HighCapacityBuffer<uint01> encoded_decrypt_password;
162 HighCapacityBuffer<uint01> encoded_link_password;
163 sint04 permission_id = Constant<sint04>::Invalid;
164 sint04 permission_owner_id = Constant<sint04>::Invalid;
165 TimeSpan lifespan = Constant<TimeSpan>::Invalid;
167 bool has_edit_permissions = false;
168 bool allow_tree = false;
169 bool allow_export = false;
170 bool allow_measure = false;
171 bool is_public = false;
172 bool share_owner_info = false;
173 bool link_shared = false;
176 };
177
188
192 {
198 Time creation_time = Constant<Time>::Invalid;
199 Time modified_time = Constant<Time>::Invalid;
200 Time access_time = Constant<Time>::Invalid;
201 uint08 resource_size = Constant<uint08>::Invalid;
202 };
203 class BinaryFile;
207 class NDEVRSERVERCLIENT_API ServerActions
208 {
209 public:
210 virtual ~ServerActions() {};
211 //virtual ServerCommandReturn getUserInfo(ServerCredentials& credentials, ServerUserInfo& info) = 0;
212 virtual ServerCommandReturn updateUserInfo(ServerCredentials& old_credentials, ServerUserInfo& new_credentials) = 0;
213 virtual ServerCommandReturn getUserInfo(ServerCredentials& credentials, ServerUserInfo& new_credentials) = 0;
214 virtual ServerCommandReturn addUser(ServerUserInfo& info) = 0;
215 virtual ServerCommandReturn setUserActive(ServerCredentials& info, bool active) = 0;
216 virtual ServerCommandReturn checkPermission(ServerPermission& resource, bool write_permission) = 0;
217 virtual ServerCommandReturn deleteResource(ServerPermission& resource) = 0;
218 virtual ServerCommandReturn deletePermission(ServerPermission& password) = 0;
219 virtual ServerCommandReturn addMessages(ServerPermission& permission, Buffer<EncodedMessage>& message) = 0;
220 virtual ServerCommandReturn getMessages(ServerPermission& permission, Buffer<EncodedMessage>& messages, TimeSpan span) = 0;
221 virtual ServerCommandReturn getResource(ServerPermission& permission, ServerResourceInfo& Resource, bool download_preview, bool download_contents) = 0;
222 virtual ServerCommandReturn getResourceVersions(Buffer<ServerResourceInfo>& versions, ServerPermission& permission, bool download_preview) = 0;
223 virtual ServerCommandReturn addPermission(ServerPermission& our_permission, ServerPermission& new_permission) = 0;
224 virtual ServerCommandReturn addResource(ServerPermission& permission, ServerResourceInfo& Resource) = 0;
225 virtual ServerCommandReturn addOrUpdateLibaryObject(ServerPermission& credentials, UUID id, ServerResourceInfo& resource) = 0;
226 virtual ServerCommandReturn getLibaryObject(ServerCredentials& credentials, UUID id, ServerResourceInfo& resource, bool download_preview, bool download_contents) = 0;
227 virtual ServerCommandReturn getLibaryObjects(ServerCredentials& credentials, Buffer<ServerResourceInfo>& resources, bool download_preview) = 0;
228 virtual ServerCommandReturn getUsers(Buffer<ServerUserInfo>& users, ServerCredentials& credentials, bool active = true, bool inactive = false, bool awaiting_aproval = false) = 0;
229 virtual ServerCommandReturn getResourcePermissions(Buffer<ServerPermission>& permissions, ServerPermission& Resource) = 0;
230 virtual ServerCommandReturn getOwnedResources(Buffer<ServerResourceInfo>& resources, ServerCredentials& credentials, bool download_preview) = 0;
231 virtual ServerCommandReturn getSharedResources(Buffer<ServerResourceInfo>& resources, ServerCredentials& resource, bool download_preview) = 0;
232 virtual ServerCommandReturn forceUserActive(ServerCredentials&, bool) { return ServerCommandReturn::e_not_supported; };
233 virtual bool open(NDEVRServerInfo& info) = 0;
234 virtual void logAction(const ServerCredentials&, const ServerCommandReturn&, uint04) {};
235 virtual void close() = 0;
236
237 static void EncodeCredentials(const ServerCredentials& credentials, BinaryFile& encoding);
238 static void DecodeCredentials(ServerCredentials& credentials, BinaryFile& encoding);
239 static void EncodeEncodedMessage(const EncodedMessage& message, BinaryFile& encoding);
240 static void DecodeEncodedMessage(EncodedMessage& message, BinaryFile& encoding);
241 static void EncodeEncodedMessages(const Buffer<EncodedMessage>& message, BinaryFile& encoding);
242 static void DecodeEncodedMessages(Buffer<EncodedMessage>& message, BinaryFile& encoding);
243 static void EncodeResourceInfo(const ServerResourceInfo& credentials, BinaryFile& encoding, bool decode_data);
244 static void DecodeResourceInfo(ServerResourceInfo& credentials, BinaryFile& encoding, bool decode_data);
245 static void EncodeResourceInfo(const Buffer<ServerResourceInfo>& files, BinaryFile& encoding, bool encode_data);
246 static void DecodeResourceInfo(Buffer<ServerResourceInfo>& files, BinaryFile& encoding, bool decode_data);
247 static void EncodeResourcePermission(const ServerPermission& password, BinaryFile& encoding, bool encode_credentials = true);
248 static void DecodeResourcePermission(ServerPermission& password, BinaryFile& encoding, bool decode_credentials = true);
249 static void EncodeResourcePermissions(const Buffer<ServerPermission>& permissions, BinaryFile& encoding);
250 static void DecodeResourcePermissions(Buffer<ServerPermission>& permissions, BinaryFile& encoding);
251 static void EncodeServerResponse(const ServerCommandReturn& response, BinaryFile& encoding);
252 static void DecodeServerResponse(ServerCommandReturn& response, BinaryFile& encoding);
253 static void EncodeUserInfo(const ServerUserInfo& info, BinaryFile& encoding);
254 static void DecodeUserInfo(ServerUserInfo& info, BinaryFile& encoding);
255 static void EncodeServerInfo(const ServerMainInfo& info, BinaryFile& encoding);
256 static void DecodeServerInfo(ServerMainInfo& info, BinaryFile& encoding);
257 };
258}
Logic for reading or writing to a binary file including logic for compressing or decompressing the fi...
Definition BinaryFile.h:136
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
A light-weight base class for Log that allows processes to update, without the need for additional in...
Manages an elliptic curve public/private key pair for asymmetric encryption and decryption.
A core part of the engine, stores variables that can be listened to with ResourceListener which will ...
Definition Resource.h:42
Abstract interface for all server-side CRUD operations on users, resources, and permissions.
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
The primary namespace for the NDEVR SDK.
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
int32_t sint04
-Defines an alias representing a 4 byte, signed integer.
Represents an encoded message associated with a resource version, including header and body.
HighCapacityBuffer< uint01 > message
Encoded message body.
sint04 resource_id
Associated resource ID.
Time time
Timestamp of the message.
sint04 version_id
Associated version ID.
sint04 user_id
User who sent the message.
HighCapacityBuffer< uint01 > header
Encoded message header.
Contains the address, credentials, and security flag needed to connect to an NDEVR server.
Identifies a resource on the server by name, ID, owner, and version.
sint04 resource_version
Version number of the resource.
sint04 resource_owner
User ID of the resource owner.
sint04 resource_id
Numeric resource ID.
String resource_name
Human-readable name of the resource.
Search criteria for querying resources on the server using regex patterns and filters.
Buffer< UUID > library_ids_black_list
Exclude these library IDs.
Buffer< sint04 > resource_ids_white_list
Only include these resource IDs.
String category_search_regex
Regex to match resource categories.
String mime_type_search_regex
Regex to match resource MIME types.
Buffer< TimeSpan > created_time_span
Filter by creation time ranges.
Buffer< UUID > library_ids_white_list
Only include these library IDs.
Buffer< sint04 > resource_owners_white_list
Only include resources owned by these user IDs.
String description_search_regex
Regex to match resource descriptions.
Buffer< sint04 > resource_owners_black_list
Exclude resources owned by these user IDs.
Buffer< TimeSpan > accessed_time_span
Filter by access time ranges.
Buffer< sint04 > resource_ids_black_list
Exclude these resource IDs.
Buffer< TimeSpan > edited_time_span
Filter by edit time ranges.
String name_search_regex
Regex to match resource names.
Encapsulates a server command's return status, including a code and optional message.
String return_message
Optional human-readable status message.
ReturnCode
Enumeration of possible return codes from server operations.
ReturnCode return_code
The status code of the operation.
Stores user credentials for server authentication, including username, password hash,...
String ip_address
IP address of the client.
String username
The user's login name.
sint04 user_id
Numeric user ID assigned by the server.
UUID encoded_user_password
Hashed/encoded user password.
bool credentials_validated
Whether credentials have been validated.
Holds general information about an NDEVR server instance.
String server_name
Display name of the server.
bool auto_approve_users
Whether new user registrations are auto-approved.
uint08 version
Server protocol version.
String admin_email
Administrator's email address.
Defines permissions for a user to access a specific resource, including encryption data.
bool allow_tree
Whether the user can view the resource tree.
bool link_shared
Whether the resource is shared via link.
HighCapacityBuffer< uint01 > encoded_link_password
Encrypted link password.
bool permission_read_validated
Whether read permission has been validated.
bool allow_measure
Whether the user can measure in the resource.
bool allow_export
Whether the user can export the resource.
sint04 permission_id
Numeric permission ID.
TimeSpan lifespan
Duration before this permission expires.
String permission_name
Display name for this permission.
bool permission_write_validated
Whether write permission has been validated.
sint04 permission_owner_id
User who owns this permission.
bool has_write_permissions
Whether the user can write to the resource.
bool share_owner_info
Whether to share owner information.
UUID link_password
Password for shared links.
bool has_edit_permissions
Whether the user can edit the resource.
HighCapacityBuffer< uint01 > encoded_decrypt_password
Encrypted decryption password.
bool is_public
Whether this permission is public.
HighCapacityBuffer< uint01 > encoded_resource_password
Encrypted resource password.
Buffer< EncodedMessage > user_permissions
Encoded permission messages.
Metadata for a server-hosted resource including type, timestamps, size, and cached data.
String categories
Semicolon-separated category tags.
Time modified_time
When the resource was last modified.
File cached_data
Local file path to cached resource data.
String mime_type
MIME type of the resource.
String resource_info
Additional resource information string.
Buffer< uint01 > icon
Icon image data for the resource.
uint08 resource_size
Size of the resource in bytes.
Time creation_time
When the resource was created.
Time access_time
When the resource was last accessed.
Extended user information including contact details and encryption keys.
Buffer< uint01 > encoded_private_key
User's encrypted private key.
Buffer< uint01 > public_key
User's public encryption key.
String phone_number
User's phone number.
String email
User's email address.
bool is_public
Whether the user profile is publicly visible.