This commit is contained in:
2025-06-16 15:14:23 +02:00
commit 074e590073
3174 changed files with 428263 additions and 0 deletions

View File

@ -0,0 +1,298 @@
using System;
using System.Collections.Specialized;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
// using Codice.Utils; // MIRROR CHANGE
using Edgegap.Codice.Utils; // MIRROR CHANGE
using UnityEngine;
namespace Edgegap.Editor.Api
{
/// <summary>
/// Handles base URL and common methods for all Edgegap APIs.
/// </summary>
public abstract class EdgegapApiBase
{
#region Vars
private readonly HttpClient _httpClient = new HttpClient(); // Base address set // MIRROR CHANGE: Unity 2020 support
protected ApiEnvironment SelectedApiEnvironment { get; }
protected EdgegapWindowMetadata.LogLevel LogLevel { get; set; }
protected bool IsLogLevelDebug => LogLevel == EdgegapWindowMetadata.LogLevel.Debug;
/// <summary>Based on SelectedApiEnvironment.</summary>
/// <returns></returns>
private string GetBaseUrl() =>
SelectedApiEnvironment == ApiEnvironment.Staging
? ApiEnvironment.Staging.GetApiUrl()
: ApiEnvironment.Console.GetApiUrl();
#endregion // Vars
/// <param name="apiEnvironment">"console" || "staging-console"?</param>
/// <param name="apiToken">Without the "token " prefix, although we'll clear this if present</param>
/// <param name="logLevel">You may want more-verbose logs other than errs</param>
protected EdgegapApiBase(
ApiEnvironment apiEnvironment,
string apiToken,
EdgegapWindowMetadata.LogLevel logLevel = EdgegapWindowMetadata.LogLevel.Error
)
{
this.SelectedApiEnvironment = apiEnvironment;
this._httpClient.BaseAddress = new Uri($"{GetBaseUrl()}/");
this._httpClient.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json")
);
string cleanedApiToken = apiToken.Replace("token ", ""); // We already prefixed token below
this._httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
"token",
cleanedApiToken
);
this.LogLevel = logLevel;
}
#region HTTP Requests
/// <summary>
/// POST | We already added "https://api.edgegap.com/" (or similar) BaseAddress via constructor.
/// </summary>
/// <param name="relativePath"></param>
/// <param name="json">Serialize to your model via Newtonsoft</param>
/// <returns>
/// - Success => returns HttpResponseMessage result
/// - Error => Catches errs => returns null (no rethrow)
/// </returns>
protected async Task<HttpResponseMessage> PostAsync(
string relativePath = "",
string json = "{}"
)
{
StringContent stringContent = CreateStringContent(json);
Uri uri = new Uri(_httpClient.BaseAddress, relativePath); // Normalize POST uri: Can't end with `/`.
if (IsLogLevelDebug)
Debug.Log($"PostAsync to: `{uri}` with json: `{json}`");
try
{
return await ExecuteRequestAsync(() => _httpClient.PostAsync(uri, stringContent));
}
catch (Exception e)
{
Debug.LogError($"Error: {e}");
throw;
}
}
/// <summary>
/// PATCH | We already added "https://api.edgegap.com/" (or similar) BaseAddress via constructor.
/// </summary>
/// <param name="relativePath"></param>
/// <param name="json">Serialize to your model via Newtonsoft</param>
/// <returns>
/// - Success => returns HttpResponseMessage result
/// - Error => Catches errs => returns null (no rethrow)
/// </returns>
protected async Task<HttpResponseMessage> PatchAsync(
string relativePath = "",
string json = "{}"
)
{
StringContent stringContent = CreateStringContent(json);
Uri uri = new Uri(_httpClient.BaseAddress, relativePath); // Normalize PATCH uri: Can't end with `/`.
if (IsLogLevelDebug)
Debug.Log($"PatchAsync to: `{uri}` with json: `{json}`");
// (!) As of 11/15/2023, .PatchAsync() is "unsupported by Unity" -- so we manually set the verb and SendAsync()
// Create the request manually
HttpRequestMessage patchRequest = new HttpRequestMessage(new HttpMethod("PATCH"), uri)
{
Content = stringContent,
};
try
{
return await ExecuteRequestAsync(() => _httpClient.SendAsync(patchRequest));
}
catch (Exception e)
{
Debug.LogError($"Error: {e}");
throw;
}
}
/// <summary>
/// GET | We already added "https://api.edgegap.com/" (or similar) BaseAddress via constructor.
/// </summary>
/// <param name="relativePath"></param>
/// <param name="customQuery">
/// To append to the URL; eg: "foo=0&bar=1"
/// (!) First query key should prefix nothing, as shown</param>
/// <returns>
/// - Success => returns HttpResponseMessage result
/// - Error => Catches errs => returns null (no rethrow)
/// </returns>
protected async Task<HttpResponseMessage> GetAsync(
string relativePath = "",
string customQuery = ""
)
{
string completeRelativeUri = prepareEdgegapUriWithQuery(relativePath, customQuery);
if (IsLogLevelDebug)
Debug.Log($"GetAsync to: `{completeRelativeUri} with customQuery: `{customQuery}`");
try
{
return await ExecuteRequestAsync(() => _httpClient.GetAsync(completeRelativeUri));
}
catch (Exception e)
{
Debug.LogError($"Error: {e}");
throw;
}
}
/// <summary>
/// DELETE | We already added "https://api.edgegap.com/" (or similar) BaseAddress via constructor.
/// </summary>
/// <param name="relativePath"></param>
/// <param name="customQuery">
/// To append to the URL; eg: "foo=0&bar=1"
/// (!) First query key should prefix nothing, as shown</param>
/// <returns>
/// - Success => returns HttpResponseMessage result
/// - Error => Catches errs => returns null (no rethrow)
/// </returns>
protected async Task<HttpResponseMessage> DeleteAsync(
string relativePath = "",
string customQuery = ""
)
{
string completeRelativeUri = prepareEdgegapUriWithQuery(relativePath, customQuery);
if (IsLogLevelDebug)
Debug.Log(
$"DeleteAsync to: `{completeRelativeUri} with customQuery: `{customQuery}`"
);
try
{
return await ExecuteRequestAsync(
() => _httpClient.DeleteAsync(completeRelativeUri)
);
}
catch (Exception e)
{
Debug.LogError($"Error: {e}");
throw;
}
}
/// <summary>POST || GET</summary>
/// <param name="requestFunc"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
private static async Task<HttpResponseMessage> ExecuteRequestAsync(
Func<Task<HttpResponseMessage>> requestFunc,
CancellationToken cancellationToken = default
)
{
HttpResponseMessage response = null;
try
{
response = await requestFunc();
}
catch (HttpRequestException e)
{
Debug.LogError($"HttpRequestException: {e.Message}");
return null;
}
catch (TaskCanceledException e)
{
if (cancellationToken.IsCancellationRequested)
Debug.LogError("Task was cancelled by caller.");
else
Debug.LogError($"TaskCanceledException: Timeout - {e.Message}");
return null;
}
catch (Exception e) // Generic exception handler
{
Debug.LogError($"Unexpected error occurred: {e.Message}");
return null;
}
// Check for a successful status code
if (response == null)
{
Debug.Log("Error: (null response) - returning 500");
return CreateUnknown500Err();
}
if (!response.IsSuccessStatusCode)
{
HttpMethod httpMethod = response.RequestMessage.Method;
Debug.Log(
$"Error: {(short)response.StatusCode} {response.ReasonPhrase} - "
+ $"{httpMethod} | {response.RequestMessage.RequestUri}` - "
+ $"{response.Content?.ReadAsStringAsync().Result}"
);
}
return response;
}
#endregion // HTTP Requests
#region Utils
/// <summary>Creates a UTF-8 encoded application/json + json obj</summary>
/// <param name="json">Arbitrary json obj</param>
/// <returns></returns>
private StringContent CreateStringContent(string json = "{}") =>
new StringContent(json, Encoding.UTF8, "application/json"); // MIRROR CHANGE: 'new()' not supported in Unity 2020
private static HttpResponseMessage CreateUnknown500Err() =>
new HttpResponseMessage(HttpStatusCode.InternalServerError); // 500 - Unknown // MIRROR CHANGE: 'new()' not supported in Unity 2020
/// <summary>
/// Merges Edgegap-required query params (source) -> merges with custom query -> normalizes.
/// </summary>
/// <param name="relativePath"></param>
/// <param name="customQuery"></param>
/// <returns></returns>
private string prepareEdgegapUriWithQuery(string relativePath, string customQuery)
{
// Create UriBuilder using the BaseAddress
UriBuilder uriBuilder = new UriBuilder(_httpClient.BaseAddress);
// Add the relative path to the UriBuilder's path
uriBuilder.Path += relativePath;
// Parse the existing query from the UriBuilder
NameValueCollection query = HttpUtility.ParseQueryString(uriBuilder.Query);
// Add default "source=unity" param
query["source"] = "unity";
// Parse and merge the custom query parameters
NameValueCollection customParams = HttpUtility.ParseQueryString(customQuery);
foreach (string key in customParams)
{
query[key] = customParams[key];
}
// Set the merged query back to the UriBuilder
uriBuilder.Query = query.ToString();
// Extract the complete relative URI and return it
return uriBuilder.Uri.PathAndQuery;
}
#endregion // Utils
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 50379f30f5137224aa05a5c7b6b5ebba
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/EdgegapApiBase.cs
uploadId: 736421

View File

@ -0,0 +1,188 @@
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Edgegap.Editor.Api.Models.Requests;
using Edgegap.Editor.Api.Models.Results;
namespace Edgegap.Editor.Api
{
/// <summary>
/// Wraps the v1/app API endpoint: Applications Control API.
/// - API Doc | https://docs.edgegap.com/api/#tag/Applications
/// </summary>
public class EdgegapAppApi : EdgegapApiBase
{
public EdgegapAppApi(
ApiEnvironment apiEnvironment,
string apiToken,
EdgegapWindowMetadata.LogLevel logLevel = EdgegapWindowMetadata.LogLevel.Error)
: base(apiEnvironment, apiToken, logLevel)
{
}
#region API Methods
/// <summary>
/// POST to v1/app
/// - Create an application that will regroup application versions.
/// - API Doc | https://docs.edgegap.com/api/#tag/Applications/operation/application-post
/// </summary>
/// <returns>
/// Http info with GetCreateAppResult data model
/// - Success: 200
/// - Fail: 409 (app already exists), 400 (reached limit)
/// </returns>
public async Task<EdgegapHttpResult<GetCreateAppResult>> CreateApp(CreateAppRequest request)
{
HttpResponseMessage response = await PostAsync("v1/app", request.ToString());
EdgegapHttpResult<GetCreateAppResult> result = new EdgegapHttpResult<GetCreateAppResult>(response); // MIRROR CHANGE: 'new()' not supported in Unity 2020
bool isSuccess = response.StatusCode == HttpStatusCode.OK; // 200
if (!isSuccess)
return result;
return result;
}
/// <summary>
/// GET to v1/app
/// - Get an application that will regroup application versions.
/// - API Doc | https://docs.edgegap.com/api/#tag/Applications/operation/application-post
/// </summary>
/// <returns>
/// Http info with GetCreateAppResult data model
/// - Success: 200
/// </returns>
public async Task<EdgegapHttpResult<GetCreateAppResult>> GetApp(string appName)
{
HttpResponseMessage response = await GetAsync($"v1/app/{appName}");
EdgegapHttpResult<GetCreateAppResult> result = new EdgegapHttpResult<GetCreateAppResult>(response); // MIRROR CHANGE: 'new()' not supported in Unity 2020
bool isSuccess = response.StatusCode == HttpStatusCode.OK; // 200
if (!isSuccess)
return result;
return result;
}
/// <summary>
/// PATCH to v1/app/{app_name}/version/{version_name}
/// - Update an *existing* application version with new specifications.
/// - API Doc | https://docs.edgegap.com/api/#tag/Applications/operation/app-versions-patch
/// </summary>
/// <returns>
/// Http info with UpdateAppVersionRequest data model
/// - Success: 200
/// </returns>
public async Task<EdgegapHttpResult<UpsertAppVersionResult>> UpdateAppVersion(UpdateAppVersionRequest request)
{
string relativePath = $"v1/app/{request.AppName}/version/{request.VersionName}";
HttpResponseMessage response = await PatchAsync(relativePath, request.ToString());
EdgegapHttpResult<UpsertAppVersionResult> result = new EdgegapHttpResult<UpsertAppVersionResult>(response); // MIRROR CHANGE: 'new()' not supported in Unity 2020
bool isSuccess = response.StatusCode == HttpStatusCode.OK; // 200
if (!isSuccess)
return result;
return result;
}
/// <summary>
/// POST to v1/app/{app_name}/version
/// - Create an new application version with new specifications.
/// - API Doc | https://docs.edgegap.com/api/#tag/Applications/operation/app-version-post
/// </summary>
/// <returns>
/// Http info with UpdateAppVersionRequest data model
/// - Success: 200 (no result model)
/// - Fail: 409 (app already exists), 400 (reached limit)
/// </returns>
public async Task<EdgegapHttpResult<UpsertAppVersionResult>> CreateAppVersion(CreateAppVersionRequest request)
{
string relativePath = $"v1/app/{request.AppName}/version";
HttpResponseMessage response = await PostAsync(relativePath, request.ToString());
EdgegapHttpResult<UpsertAppVersionResult> result = new EdgegapHttpResult<UpsertAppVersionResult>(response); // MIRROR CHANGE: 'new()' not supported in Unity 2020
bool isSuccess = response.StatusCode == HttpStatusCode.OK; // 200
if (!isSuccess)
return result;
return result;
}
/// <summary>
/// GET to v1/apps
/// - Get all applications.
/// - API Doc | https://docs.edgegap.com/api/#tag/Applications/operation/applications-get
/// </summary>
/// <returns>
/// Http info with GetAppsResult data model
/// - Success: 200
/// </returns>
public async Task<EdgegapHttpResult<GetAppsResult>> GetApps()
{
HttpResponseMessage response = await GetAsync($"v1/apps");
EdgegapHttpResult<GetAppsResult> result = new EdgegapHttpResult<GetAppsResult>(response); // MIRROR CHANGE: 'new()' not supported in Unity 2020
bool isSuccess = response.StatusCode == HttpStatusCode.OK; // 200
if (!isSuccess)
return result;
return result;
}
/// <summary>
/// GET to v1/app/{appName}/versions
/// </summary>
/// <returns>
/// Http info with GetAppVersionsResult data model
/// - Success: 200
/// </returns>
public async Task<EdgegapHttpResult<GetAppVersionsResult>> GetAppVersions(string appName)
{
HttpResponseMessage response = await GetAsync($"v1/app/{appName}/versions");
EdgegapHttpResult<GetAppVersionsResult> result = new EdgegapHttpResult<GetAppVersionsResult>(response);
bool isSuccess = response.StatusCode == HttpStatusCode.OK; // 200
if (!isSuccess)
return result;
return result;
}
#endregion // API Methods
#region Chained API Methods
/// <summary>
/// PATCH and/or POST to v1/app/: Upsert an *existing* application version with new specifications.
/// - Consumes either 1 or 2 API calls: 1st tries to PATCH, then POST if PATCH fails (!exists).
/// - API POST Doc | https://docs.edgegap.com/api/#tag/Applications/operation/app-version-post
/// - API PATCH Doc | https://docs.edgegap.com/api/#tag/Applications/operation/app-versions-patch
/// </summary>
/// <returns>
/// Http info with UpdateAppVersionRequest data model
/// - Success: 200 (no result model)
/// - Fail: 409 (app already exists), 400 (reached limit)
/// </returns>
public async Task<EdgegapHttpResult<UpsertAppVersionResult>> UpsertAppVersion(UpdateAppVersionRequest request)
{
EdgegapHttpResult<UpsertAppVersionResult> result = await UpdateAppVersion(request); // PATCH
if (result.HasErr)
{
// Try to create, instead
CreateAppVersionRequest createAppVersionRequest = CreateAppVersionRequest.FromUpdateRequest(request);
result = await CreateAppVersion(createAppVersionRequest); // POST
}
bool isSuccess = result.StatusCode == HttpStatusCode.OK; // 200
if (!isSuccess)
return result;
return result;
}
#endregion // Chained API Methods
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 3b0b3b865abe64b49a4000294c4e9593
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/EdgegapAppApi.cs
uploadId: 736421

View File

@ -0,0 +1,206 @@
using System;
using System.Diagnostics;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Edgegap.Editor.Api.Models.Requests;
using Edgegap.Editor.Api.Models.Results;
using UnityEngine.Assertions;
namespace Edgegap.Editor.Api
{
/// <summary>
/// Wraps the v1/[deploy | status | stop] API endpoints: Deployments Control API.
/// - API Doc | https://docs.edgegap.com/api/#tag/Deployments
/// </summary>
public class EdgegapDeploymentsApi : EdgegapApiBase
{
public EdgegapDeploymentsApi(
ApiEnvironment apiEnvironment,
string apiToken,
EdgegapWindowMetadata.LogLevel logLevel = EdgegapWindowMetadata.LogLevel.Error
)
: base(apiEnvironment, apiToken, logLevel) { }
#region API Methods
/// <summary>
/// POST v1/deploy
/// - Create a new deployment. Deployment is a server instance of your application version.
/// - API Doc | https://docs.edgegap.com/api/#tag/Deployments
/// </summary>
/// <returns>
/// Http info with CreateDeploymentResult data model
/// - Success: 200
/// </returns>
public async Task<EdgegapHttpResult<CreateDeploymentResult>> CreateDeploymentAsync(
CreateDeploymentRequest request
)
{
HttpResponseMessage response = await PostAsync("v1/deploy", request.ToString());
EdgegapHttpResult<CreateDeploymentResult> result =
new EdgegapHttpResult<CreateDeploymentResult>(response); // MIRROR CHANGE: 'new()' not supported in Unity 2020
return result;
}
/// <summary>
/// GET v1/status/{requestId}
/// - Retrieve the information for a deployment.
/// - API Doc | https://docs.edgegap.com/api/#tag/Deployments/operation/deployment-status-get
/// </summary>
/// <param name="requestId">
/// Unique Identifier to keep track of your request across all Arbitrium ecosystem.
/// It's included in the response of the app deploy. Ex: "93924761ccde"</param>
/// <returns>
/// Http info with GetDeploymentStatusResult data model
/// - Success: 200
/// </returns>
public async Task<EdgegapHttpResult<GetDeploymentStatusResult>> GetDeploymentStatusAsync(
string requestId
)
{
HttpResponseMessage response = await GetAsync($"v1/status/{requestId}");
EdgegapHttpResult<GetDeploymentStatusResult> result =
new EdgegapHttpResult<GetDeploymentStatusResult>(response); // MIRROR CHANGE: 'new()' not supported in Unity 2020
bool isSuccess = response.StatusCode == HttpStatusCode.OK; // 200
if (!isSuccess)
return result;
return result;
}
public async Task<EdgegapHttpResult<GetDeploymentsResult>> GetDeploymentsAsync()
{
HttpResponseMessage response = await GetAsync($"v1/deployments");
EdgegapHttpResult<GetDeploymentsResult> result =
new EdgegapHttpResult<GetDeploymentsResult>(response);
bool isSuccess = response.StatusCode == HttpStatusCode.OK; // 200
if (!isSuccess)
return result;
return result;
}
/// <summary>
/// DELETE v1/stop/{requestId}
/// - Delete an instance of deployment. It will stop the running container and all its games.
/// - API Doc | https://docs.edgegap.com/api/#tag/Deployments/operation/deployment-status-get
/// </summary>
/// <param name="requestId">
/// Unique Identifier to keep track of your request across all Arbitrium ecosystem.
/// It's included in the response of the app deploy. Ex: "93924761ccde"</param>
/// <returns>
/// Http info with GetDeploymentStatusResult data model
/// - Success: 200
/// </returns>
public async Task<EdgegapHttpResult<StopActiveDeploymentResult>> StopActiveDeploymentAsync(
string requestId
)
{
HttpResponseMessage response = await DeleteAsync($"v1/stop/{requestId}");
EdgegapHttpResult<StopActiveDeploymentResult> result =
new EdgegapHttpResult<StopActiveDeploymentResult>(response); // MIRROR CHANGE: 'new()' not supported in Unity 2020
bool isSuccess = response.StatusCode == HttpStatusCode.OK; // 200
if (!isSuccess)
return result;
return result;
}
#endregion // API Methods
#region Chained API Methods
/// <summary>
/// POST v1/deploy => GET v1/status/{requestId}
/// - Create a new deployment. Deployment is a server instance of your application version.
/// - Then => await READY status.
/// - API Doc | https://docs.edgegap.com/api/#tag/Deployments
/// </summary>
/// <returns>
/// Http info with CreateDeploymentResult data model (with a READY deployment status)
/// - Success: 200
/// - Error: If createResult.HasErr, returns createResult
/// </returns>
public async Task<
EdgegapHttpResult<CreateDeploymentResult>
> CreateDeploymentAwaitReadyStatusAsync(
CreateDeploymentRequest request,
TimeSpan pollInterval
)
{
EdgegapHttpResult<CreateDeploymentResult> createResponse = await CreateDeploymentAsync(
request
);
// Create =>
bool isCreateSuccess = createResponse.StatusCode == HttpStatusCode.OK; // 200
if (!isCreateSuccess)
return createResponse;
// Await Status READY =>
string requestId = createResponse.Data.RequestId;
_ = await AwaitReadyStatusAsync(requestId, pollInterval);
// Return no matter what the result; no need to validate
return createResponse;
}
/// <summary>If you recently deployed but want to await READY status.</summary>
/// <param name="requestId"></param>
/// <param name="pollInterval"></param>
public async Task<EdgegapHttpResult<GetDeploymentStatusResult>> AwaitReadyStatusAsync(
string requestId,
TimeSpan pollInterval
)
{
Assert.IsTrue(!string.IsNullOrEmpty(requestId)); // Validate
EdgegapHttpResult<GetDeploymentStatusResult> statusResponse = null;
CancellationTokenSource cts = new CancellationTokenSource(
TimeSpan.FromMinutes( // MIRROR CHANGE: 'new()' not supported in Unity 2020
EdgegapWindowMetadata.DEPLOYMENT_AWAIT_READY_STATUS_TIMEOUT_MINS
)
);
bool isReady = false;
while (!isReady && !cts.Token.IsCancellationRequested)
{
await Task.Delay(pollInterval, cts.Token);
statusResponse = await GetDeploymentStatusAsync(requestId);
isReady = statusResponse.Data.CurrentStatus == EdgegapWindowMetadata.READY_STATUS;
}
return statusResponse;
}
/// <summary>If you recently stopped a deployment, but want to await TERMINATED (410) status.</summary>
/// <param name="requestId"></param>
/// <param name="pollInterval"></param>
public async Task<
EdgegapHttpResult<StopActiveDeploymentResult>
> AwaitTerminatedDeleteStatusAsync(string requestId, TimeSpan pollInterval)
{
EdgegapHttpResult<StopActiveDeploymentResult> deleteResponse = null;
CancellationTokenSource cts = new CancellationTokenSource(
TimeSpan.FromMinutes( // MIRROR CHANGE: 'new()' not supported in Unity 2020
EdgegapWindowMetadata.DEPLOYMENT_AWAIT_READY_STATUS_TIMEOUT_MINS
)
);
bool isStopped = false;
while (!isStopped && !cts.Token.IsCancellationRequested)
{
await Task.Delay(pollInterval, cts.Token);
deleteResponse = await StopActiveDeploymentAsync(requestId);
isStopped = deleteResponse.StatusCode == HttpStatusCode.Gone; // 410
}
return deleteResponse;
}
#endregion Chained API Methods
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 37ecdc6abda4402419438f2284ef2d95
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/EdgegapDeploymentsApi.cs
uploadId: 736421

View File

@ -0,0 +1,42 @@
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Edgegap.Editor.Api.Models.Results;
namespace Edgegap.Editor.Api
{
/// <summary>
/// Wraps the v1/ip API endpoint: "IP Lookup" API.
/// - API Doc | https://docs.edgegap.com/api/#tag/IP-Lookup
/// </summary>
public class EdgegapIpApi : EdgegapApiBase
{
public EdgegapIpApi(
ApiEnvironment apiEnvironment,
string apiToken,
EdgegapWindowMetadata.LogLevel logLevel = EdgegapWindowMetadata.LogLevel.Error
)
: base(apiEnvironment, apiToken, logLevel) { }
#region API Methods
/// <summary>
/// GET to v1/app
/// - Retrieve your public IP address.
/// - API Doc | https://docs.edgegap.com/api/#tag/IP-Lookup/operation/IP
/// </summary>
/// <returns>
/// Http info with GetCreateAppResult data model
/// - Success: 200
/// - Fail: 409 (app already exists), 400 (reached limit)
/// </returns>
public async Task<EdgegapHttpResult<GetYourPublicIpResult>> GetYourPublicIp()
{
HttpResponseMessage response = await GetAsync("v1/ip");
EdgegapHttpResult<GetYourPublicIpResult> result =
new EdgegapHttpResult<GetYourPublicIpResult>(response); // MIRROR CHANGE: 'new()' not supported in Unity 2020
return result;
}
#endregion // API Methods
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: fac4a7425623f39488af09d60549313e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/EdgegapIpApi.cs
uploadId: 736421

View File

@ -0,0 +1,52 @@
using System.Net.Http;
using System.Threading.Tasks;
using Edgegap.Editor.Api.Models.Results;
using Newtonsoft.Json.Linq;
namespace Edgegap.Editor.Api
{
/// <summary>Wraps the v1/wizard API endpoint. Used for internal purposes.</summary>
public class EdgegapWizardApi : EdgegapApiBase
{
/// <summary>Extended path after the base uri</summary>
public EdgegapWizardApi(
ApiEnvironment apiEnvironment,
string apiToken,
EdgegapWindowMetadata.LogLevel logLevel = EdgegapWindowMetadata.LogLevel.Error)
: base(apiEnvironment, apiToken, logLevel)
{
}
#region API Methods
/// <summary>POST to v1/wizard/init-quick-start</summary>
/// <returns>
/// Http info with no explicit data model
/// - Success: 204 (no result model)
/// </returns>
public async Task<EdgegapHttpResult> InitQuickStart()
{
string json = new JObject { ["source"] = "unity" }.ToString();
HttpResponseMessage response = await PostAsync("v1/wizard/init-quick-start", json);
EdgegapHttpResult result = new EdgegapHttpResult(response); // MIRROR CHANGE: 'new()' not supported in Unity 2020
return result;
}
/// <summary>GET to v1/wizard/registry-credentials</summary>
/// <returns>
/// - Http info with GetRegistryCredentialsResult data model
/// - Success: 200
/// - Error: Likely if called before a successful InitQuickStart(),
/// or if called in a staging env. Soon, this will be available in production.
/// </returns>
public async Task<EdgegapHttpResult<GetRegistryCredentialsResult>> GetRegistryCredentials()
{
HttpResponseMessage response = await GetAsync("v1/wizard/registry-credentials");
EdgegapHttpResult<GetRegistryCredentialsResult> result = new EdgegapHttpResult<GetRegistryCredentialsResult>(response); // MIRROR CHANGE: 'new()' not supported in Unity 2020
return result;
}
#endregion // API Methods
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: f6986ee67361f0b45928ccd70c7ab12c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/EdgegapWizardApi.cs
uploadId: 736421

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: aed107c714fce71449ef56590221c567
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,28 @@
using Newtonsoft.Json;
namespace Edgegap.Editor.Api.Models
{
/// <summary>
/// Used in `UpdateAppVersionRequest`, `CreateAppVersionRequest`.
/// For GetDeploymentStatusResult, see DeploymentPortsData
/// </summary>
public class AppPortsData
{
/// <summary>1024~49151; Default 7770</summary>
[JsonProperty("port")]
public int Port { get; set; } = EdgegapWindowMetadata.PORT_DEFAULT;
/// <summary>Default "UDP"</summary>
[JsonProperty("protocol")]
public string ProtocolStr { get; set; } = EdgegapWindowMetadata.DEFAULT_PROTOCOL_TYPE.ToString();
[JsonProperty("to_check")]
public bool ToCheck { get; set; } = true;
[JsonProperty("tls_upgrade")]
public bool TlsUpgrade { get; set; }
[JsonProperty("name")]
public string PortName { get; set; } = "Game Port";
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: b6d4864ea3706574fb35920c6fab46fa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/AppPortsData.cs
uploadId: 736421

View File

@ -0,0 +1,29 @@
using Newtonsoft.Json;
namespace Edgegap.Editor.Api.Models
{
/// <summary>Used in `GetDeploymentStatus`.</summary>
public class DeploymentPortsData
{
[JsonProperty("external")]
public int External { get; set; }
[JsonProperty("internal")]
public int Internal { get; set; }
[JsonProperty("protocol")]
public string Protocol { get; set; }
[JsonProperty("name")]
public string PortName { get; set; }
[JsonProperty("tls_upgrade")]
public bool TlsUpgrade { get; set; }
[JsonProperty("link")]
public string Link { get; set; }
[JsonProperty("proxy")]
public int? Proxy { get; set; }
}
}

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 62d51b44b8414c9f968ca607ccb06b7e
timeCreated: 1701522748
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/DeploymentPortsData.cs
uploadId: 736421

View File

@ -0,0 +1,28 @@
using Newtonsoft.Json;
namespace Edgegap.Editor.Api.Models
{
public class LocationData
{
[JsonProperty("city")]
public string City { get; set; }
[JsonProperty("country")]
public string Country { get; set; }
[JsonProperty("continent")]
public string Continent { get; set; }
[JsonProperty("administrative_division")]
public string AdministrativeDivision { get; set; }
[JsonProperty("timezone")]
public string Timezone { get; set; }
[JsonProperty("latitude")]
public double Latitude { get; set; }
[JsonProperty("longitude")]
public double Longitude { get; set; }
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 57eed0dbd556e074c992cf6599a1f6bd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/LocationData.cs
uploadId: 736421

View File

@ -0,0 +1,18 @@
namespace Edgegap.Editor.Api.Models
{
/// <summary>
/// Unity default: UDP.
/// (!) UDP !works in WebGL.
/// </summary>
public enum ProtocolType
{
/// <summary>Unity default - fastest; !works in WebGL.</summary>
UDP,
/// <summary>Slower, but more reliable; works in WebGL.</summary>
TCP,
/// <summary>Slower, but more reliable; works in WebGL.</summary>
WS,
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: be5acd63e783b364ebdbb783639e2d32
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/ProtocolType.cs
uploadId: 736421

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d1b2a5c481353934f906c30ba047df9b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,55 @@
using Newtonsoft.Json;
namespace Edgegap.Editor.Api.Models.Requests
{
/// <summary>
/// Request model for https://docs.edgegap.com/api/#tag/Applications/operation/application-post
/// </summary>
public class CreateAppRequest
{
#region Required
/// <summary>*The application name.</summary>
[JsonProperty("name")]
public string AppName { get; set; }
#endregion // Required
#region Optional
/// <summary>*If the application can be deployed.</summary>
[JsonProperty("is_active")]
public bool IsActive { get; set; }
/// <summary>*Image base64 string.</summary>
[JsonProperty("image")]
public string Image { get; set; }
/// <summary>If the telemetry agent is installed on the versions of this app.</summary>
[JsonProperty("is_telemetry_agent_active")]
public bool IsTelemetryAgentActive { get; set; }
#endregion // Optional
/// <summary>Used by Newtonsoft</summary>
public CreateAppRequest()
{
}
/// <summary>Init with required info</summary>
/// <param name="appName">The application name</param>
/// <param name="isActive">If the application can be deployed</param>
/// <param name="image">Image base64 string</param>
public CreateAppRequest(
string appName,
bool isActive,
string image)
{
this.AppName = appName;
this.IsActive = isActive;
this.Image = image;
}
/// <summary>Parse to json str</summary>
public override string ToString() =>
JsonConvert.SerializeObject(this);
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 0a492d7c515b8894ea30b37db6b7efe4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/Requests/CreateAppRequest.cs
uploadId: 736421

View File

@ -0,0 +1,225 @@
using System;
using Newtonsoft.Json;
using UnityEngine;
namespace Edgegap.Editor.Api.Models.Requests
{
/// <summary>
/// Request model for `POST v1/app/{app_name}/version`.
/// API Doc | https://docs.edgegap.com/api/#tag/Applications/operation/app-version-post
/// </summary>
public class CreateAppVersionRequest
{
#region Required
/// <summary>*The name of the application associated.</summary>
[JsonIgnore] // *Path var
public string AppName { get; set; }
/// <summary>*The name of the application associated.</summary>
[JsonProperty("name")]
public string VersionName { get; set; } = EdgegapWindowMetadata.DEFAULT_VERSION_TAG;
/// <summary>*The tag of your image. Default == "latest".</summary>
/// <example>"0.1.2" || "latest" (although "latest" !recommended; use actual versions in production)</example>
[JsonProperty("docker_tag")]
public string DockerTag { get; set; } = EdgegapWindowMetadata.DEFAULT_VERSION_TAG;
/// <summary>*The name of your image.</summary>
/// <example>"edgegap/demo" || "myCompany-someId/mylowercaseapp"</example>
[JsonProperty("docker_image")]
public string DockerImage { get; set; } = "";
/// <summary>*The Repository where the image is.</summary>
/// <example>"registry.edgegap.com" || "harbor.edgegap.com" || "docker.io"</example>
[JsonProperty("docker_repository")]
public string DockerRepository { get; set; } = "";
/// <summary>*Units of vCPU needed (1024 = 1vcpu)</summary>
[JsonProperty("req_cpu")]
public int ReqCpu { get; set; } = 256;
/// <summary>*Units of memory in MB needed (1024 = 1 GPU)</summary>
[JsonProperty("req_memory")]
public int ReqMemory { get; set; } = 256;
/// <summary>*Required: At least 1 { Port, ProtocolStr }.</summary>
[JsonProperty("ports")]
public AppPortsData[] Ports { get; set; } = {};
/// <summary>The username to access the docker repository</summary>
[JsonProperty("private_username")]
public string PrivateUsername { get; set; } = "";
/// <summary>The Private Password or Token of the username (We recommend to use a token)</summary>
[JsonProperty("private_token")]
public string PrivateToken { get; set; } = "";
#endregion // Required
// #region Optional
// [JsonProperty("is_active")]
// public bool IsActive { get; set; } = true;
//
// [JsonProperty("req_video")]
// public int ReqVideo { get; set; } = 256;
//
// [JsonProperty("max_duration")]
// public int MaxDuration { get; set; } = 30;
//
// [JsonProperty("use_telemetry")]
// public bool UseTelemetry { get; set; } = true;
//
// [JsonProperty("inject_context_env")]
// public bool InjectContextEnv { get; set; } = true;
//
// [JsonProperty("whitelisting_active")]
// public bool WhitelistingActive { get; set; } = true;
//
// [JsonProperty("force_cache")]
// public bool ForceCache { get; set; }
//
// [JsonProperty("cache_min_hour")]
// public int CacheMinHour { get; set; }
//
// [JsonProperty("cache_max_hour")]
// public int CacheMaxHour { get; set; }
//
// [JsonProperty("time_to_deploy")]
// public int TimeToDeploy { get; set; } = 15;
//
// [JsonProperty("enable_all_locations")]
// public bool EnableAllLocations { get; set; }
//
// [JsonProperty("termination_grace_period_seconds")]
// public int TerminationGracePeriodSeconds { get; set; } = 5;
//
// [JsonProperty("endpoint_storage")]
// public string EndpointStorage { get; set; } = "";
//
// [JsonProperty("command")]
// public string Command { get; set; }
//
// [JsonProperty("arguments")]
// public string Arguments { get; set; }
//
// [JsonProperty("verify_image")]
// public bool VerifyImage { get; set; }
//
// [JsonProperty("session_config")]
// public SessionConfigData SessionConfig { get; set; } = new();
//
// [JsonProperty("probe")]
// public ProbeData Probe { get; set; } = new();
//
// [JsonProperty("envs")]
// public EnvsData[] Envs { get; set; } = {};
//
// public class SessionConfigData
// {
// [JsonProperty("kind")]
// public string Kind { get; set; } = "Seat";
//
// [JsonProperty("sockets")]
// public int Sockets { get; set; } = 10;
//
// [JsonProperty("autodeploy")]
// public bool Autodeploy { get; set; } = true;
//
// [JsonProperty("empty_ttl")]
// public int EmptyTtl { get; set; } = 60;
//
// [JsonProperty("session_max_duration")]
// public int SessionMaxDuration { get; set; } = 60;
// }
//
//
// public class ProbeData
// {
// [JsonProperty("optimal_ping")]
// public int OptimalPing { get; set; } = 60;
//
// [JsonProperty("rejected_ping")]
// public int RejectedPing { get; set; } = 180;
// }
//
// public class EnvsData
// {
// [JsonProperty("key")]
// public string Key { get; set; }
//
// [JsonProperty("value")]
// public string Value { get; set; }
//
// [JsonProperty("is_secret")]
// public bool IsSecret { get; set; } = true;
// }
// #endregion // Optional
/// <summary>Used by Newtonsoft</summary>
public CreateAppVersionRequest()
{
}
/// <summary>
/// Init with required info.
/// (!) If looking for refs, also see FromUpdateRequest() builder below.
/// </summary>
/// <param name="appName">The name of the application.</param>
/// <param name="containerRegistryUsername"></param>
/// <param name="containerRegistryPasswordToken"></param>
/// <param name="portNum"></param>
/// <param name="protocolType"></param>
public CreateAppVersionRequest(
string appName,
string containerRegistryUsername,
string containerRegistryPasswordToken,
int portNum,
ProtocolType protocolType)
{
this.AppName = appName;
this.PrivateUsername = containerRegistryUsername;
this.PrivateToken = containerRegistryPasswordToken;
this.Ports = new AppPortsData[]
{
new AppPortsData() // MIRROR CHANGE: 'new()' not supported in Unity 2020
{
Port = portNum,
ProtocolStr = protocolType.ToString(),
},
};
}
/// <summary>
/// Port from Update PATCH model: If you tried to Update, but !exists, you probably want to create it next.
/// </summary>
/// <param name="updateRequest"></param>
public static CreateAppVersionRequest FromUpdateRequest(UpdateAppVersionRequest updateRequest)
{
// Convert the updateRequest to JSON
string json = JsonConvert.SerializeObject(updateRequest);
// Deserialize the JSON back to CreateAppVersionRequest
CreateAppVersionRequest createReq = null;
try
{
createReq = JsonConvert.DeserializeObject<CreateAppVersionRequest>(json);
createReq.AppName = updateRequest.AppName; // Normally JsonIgnored in Update
createReq.VersionName = updateRequest.VersionName; // Normally JsonIgnored in Update
createReq.PrivateUsername = updateRequest.PrivateUsername;
createReq.PrivateToken = updateRequest.PrivateToken;
}
catch (Exception e)
{
Debug.LogError($"Error (when parsing CreateAppVersionRequest from CreateAppVersionRequest): {e}");
throw;
}
return createReq;
}
/// <summary>Parse to json str</summary>
public override string ToString() =>
JsonConvert.SerializeObject(this);
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 0bb645e2f9d04384a85739269cc8a4e1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/Requests/CreateAppVersionRequest.cs
uploadId: 736421

View File

@ -0,0 +1,62 @@
using Newtonsoft.Json;
namespace Edgegap.Editor.Api.Models.Requests
{
/// <summary>
/// Request model for `POST v1/deploy`.
/// API Doc | https://docs.edgegap.com/api/#tag/Deployments/operation/deploy
/// </summary>
public class CreateDeploymentRequest
{
#region Required
/// <summary>*Required: The name of the App you want to deploy.</summary>
[JsonProperty("app_name")]
public string AppName { get; set; }
/// <summary>
/// *Required: The name of the App Version you want to deploy;
/// if not present, the last version created is picked.
/// </summary>
[JsonProperty("version_name")]
public string VersionName { get; set; }
/// <summary>
/// *Required: The List of IP of your user.
/// </summary>
[JsonProperty("ip_list")]
public string[] IpList { get; set; }
/// <summary>
/// *Required: The list of IP of your user with their location (latitude, longitude).
/// </summary>
[JsonProperty("geo_ip_list")]
public string[] GeoIpList { get; set; } = { };
#endregion // Required
/// <summary>
/// The list of tags assigned to the deployment
/// </summary>
[JsonProperty("tags")]
public string[] Tags { get; set; } = { EdgegapWindowMetadata.DEFAULT_DEPLOYMENT_TAG };
/// <summary>Used by Newtonsoft</summary>
public CreateDeploymentRequest() { }
/// <summary>Init with required info; used for a single external IP address.</summary>
/// <param name="appName">The name of the application.</param>
/// <param name="versionName">
/// The name of the App Version you want to deploy, if not present,
/// the last version created is picked.
/// </param>
/// <param name="externalIp">Obtain from IpApi.</param>
public CreateDeploymentRequest(string appName, string versionName, string externalIp)
{
this.AppName = appName;
this.VersionName = versionName;
this.IpList = new[] { externalIp };
}
/// <summary>Parse to json str</summary>
public override string ToString() => JsonConvert.SerializeObject(this);
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: aae7b317093230e419bc0f8be1097ea6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/Requests/CreateDeploymentRequest.cs
uploadId: 736421

View File

@ -0,0 +1,175 @@
using Newtonsoft.Json;
namespace Edgegap.Editor.Api.Models.Requests
{
/// <summary>
/// Request model for `PATCH v1/app/{app_name}/version/{version_name}`.
/// Request model for https://docs.edgegap.com/api/#tag/Applications/operation/app-versions-patch
/// TODO: Split "Create" and "Update" into their own, separate models: CTRL+F for "(!)" for more info.
/// </summary>
public class UpdateAppVersionRequest
{
#region Required
/// <summary>*Required: The name of the application.</summary>
[JsonIgnore] // *Path var
public string AppName { get; set; }
#endregion // Required
#region Optional
/// <summary>The name of the application version.</summary>
[JsonIgnore] // *Path var
public string VersionName { get; set; } = EdgegapWindowMetadata.DEFAULT_VERSION_TAG;
/// <summary>At least 1 { Port, ProtocolStr }</summary>
[JsonProperty("ports")]
public AppPortsData[] Ports { get; set; } = {};
/// <summary>The Repository where the image is.</summary>
/// <example>"registry.edgegap.com" || "harbor.edgegap.com" || "docker.io"</example>
[JsonProperty("docker_repository")]
public string DockerRepository { get; set; } = "";
/// <summary>The name of your image.</summary>
/// <example>"edgegap/demo" || "myCompany-someId/mylowercaseapp"</example>
[JsonProperty("docker_image")]
public string DockerImage { get; set; } = "";
/// <summary>The tag of your image. Default == "latest".</summary>
/// <example>"0.1.2" || "latest" (although "latest" !recommended; use actual versions in production)</example>
[JsonProperty("docker_tag")]
public string DockerTag { get; set; } = EdgegapWindowMetadata.DEFAULT_VERSION_TAG;
[JsonProperty("is_active")]
public bool IsActive { get; set; } = true;
[JsonProperty("private_username")]
public string PrivateUsername { get; set; } = "";
[JsonProperty("private_token")]
public string PrivateToken { get; set; } = "";
#region (!) Shows in API docs for PATCH, but could be CREATE only? "Unknown Args"
// [JsonProperty("req_cpu")]
// public int ReqCpu { get; set; } = 256;
//
// [JsonProperty("req_memory")]
// public int ReqMemory { get; set; } = 256;
//
// [JsonProperty("req_video")]
// public int ReqVideo { get; set; } = 256;
#endregion // (!) Shows in API docs for PATCH, but could be CREATE only? "Unknown Args"
[JsonProperty("max_duration")]
public int MaxDuration { get; set; } = 60;
[JsonProperty("use_telemetry")]
public bool UseTelemetry { get; set; } = true;
[JsonProperty("inject_context_env")]
public bool InjectContextEnv { get; set; } = true;
[JsonProperty("whitelisting_active")]
public bool WhitelistingActive { get; set; } = false;
[JsonProperty("force_cache")]
public bool ForceCache { get; set; }
[JsonProperty("cache_min_hour")]
public int CacheMinHour { get; set; }
[JsonProperty("cache_max_hour")]
public int CacheMaxHour { get; set; }
[JsonProperty("time_to_deploy")]
public int TimeToDeploy { get; set; } = 120;
[JsonProperty("enable_all_locations")]
public bool EnableAllLocations { get; set; }
[JsonProperty("termination_grace_period_seconds")]
public int TerminationGracePeriodSeconds { get; set; } = 5;
// // (!) BUG: Expects empty string "" at minimum; however, empty string will throw server err
// [JsonProperty("endpoint_storage")]
// public string EndpointStorage { get; set; }
[JsonProperty("command")]
public string Command { get; set; }
[JsonProperty("arguments")]
public string Arguments { get; set; }
// /// <summary>
// /// (!) Setting this will trigger a very specific type of game that will affect the AppVersion.
// /// TODO: Is leaving as null the same as commenting out?
// /// </summary>
// [JsonProperty("session_config")]
// public SessionConfigData SessionConfig { get; set; }
[JsonProperty("probe")]
public ProbeData Probe { get; set; } = new ProbeData(); // MIRROR CHANGE: 'new()' not supported in Unity 2020
[JsonProperty("envs")]
public EnvsData[] Envs { get; set; } = {};
public class SessionConfigData
{
[JsonProperty("kind")]
public string Kind { get; set; } = "Seat";
[JsonProperty("sockets")]
public int Sockets { get; set; } = 10;
[JsonProperty("autodeploy")]
public bool Autodeploy { get; set; } = true;
[JsonProperty("empty_ttl")]
public int EmptyTtl { get; set; } = 60;
[JsonProperty("session_max_duration")]
public int SessionMaxDuration { get; set; } = 60;
}
public class ProbeData
{
[JsonProperty("optimal_ping")]
public int OptimalPing { get; set; } = 60;
[JsonProperty("rejected_ping")]
public int RejectedPing { get; set; } = 180;
}
public class EnvsData
{
[JsonProperty("key")]
public string Key { get; set; }
[JsonProperty("value")]
public string Value { get; set; }
[JsonProperty("is_secret")]
public bool IsSecret { get; set; } = true;
}
#endregion // Optional
/// <summary>Used by Newtonsoft</summary>
public UpdateAppVersionRequest()
{
}
/// <summary>
/// Init with required info. Default version/tag == "default".
/// Since we're updating, we only require the AppName.
/// </summary>
/// <param name="appName">The name of the application.</param>
public UpdateAppVersionRequest(string appName)
{
this.AppName = appName;
}
/// <summary>Parse to json str</summary>
public override string ToString() =>
JsonConvert.SerializeObject(this);
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 8da9712633ee1e64faca0b960d4bed31
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/Requests/UpdateAppVersionRequest.cs
uploadId: 736421

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: aa4ceffbc97b8254885a63937def2324
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,53 @@
using Newtonsoft.Json;
namespace Edgegap.Editor.Api.Models.Results
{
/// <summary>
/// Result model for `POST v1/deploy`.
/// </summary>
public class CreateDeploymentResult
{
[JsonProperty("request_id")]
public string RequestId { get; set; }
[JsonProperty("request_dns")]
public string RequestDns { get; set; }
[JsonProperty("request_app")]
public string RequestApp { get; set; }
[JsonProperty("request_version")]
public string RequestVersion { get; set; }
[JsonProperty("request_user_count")]
public int RequestUserCount { get; set; }
[JsonProperty("city")]
public string City { get; set; }
[JsonProperty("country")]
public string Country { get; set; }
[JsonProperty("continent")]
public string Continent { get; set; }
[JsonProperty("administrative_division")]
public string AdministrativeDivision { get; set; }
[JsonProperty("tags")]
public string[] Tags { get; set; }
[JsonProperty("container_log_storage")]
public ContainerLogStorageData ContainerLogStorage { get; set; }
public class ContainerLogStorageData
{
[JsonProperty("enabled")]
public bool Enabled { get; set; }
[JsonProperty("endpoint_storage")]
public string EndpointStorage { get; set; }
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 8361abc6f84fccd4cba26dc285d335dd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/Results/CreateDeploymentResult.cs
uploadId: 736421

View File

@ -0,0 +1,12 @@
using Newtonsoft.Json;
namespace Edgegap.Editor.Api.Models.Results
{
/// <summary>Edgegap error, generally just containing `message`</summary>
public class EdgegapErrorResult
{
/// <summary>Friendly, UI-facing error message from Edgegap; can be lengthy.</summary>
[JsonProperty("message")]
public string ErrorMessage { get; set; }
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 5b29093cb10cf3040b76f4fbe77a435d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/Results/EdgegapErrorResult.cs
uploadId: 736421

View File

@ -0,0 +1,120 @@
using System;
using System.Net;
using System.Net.Http;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using UnityEngine;
namespace Edgegap.Editor.Api.Models.Results
{
/// <summary>
/// Wraps the inner json data with outer http info.
/// This class overload contains no json-deserialiable data result.
/// </summary>
public class EdgegapHttpResult
{
/// <summary>HTTP Status code for the request.</summary>
public HttpStatusCode StatusCode { get; }
/// <summary>This could be err, success, or null.</summary>
public string Json { get; }
/// <summary>eg: "POST"</summary>
public HttpMethod HttpMethod;
/// <summary>
/// Typically is sent by servers together with the status code.
/// Useful for fallback err descriptions, often based on the status code.
/// </summary>
public string ReasonPhrase { get; }
/// <summary>Contains `message` with friendly info.</summary>
public bool HasErr => Error != null;
public EdgegapErrorResult Error
{
get { return JsonConvert.DeserializeObject<EdgegapErrorResult>(Json); }
}
#region Common Shortcuts
/// <summary>OK</summary>
public bool IsResultCode200 => StatusCode == HttpStatusCode.OK;
/// <summary>NoContent</summary>
public bool IsResultCode204 => StatusCode == HttpStatusCode.NoContent;
/// <summary>Forbidden</summary>
public bool IsResultCode403 => StatusCode == HttpStatusCode.Forbidden;
/// <summary>Conflict</summary>
public bool IsResultCode409 => StatusCode == HttpStatusCode.Conflict;
/// <summary>BadRequest</summary>
public bool IsResultCode400 => StatusCode == HttpStatusCode.BadRequest;
/// <summary>Gone</summary>
public bool IsResultCode410 => StatusCode == HttpStatusCode.Gone;
#endregion // Common Shortcuts
/// <summary>
/// Constructor that initializes the class based on an HttpResponseMessage.
/// </summary>
public EdgegapHttpResult(HttpResponseMessage httpResponse)
{
this.ReasonPhrase = httpResponse.ReasonPhrase;
this.StatusCode = httpResponse.StatusCode;
try
{
// TODO: This can be read async with `await`, but can't do this in a Constructor.
// Instead, make a factory builder Task =>
Json = httpResponse.Content.ReadAsStringAsync().Result;
}
catch (Exception e)
{
Debug.LogError(
$"Couldn't parse error response. HTTP {httpResponse.StatusCode}.\n{e}"
);
}
}
}
/// <summary>
/// Wraps the inner json data with outer http info.
/// This class overload contains json-deserialiable data result.
/// </summary>
public class EdgegapHttpResult<TResult> : EdgegapHttpResult
{
/// <summary>The actual result model from Json. Could be null!</summary>
public TResult Data { get; set; }
public EdgegapHttpResult(HttpResponseMessage httpResponse, bool isLogLevelDebug = false)
: base(httpResponse)
{
this.HttpMethod = httpResponse.RequestMessage.Method;
// Assuming JSON content and using Newtonsoft.Json for deserialization
bool isDeserializable =
httpResponse.Content != null
&& httpResponse.Content.Headers.ContentType.MediaType == "application/json";
if (isDeserializable)
{
try
{
this.Data = JsonConvert.DeserializeObject<TResult>(Json);
}
catch (Exception e)
{
Debug.LogError(
$"Error (deserializing EdgegapHttpResult.Data): {e} - json: {Json}"
);
throw;
}
}
if (isLogLevelDebug)
UnityEngine.Debug.Log($"{typeof(TResult).Name} result: {JObject.Parse(Json)}"); // Prettified
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 888bfc2c113487b44a3103648d2c2ae3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/Results/EdgegapHttpResult.cs
uploadId: 736421

View File

@ -0,0 +1,15 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace Edgegap.Editor.Api.Models.Results
{
/// <summary>
/// Result model for `[GET] v1/app/{app_name}/versions`.
/// GET API Doc | https://docs.edgegap.com/api/#tag/Applications/operation/app-versions-get
/// </summary>
public class GetAppVersionsResult
{
[JsonProperty("versions")]
public List<VersionData> Versions { get; set; }
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 39dff8eb2a96db14581701965c2663c2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/Results/GetAppVersionsResult.cs
uploadId: 736421

View File

@ -0,0 +1,15 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace Edgegap.Editor.Api.Models.Results
{
/// <summary>
/// Result model for `[GET] v1/apps`.
/// GET API Doc | https://docs.edgegap.com/api/#tag/Applications/operation/applications-get
/// </summary>
public class GetAppsResult
{
[JsonProperty("applications")]
public List<GetCreateAppResult> Applications { get; set; }
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 88f306b7c80ebad4eada4c62e875d2a6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/Results/GetAppsResult.cs
uploadId: 736421

View File

@ -0,0 +1,31 @@
using Newtonsoft.Json;
namespace Edgegap.Editor.Api.Models.Results
{
/// <summary>
/// Result model for `[GET | POST] v1/app`.
/// POST API Doc | https://docs.edgegap.com/api/#tag/Applications/operation/application-post
/// GET API Doc | https://docs.edgegap.com/api/#tag/Applications/operation/application-get
/// </summary>
public class GetCreateAppResult
{
[JsonProperty("name")]
public string AppName { get; set; }
[JsonProperty("is_active")]
public bool IsActive { get; set; }
/// <summary>Optional</summary>
[JsonProperty("is_telemetry_agent_active")]
public bool IsTelemetryAgentActive { get; set; }
[JsonProperty("image")]
public string Image { get; set; }
[JsonProperty("create_time")]
public string CreateTimeStr { get; set; }
[JsonProperty("last_updated")]
public string LastUpdatedStr { get; set; }
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: a66c935238edd8846b1e9e9e19cfab70
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/Results/GetCreateAppResult.cs
uploadId: 736421

View File

@ -0,0 +1,20 @@
using Newtonsoft.Json;
namespace Edgegap.Editor.Api.Models.Results
{
/// <summary>
/// Result model of a deployment for `GET v1/deployments`.
/// API Doc | https://docs.edgegap.com/api/#tag/Deployments/operation/deployments-get
/// </summary>
public class GetDeploymentResult
{
[JsonProperty("request_id")]
public string RequestId { get; set; }
[JsonProperty("ready")]
public bool Ready { get; set; }
[JsonProperty("tags")]
public string[] Tags { get; set; }
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 87df84c48a738aa48b66d0c42aacb3db
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/Results/GetDeploymentResult.cs
uploadId: 736421

View File

@ -0,0 +1,89 @@
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Edgegap.Editor.Api.Models.Results
{
/// <summary>
/// Result model for `GET v1/status/{request_id}`.
/// API Doc | https://docs.edgegap.com/api/#tag/Deployments/operation/deployment-status-get
/// </summary>
public class GetDeploymentStatusResult
{
[JsonProperty("request_id")]
public string RequestId { get; set; }
[JsonProperty("fqdn")]
public string Fqdn { get; set; }
[JsonProperty("app_name")]
public string AppName { get; set; }
[JsonProperty("app_version")]
public string AppVersion { get; set; }
[JsonProperty("current_status")]
public string CurrentStatus { get; set; }
[JsonProperty("running")]
public bool Running { get; set; }
[JsonProperty("whitelisting_active")]
public bool WhitelistingActive { get; set; }
[JsonProperty("start_time")]
public string StartTime { get; set; }
[JsonProperty("removal_time")]
public string RemovalTime { get; set; }
[JsonProperty("elapsed_time")]
public int? ElapsedTime { get; set; }
[JsonProperty("last_status")]
public string LastStatus { get; set; }
[JsonProperty("error")]
public bool Error { get; set; }
[JsonProperty("error_detail")]
public string ErrorDetail { get; set; }
[JsonProperty("public_ip")]
public string PublicIp { get; set; }
[JsonProperty("sessions")]
public SessionData[] Sessions { get; set; }
[JsonProperty("location")]
public LocationData Location { get; set; }
[JsonProperty("tags")]
public string[] Tags { get; set; }
[JsonProperty("sockets")]
public string Sockets { get; set; }
[JsonProperty("sockets_usage")]
public string SocketsUsage { get; set; }
[JsonProperty("command")]
public string Command { get; set; }
[JsonProperty("arguments")]
public string Arguments { get; set; }
/// <summary>
/// TODO: Server should swap `ports` to an array of DeploymentPortsData (instead of an object of dynamic unknown objects).
/// <example>
/// {
/// "7777", {}
/// },
/// {
/// "Some Port Name", {}
/// }
/// </example>
/// </summary>
[JsonProperty("ports")]
public Dictionary<string, DeploymentPortsData> PortsDict { get; set; }
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: c658b7f5c5d5d0648934b0ae1d71de9a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/Results/GetDeploymentStatusResult.cs
uploadId: 736421

View File

@ -0,0 +1,14 @@
using Newtonsoft.Json;
namespace Edgegap.Editor.Api.Models.Results
{
/// <summary>
/// Result model for `GET v1/deployments`.
/// API Doc | https://docs.edgegap.com/api/#tag/Deployments/operation/deployments-get
/// </summary>
public class GetDeploymentsResult
{
[JsonProperty("data")]
public GetDeploymentResult[] Data { get; set; }
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: d39faf2ee20bb0647b63b9b72910d2c8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/Results/GetDeploymentsResult.cs
uploadId: 736421

View File

@ -0,0 +1,22 @@
using Newtonsoft.Json;
namespace Edgegap.Editor.Api.Models.Results
{
/// <summary>
/// Result model for `GET v1/wizard/registry-credentials`.
/// </summary>
public class GetRegistryCredentialsResult
{
[JsonProperty("registry_url")]
public string RegistryUrl { get; set; }
[JsonProperty("project")]
public string Project { get; set; }
[JsonProperty("username")]
public string Username { get; set; }
[JsonProperty("token")]
public string Token { get; set; }
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 8e6af130c329d2b43b2f4b0dc8639477
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/Results/GetRegistryCredentialsResult.cs
uploadId: 736421

View File

@ -0,0 +1,14 @@
using Newtonsoft.Json;
namespace Edgegap.Editor.Api.Models.Results
{
/// <summary>
/// Result model for `GET v1/ip`.
/// GET API Doc | https://docs.edgegap.com/api/#tag/IP-Lookup/operation/IP
/// </summary>
public class GetYourPublicIpResult
{
[JsonProperty("public_ip")]
public string PublicIp { get; set; }
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 73c9651ef0fdfcb449ec0120016963a0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/Results/GetYourPublicIpResult.cs
uploadId: 736421

View File

@ -0,0 +1,84 @@
using Newtonsoft.Json;
namespace Edgegap.Editor.Api.Models.Results
{
public class StopActiveDeploymentResult
{
[JsonProperty("message")]
public string Message { get; set; }
[JsonProperty("deployment_summary")]
public DeploymentSummaryData DeploymentSummary { get; set; }
public class DeploymentSummaryData
{
[JsonProperty("request_id")]
public string RequestId { get; set; }
[JsonProperty("fqdn")]
public string Fqdn { get; set; }
[JsonProperty("app_name")]
public string AppName { get; set; }
[JsonProperty("app_version")]
public string AppVersion { get; set; }
[JsonProperty("current_status")]
public string CurrentStatus { get; set; }
[JsonProperty("running")]
public bool Running { get; set; }
[JsonProperty("whitelisting_active")]
public bool WhitelistingActive { get; set; }
[JsonProperty("start_time")]
public string StartTime { get; set; }
[JsonProperty("removal_time")]
public string RemovalTime { get; set; }
[JsonProperty("elapsed_time")]
public int? ElapsedTime { get; set; }
[JsonProperty("last_status")]
public string LastStatus { get; set; }
[JsonProperty("error")]
public bool Error { get; set; }
[JsonProperty("error_detail")]
public string ErrorDetail { get; set; }
[JsonProperty("ports")]
public PortsData Ports { get; set; }
[JsonProperty("public_ip")]
public string PublicIp { get; set; }
[JsonProperty("sessions")]
public SessionData[] Sessions { get; set; }
[JsonProperty("location")]
public LocationData Location { get; set; }
[JsonProperty("tags")]
public string[] Tags { get; set; }
[JsonProperty("sockets")]
public string Sockets { get; set; }
[JsonProperty("sockets_usage")]
public string SocketsUsage { get; set; }
[JsonProperty("command")]
public string Command { get; set; }
[JsonProperty("arguments")]
public string Arguments { get; set; }
}
public class PortsData { }
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 9e2e4d9424ca8f7459803e631acf912f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/Results/StopActiveDeploymentResult.cs
uploadId: 736421

View File

@ -0,0 +1,165 @@
using Newtonsoft.Json;
namespace Edgegap.Editor.Api.Models.Results
{
/// <summary>
/// Result model for:
/// - `POST 1/app/{app_name}/version`
/// - `PATCH v1/app/{app_name}/version/{version_name}`
/// POST API Doc | https://docs.edgegap.com/api/#tag/Applications/operation/application-post
/// PATCH API Doc | https://docs.edgegap.com/api/#tag/Applications/operation/app-versions-patch
/// </summary>
public class UpsertAppVersionResult
{
[JsonProperty("success")]
public bool Success { get; set; }
[JsonProperty("version")]
public VersionData Version { get; set; }
public class VersionData
{
[JsonProperty("name")]
public string VersionName { get; set; }
[JsonProperty("is_active")]
public bool IsActive { get; set; }
[JsonProperty("docker_repository")]
public string DockerRepository { get; set; }
[JsonProperty("docker_image")]
public string DockerImage { get; set; }
[JsonProperty("docker_tag")]
public string DockerTag { get; set; }
[JsonProperty("private_username")]
public string PrivateUsername { get; set; }
[JsonProperty("private_token")]
public string PrivateToken { get; set; }
[JsonProperty("req_cpu")]
public int? ReqCpu { get; set; }
[JsonProperty("req_memory")]
public int? ReqMemory { get; set; }
[JsonProperty("req_video")]
public int? ReqVideo { get; set; }
[JsonProperty("max_duration")]
public int? MaxDuration { get; set; }
[JsonProperty("use_telemetry")]
public bool UseTelemetry { get; set; }
[JsonProperty("inject_context_env")]
public bool InjectContextEnv { get; set; }
[JsonProperty("whitelisting_active")]
public bool WhitelistingActive { get; set; }
[JsonProperty("force_cache")]
public bool ForceCache { get; set; }
[JsonProperty("cache_min_hour")]
public int? CacheMinHour { get; set; }
[JsonProperty("cache_max_hour")]
public int? CacheMaxHour { get; set; }
[JsonProperty("time_to_deploy")]
public int? TimeToDeploy { get; set; }
[JsonProperty("enable_all_locations")]
public bool EnableAllLocations { get; set; }
[JsonProperty("session_config")]
public SessionConfigData SessionConfig { get; set; }
[JsonProperty("ports")]
public PortsData[] Ports { get; set; }
[JsonProperty("probe")]
public ProbeData Probe { get; set; }
[JsonProperty("envs")]
public EnvsData[] Envs { get; set; }
[JsonProperty("verify_image")]
public bool VerifyImage { get; set; }
[JsonProperty("termination_grace_period_seconds")]
public int? TerminationGracePeriodSeconds { get; set; }
[JsonProperty("endpoint_storage")]
public string EndpointStorage { get; set; }
[JsonProperty("command")]
public string Command { get; set; }
[JsonProperty("arguments")]
public string Arguments { get; set; }
}
public class SessionConfigData
{
[JsonProperty("kind")]
public string Kind { get; set; }
[JsonProperty("sockets")]
public int? Sockets { get; set; }
[JsonProperty("autodeploy")]
public bool Autodeploy { get; set; }
[JsonProperty("empty_ttl")]
public int? EmptyTtl { get; set; }
[JsonProperty("session_max_duration")]
public int? SessionMaxDuration { get; set; }
}
public class PortsData
{
[JsonProperty("port")]
public int? Port { get; set; }
[JsonProperty("protocol")]
public string Protocol { get; set; }
[JsonProperty("to_check")]
public bool ToCheck { get; set; }
[JsonProperty("tls_upgrade")]
public bool TlsUpgrade { get; set; }
[JsonProperty("name")]
public string PortName { get; set; }
}
public class ProbeData
{
[JsonProperty("optimal_ping")]
public int? OptimalPing { get; set; }
[JsonProperty("rejected_ping")]
public int? RejectedPing { get; set; }
}
public class EnvsData
{
[JsonProperty("key")]
public string Key { get; set; }
[JsonProperty("value")]
public string Value { get; set; }
[JsonProperty("is_secret")]
public bool IsSecret { get; set; }
}
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: a7dde7d59c66d8c44b86af35e853f9f5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/Results/UpsertAppVersionResult.cs
uploadId: 736421

View File

@ -0,0 +1,28 @@
using Newtonsoft.Json;
namespace Edgegap.Editor.Api.Models
{
/// <summary>
/// Shared model for `GetDeploymentStatusResult`, `StopActiveDeploymentResult`.
/// </summary>
public class SessionData
{
[JsonProperty("session_id")]
public string SessionId { get; set; }
[JsonProperty("status")]
public string Status { get; set; }
[JsonProperty("ready")]
public bool Ready { get; set; }
[JsonProperty("linked")]
public bool Linked { get; set; }
[JsonProperty("kind")]
public string Kind { get; set; }
[JsonProperty("user_count")]
public string UserCount { get; set; }
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 5f9024e4ca5438e4788e461387313531
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/SessionData.cs
uploadId: 736421

View File

@ -0,0 +1,13 @@
using Newtonsoft.Json;
namespace Edgegap.Editor.Api.Models
{
public class VersionData
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("is_active")]
public bool IsActive { get; set; }
}
}

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 7dfe72e265bef484ea78bd7e105e0e77
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 129321
packageName: Mirror
packageVersion: 96.0.1
assetPath: Assets/Mirror/Hosting/Edgegap/Editor/Api/Models/VersionData.cs
uploadId: 736421