1+
2+ #nullable enable
3+
4+ namespace Together
5+ {
6+ /// <summary>
7+ /// If no httpClient is provided, a new one will be created.<br/>
8+ /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
9+ /// </summary>
10+ public sealed partial class ABExperimentServiceClient : global ::Together . IABExperimentServiceClient , global ::System . IDisposable
11+ {
12+ /// <summary>
13+ ///
14+ /// </summary>
15+ public const string DefaultBaseUrl = "https://api.together.ai/v2" ;
16+
17+ private bool _disposeHttpClient = true ;
18+
19+ /// <inheritdoc/>
20+ public global ::System . Net . Http . HttpClient HttpClient { get ; }
21+
22+ /// <inheritdoc/>
23+ public System . Uri ? BaseUri => HttpClient . BaseAddress ;
24+
25+ /// <inheritdoc/>
26+ public global ::System . Collections . Generic . List < global ::Together . EndPointAuthorization > Authorizations { get ; }
27+
28+ /// <inheritdoc/>
29+ public bool ReadResponseAsString { get ; set ; }
30+ #if DEBUG
31+ = true;
32+ #endif
33+
34+ /// <inheritdoc/>
35+ public global ::Together . AutoSDKClientOptions Options { get ; }
36+
37+
38+ internal global ::Together . AutoSDKServerConfiguration AutoSDKServerConfiguration { get ; set ; } = new global ::Together . AutoSDKServerConfiguration ( ) ;
39+ /// <summary>
40+ ///
41+ /// </summary>
42+ public global ::System . Text . Json . Serialization . JsonSerializerContext JsonSerializerContext { get ; set ; } = global ::Together . SourceGenerationContext . Default ;
43+
44+
45+ /// <summary>
46+ /// Creates a new instance of the ABExperimentServiceClient.
47+ /// If no httpClient is provided, a new one will be created.
48+ /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
49+ /// </summary>
50+ /// <param name="httpClient">The HttpClient instance. If not provided, a new one will be created.</param>
51+ /// <param name="baseUri">The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used.</param>
52+ /// <param name="authorizations">The authorizations to use for the requests.</param>
53+ /// <param name="disposeHttpClient">Dispose the HttpClient when the instance is disposed. True by default.</param>
54+ public ABExperimentServiceClient (
55+ global ::System . Net . Http . HttpClient ? httpClient = null ,
56+ global ::System . Uri ? baseUri = null ,
57+ global ::System . Collections . Generic . List < global ::Together . EndPointAuthorization > ? authorizations = null ,
58+ bool disposeHttpClient = true ) : this (
59+ httpClient ,
60+ baseUri ,
61+ authorizations ,
62+ options : null ,
63+ disposeHttpClient : disposeHttpClient )
64+ {
65+ }
66+
67+ /// <summary>
68+ /// Creates a new instance of the ABExperimentServiceClient with explicit options but no base URL override.
69+ /// Skips passing <c>baseUri</c> so the default base URL from the OpenAPI spec applies.
70+ /// </summary>
71+ /// <param name="httpClient">The HttpClient instance. If not provided, a new one will be created.</param>
72+ /// <param name="authorizations">The authorizations to use for the requests.</param>
73+ /// <param name="options">Client-wide request defaults such as headers, query parameters, retries, and timeout.</param>
74+ /// <param name="disposeHttpClient">Dispose the HttpClient when the instance is disposed. True by default.</param>
75+ public ABExperimentServiceClient (
76+ global ::System . Net . Http . HttpClient ? httpClient ,
77+ global ::System . Collections . Generic . List < global ::Together . EndPointAuthorization > ? authorizations ,
78+ global ::Together . AutoSDKClientOptions ? options ,
79+ bool disposeHttpClient = true ) : this (
80+ httpClient ,
81+ baseUri : null ,
82+ authorizations ,
83+ options ,
84+ disposeHttpClient : disposeHttpClient )
85+ {
86+ }
87+
88+ /// <summary>
89+ /// Creates a new instance of the ABExperimentServiceClient.
90+ /// If no httpClient is provided, a new one will be created.
91+ /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
92+ /// </summary>
93+ /// <param name="httpClient">The HttpClient instance. If not provided, a new one will be created.</param>
94+ /// <param name="baseUri">The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used.</param>
95+ /// <param name="authorizations">The authorizations to use for the requests.</param>
96+ /// <param name="options">Client-wide request defaults such as headers, query parameters, retries, and timeout.</param>
97+ /// <param name="disposeHttpClient">Dispose the HttpClient when the instance is disposed. True by default.</param>
98+ public ABExperimentServiceClient (
99+ global ::System . Net . Http . HttpClient ? httpClient ,
100+ global ::System . Uri ? baseUri ,
101+ global ::System . Collections . Generic . List < global ::Together . EndPointAuthorization > ? authorizations ,
102+ global ::Together . AutoSDKClientOptions ? options ,
103+ bool disposeHttpClient = true )
104+ {
105+
106+ HttpClient = httpClient ?? new global ::System . Net . Http . HttpClient ( ) ;
107+ if ( baseUri is not null )
108+ {
109+ HttpClient . BaseAddress ??= baseUri ;
110+ }
111+ Authorizations = authorizations ?? new global ::System . Collections . Generic . List < global ::Together . EndPointAuthorization > ( ) ;
112+ Options = options ?? new global ::Together . AutoSDKClientOptions ( ) ;
113+ _disposeHttpClient = disposeHttpClient ;
114+
115+ AutoSDKServerConfiguration . ExplicitBaseUri = baseUri ?? httpClient ? . BaseAddress ;
116+
117+ Initialized ( HttpClient ) ;
118+ }
119+
120+ /// <inheritdoc/>
121+ public void Dispose ( )
122+ {
123+ if ( _disposeHttpClient )
124+ {
125+ HttpClient . Dispose ( ) ;
126+ }
127+ }
128+
129+ partial void Initialized (
130+ global ::System . Net . Http . HttpClient client ) ;
131+ partial void PrepareArguments (
132+ global ::System . Net . Http . HttpClient client ) ;
133+ partial void PrepareRequest (
134+ global ::System . Net . Http . HttpClient client ,
135+ global ::System . Net . Http . HttpRequestMessage request ) ;
136+ partial void ProcessResponse (
137+ global ::System . Net . Http . HttpClient client ,
138+ global ::System . Net . Http . HttpResponseMessage response ) ;
139+ partial void ProcessResponseContent (
140+ global ::System . Net . Http . HttpClient client ,
141+ global ::System . Net . Http . HttpResponseMessage response ,
142+ ref string content ) ;
143+
144+
145+ private global ::System . Uri ? ResolveBaseUri (
146+ global ::Together . AutoSDKServer [ ] servers ,
147+ string defaultBaseUrl )
148+ {
149+ if ( AutoSDKServerConfiguration . ExplicitBaseUri is global ::System . Uri explicitBaseUri )
150+ {
151+ return explicitBaseUri ;
152+ }
153+
154+ if ( AutoSDKServerConfiguration . SelectedServer is global ::Together . AutoSDKServer selectedServer )
155+ {
156+ foreach ( var server in servers )
157+ {
158+ if ( string . Equals ( server . Id , selectedServer . Id , global ::System . StringComparison . Ordinal ) )
159+ {
160+ return server . Uri ;
161+ }
162+ }
163+ }
164+
165+ if ( servers . Length > 0 )
166+ {
167+ return servers [ 0 ] . Uri ;
168+ }
169+
170+ return string . IsNullOrWhiteSpace ( defaultBaseUrl )
171+ ? HttpClient . BaseAddress
172+ : new global ::System . Uri ( defaultBaseUrl , global ::System . UriKind . RelativeOrAbsolute ) ;
173+ }
174+ }
175+ }
0 commit comments