1
+
2
+ #nullable enable
3
+
4
+ namespace DeepInfra
5
+ {
6
+ public partial class DeepInfraApi
7
+ {
8
+ partial void PrepareAccountSetUsernameV1MeUsernamePatchArguments (
9
+ global ::System . Net . Http . HttpClient httpClient ,
10
+ global ::DeepInfra . MeUsername request ) ;
11
+ partial void PrepareAccountSetUsernameV1MeUsernamePatchRequest (
12
+ global ::System . Net . Http . HttpClient httpClient ,
13
+ global ::System . Net . Http . HttpRequestMessage httpRequestMessage ,
14
+ global ::DeepInfra . MeUsername request ) ;
15
+ partial void ProcessAccountSetUsernameV1MeUsernamePatchResponse (
16
+ global ::System . Net . Http . HttpClient httpClient ,
17
+ global ::System . Net . Http . HttpResponseMessage httpResponseMessage ) ;
18
+
19
+ partial void ProcessAccountSetUsernameV1MeUsernamePatchResponseContent (
20
+ global ::System . Net . Http . HttpClient httpClient ,
21
+ global ::System . Net . Http . HttpResponseMessage httpResponseMessage ,
22
+ ref string content ) ;
23
+
24
+ /// <summary>
25
+ /// Account Set Username
26
+ /// </summary>
27
+ /// <param name="request"></param>
28
+ /// <param name="cancellationToken">The token to cancel the operation with</param>
29
+ /// <exception cref="global::System.InvalidOperationException"></exception>
30
+ public async global ::System . Threading . Tasks . Task < global ::DeepInfra . AccountSetUsernameV1MeUsernamePatchResponse > AccountSetUsernameV1MeUsernamePatchAsync (
31
+ global ::DeepInfra . MeUsername request ,
32
+ global ::System . Threading . CancellationToken cancellationToken = default )
33
+ {
34
+ request = request ?? throw new global ::System . ArgumentNullException ( nameof ( request ) ) ;
35
+
36
+ PrepareArguments (
37
+ client : _httpClient ) ;
38
+ PrepareAccountSetUsernameV1MeUsernamePatchArguments (
39
+ httpClient : _httpClient ,
40
+ request : request ) ;
41
+
42
+ using var httpRequest = new global ::System . Net . Http . HttpRequestMessage (
43
+ method : new global ::System . Net . Http . HttpMethod ( "PATCH" ) ,
44
+ requestUri : new global ::System . Uri ( _httpClient . BaseAddress ? . AbsoluteUri . TrimEnd ( '/' ) + "/v1/me/username" , global ::System . UriKind . RelativeOrAbsolute ) ) ;
45
+ var __httpRequestContent = new global ::System . Net . Http . StringContent (
46
+ content : global ::System . Text . Json . JsonSerializer . Serialize ( request , global ::DeepInfra . SourceGenerationContext . Default . MeUsername ) ,
47
+ encoding : global ::System . Text . Encoding . UTF8 ,
48
+ mediaType : "application/json" ) ;
49
+ httpRequest . Content = __httpRequestContent ;
50
+
51
+ PrepareRequest (
52
+ client : _httpClient ,
53
+ request : httpRequest ) ;
54
+ PrepareAccountSetUsernameV1MeUsernamePatchRequest (
55
+ httpClient : _httpClient ,
56
+ httpRequestMessage : httpRequest ,
57
+ request : request ) ;
58
+
59
+ using var response = await _httpClient . SendAsync (
60
+ request : httpRequest ,
61
+ completionOption : global ::System . Net . Http . HttpCompletionOption . ResponseContentRead ,
62
+ cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ;
63
+
64
+ ProcessResponse (
65
+ client : _httpClient ,
66
+ response : response ) ;
67
+ ProcessAccountSetUsernameV1MeUsernamePatchResponse (
68
+ httpClient : _httpClient ,
69
+ httpResponseMessage : response ) ;
70
+
71
+ var __content = await response . Content . ReadAsStringAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
72
+
73
+ ProcessResponseContent (
74
+ client : _httpClient ,
75
+ response : response ,
76
+ content : ref __content ) ;
77
+ ProcessAccountSetUsernameV1MeUsernamePatchResponseContent (
78
+ httpClient : _httpClient ,
79
+ httpResponseMessage : response ,
80
+ content : ref __content ) ;
81
+
82
+ try
83
+ {
84
+ response . EnsureSuccessStatusCode ( ) ;
85
+ }
86
+ catch ( global ::System . Net . Http . HttpRequestException ex )
87
+ {
88
+ throw new global ::System . InvalidOperationException ( __content , ex ) ;
89
+ }
90
+
91
+ return
92
+ global ::System . Text . Json . JsonSerializer . Deserialize ( __content , global ::DeepInfra . SourceGenerationContext . Default . AccountSetUsernameV1MeUsernamePatchResponse ) ??
93
+ throw new global ::System . InvalidOperationException ( $ "Response deserialization failed for \" { __content } \" ") ;
94
+ }
95
+
96
+ /// <summary>
97
+ /// Account Set Username
98
+ /// </summary>
99
+ /// <param name="username">
100
+ /// String with length between 1 and 39 characters. Only alphanumeric characters and dashes allowed. Must contain no leading, trailing or consecutive dashes.
101
+ /// </param>
102
+ /// <param name="cancellationToken">The token to cancel the operation with</param>
103
+ /// <exception cref="global::System.InvalidOperationException"></exception>
104
+ public async global ::System . Threading . Tasks . Task < global ::DeepInfra . AccountSetUsernameV1MeUsernamePatchResponse > AccountSetUsernameV1MeUsernamePatchAsync (
105
+ string username ,
106
+ global ::System . Threading . CancellationToken cancellationToken = default )
107
+ {
108
+ var request = new global ::DeepInfra . MeUsername
109
+ {
110
+ Username = username ,
111
+ } ;
112
+
113
+ return await AccountSetUsernameV1MeUsernamePatchAsync (
114
+ request : request ,
115
+ cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ;
116
+ }
117
+ }
118
+ }
0 commit comments