|
2 | 2 | using System.Net.Http;
|
3 | 3 | using k8s.Models;
|
4 | 4 |
|
5 |
| -namespace k8s |
| 5 | +namespace k8s.Fluent |
6 | 6 | {
|
7 |
| - public partial class Kubernetes |
| 7 | + public static class KubernetesFluent |
8 | 8 | {
|
9 | 9 | /// <summary>Creates a new Kubernetes object of the given type and sets its <see cref="IKubernetesObject.ApiVersion"/> and
|
10 | 10 | /// <see cref="IKubernetesObject.Kind"/>.
|
11 | 11 | /// </summary>
|
12 |
| - public T New<T>() where T : IKubernetesObject, new() => Scheme.New<T>(); |
| 12 | + public static T New<T>(this Kubernetes client) where T : IKubernetesObject, new() => client.Scheme.New<T>(); |
13 | 13 |
|
14 | 14 | /// <summary>Creates a new Kubernetes object of the given type and sets its <see cref="IKubernetesObject.ApiVersion"/>,
|
15 | 15 | /// <see cref="IKubernetesObject.Kind"/>, and <see cref="V1ObjectMeta.Name"/>.
|
16 | 16 | /// </summary>
|
17 |
| - public T New<T>(string name) where T : IKubernetesObject<V1ObjectMeta>, new() => Scheme.New<T>(name); |
| 17 | + public static T New<T>(this Kubernetes client, string name) where T : IKubernetesObject<V1ObjectMeta>, new() => client.Scheme.New<T>(name); |
18 | 18 |
|
19 | 19 | /// <summary>Creates a new Kubernetes object of the given type and sets its <see cref="IKubernetesObject.ApiVersion"/>,
|
20 | 20 | /// <see cref="IKubernetesObject.Kind"/>, <see cref="V1ObjectMeta.Namespace"/>, and <see cref="V1ObjectMeta.Name"/>.
|
21 | 21 | /// </summary>
|
22 |
| - public T New<T>(string ns, string name) where T : IKubernetesObject<V1ObjectMeta>, new() => Scheme.New<T>(ns, name); |
| 22 | + public static T New<T>(this Kubernetes client, string ns, string name) where T : IKubernetesObject<V1ObjectMeta>, new() => client.Scheme.New<T>(ns, name); |
23 | 23 |
|
24 | 24 | /// <summary>Creates a new <see cref="KubernetesRequest"/> using the given <see cref="HttpMethod"/>
|
25 | 25 | /// (<see cref="HttpMethod.Get"/> by default).
|
26 | 26 | /// </summary>
|
27 |
| - public KubernetesRequest Request(HttpMethod method = null) => new KubernetesRequest(this).Method(method); |
| 27 | + public static KubernetesRequest Request(this Kubernetes client, HttpMethod method = null) => new KubernetesRequest(client).Method(method); |
28 | 28 |
|
29 | 29 | /// <summary>Creates a new <see cref="KubernetesRequest"/> using the given <see cref="HttpMethod"/>
|
30 | 30 | /// and resource URI components.
|
31 | 31 | /// </summary>
|
32 |
| - public KubernetesRequest Request( |
| 32 | + public static KubernetesRequest Request(this Kubernetes client, |
33 | 33 | HttpMethod method, string type = null, string ns = null, string name = null, string group = null, string version = null) =>
|
34 |
| - new KubernetesRequest(this).Method(method).Group(group).Version(version).Type(type).Namespace(ns).Name(name); |
| 34 | + new KubernetesRequest(client).Method(method).Group(group).Version(version).Type(type).Namespace(ns).Name(name); |
35 | 35 |
|
36 | 36 | /// <summary>Creates a new <see cref="KubernetesRequest"/> to access the given type of object.</summary>
|
37 |
| - public KubernetesRequest Request(Type type) => new KubernetesRequest(this).GVK(type); |
| 37 | + public static KubernetesRequest Request(this Kubernetes client, Type type) => new KubernetesRequest(client).GVK(type); |
38 | 38 |
|
39 | 39 | /// <summary>Creates a new <see cref="KubernetesRequest"/> to access the given type of object with an optional name and namespace.</summary>
|
40 |
| - public KubernetesRequest Request(HttpMethod method, Type type, string ns = null, string name = null) => |
41 |
| - Request(method).GVK(type).Namespace(ns).Name(name); |
| 40 | + public static KubernetesRequest Request(this Kubernetes client, HttpMethod method, Type type, string ns = null, string name = null) => |
| 41 | + Request(client, method).GVK(type).Namespace(ns).Name(name); |
42 | 42 |
|
43 | 43 | /// <summary>Creates a new <see cref="KubernetesRequest"/> to access the given type of object with an optional name and namespace.</summary>
|
44 |
| - public KubernetesRequest Request<T>(string ns = null, string name = null) => Request(null, typeof(T), ns, name); |
| 44 | + public static KubernetesRequest Request<T>(this Kubernetes client, string ns = null, string name = null) => Request(client, null, typeof(T), ns, name); |
45 | 45 |
|
46 | 46 | /// <summary>Creates a new <see cref="KubernetesRequest"/> to access the given object.</summary>
|
47 |
| - public KubernetesRequest Request(IKubernetesObject obj, bool setBody = true) => new KubernetesRequest(this).Set(obj, setBody); |
| 47 | + public static KubernetesRequest Request(this Kubernetes client, IKubernetesObject obj, bool setBody = true) => new KubernetesRequest(client).Set(obj, setBody); |
48 | 48 | }
|
49 | 49 | }
|
0 commit comments