mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 10:46:30 +00:00
consolidate CommonSecurity to Common.dll
This commit is contained in:
@@ -4,7 +4,6 @@ using System.Runtime.CompilerServices;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Azaion.Common.Database;
|
||||
using Azaion.Common.Extensions;
|
||||
using Azaion.CommonSecurity.DTO;
|
||||
|
||||
namespace Azaion.Common.DTO;
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using CommandLine;
|
||||
using MessagePack;
|
||||
|
||||
namespace Azaion.Common.DTO;
|
||||
|
||||
[MessagePackObject]
|
||||
public class ApiCredentials : EventArgs
|
||||
{
|
||||
[Key(nameof(Email))]
|
||||
[Option('e', "email", Required = true, HelpText = "User Email")]
|
||||
public string Email { get; set; } = null!;
|
||||
|
||||
[Key(nameof(Password))]
|
||||
[Option('p', "pass", Required = true, HelpText = "User Password")]
|
||||
public string Password { get; set; } = null!;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Azaion.Common.DTO;
|
||||
|
||||
public class BusinessExceptionDto
|
||||
{
|
||||
public int ErrorCode { get; set; }
|
||||
public string Message { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Azaion.CommonSecurity;
|
||||
using Azaion.CommonSecurity.DTO;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Azaion.Common.DTO.Config;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace Azaion.Common.DTO;
|
||||
|
||||
public class DirectoriesConfig
|
||||
|
||||
{
|
||||
public string ApiResourcesDirectory { get; set; } = null!;
|
||||
|
||||
public string VideosDirectory { get; set; } = null!;
|
||||
public string LabelsDirectory { get; set; } = null!;
|
||||
public string ImagesDirectory { get; set; } = null!;
|
||||
public string ResultsDirectory { get; set; } = null!;
|
||||
public string ThumbnailsDirectory { get; set; } = null!;
|
||||
|
||||
public string GpsSatDirectory { get; set; } = null!;
|
||||
public string GpsRouteDirectory { get; set; } = null!;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace Azaion.Common.DTO;
|
||||
|
||||
public abstract class ExternalClientConfig
|
||||
{
|
||||
public string ZeroMqHost { get; set; } = "";
|
||||
public int ZeroMqPort { get; set; }
|
||||
}
|
||||
|
||||
public class LoaderClientConfig : ExternalClientConfig
|
||||
{
|
||||
public string ApiUrl { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class InferenceClientConfig : ExternalClientConfig
|
||||
{
|
||||
public string ApiUrl { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class GpsDeniedClientConfig : ExternalClientConfig
|
||||
{
|
||||
public int ZeroMqReceiverPort { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Azaion.Common.DTO;
|
||||
|
||||
public static class EnumerableExtensions
|
||||
{
|
||||
public static bool In<T>(this T obj, params T[] objects) =>
|
||||
objects.Contains(obj);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Azaion.Common.DTO;
|
||||
|
||||
public class InitConfig
|
||||
{
|
||||
public LoaderClientConfig LoaderClientConfig { get; set; } = null!;
|
||||
public InferenceClientConfig InferenceClientConfig { get; set; } = null!;
|
||||
public GpsDeniedClientConfig GpsDeniedClientConfig { get; set; } = null!;
|
||||
public DirectoriesConfig DirectoriesConfig { get; set; } = null!;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Azaion.Common.DTO;
|
||||
|
||||
public class LoginResponse
|
||||
{
|
||||
public string Token { get; set; } = null!;
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using Azaion.Common.Database;
|
||||
using Azaion.CommonSecurity.DTO;
|
||||
|
||||
namespace Azaion.Common.DTO.Queue;
|
||||
using MessagePack;
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
using MessagePack;
|
||||
|
||||
namespace Azaion.Common.DTO;
|
||||
|
||||
[MessagePackObject]
|
||||
public class RemoteCommand(CommandType commandType, byte[]? data = null, string? message = null)
|
||||
{
|
||||
[Key("CommandType")]
|
||||
public CommandType CommandType { get; set; } = commandType;
|
||||
|
||||
[Key("Data")]
|
||||
public byte[]? Data { get; set; } = data;
|
||||
|
||||
[Key("Message")]
|
||||
public string? Message { get; set; } = message;
|
||||
|
||||
public static RemoteCommand Create(CommandType commandType) =>
|
||||
new(commandType);
|
||||
|
||||
public static RemoteCommand Create<T>(CommandType commandType, T data, string? message = null) where T : class =>
|
||||
new(commandType, MessagePackSerializer.Serialize(data), message);
|
||||
|
||||
public override string ToString() => $"({CommandType.ToString().ToUpper()}: Data: {Data?.Length ?? 0} bytes. Message: {Message})";
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public class LoadFileData(string filename, string? folder = null )
|
||||
{
|
||||
[Key(nameof(Folder))]
|
||||
public string? Folder { get; set; } = folder;
|
||||
|
||||
[Key(nameof(Filename))]
|
||||
public string Filename { get; set; } = filename;
|
||||
}
|
||||
|
||||
|
||||
public enum CommandType
|
||||
{
|
||||
None = 0,
|
||||
Ok = 3,
|
||||
Login = 10,
|
||||
ListRequest = 15,
|
||||
ListFiles = 18,
|
||||
Load = 20,
|
||||
LoadBigSmall = 22,
|
||||
UploadBigSmall = 24,
|
||||
DataBytes = 25,
|
||||
Inference = 30,
|
||||
InferenceData = 35,
|
||||
StopInference = 40,
|
||||
AIAvailabilityCheck = 80,
|
||||
AIAvailabilityResult = 85,
|
||||
Error = 90,
|
||||
Exit = 100,
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Azaion.Common.DTO;
|
||||
|
||||
public enum RoleEnum
|
||||
{
|
||||
None = 0,
|
||||
Operator = 10, //only annotator is available. Could send annotations to queue.
|
||||
Validator = 20, //annotator + dataset explorer. This role allows to receive annotations from the queue.
|
||||
CompanionPC = 30,
|
||||
Admin = 40, //
|
||||
ApiAdmin = 1000 //everything
|
||||
}
|
||||
|
||||
public static class RoleEnumExtensions
|
||||
{
|
||||
public static bool IsValidator(this RoleEnum role) =>
|
||||
role.In(RoleEnum.Validator, RoleEnum.Admin, RoleEnum.ApiAdmin);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace Azaion.Common.DTO;
|
||||
|
||||
public class User
|
||||
{
|
||||
public string Id { get; set; } = "";
|
||||
public string Email { get; set; } = "";
|
||||
public RoleEnum Role { get; set; }
|
||||
public UserConfig? UserConfig { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class UserConfig
|
||||
{
|
||||
public UserQueueOffsets? QueueOffsets { get; set; } = new();
|
||||
}
|
||||
|
||||
public class UserQueueOffsets
|
||||
{
|
||||
public ulong AnnotationsOffset { get; set; }
|
||||
public ulong AnnotationsConfirmOffset { get; set; }
|
||||
public ulong AnnotationsCommandsOffset { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user