-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
netstandard2 extendable lib model, basic rest (#793)
* first lib model * add missing files * happy test * add vanilla rest for extend * fix new url pattern * address comments * add v to tag * bump ver * add missing file when ren * support multi pkg * fix gh action * fix env var * ren title * use gh action to set ver * remove unused * remove unused
- Loading branch information
Showing
65 changed files
with
333 additions
and
895 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
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
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 |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
using System.Threading.Tasks; | ||
using k8s; | ||
using k8s.Models; | ||
using k8s.Autorest; | ||
|
||
namespace attach | ||
{ | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
using System.Threading.Tasks; | ||
using k8s; | ||
using k8s.Models; | ||
using k8s.Autorest; | ||
|
||
namespace watch | ||
{ | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using k8s.Autorest; | ||
using System.Net.Http.Headers; | ||
|
||
|
||
namespace k8s | ||
{ | ||
public abstract partial class AbstractKubernetes | ||
{ | ||
private sealed class QueryBuilder | ||
{ | ||
private List<string> parameters = new List<string>(); | ||
|
||
public void Append(string key, params object[] values) | ||
{ | ||
foreach (var value in values) | ||
{ | ||
switch (value) | ||
{ | ||
case int intval: | ||
parameters.Add($"{key}={intval}"); | ||
break; | ||
case string strval: | ||
parameters.Add($"{key}={Uri.EscapeDataString(strval)}"); | ||
break; | ||
case bool boolval: | ||
parameters.Add($"{key}={(boolval ? "true" : "false")}"); | ||
break; | ||
default: | ||
// null | ||
break; | ||
} | ||
} | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
if (parameters.Count > 0) | ||
{ | ||
return "?" + string.Join("&", parameters); | ||
} | ||
|
||
return ""; | ||
} | ||
} | ||
|
||
private Task<HttpResponseMessage> SendRequest<T>(T body, HttpRequestMessage httpRequest, CancellationToken cancellationToken) | ||
{ | ||
if (body != null) | ||
{ | ||
var requestContent = KubernetesJson.Serialize(body); | ||
httpRequest.Content = new StringContent(requestContent, System.Text.Encoding.UTF8); | ||
httpRequest.Content.Headers.ContentType = GetHeader(body); | ||
return SendRequestRaw(requestContent, httpRequest, cancellationToken); | ||
} | ||
|
||
return SendRequestRaw("", httpRequest, cancellationToken); | ||
} | ||
|
||
public virtual TimeSpan HttpClientTimeout { get; set; } = TimeSpan.FromSeconds(100); | ||
|
||
protected abstract Task<HttpOperationResponse<T>> CreateResultAsync<T>(HttpRequestMessage httpRequest, HttpResponseMessage httpResponse, bool? watch, CancellationToken cancellationToken); | ||
|
||
protected abstract HttpRequestMessage CreateRequest(string relativeUri, string method, IDictionary<string, IList<string>> customHeaders); | ||
|
||
protected abstract MediaTypeHeaderValue GetHeader(object body); | ||
|
||
protected abstract Task<HttpResponseMessage> SendRequestRaw(string requestContent, HttpRequestMessage httpRequest, CancellationToken cancellationToken); | ||
} | ||
} |
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,5 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("KubernetesClient")] | ||
[assembly: InternalsVisibleTo("KubernetesClient.VanillaRest")] | ||
[assembly: InternalsVisibleTo("KubernetesClient.Tests")] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,5 @@ | ||
global using System; | ||
global using System.Collections.Generic; | ||
global using System.Linq; | ||
global using System.Text.Json; | ||
global using System.Text.Json.Serialization; |
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,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0</TargetFrameworks> | ||
<RootNamespace>k8s</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="Generator" /> | ||
<AdditionalFiles Include="..\..\swagger.json" Generator="api" /> | ||
<ProjectReference Include="..\KubernetesClient.Models\KubernetesClient.Models.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\LibKubernetesGenerator\LibKubernetesGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("KubernetesClient")] | ||
[assembly: InternalsVisibleTo("KubernetesClient.Basic")] | ||
[assembly: InternalsVisibleTo("KubernetesClient.Tests")] |
File renamed without changes.
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,5 @@ | ||
global using System; | ||
global using System.Collections.Generic; | ||
global using System.Linq; | ||
global using System.Text.Json; | ||
global using System.Text.Json.Serialization; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
18 changes: 18 additions & 0 deletions
18
src/KubernetesClient.Models/KubernetesClient.Models.csproj
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,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0</TargetFrameworks> | ||
<RootNamespace>k8s.Models</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="Generator" /> | ||
<AdditionalFiles Include="..\..\swagger.json" Generator="model,modelext,versionconverter" /> | ||
<ProjectReference Include="..\LibKubernetesGenerator\LibKubernetesGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.Text.Json" Version="6.0.0" /> | ||
<PackageReference Include="AutoMapper" Version="10.1.1" /> | ||
<PackageReference Include="Fractions" Version="7.0.0" /> | ||
</ItemGroup> | ||
</Project> |
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.