Implementing a more modular API (#1627)
* fix typo * Add modular API * Use x-kubernetes-action instead of operationId to generate method names * fix * Clean code style warnings * Refactor client constructors to use Kubernetes type instead of IKubernetes * Add ClientSet tests for Kubernetes pod operations * Fix order of parameters in Pod API calls for consistency * Enhance documentation for ClientSet and ResourceClient classes * Refactor ClientSet and GroupClient for Kubernetes usage * Refactor Pod API calls in tests to use singular form for consistency * Refactor Pod API calls to use 'Create' and 'Update' methods for consistency
This commit is contained in:
26
examples/clientset/Program.cs
Normal file
26
examples/clientset/Program.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
// See https://aka.ms/new-console-template for more information
|
||||
using k8s;
|
||||
using k8s.ClientSets;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace clientset
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
private static async Task Main(string[] args)
|
||||
{
|
||||
var config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
|
||||
var client = new Kubernetes(config);
|
||||
|
||||
ClientSet clientSet = new ClientSet(client);
|
||||
var list = await clientSet.CoreV1.Pod.ListAsync("default").ConfigureAwait(false);
|
||||
foreach (var item in list)
|
||||
{
|
||||
System.Console.WriteLine(item.Metadata.Name);
|
||||
}
|
||||
|
||||
var pod = await clientSet.CoreV1.Pod.GetAsync("test","default").ConfigureAwait(false);
|
||||
System.Console.WriteLine(pod?.Metadata?.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
6
examples/clientset/clientset.csproj
Normal file
6
examples/clientset/clientset.csproj
Normal file
@@ -0,0 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user