Current section
Files
Jump to
Current section
Files
lib/kubegen/k8s_client/example_com/v1alpha1/foo.ex
defmodule Kubegen.K8sClient.ExampleCom.V1alpha1.Foo do
@resource_path "apis/example.com/v1alpha1/namespaces/:namespace/foos/:name"
defp req() do
Req.new()
|> Kubereq.attach(kubeconfig: Kubereq.Kubeconfig.Default, resource_path: @resource_path)
end
@doc """
Create a resource of kind `foos` in apiVersion `example.com/v1alpha1`.
"""
@spec create(resource :: map()) :: Kubereq.response()
def create(resource) do
Kubereq.create(req(), resource)
end
@doc """
Get the resource of kind `foos` in apiVersion `example.com/v1alpha1` by `name`.
"""
@spec get(namespace :: Kubereq.namespace(), name :: String.t()) :: Kubereq.response()
def get(namespace, name) do
Kubereq.get(req(), namespace, name)
end
@doc """
Wait until the given `callback` resolves to true for a resource of kind
`foos` in apiVersion example.com/v1alpha1.
### Callback Args and Result
The given `callback` is called with the resource as argument. If the resource
was deleted, `:deleted` is passed as argument.
The callback should return a boolean.
### Options
* `timeout` - Timeout in ms after function terminates with `{:error, :timeout}`.
Defaults to `10_000`.
"""
@spec wait_until(
namespace :: Kubereq.namespace(),
name :: String.t(),
callback :: Kubereq.wait_until_callback()
) :: :ok | {:error, :timeout}
@spec wait_until(
namespace :: Kubereq.namespace(),
name :: String.t(),
callback :: Kubereq.wait_until_callback(),
timeout :: integer()
) :: Kubereq.wait_until_response()
def wait_until(namespace, name, callback, timeout \\ 10000) do
Kubereq.wait_until(req(), namespace, name, callback, timeout)
end
@doc """
List resources of kind `foos` in apiVersion `example.com/v1alpha1` in all namespaces.
"""
@spec list() :: Kubereq.response()
def list() do
list(nil, [])
end
@doc """
List resources of kind `foos` in apiVersion `example.com/v1alpha1` in all namespaces.
### Options
* `:field_selectors` - A list of field selectors. See `Kubereq.Step.FieldSelector` for more infos.
* `:label_selectors` - A list of field selectors. See `Kubereq.Step.LabelSelector` for more infos.
"""
@spec list(opts :: Keyword.t()) :: Kubereq.response()
def list(opts) when is_list(opts) do
list(nil, opts)
end
@doc """
List resources of kind `foos` in apiVersion
`example.com/v1alpha1` in the given `namespace`.
### Options
* `:field_selectors` - A list of field selectors. See `Kubereq.Step.FieldSelector` for more infos.
* `:label_selectors` - A list of field selectors. See `Kubereq.Step.LabelSelector` for more infos.
"""
@spec list(namespace :: Kubereq.namespace()) :: Kubereq.response()
@spec list(namespace :: Kubereq.namespace(), opts :: Keyword.t()) :: Kubereq.response()
def list(namespace, opts \\ []) when is_binary(namespace) or is_nil(namespace) do
Kubereq.list(req(), namespace, opts)
end
@doc """
Deletes the resource of kind `foos` in apiVersion `example.com/v1alpha1`
with `name` in `namespace`.
"""
@spec delete(namespace :: String.t(), name :: Kubereq.namespace()) :: Kubereq.response()
def delete(namespace, name) do
Kubereq.delete(req(), namespace, name)
end
@doc """
Deletes all the resources of kind `foos` in apiVersion
`example.com/v1alpha1` in `namespace`.
### Options
* `:field_selectors` - A list of field selectors. See `Kubereq.Step.FieldSelector` for more infos.
* `:label_selectors` - A list of field selectors. See `Kubereq.Step.LabelSelector` for more infos.
"""
@spec delete_all(namespace :: Kubereq.namespace(), opts :: keyword()) :: Kubereq.response()
def delete_all(namespace, opts \\ []) do
Kubereq.delete_all(req(), namespace, opts)
end
@doc """
Updates the given resource of kind `foos` in apiVersion
`example.com/v1alpha1`.
"""
@spec update(resource :: map()) :: Kubereq.response()
def update(resource) do
Kubereq.update(req(), resource)
end
@doc """
Server-Side applies the given resources of kind `foos` in apiVersion
`example.com/v1alpha1`.
In order to understand `field_manager` and `force`, refer to the
[Kubernetes documentation about Field Management](https://kubernetes.io/docs/reference/using-api/server-side-apply/#field-management)
"""
@spec apply(resource :: map()) :: Kubereq.response()
@spec apply(resource :: map(), field_manager :: String.t(), force :: boolean) ::
Kubereq.response()
def apply(resource, field_manager \\ "Elixir", force \\ true) do
Kubereq.apply(req(), resource, field_manager, force)
end
@doc """
Patches the given resource of kind `foos` in apiVersion
`example.com/v1alpha1` with the given `json_patch`.
"""
@spec json_patch(name :: String.t(), namespace :: Kubereq.namespace(), json_patch :: map()) ::
Kubereq.response()
def json_patch(name, namespace, json_patch) do
Kubereq.json_patch(req(), json_patch, namespace, name)
end
@doc """
Patches the given resource of kind `foos` in apiVersion
`example.com/v1alpha1` with the given `merge_patch`.
"""
@spec merge_patch(
name :: String.t(),
namespace :: Kubereq.namespace(),
merge_patch :: String.t()
) :: Kubereq.response()
def merge_patch(name, namespace, merge_patch) do
Kubereq.merge_patch(req(), merge_patch, namespace, name)
end
@doc """
Watches for events on all resources of kind `foos` in apiVersion
`example.com/v1alpha1` in all namespaces.
"""
@spec watch() :: Kubereq.watch_response()
def watch() do
watch(nil, [])
end
@doc """
Watches for events on all resources of kind `foos` in apiVersion
`example.com/v1alpha1` in all namespaces.
### Options
* `:resource_version` - If given, starts to stream from the given `resourceVersion` of the resource list. Otherwise starts streaming from HEAD.
* `:stream_to` - If set to a `pid`, streams events to the given pid. If set to `{pid, ref}`, the messages are in the form `{ref, event}`.
* `:field_selectors` - A list of field selectors. See `Kubereq.Step.FieldSelector` for more infos.
* `:label_selectors` - A list of field selectors. See `Kubereq.Step.LabelSelector` for more infos.
"""
@spec watch(opts :: keyword()) :: Kubereq.watch_response()
def watch(opts) when is_list(opts) do
watch(nil, opts)
end
@doc """
Watches for events on all resources of kind `foos` in apiVersion
`example.com/v1alpha1` in the given `namespace`.
### Options
* `:resource_version` - If given, starts to stream from the given `resourceVersion` of the resource list. Otherwise starts streaming from HEAD.
* `:stream_to` - If set to a `pid`, streams events to the given pid. If set to `{pid, ref}`, the messages are in the form `{ref, event}`.
* `:field_selectors` - A list of field selectors. See `Kubereq.Step.FieldSelector` for more infos.
* `:label_selectors` - A list of field selectors. See `Kubereq.Step.LabelSelector` for more infos.
"""
@spec watch(namespace :: Kubereq.namespace(), opts :: keyword()) :: Kubereq.watch_response()
def watch(namespace, opts \\ []) do
Kubereq.watch(req(), namespace, opts)
end
@doc """
Watches for events on a single resource of kind `foos`
in apiVersion `example.com/v1alpha1` in the given `namespace`.
### Options
* `:resource_version` - If given, starts to stream from the given `resourceVersion` of the resource list. Otherwise starts streaming from HEAD.
* `:stream_to` - If set to a `pid`, streams events to the given pid. If set to `{pid, ref}`, the messages are in the form `{ref, event}`.
* `:field_selectors` - A list of field selectors. See `Kubereq.Step.FieldSelector` for more infos.
* `:label_selectors` - A list of field selectors. See `Kubereq.Step.LabelSelector` for more infos.
"""
@spec watch_single(namespace :: binary(), name :: binary(), opts :: keyword()) ::
Kubereq.watch_response()
def watch_single(namespace, name, opts \\ []) do
Kubereq.watch_single(req(), namespace, name, opts)
end
end