Skip to content

Commit 45ef8cd

Browse files
author
github-actions[bot]
committed
feat: Updated OpenAPI spec
1 parent a198f2a commit 45ef8cd

20 files changed

Lines changed: 1031 additions & 18 deletions

src/libs/Pika/Generated/Pika.AvatarClient.GenerateAvatar.g.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ namespace Pika
66
public partial class AvatarClient
77
{
88

9+
private static readonly global::Pika.AutoSDKServer[] s_GenerateAvatarServers = new global::Pika.AutoSDKServer[]
10+
{ new global::Pika.AutoSDKServer(
11+
id: "https-api-pika-art",
12+
name: "Primary API endpoint",
13+
url: "https://api.pika.art/",
14+
description: "Primary API endpoint"),
15+
new global::Pika.AutoSDKServer(
16+
id: "https-srkibaanghvsriahb-pika-art-proxy-realtime",
17+
name: "Proxy/realtime endpoint (used by Python SDK)",
18+
url: "https://srkibaanghvsriahb.pika.art/proxy/realtime",
19+
description: "Proxy/realtime endpoint (used by Python SDK)"),
20+
};
21+
922

1023
private static readonly global::Pika.EndPointSecurityRequirement s_GenerateAvatarSecurityRequirement0 =
1124
new global::Pika.EndPointSecurityRequirement
@@ -88,7 +101,9 @@ partial void ProcessGenerateAvatarResponseContent(
88101
{
89102
var __pathBuilder = new global::Pika.PathBuilder(
90103
path: "/avatar/generate",
91-
baseUri: HttpClient.BaseAddress);
104+
baseUri: ResolveBaseUri(
105+
servers: s_GenerateAvatarServers,
106+
defaultBaseUrl: "https://api.pika.art/"));
92107
var __path = __pathBuilder.ToString();
93108
__path = global::Pika.AutoSDKRequestOptionsSupport.AppendQueryParameters(
94109
path: __path,

src/libs/Pika/Generated/Pika.AvatarClient.g.cs

Lines changed: 146 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public sealed partial class AvatarClient : global::Pika.IAvatarClient, global::S
2020
public global::System.Net.Http.HttpClient HttpClient { get; }
2121

2222
/// <inheritdoc/>
23-
public System.Uri? BaseUri => HttpClient.BaseAddress;
23+
public System.Uri? BaseUri => ResolveDisplayedBaseUri();
2424

2525
/// <inheritdoc/>
2626
public global::System.Collections.Generic.List<global::Pika.EndPointAuthorization> Authorizations { get; }
@@ -33,12 +33,43 @@ public sealed partial class AvatarClient : global::Pika.IAvatarClient, global::S
3333

3434
/// <inheritdoc/>
3535
public global::Pika.AutoSDKClientOptions Options { get; }
36+
37+
38+
internal global::Pika.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::Pika.AutoSDKServerConfiguration();
3639
/// <summary>
3740
///
3841
/// </summary>
3942
public global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext { get; set; } = global::Pika.SourceGenerationContext.Default;
4043

4144

45+
46+
private static readonly global::Pika.AutoSDKServer[] s_availableServers = new global::Pika.AutoSDKServer[]
47+
{ new global::Pika.AutoSDKServer(
48+
id: "https-api-pika-art",
49+
name: "Primary API endpoint",
50+
url: "https://api.pika.art/",
51+
description: "Primary API endpoint"),
52+
new global::Pika.AutoSDKServer(
53+
id: "https-srkibaanghvsriahb-pika-art-proxy-realtime",
54+
name: "Proxy/realtime endpoint (used by Python SDK)",
55+
url: "https://srkibaanghvsriahb.pika.art/proxy/realtime",
56+
description: "Proxy/realtime endpoint (used by Python SDK)"),
57+
};
58+
59+
/// <summary>
60+
/// The server options available for this client.
61+
/// </summary>
62+
public global::System.Collections.Generic.IReadOnlyList<global::Pika.AutoSDKServer> AvailableServers => s_availableServers;
63+
64+
/// <summary>
65+
/// The currently selected server for this client, if any.
66+
/// </summary>
67+
public global::Pika.AutoSDKServer? SelectedServer
68+
{
69+
get => ResolveSelectedServer();
70+
set => SelectServer(value);
71+
}
72+
4273
/// <summary>
4374
/// Creates a new instance of the AvatarClient.
4475
/// If no httpClient is provided, a new one will be created.
@@ -85,6 +116,8 @@ public AvatarClient(
85116
Options = options ?? new global::Pika.AutoSDKClientOptions();
86117
_disposeHttpClient = disposeHttpClient;
87118

119+
AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress;
120+
88121
Initialized(HttpClient);
89122
}
90123

@@ -111,5 +144,117 @@ partial void ProcessResponseContent(
111144
global::System.Net.Http.HttpClient client,
112145
global::System.Net.Http.HttpResponseMessage response,
113146
ref string content);
147+
148+
149+
/// <summary>
150+
/// Selects one of the generated server options by id.
151+
/// </summary>
152+
public bool TrySelectServer(string serverId)
153+
{
154+
if (string.IsNullOrWhiteSpace(serverId))
155+
{
156+
return false;
157+
}
158+
159+
foreach (var server in s_availableServers)
160+
{
161+
if (string.Equals(server.Id, serverId, global::System.StringComparison.OrdinalIgnoreCase))
162+
{
163+
AutoSDKServerConfiguration.SelectedServer = server;
164+
AutoSDKServerConfiguration.ExplicitBaseUri = null;
165+
return true;
166+
}
167+
}
168+
169+
return false;
170+
}
171+
172+
/// <summary>
173+
/// Clears the currently selected server.
174+
/// </summary>
175+
public void ClearSelectedServer()
176+
{
177+
AutoSDKServerConfiguration.SelectedServer = null;
178+
}
179+
180+
private global::Pika.AutoSDKServer? ResolveSelectedServer()
181+
{
182+
var selectedServer = AutoSDKServerConfiguration.SelectedServer;
183+
if (selectedServer is null)
184+
{
185+
return null;
186+
}
187+
188+
foreach (var server in s_availableServers)
189+
{
190+
if (string.Equals(server.Id, selectedServer.Id, global::System.StringComparison.Ordinal))
191+
{
192+
return server;
193+
}
194+
}
195+
196+
return null;
197+
}
198+
199+
private void SelectServer(global::Pika.AutoSDKServer? server)
200+
{
201+
if (server is null)
202+
{
203+
AutoSDKServerConfiguration.SelectedServer = null;
204+
return;
205+
}
206+
207+
foreach (var candidate in s_availableServers)
208+
{
209+
if (string.Equals(candidate.Id, server.Id, global::System.StringComparison.Ordinal))
210+
{
211+
AutoSDKServerConfiguration.SelectedServer = candidate;
212+
AutoSDKServerConfiguration.ExplicitBaseUri = null;
213+
return;
214+
}
215+
}
216+
217+
throw new global::System.ArgumentException("The provided server is not available for this client.", nameof(server));
218+
}
219+
220+
private global::System.Uri? ResolveDisplayedBaseUri()
221+
{
222+
if (AutoSDKServerConfiguration.ExplicitBaseUri is global::System.Uri explicitBaseUri)
223+
{
224+
return explicitBaseUri;
225+
}
226+
227+
return ResolveSelectedServer()?.Uri ?? HttpClient.BaseAddress;
228+
}
229+
230+
private global::System.Uri? ResolveBaseUri(
231+
global::Pika.AutoSDKServer[] servers,
232+
string defaultBaseUrl)
233+
{
234+
if (AutoSDKServerConfiguration.ExplicitBaseUri is global::System.Uri explicitBaseUri)
235+
{
236+
return explicitBaseUri;
237+
}
238+
239+
if (AutoSDKServerConfiguration.SelectedServer is global::Pika.AutoSDKServer selectedServer)
240+
{
241+
foreach (var server in servers)
242+
{
243+
if (string.Equals(server.Id, selectedServer.Id, global::System.StringComparison.Ordinal))
244+
{
245+
return server.Uri;
246+
}
247+
}
248+
}
249+
250+
if (servers.Length > 0)
251+
{
252+
return servers[0].Uri;
253+
}
254+
255+
return string.IsNullOrWhiteSpace(defaultBaseUrl)
256+
? HttpClient.BaseAddress
257+
: new global::System.Uri(defaultBaseUrl, global::System.UriKind.RelativeOrAbsolute);
258+
}
114259
}
115260
}

src/libs/Pika/Generated/Pika.DeveloperClient.CreateTopup.g.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ namespace Pika
66
public partial class DeveloperClient
77
{
88

9+
private static readonly global::Pika.AutoSDKServer[] s_CreateTopupServers = new global::Pika.AutoSDKServer[]
10+
{ new global::Pika.AutoSDKServer(
11+
id: "https-api-pika-art",
12+
name: "Primary API endpoint",
13+
url: "https://api.pika.art/",
14+
description: "Primary API endpoint"),
15+
new global::Pika.AutoSDKServer(
16+
id: "https-srkibaanghvsriahb-pika-art-proxy-realtime",
17+
name: "Proxy/realtime endpoint (used by Python SDK)",
18+
url: "https://srkibaanghvsriahb.pika.art/proxy/realtime",
19+
description: "Proxy/realtime endpoint (used by Python SDK)"),
20+
};
21+
922

1023
private static readonly global::Pika.EndPointSecurityRequirement s_CreateTopupSecurityRequirement0 =
1124
new global::Pika.EndPointSecurityRequirement
@@ -87,7 +100,9 @@ partial void ProcessCreateTopupResponseContent(
87100
{
88101
var __pathBuilder = new global::Pika.PathBuilder(
89102
path: "/developer/topup",
90-
baseUri: HttpClient.BaseAddress);
103+
baseUri: ResolveBaseUri(
104+
servers: s_CreateTopupServers,
105+
defaultBaseUrl: "https://api.pika.art/"));
91106
var __path = __pathBuilder.ToString();
92107
__path = global::Pika.AutoSDKRequestOptionsSupport.AppendQueryParameters(
93108
path: __path,

src/libs/Pika/Generated/Pika.DeveloperClient.GetDeveloperBalance.g.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ namespace Pika
66
public partial class DeveloperClient
77
{
88

9+
private static readonly global::Pika.AutoSDKServer[] s_GetDeveloperBalanceServers = new global::Pika.AutoSDKServer[]
10+
{ new global::Pika.AutoSDKServer(
11+
id: "https-api-pika-art",
12+
name: "Primary API endpoint",
13+
url: "https://api.pika.art/",
14+
description: "Primary API endpoint"),
15+
new global::Pika.AutoSDKServer(
16+
id: "https-srkibaanghvsriahb-pika-art-proxy-realtime",
17+
name: "Proxy/realtime endpoint (used by Python SDK)",
18+
url: "https://srkibaanghvsriahb.pika.art/proxy/realtime",
19+
description: "Proxy/realtime endpoint (used by Python SDK)"),
20+
};
21+
922

1023
private static readonly global::Pika.EndPointSecurityRequirement s_GetDeveloperBalanceSecurityRequirement0 =
1124
new global::Pika.EndPointSecurityRequirement
@@ -79,7 +92,9 @@ partial void ProcessGetDeveloperBalanceResponseContent(
7992
{
8093
var __pathBuilder = new global::Pika.PathBuilder(
8194
path: "/developer/balance",
82-
baseUri: HttpClient.BaseAddress);
95+
baseUri: ResolveBaseUri(
96+
servers: s_GetDeveloperBalanceServers,
97+
defaultBaseUrl: "https://api.pika.art/"));
8398
var __path = __pathBuilder.ToString();
8499
__path = global::Pika.AutoSDKRequestOptionsSupport.AppendQueryParameters(
85100
path: __path,

src/libs/Pika/Generated/Pika.DeveloperClient.GetTopupProducts.g.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ namespace Pika
66
public partial class DeveloperClient
77
{
88

9+
private static readonly global::Pika.AutoSDKServer[] s_GetTopupProductsServers = new global::Pika.AutoSDKServer[]
10+
{ new global::Pika.AutoSDKServer(
11+
id: "https-api-pika-art",
12+
name: "Primary API endpoint",
13+
url: "https://api.pika.art/",
14+
description: "Primary API endpoint"),
15+
new global::Pika.AutoSDKServer(
16+
id: "https-srkibaanghvsriahb-pika-art-proxy-realtime",
17+
name: "Proxy/realtime endpoint (used by Python SDK)",
18+
url: "https://srkibaanghvsriahb.pika.art/proxy/realtime",
19+
description: "Proxy/realtime endpoint (used by Python SDK)"),
20+
};
21+
922

1023
private static readonly global::Pika.EndPointSecurityRequirement s_GetTopupProductsSecurityRequirement0 =
1124
new global::Pika.EndPointSecurityRequirement
@@ -79,7 +92,9 @@ partial void ProcessGetTopupProductsResponseContent(
7992
{
8093
var __pathBuilder = new global::Pika.PathBuilder(
8194
path: "/developer/topup/products",
82-
baseUri: HttpClient.BaseAddress);
95+
baseUri: ResolveBaseUri(
96+
servers: s_GetTopupProductsServers,
97+
defaultBaseUrl: "https://api.pika.art/"));
8398
var __path = __pathBuilder.ToString();
8499
__path = global::Pika.AutoSDKRequestOptionsSupport.AppendQueryParameters(
85100
path: __path,

0 commit comments

Comments
 (0)