Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

merge models #1749

Merged
merged 1 commit into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 70 additions & 39 deletions src/ApiService/ApiService/OneFuzzTypes/Model.cs
Original file line number Diff line number Diff line change
@@ -1,61 +1,92 @@
using Azure.Data.Tables;
using Azure.ResourceManager.Storage.Models;
using Microsoft.OneFuzz.Service.OneFuzzLib.Orm;
using System;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
using System.Collections.Generic;

namespace Microsoft.OneFuzz.Service;


record NodeCommandStopIfFree { }
/// Convention for database entities:
/// All entities are represented by immutable records
/// All database entities need to derive from EntityBase
/// Only properties that also apears as parameter initializers are mapped to the database
/// The name of the property will be tranlated to snake case and used as the column name
/// It is possible to rename the column name by using the [property:JsonPropertyName("column_name")] attribute
/// the "partion key" and "row key" are identified by the [PartitionKey] and [RowKey] attributes
/// Guids are mapped to string in the db

record StopNodeCommand{}

record StopTaskNodeCommand{
Guid TaskId;
[SkipRename]
public enum HeartbeatType
{
MachineAlive,
TaskAlive,
}

record NodeCommandAddSshKey{
string PublicKey;
}
public record HeartbeatData(HeartbeatType type);

record NodeCommand
{
StopNodeCommand? Stop;
StopTaskNodeCommand? StopTask;
NodeCommandAddSshKey? AddSshKey;
NodeCommandStopIfFree? StopIfFree;
}
public record NodeHeartbeatEntry(Guid NodeId, HeartbeatData[] data);

enum NodeTaskState
{
init,
setting_up,
running,
}
public record NodeCommandStopIfFree();

record NodeTasks
{
Guid MachineId;
Guid TaskId;
NodeTaskState State = NodeTaskState.init;
public record StopNodeCommand();

public record StopTaskNodeCommand(Guid TaskId);

public record NodeCommandAddSshKey(string PublicKey);


public record NodeCommand
(
StopNodeCommand? Stop,
StopTaskNodeCommand? StopTask,
NodeCommandAddSshKey? AddSshKey,
NodeCommandStopIfFree? StopIfFree
);

public enum NodeTaskState
{
Init,
SettingUp,
Running,
}

enum NodeState
public record NodeTasks
(
Guid MachineId,
Guid TaskId,
NodeTaskState State = NodeTaskState.Init
);

public enum NodeState
{
init,
Init,
free,
setting_up,
rebooting,
ready,
busy,
done,
shutdown,
halt,
SettingUp,
Rebooting,
Ready,
Busy,
Done,
Shutdown,
Halt,
}


public partial record Node
(
DateTimeOffset? InitializedAt,
[PartitionKey] string PoolName,
Guid? PoolId,
[RowKey] Guid MachineId,
NodeState State,
Guid? ScalesetId,
DateTimeOffset Heartbeat,
Version Version,
bool ReimageRequested,
bool DeleteRequested,
bool DebugKeepNode
) : EntityBase();


public record Error (ErrorCode Code, string[]? Errors = null);

public record UserInfo (Guid? ApplicationId, Guid? ObjectId, String? Upn);
public record UserInfo (Guid? ApplicationId, Guid? ObjectId, String? Upn);
1 change: 0 additions & 1 deletion src/ApiService/ApiService/UserCredentials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using ApiService;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Network.Models;
using Microsoft.Azure.Functions.Worker.Http;
Expand Down
87 changes: 0 additions & 87 deletions src/ApiService/ApiService/model.cs

This file was deleted.