Add CloudScript models

This commit is contained in:
AeonLucid
2021-10-31 03:42:19 +01:00
parent 876fcb2369
commit 07cd3e9855
11 changed files with 353 additions and 0 deletions
@@ -0,0 +1,9 @@
namespace Prospect.Server.Api.Models.Client.Data
{
public enum CloudScriptRevisionOption
{
Live,
Latest,
Specific
}
}
@@ -0,0 +1,29 @@
using System.Text.Json.Serialization;
namespace Prospect.Server.Api.Models.Client.Data
{
public class FFunctionExecutionError
{
/// <summary>
/// [optional] Error code, such as CloudScriptAzureFunctionsExecutionTimeLimitExceeded, CloudScriptAzureFunctionsArgumentSizeExceeded,
/// CloudScriptAzureFunctionsReturnSizeExceeded or CloudScriptAzureFunctionsHTTPRequestError
/// </summary>
[JsonPropertyName("Error")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string Error { get; set; }
/// <summary>
/// [optional] Details about the error
/// </summary>
[JsonPropertyName("Message")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string Message { get; set; }
/// <summary>
/// [optional] Point during the execution of the function at which the error occurred, if any
/// </summary>
[JsonPropertyName("StackTrace")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string StackTrace { get; set; }
}
}
@@ -0,0 +1,28 @@
using System.Text.Json.Serialization;
namespace Prospect.Server.Api.Models.Client.Data
{
public class FLogStatement
{
/// <summary>
/// [optional] Optional object accompanying the message as contextual information
/// </summary>
[JsonPropertyName("Data")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public object Data { get; set; }
/// <summary>
/// [optional] 'Debug', 'Info', or 'Error'
/// </summary>
[JsonPropertyName("Level")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string Level { get; set; }
/// <summary>
/// [optional] undefined
/// </summary>
[JsonPropertyName("Message")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string Message { get; set; }
}
}
@@ -0,0 +1,29 @@
using System.Text.Json.Serialization;
namespace Prospect.Server.Api.Models.Client.Data
{
public class FScriptExecutionError
{
/// <summary>
/// [optional] Error code, such as CloudScriptNotFound, JavascriptException, CloudScriptFunctionArgumentSizeExceeded,
/// CloudScriptAPIRequestCountExceeded, CloudScriptAPIRequestError, or CloudScriptHTTPRequestError
/// </summary>
[JsonPropertyName("Error")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string Error { get; set; }
/// <summary>
/// [optional] Details about the error
/// </summary>
[JsonPropertyName("Message")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string Message { get; set; }
/// <summary>
/// [optional] Point during the execution of the script at which the error occurred, if any
/// </summary>
[JsonPropertyName("StackTrace")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string StackTrace { get; set; }
}
}
@@ -0,0 +1,85 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Prospect.Server.Api.Models.Client.Data;
namespace Prospect.Server.Api.Models.Client
{
public class FExecuteCloudScriptResult
{
/// <summary>
/// Number of PlayFab API requests issued by the CloudScript function
/// </summary>
[JsonPropertyName("APIRequestsIssued")]
public int APIRequestsIssued { get; set; }
/// <summary>
/// [optional] Information about the error, if any, that occurred during execution
/// </summary>
[JsonPropertyName("Error")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public FScriptExecutionError Error { get; set; }
[JsonPropertyName("ExecutionTimeSeconds")]
public double? ExecutionTimeSeconds { get; set; }
/// <summary>
/// [optional] The name of the function that executed
/// </summary>
[JsonPropertyName("FunctionName")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string FunctionName { get; set; }
/// <summary>
/// [optional] The object returned from the CloudScript function, if any
/// </summary>
[JsonPropertyName("FunctionResult")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public object FunctionResult { get; set; }
/// <summary>
/// [optional] Flag indicating if the FunctionResult was too large and was subsequently dropped from this event. This only occurs if
/// the total event size is larger than 350KB.
/// </summary>
[JsonPropertyName("FunctionResultTooLarge")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? FunctionResultTooLarge { get; set; }
/// <summary>
/// Number of external HTTP requests issued by the CloudScript function
/// </summary>
[JsonPropertyName("HttpRequestsIssued")]
public int HttpRequestsIssued { get; set; }
/// <summary>
/// [optional] Entries logged during the function execution. These include both entries logged in the function code using log.info()
/// and log.error() and error entries for API and HTTP request failures.
/// </summary>
[JsonPropertyName("Logs")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public List<FLogStatement> Logs { get; set; }
/// <summary>
/// [optional] Flag indicating if the logs were too large and were subsequently dropped from this event. This only occurs if the total
/// event size is larger than 350KB after the FunctionResult was removed.
/// </summary>
[JsonPropertyName("LogsTooLarge")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? LogsTooLarge { get; set; }
[JsonPropertyName("MemoryConsumedBytes")]
public uint MemoryConsumedBytes { get; set; }
/// <summary>
/// Processor time consumed while executing the function. This does not include time spent waiting on API calls or HTTP
/// requests.
/// </summary>
[JsonPropertyName("ProcessorTimeSeconds")]
public double ProcessorTimeSeconds { get; set; }
/// <summary>
/// The revision of the CloudScript that executed
/// </summary>
[JsonPropertyName("Revision")]
public int Revision { get; set; }
}
}
@@ -0,0 +1,60 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Prospect.Server.Api.Models.Client.Data;
namespace Prospect.Server.Api.Models.Client
{
public class FExecuteCloudScriptServerRequest
{
/// <summary>
/// [optional] The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.).
/// </summary>
[JsonPropertyName("CustomTags")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public Dictionary<string, string> CustomTags { get; set; }
/// <summary>
/// The name of the CloudScript function to execute
/// </summary>
[JsonPropertyName("FunctionName")]
public string FunctionName { get; set; }
/// <summary>
/// [optional] Object that is passed in to the function as the first argument
/// </summary>
[JsonPropertyName("FunctionParameter")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string FunctionParameter { get; set; }
/// <summary>
/// [optional] Generate a 'player_executed_cloudscript' PlayStream event containing the results of the function execution and other
/// contextual information. This event will show up in the PlayStream debugger console for the player in Game Manager.
/// </summary>
[JsonPropertyName("GeneratePlayStreamEvent")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? GeneratePlayStreamEvent { get; set; }
/// <summary>
/// The unique user identifier for the player on whose behalf the script is being run
/// </summary>
[JsonPropertyName("PlayFabId")]
public string PlayFabId { get; set; }
/// <summary>
/// [optional] Option for which revision of the CloudScript to execute. 'Latest' executes the most recently created revision, 'Live'
/// executes the current live, published revision, and 'Specific' executes the specified revision. The default value is
/// 'Specific', if the SpeificRevision parameter is specified, otherwise it is 'Live'.
/// </summary>
[JsonPropertyName("RevisionSelection")]
[JsonConverter(typeof(JsonStringEnumConverter))]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public CloudScriptRevisionOption? RevisionSelection { get; set; }
/// <summary>
/// [optional] The specivic revision to execute, when RevisionSelection is set to 'Specific'
/// </summary>
[JsonPropertyName("SpecificRevision")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public int? SpecificRevision { get; set; }
}
}
@@ -0,0 +1,44 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Prospect.Server.Api.Models.Client.Data;
namespace Prospect.Server.Api.Models.Client
{
public class FExecuteFunctionRequest
{
/// <summary>
/// [optional] The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.).
/// </summary>
[JsonPropertyName("CustomTags")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public Dictionary<string, string> CustomTags { get; set; }
/// <summary>
/// [optional] The entity to perform this action on.
/// </summary>
[JsonPropertyName("Entity")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public FEntityKey Entity { get; set; }
/// <summary>
/// The name of the CloudScript function to execute
/// </summary>
[JsonPropertyName("FunctionName")]
public string FunctionName { get; set; }
/// <summary>
/// [optional] Object that is passed in to the function as the FunctionArgument field of the FunctionExecutionContext data structure
/// </summary>
[JsonPropertyName("FunctionParameter")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string FunctionParameter { get; set; }
/// <summary>
/// [optional] Generate a 'entity_executed_cloudscript_function' PlayStream event containing the results of the function execution and
/// other contextual information. This event will show up in the PlayStream debugger console for the player in Game Manager.
/// </summary>
[JsonPropertyName("GeneratePlayStreamEvent")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? GeneratePlayStreamEvent { get; set; }
}
}
@@ -0,0 +1,41 @@
using System.Text.Json.Serialization;
using Prospect.Server.Api.Models.Client.Data;
namespace Prospect.Server.Api.Models.Client
{
public class FExecuteFunctionResult
{
/// <summary>
/// [optional] Error from the CloudScript Azure Function.
/// </summary>
[JsonPropertyName("Error")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public FFunctionExecutionError Error { get; set; }
/// <summary>
/// The amount of time the function took to execute
/// </summary>
[JsonPropertyName("ExecutionTimeMilliseconds")]
public int ExecutionTimeMilliseconds { get; set; }
/// <summary>
/// [optional] The name of the function that executed
/// </summary>
[JsonPropertyName("FunctionName")]
public string FunctionName { get; set; }
/// <summary>
/// [optional] The object returned from the function, if any
/// </summary>
[JsonPropertyName("FunctionResult")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public object FunctionResult { get; set; }
/// <summary>
/// [optional] Flag indicating if the FunctionResult was too large and was subsequently dropped from this event.
/// </summary>
[JsonPropertyName("FunctionResultTooLarge")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool? FunctionResultTooLarge { get; set; }
}
}
@@ -9,6 +9,7 @@ namespace Prospect.Server.Api.Models.Client
/// [optional] The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.).
/// </summary>
[JsonPropertyName("CustomTags")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public Dictionary<string, string> CustomTags { get; set; }
}
}
@@ -9,6 +9,7 @@ namespace Prospect.Server.Api.Models.Client
/// [optional] The optional custom tags associated with the request (e.g. build number, external trace identifiers, etc.).
/// </summary>
[JsonPropertyName("CustomTags")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public Dictionary<string, string> CustomTags { get; set; }
/// <summary>