-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
187 changed files
with
10,823 additions
and
419 deletions.
There are no files selected for viewing
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
1 change: 1 addition & 0 deletions
1
...apshotTests/Snapshots/ideogram/NewtonsoftJson/Tests.SdkGenerator_Diagnostics.verified.txt
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 @@ | ||
[] |
21 changes: 21 additions & 0 deletions
21
...SDK.SnapshotTests/Snapshots/ideogram/NewtonsoftJson/_#G.Api.Authorizations..g.verified.cs
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,21 @@ | ||
//HintName: G.Api.Authorizations..g.cs | ||
|
||
#nullable enable | ||
|
||
namespace G | ||
{ | ||
public sealed partial class Api | ||
{ | ||
/// <summary> | ||
/// Authorize using ApiKey authentication. | ||
/// </summary> | ||
/// <param name="apiKey"></param> | ||
public void AuthorizeUsingApiKey( | ||
string apiKey) | ||
{ | ||
apiKey = apiKey ?? throw new global::System.ArgumentNullException(nameof(apiKey)); | ||
|
||
_httpClient.DefaultRequestHeaders.Add("Api-Key", apiKey); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...toSDK.SnapshotTests/Snapshots/ideogram/NewtonsoftJson/_#G.Api.Constructors..g.verified.cs
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,28 @@ | ||
//HintName: G.Api.Constructors..g.cs | ||
|
||
#nullable enable | ||
|
||
namespace G | ||
{ | ||
public sealed partial class Api | ||
{ | ||
/// <inheritdoc cref="Api(global::System.Net.Http.HttpClient?, global::System.Uri?)"/> | ||
public Api( | ||
string apiKey, | ||
global::System.Net.Http.HttpClient? httpClient = null, | ||
global::System.Uri? baseUri = null) : this(httpClient, baseUri) | ||
{ | ||
Authorizing(_httpClient, ref apiKey); | ||
|
||
AuthorizeUsingApiKey(apiKey); | ||
|
||
Authorized(_httpClient); | ||
} | ||
|
||
partial void Authorizing( | ||
global::System.Net.Http.HttpClient client, | ||
ref string apiKey); | ||
partial void Authorized( | ||
global::System.Net.Http.HttpClient client); | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
src/tests/AutoSDK.SnapshotTests/Snapshots/ideogram/NewtonsoftJson/_#G.Api.g.verified.cs
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,90 @@ | ||
//HintName: G.Api.g.cs | ||
|
||
#nullable enable | ||
|
||
namespace G | ||
{ | ||
/// <summary> | ||
/// This is the API definition for Ideogram AI.<br/> | ||
/// If no httpClient is provided, a new one will be created.<br/> | ||
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. | ||
/// </summary> | ||
public sealed partial class Api : global::G.IApi, global::System.IDisposable | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public const string BaseUrl = ""; | ||
|
||
private readonly global::System.Net.Http.HttpClient _httpClient; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public global::Newtonsoft.Json.JsonSerializerSettings JsonSerializerOptions { get; set; } = new global::Newtonsoft.Json.JsonSerializerSettings(); | ||
|
||
|
||
/// <summary> | ||
/// All things related to generating content. | ||
/// </summary> | ||
public GenerateClient Generate => new GenerateClient(_httpClient) | ||
{ | ||
JsonSerializerOptions = JsonSerializerOptions, | ||
}; | ||
|
||
/// <summary> | ||
/// Content related to managing API account and API access | ||
/// </summary> | ||
public ManageClient Manage => new ManageClient(_httpClient) | ||
{ | ||
JsonSerializerOptions = JsonSerializerOptions, | ||
}; | ||
|
||
/// <summary> | ||
/// Operations related to understanding visual content | ||
/// </summary> | ||
public VisionClient Vision => new VisionClient(_httpClient) | ||
{ | ||
JsonSerializerOptions = JsonSerializerOptions, | ||
}; | ||
|
||
/// <summary> | ||
/// Creates a new instance of the Api. | ||
/// If no httpClient is provided, a new one will be created. | ||
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. | ||
/// </summary> | ||
/// <param name="httpClient"></param> | ||
/// <param name="baseUri"></param> | ||
/// <param name="jsonSerializerOptions"></param> | ||
public Api( | ||
global::System.Net.Http.HttpClient? httpClient = null, | ||
global::System.Uri? baseUri = null) | ||
{ | ||
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient(); | ||
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl); | ||
|
||
Initialized(_httpClient); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void Dispose() | ||
{ | ||
_httpClient.Dispose(); | ||
} | ||
|
||
partial void Initialized( | ||
global::System.Net.Http.HttpClient client); | ||
partial void PrepareArguments( | ||
global::System.Net.Http.HttpClient client); | ||
partial void PrepareRequest( | ||
global::System.Net.Http.HttpClient client, | ||
global::System.Net.Http.HttpRequestMessage request); | ||
partial void ProcessResponse( | ||
global::System.Net.Http.HttpClient client, | ||
global::System.Net.Http.HttpResponseMessage response); | ||
partial void ProcessResponseContent( | ||
global::System.Net.Http.HttpClient client, | ||
global::System.Net.Http.HttpResponseMessage response, | ||
ref string content); | ||
} | ||
} |
124 changes: 124 additions & 0 deletions
124
...ests/Snapshots/ideogram/NewtonsoftJson/_#G.GenerateClient.PostGenerateImage.g.verified.cs
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,124 @@ | ||
//HintName: G.GenerateClient.PostGenerateImage.g.cs | ||
|
||
#nullable enable | ||
|
||
namespace G | ||
{ | ||
public partial class GenerateClient | ||
{ | ||
partial void PreparePostGenerateImageArguments( | ||
global::System.Net.Http.HttpClient httpClient, | ||
global::G.GenerateImageRequest request); | ||
partial void PreparePostGenerateImageRequest( | ||
global::System.Net.Http.HttpClient httpClient, | ||
global::System.Net.Http.HttpRequestMessage httpRequestMessage, | ||
global::G.GenerateImageRequest request); | ||
partial void ProcessPostGenerateImageResponse( | ||
global::System.Net.Http.HttpClient httpClient, | ||
global::System.Net.Http.HttpResponseMessage httpResponseMessage); | ||
|
||
partial void ProcessPostGenerateImageResponseContent( | ||
global::System.Net.Http.HttpClient httpClient, | ||
global::System.Net.Http.HttpResponseMessage httpResponseMessage, | ||
ref string content); | ||
|
||
/// <summary> | ||
/// Generates images synchronously based on a given prompt and optional parameters.<br/> | ||
/// A request to generate an image with Ideogram. | ||
/// </summary> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken">The token to cancel the operation with</param> | ||
/// <exception cref="global::System.InvalidOperationException"></exception> | ||
public async global::System.Threading.Tasks.Task<global::G.GenerateImageResponse> PostGenerateImageAsync( | ||
global::G.GenerateImageRequest request, | ||
global::System.Threading.CancellationToken cancellationToken = default) | ||
{ | ||
request = request ?? throw new global::System.ArgumentNullException(nameof(request)); | ||
|
||
PrepareArguments( | ||
client: _httpClient); | ||
PreparePostGenerateImageArguments( | ||
httpClient: _httpClient, | ||
request: request); | ||
|
||
var __pathBuilder = new PathBuilder( | ||
path: "/generate", | ||
baseUri: _httpClient.BaseAddress); | ||
var __path = __pathBuilder.ToString(); | ||
using var httpRequest = new global::System.Net.Http.HttpRequestMessage( | ||
method: global::System.Net.Http.HttpMethod.Post, | ||
requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); | ||
var __httpRequestContentBody = global::Newtonsoft.Json.JsonConvert.SerializeObject(request, JsonSerializerOptions); | ||
var __httpRequestContent = new global::System.Net.Http.StringContent( | ||
content: __httpRequestContentBody, | ||
encoding: global::System.Text.Encoding.UTF8, | ||
mediaType: "application/json"); | ||
httpRequest.Content = __httpRequestContent; | ||
|
||
PrepareRequest( | ||
client: _httpClient, | ||
request: httpRequest); | ||
PreparePostGenerateImageRequest( | ||
httpClient: _httpClient, | ||
httpRequestMessage: httpRequest, | ||
request: request); | ||
|
||
using var response = await _httpClient.SendAsync( | ||
request: httpRequest, | ||
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, | ||
cancellationToken: cancellationToken).ConfigureAwait(false); | ||
|
||
ProcessResponse( | ||
client: _httpClient, | ||
response: response); | ||
ProcessPostGenerateImageResponse( | ||
httpClient: _httpClient, | ||
httpResponseMessage: response); | ||
|
||
var __content = await response.Content.ReadAsStringAsync().ConfigureAwait(false); | ||
|
||
ProcessResponseContent( | ||
client: _httpClient, | ||
response: response, | ||
content: ref __content); | ||
ProcessPostGenerateImageResponseContent( | ||
httpClient: _httpClient, | ||
httpResponseMessage: response, | ||
content: ref __content); | ||
|
||
try | ||
{ | ||
response.EnsureSuccessStatusCode(); | ||
} | ||
catch (global::System.Net.Http.HttpRequestException ex) | ||
{ | ||
throw new global::System.InvalidOperationException(__content, ex); | ||
} | ||
|
||
return | ||
global::Newtonsoft.Json.JsonConvert.DeserializeObject<global::G.GenerateImageResponse?>(__content, JsonSerializerOptions) ?? | ||
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); | ||
} | ||
|
||
/// <summary> | ||
/// Generates images synchronously based on a given prompt and optional parameters.<br/> | ||
/// A request to generate an image with Ideogram. | ||
/// </summary> | ||
/// <param name="imageRequest"></param> | ||
/// <param name="cancellationToken">The token to cancel the operation with</param> | ||
/// <exception cref="global::System.InvalidOperationException"></exception> | ||
public async global::System.Threading.Tasks.Task<global::G.GenerateImageResponse> PostGenerateImageAsync( | ||
global::G.ImageRequest imageRequest, | ||
global::System.Threading.CancellationToken cancellationToken = default) | ||
{ | ||
var request = new global::G.GenerateImageRequest | ||
{ | ||
ImageRequest = imageRequest, | ||
}; | ||
|
||
return await PostGenerateImageAsync( | ||
request: request, | ||
cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
} | ||
} |
Oops, something went wrong.