1616
1717using DataStax . AstraDB . DataApi . Collections ;
1818using DataStax . AstraDB . DataApi . SerDes ;
19+ using DataStax . AstraDB . DataApi . Tables ;
1920using Microsoft . Extensions . Logging ;
2021using System ;
2122using System . Collections . Generic ;
@@ -109,7 +110,7 @@ internal async Task<ApiResponseWithStatus<TStatus>> RunAsyncReturnStatus<TStatus
109110 return response ;
110111 }
111112
112- internal async Task < ApiResponseWithData < TData , TStatus > > RunAsyncReturnData < TData , TDocument , TStatus > ( bool runSynchronously )
113+ internal async Task < ApiResponseWithData < TData , TStatus > > RunAsyncReturnDocumentData < TData , TDocument , TStatus > ( bool runSynchronously )
113114 {
114115 var useDocumentConverter = typeof ( TDocument ) != typeof ( Document ) ;
115116 if ( useDocumentConverter )
@@ -127,6 +128,16 @@ internal async Task<ApiResponseWithData<TData, TStatus>> RunAsyncReturnData<TDat
127128 return response ;
128129 }
129130
131+ internal async Task < ApiResponseWithData < TData , TStatus > > RunAsyncReturnData < TData , TStatus > ( bool runSynchronously )
132+ {
133+ var response = await RunCommandAsync < ApiResponseWithData < TData , TStatus > > ( HttpMethod . Post , runSynchronously ) . ConfigureAwait ( false ) ;
134+ if ( response . Errors != null && response . Errors . Count > 0 )
135+ {
136+ throw new CommandException ( response . Errors ) ;
137+ }
138+ return response ;
139+ }
140+
130141 internal async Task < T > RunAsyncRaw < T > ( bool runSynchronously )
131142 {
132143 return await RunAsyncRaw < T > ( HttpMethod . Post , runSynchronously ) . ConfigureAwait ( false ) ;
@@ -142,9 +153,18 @@ internal string Serialize<T>(T input, JsonSerializerOptions serializeOptions = n
142153 var commandOptions = CommandOptions . Merge ( _commandOptionsTree . ToArray ( ) ) ;
143154 serializeOptions ??= new JsonSerializerOptions ( ) ;
144155 serializeOptions . Converters . Add ( new ObjectIdConverter ( ) ) ;
145- serializeOptions . Converters . Add ( new SerDes . GuidConverter ( ) ) ;
146- serializeOptions . Converters . Add ( new DateTimeConverter < DateTimeOffset > ( ) ) ;
147- serializeOptions . Converters . Add ( new DateTimeConverter < DateTime > ( ) ) ;
156+ serializeOptions . Converters . Add ( new DurationConverter ( ) ) ;
157+ serializeOptions . Converters . Add ( new ByteArrayAsBinaryJsonConverter ( ) ) ;
158+ if ( commandOptions . SerializeDateAsDollarDate == true )
159+ {
160+ serializeOptions . Converters . Add ( new DateTimeConverter < DateTimeOffset > ( ) ) ;
161+ serializeOptions . Converters . Add ( new DateTimeConverter < DateTime > ( ) ) ;
162+ }
163+ if ( commandOptions . SerializeGuidAsDollarUuid == true )
164+ {
165+ serializeOptions . Converters . Add ( new GuidConverter ( ) ) ;
166+ }
167+ serializeOptions . Converters . Add ( new IpAddressConverter ( ) ) ;
148168 if ( commandOptions . InputConverter != null )
149169 {
150170 serializeOptions . Converters . Add ( commandOptions . InputConverter ) ;
@@ -166,15 +186,23 @@ internal T Deserialize<T>(string input)
166186 {
167187 var commandOptions = CommandOptions . Merge ( _commandOptionsTree . ToArray ( ) ) ;
168188 var deserializeOptions = new JsonSerializerOptions ( ) ;
169-
189+ deserializeOptions . Converters . Add ( new DurationConverter ( ) ) ;
190+ deserializeOptions . Converters . Add ( new ByteArrayAsBinaryJsonConverter ( ) ) ;
170191 if ( commandOptions . OutputConverter != null )
171192 {
172193 deserializeOptions . Converters . Add ( commandOptions . OutputConverter ) ;
173194 }
174195 deserializeOptions . Converters . Add ( new ObjectIdConverter ( ) ) ;
175- deserializeOptions . Converters . Add ( new SerDes . GuidConverter ( ) ) ;
176- deserializeOptions . Converters . Add ( new DateTimeConverter < DateTimeOffset > ( ) ) ;
177- deserializeOptions . Converters . Add ( new DateTimeConverter < DateTime > ( ) ) ;
196+ if ( commandOptions . SerializeGuidAsDollarUuid == true )
197+ {
198+ deserializeOptions . Converters . Add ( new GuidConverter ( ) ) ;
199+ }
200+ if ( commandOptions . SerializeDateAsDollarDate == true )
201+ {
202+ deserializeOptions . Converters . Add ( new DateTimeConverter < DateTimeOffset > ( ) ) ;
203+ deserializeOptions . Converters . Add ( new DateTimeConverter < DateTime > ( ) ) ;
204+ }
205+ deserializeOptions . Converters . Add ( new IpAddressConverter ( ) ) ;
178206
179207 return JsonSerializer . Deserialize < T > ( input , deserializeOptions ) ;
180208 }
0 commit comments