-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from hathora/speakeasy-sdk-regen-1713493513
chore: 🐝 Update SDK - Generate
- Loading branch information
Showing
479 changed files
with
12,411 additions
and
3,219 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
speakeasyVersion: 1.285.3 | ||
sources: {} | ||
targets: {} | ||
workflow: | ||
workflowVersion: 1.0.0 | ||
speakeasyVersion: latest | ||
sources: | ||
my-source: | ||
inputs: | ||
- location: https://hathora.dev/swagger.json | ||
overlays: | ||
- location: overlay.yaml | ||
targets: | ||
cloud-sdk-unity: | ||
target: unity | ||
source: my-source | ||
output: . |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
|
||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost when | ||
// the code is regenerated. | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
#nullable enable | ||
namespace HathoraCloud | ||
{ | ||
using HathoraCloud.Models.Errors; | ||
using HathoraCloud.Models.Operations; | ||
using HathoraCloud.Models.Shared; | ||
using HathoraCloud.Utils; | ||
using Newtonsoft.Json; | ||
using System.Collections.Generic; | ||
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
using System; | ||
using UnityEngine.Networking; | ||
|
||
/// <summary> | ||
/// Service that allows clients to directly ping all Hathora regions to get latency information | ||
/// </summary> | ||
public interface IDiscoveryV2 | ||
{ | ||
|
||
/// <summary> | ||
/// Returns an array of all regions with a host and port that a client can directly ping. Open a websocket connection to `wss://<host>:<port>/ws` and send a packet. To calculate ping, measure the time it takes to get an echo packet back. | ||
/// </summary> | ||
Task<GetPingServiceEndpointsResponse> GetPingServiceEndpointsAsync(); | ||
} | ||
|
||
/// <summary> | ||
/// Service that allows clients to directly ping all Hathora regions to get latency information | ||
/// </summary> | ||
public class DiscoveryV2: IDiscoveryV2 | ||
{ | ||
public SDKConfig SDKConfiguration { get; private set; } | ||
private const string _target = "unity"; | ||
private const string _sdkVersion = "0.29.0"; | ||
private const string _sdkGenVersion = "2.326.3"; | ||
private const string _openapiDocVersion = "0.0.1"; | ||
private const string _userAgent = "speakeasy-sdk/unity 0.29.0 2.326.3 0.0.1 HathoraCloud"; | ||
private string _serverUrl = ""; | ||
private ISpeakeasyHttpClient _defaultClient; | ||
private Func<Security>? _securitySource; | ||
|
||
public DiscoveryV2(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySource, string serverUrl, SDKConfig config) | ||
{ | ||
_defaultClient = defaultClient; | ||
_securitySource = securitySource; | ||
_serverUrl = serverUrl; | ||
SDKConfiguration = config; | ||
} | ||
|
||
|
||
|
||
public async Task<GetPingServiceEndpointsResponse> GetPingServiceEndpointsAsync() | ||
{ | ||
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails(); | ||
var urlString = baseUrl + "/discovery/v2/ping"; | ||
|
||
var httpRequest = new UnityWebRequest(urlString, UnityWebRequest.kHttpVerbGET); | ||
DownloadHandlerStream downloadHandler = new DownloadHandlerStream(); | ||
httpRequest.downloadHandler = downloadHandler; | ||
httpRequest.SetRequestHeader("user-agent", _userAgent); | ||
|
||
var client = _defaultClient; | ||
|
||
var httpResponse = await client.SendAsync(httpRequest); | ||
int? errorCode = null; | ||
string? contentType = null; | ||
switch (httpResponse.result) | ||
{ | ||
case UnityWebRequest.Result.ConnectionError: | ||
case UnityWebRequest.Result.DataProcessingError: | ||
case UnityWebRequest.Result.ProtocolError: | ||
errorCode = (int)httpRequest.responseCode; | ||
contentType = httpRequest.GetResponseHeader("Content-Type"); | ||
httpRequest.Dispose(); | ||
break; | ||
case UnityWebRequest.Result.Success: | ||
Console.WriteLine("Success"); | ||
break; | ||
} | ||
|
||
if (contentType == null) | ||
{ | ||
contentType = httpResponse.GetResponseHeader("Content-Type") ?? "application/octet-stream"; | ||
} | ||
int httpCode = errorCode ?? (int)httpResponse.responseCode; | ||
var response = new GetPingServiceEndpointsResponse | ||
{ | ||
StatusCode = httpCode, | ||
ContentType = contentType, | ||
RawResponse = httpResponse | ||
}; | ||
if (httpCode == 200) | ||
{ | ||
if(Utilities.IsContentTypeMatch("application/json",response.ContentType)) | ||
{ | ||
var obj = JsonConvert.DeserializeObject<List<PingEndpoints>>(httpResponse.downloadHandler.text, new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = Utilities.GetDefaultJsonDeserializers() }); | ||
response.PingEndpoints = obj; | ||
} | ||
else | ||
{ | ||
throw new SDKException("API error occurred", httpCode, httpResponse.downloadHandler.text, httpResponse); | ||
} | ||
} | ||
else if (httpCode >= 400 && httpCode < 500 || httpCode >= 500 && httpCode < 600) | ||
{ | ||
throw new SDKException("API error occurred", httpCode, httpResponse.downloadHandler.text, httpResponse); | ||
} | ||
else | ||
{ | ||
throw new SDKException("unknown status code received", httpCode, httpResponse.downloadHandler.text, httpResponse); | ||
} | ||
return response; | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.