Skip to content

Commit 6043dca

Browse files
tg123brendandburns
authored andcommitted
generate with stream support (#75)
1 parent ff7a455 commit 6043dca

File tree

3 files changed

+14
-24
lines changed

3 files changed

+14
-24
lines changed

src/generated/IKubernetes.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace k8s
1111
using Newtonsoft.Json;
1212
using System.Collections;
1313
using System.Collections.Generic;
14+
using System.IO;
1415
using System.Threading;
1516
using System.Threading.Tasks;
1617

@@ -2742,7 +2743,7 @@ public partial interface IKubernetes : System.IDisposable
27422743
/// <param name='cancellationToken'>
27432744
/// The cancellation token.
27442745
/// </param>
2745-
Task<HttpOperationResponse<string>> ReadNamespacedPodLogWithHttpMessagesAsync(string name, string namespaceParameter, string container = default(string), bool? follow = default(bool?), int? limitBytes = default(int?), string pretty = default(string), bool? previous = default(bool?), int? sinceSeconds = default(int?), int? tailLines = default(int?), bool? timestamps = default(bool?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
2746+
Task<HttpOperationResponse<Stream>> ReadNamespacedPodLogWithHttpMessagesAsync(string name, string namespaceParameter, string container = default(string), bool? follow = default(bool?), int? limitBytes = default(int?), string pretty = default(string), bool? previous = default(bool?), int? sinceSeconds = default(int?), int? tailLines = default(int?), bool? timestamps = default(bool?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
27462747

27472748
/// <summary>
27482749
/// connect GET requests to portforward of Pod

src/generated/Kubernetes.cs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace k8s
1212
using Newtonsoft.Json;
1313
using System.Collections;
1414
using System.Collections.Generic;
15+
using System.IO;
1516
using System.Net;
1617
using System.Net.Http;
1718
using System.Threading;
@@ -240,6 +241,7 @@ public Kubernetes(System.Uri baseUri, ServiceClientCredentials credentials, Http
240241
/// </summary>
241242
private void Initialize()
242243
{
244+
BaseUri = new System.Uri("http://localhost");
243245
SerializationSettings = new JsonSerializerSettings
244246
{
245247
Formatting = Newtonsoft.Json.Formatting.Indented,
@@ -12794,7 +12796,7 @@ private void Initialize()
1279412796
/// <return>
1279512797
/// A response object containing the response body and response headers.
1279612798
/// </return>
12797-
public async Task<HttpOperationResponse<string>> ReadNamespacedPodLogWithHttpMessagesAsync(string name, string namespaceParameter, string container = default(string), bool? follow = default(bool?), int? limitBytes = default(int?), string pretty = default(string), bool? previous = default(bool?), int? sinceSeconds = default(int?), int? tailLines = default(int?), bool? timestamps = default(bool?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
12799+
public async Task<HttpOperationResponse<Stream>> ReadNamespacedPodLogWithHttpMessagesAsync(string name, string namespaceParameter, string container = default(string), bool? follow = default(bool?), int? limitBytes = default(int?), string pretty = default(string), bool? previous = default(bool?), int? sinceSeconds = default(int?), int? tailLines = default(int?), bool? timestamps = default(bool?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
1279812800
{
1279912801
if (name == null)
1280012802
{
@@ -12900,7 +12902,7 @@ private void Initialize()
1290012902
ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
1290112903
}
1290212904
cancellationToken.ThrowIfCancellationRequested();
12903-
_httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
12905+
_httpResponse = await HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
1290412906
if (_shouldTrace)
1290512907
{
1290612908
ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
@@ -12931,26 +12933,13 @@ private void Initialize()
1293112933
throw ex;
1293212934
}
1293312935
// Create Result
12934-
var _result = new HttpOperationResponse<string>();
12936+
var _result = new HttpOperationResponse<Stream>();
1293512937
_result.Request = _httpRequest;
1293612938
_result.Response = _httpResponse;
1293712939
// Deserialize Response
1293812940
if ((int)_statusCode == 200)
1293912941
{
12940-
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
12941-
try
12942-
{
12943-
_result.Body = SafeJsonConvert.DeserializeObject<string>(_responseContent, DeserializationSettings);
12944-
}
12945-
catch (JsonException ex)
12946-
{
12947-
_httpRequest.Dispose();
12948-
if (_httpResponse != null)
12949-
{
12950-
_httpResponse.Dispose();
12951-
}
12952-
throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
12953-
}
12942+
_result.Body = await _httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
1295412943
}
1295512944
if (_shouldTrace)
1295612945
{

src/generated/KubernetesExtensions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace k8s
88
{
99
using Models;
10+
using System.IO;
1011
using System.Threading;
1112
using System.Threading.Tasks;
1213

@@ -5504,7 +5505,7 @@ public static V1APIResourceList GetAPIResources(this IKubernetes operations)
55045505
/// If true, add an RFC3339 or RFC3339Nano timestamp at the beginning of every
55055506
/// line of log output. Defaults to false.
55065507
/// </param>
5507-
public static string ReadNamespacedPodLog(this IKubernetes operations, string name, string namespaceParameter, string container = default(string), bool? follow = default(bool?), int? limitBytes = default(int?), string pretty = default(string), bool? previous = default(bool?), int? sinceSeconds = default(int?), int? tailLines = default(int?), bool? timestamps = default(bool?))
5508+
public static Stream ReadNamespacedPodLog(this IKubernetes operations, string name, string namespaceParameter, string container = default(string), bool? follow = default(bool?), int? limitBytes = default(int?), string pretty = default(string), bool? previous = default(bool?), int? sinceSeconds = default(int?), int? tailLines = default(int?), bool? timestamps = default(bool?))
55085509
{
55095510
return operations.ReadNamespacedPodLogAsync(name, namespaceParameter, container, follow, limitBytes, pretty, previous, sinceSeconds, tailLines, timestamps).GetAwaiter().GetResult();
55105511
}
@@ -5557,12 +5558,11 @@ public static V1APIResourceList GetAPIResources(this IKubernetes operations)
55575558
/// <param name='cancellationToken'>
55585559
/// The cancellation token.
55595560
/// </param>
5560-
public static async Task<string> ReadNamespacedPodLogAsync(this IKubernetes operations, string name, string namespaceParameter, string container = default(string), bool? follow = default(bool?), int? limitBytes = default(int?), string pretty = default(string), bool? previous = default(bool?), int? sinceSeconds = default(int?), int? tailLines = default(int?), bool? timestamps = default(bool?), CancellationToken cancellationToken = default(CancellationToken))
5561+
public static async Task<Stream> ReadNamespacedPodLogAsync(this IKubernetes operations, string name, string namespaceParameter, string container = default(string), bool? follow = default(bool?), int? limitBytes = default(int?), string pretty = default(string), bool? previous = default(bool?), int? sinceSeconds = default(int?), int? tailLines = default(int?), bool? timestamps = default(bool?), CancellationToken cancellationToken = default(CancellationToken))
55615562
{
5562-
using (var _result = await operations.ReadNamespacedPodLogWithHttpMessagesAsync(name, namespaceParameter, container, follow, limitBytes, pretty, previous, sinceSeconds, tailLines, timestamps, null, cancellationToken).ConfigureAwait(false))
5563-
{
5564-
return _result.Body;
5565-
}
5563+
var _result = await operations.ReadNamespacedPodLogWithHttpMessagesAsync(name, namespaceParameter, container, follow, limitBytes, pretty, previous, sinceSeconds, tailLines, timestamps, null, cancellationToken).ConfigureAwait(false);
5564+
_result.Request.Dispose();
5565+
return _result.Body;
55665566
}
55675567

55685568
/// <summary>

0 commit comments

Comments
 (0)