Skip to content

Commit

Permalink
Merge pull request #13 from hathora/speakeasy-sdk-regen-1713493513
Browse files Browse the repository at this point in the history
chore: 🐝 Update SDK - Generate
  • Loading branch information
jchu231 authored May 10, 2024
2 parents a59e97f + 28ac5d7 commit edb699a
Show file tree
Hide file tree
Showing 479 changed files with 12,411 additions and 3,219 deletions.
283 changes: 224 additions & 59 deletions .speakeasy/gen.lock

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions .speakeasy/workflow.lock
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: .
351 changes: 239 additions & 112 deletions HathoraCloud/AppV1.cs

Large diffs are not rendered by default.

236 changes: 155 additions & 81 deletions HathoraCloud/AuthV1.cs

Large diffs are not rendered by default.

289 changes: 201 additions & 88 deletions HathoraCloud/BillingV1.cs

Large diffs are not rendered by default.

397 changes: 265 additions & 132 deletions HathoraCloud/BuildV1.cs

Large diffs are not rendered by default.

524 changes: 524 additions & 0 deletions HathoraCloud/BuildV2.cs

Large diffs are not rendered by default.

339 changes: 258 additions & 81 deletions HathoraCloud/DeploymentV1.cs

Large diffs are not rendered by default.

434 changes: 434 additions & 0 deletions HathoraCloud/DeploymentV2.cs

Large diffs are not rendered by default.

76 changes: 49 additions & 27 deletions HathoraCloud/DiscoveryV1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,95 +10,117 @@
#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
/// Deprecated. Does not include latest Regions (missing Dallas region). Use <a href="https://hathora.dev/api#tag/DiscoveryV2">DiscoveryV2</a>.
/// </summary>
public interface IDiscoveryV1
{

/// <summary>
/// Returns an array of all regions with a host and port that a client can directly ping. Open a websocket connection to `wss://&lt;host&gt;:&lt;port&gt;/ws` and send a packet. To calculate ping, measure the time it takes to get an echo packet back.
/// Returns an array of V1 regions with a host and port that a client can directly ping. Open a websocket connection to `wss://&lt;host&gt;:&lt;port&gt;/ws` and send a packet. To calculate ping, measure the time it takes to get an echo packet back.
/// </summary>
Task<GetPingServiceEndpointsResponse> GetPingServiceEndpointsAsync();
Task<GetPingServiceEndpointsDeprecatedResponse> GetPingServiceEndpointsDeprecatedAsync();
}

/// <summary>
/// Service that allows clients to directly ping all Hathora regions to get latency information
/// Deprecated. Does not include latest Regions (missing Dallas region). Use <a href="https://hathora.dev/api#tag/DiscoveryV2">DiscoveryV2</a>.
/// </summary>
public class DiscoveryV1: IDiscoveryV1
{
public SDKConfig SDKConfiguration { get; private set; }
private const string _target = "unity";
private const string _sdkVersion = "0.28.4";
private const string _sdkGenVersion = "2.239.0";
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.28.4 2.239.0 0.0.1 hathora-cloud";
private const string _userAgent = "speakeasy-sdk/unity 0.29.0 2.326.3 0.0.1 HathoraCloud";
private string _serverUrl = "";
private ISpeakeasyHttpClient _defaultClient;
private ISpeakeasyHttpClient _securityClient;
private Func<Security>? _securitySource;

public DiscoveryV1(ISpeakeasyHttpClient defaultClient, ISpeakeasyHttpClient securityClient, string serverUrl, SDKConfig config)
public DiscoveryV1(ISpeakeasyHttpClient defaultClient, Func<Security>? securitySource, string serverUrl, SDKConfig config)
{
_defaultClient = defaultClient;
_securityClient = securityClient;
_securitySource = securitySource;
_serverUrl = serverUrl;
SDKConfiguration = config;
}


public async Task<GetPingServiceEndpointsResponse> GetPingServiceEndpointsAsync()
[Obsolete("This method will be removed in a future release, please migrate away from it as soon as possible")]
public async Task<GetPingServiceEndpointsDeprecatedResponse> GetPingServiceEndpointsDeprecatedAsync()
{
string baseUrl = this.SDKConfiguration.GetTemplatedServerDetails();
var urlString = baseUrl + "/discovery/v1/ping";

var httpRequest = new UnityWebRequest(urlString, UnityWebRequest.kHttpVerbGET);
DownloadHandlerStream downloadHandler = new DownloadHandlerStream();
httpRequest.downloadHandler = downloadHandler;
httpRequest.SetRequestHeader("user-agent", _userAgent);


var client = _securityClient;


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:
var errorMsg = httpResponse.error;
errorCode = (int)httpRequest.responseCode;
contentType = httpRequest.GetResponseHeader("Content-Type");
httpRequest.Dispose();
throw new Exception(errorMsg);
break;
case UnityWebRequest.Result.Success:
Console.WriteLine("Success");
break;
}

var contentType = httpResponse.GetResponseHeader("Content-Type");

var response = new GetPingServiceEndpointsResponse
if (contentType == null)
{
StatusCode = (int)httpResponse.responseCode,
contentType = httpResponse.GetResponseHeader("Content-Type") ?? "application/octet-stream";
}
int httpCode = errorCode ?? (int)httpResponse.responseCode;
var response = new GetPingServiceEndpointsDeprecatedResponse
{
StatusCode = httpCode,
ContentType = contentType,
RawResponse = httpResponse
};

if((response.StatusCode == 200))
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
{
response.DiscoveryResponse = JsonConvert.DeserializeObject<List<DiscoveryResponse>>(httpResponse.downloadHandler.text, new JsonSerializerSettings(){ NullValueHandling = NullValueHandling.Ignore, Converters = new JsonConverter[] { new FlexibleObjectDeserializer(), new DateOnlyConverter(), new EnumSerializer() }});
throw new SDKException("API error occurred", httpCode, httpResponse.downloadHandler.text, httpResponse);
}

return response;
}
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;
}


}
}
126 changes: 126 additions & 0 deletions HathoraCloud/DiscoveryV2.cs
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://&lt;host&gt;:&lt;port&gt;/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;
}


}
}
10 changes: 5 additions & 5 deletions HathoraCloud/HathoraCloud.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsPackable>true</IsPackable>
<PackageId>hathora-cloud</PackageId>
<Version>0.28.4</Version>
<PackageId>HathoraCloud</PackageId>
<Version>0.29.0</Version>
<Authors>Hathora</Authors>
<TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable>
<PackageReadmeFile>README.md</PackageReadmeFile>
<DocumentationFile>docs/hathora-cloud.xml</DocumentationFile>
<DocumentationFile>docs/HathoraCloud.xml</DocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>

<ItemGroup>
<None Include="../README.md" Pack="true" PackagePath="/"/>
<None Include="../docs/*" Pack="true" PackagePath="/docs"/>
<None Include="..\README.md" Pack="true" PackagePath="\"/>
<None Include="..\docs\**\*" Pack="true" PackagePath="\docs" CopyToOutputDirectory="PreserveNewest"/>

<PackageReference Include="newtonsoft.json" Version="13.0.3" />
<PackageReference Include="nodatime" Version="3.1.9" />
Expand Down
Loading

0 comments on commit edb699a

Please sign in to comment.