Packages
k8s
1.0.0-rc1
2.8.0
2.7.0
2.6.2
2.6.1
2.6.0
2.5.0
2.4.2
2.4.1
2.4.0
2.3.0
2.2.0
2.1.1
2.1.0
2.0.3
2.0.2
2.0.1
2.0.0
2.0.0-rc.6
2.0.0-rc.5
2.0.0-rc.4
2.0.0-rc.3
2.0.0-rc.2
2.0.0-rc.1
2.0.0-rc.0
1.2.1
1.2.0
1.1.10
1.1.9
1.1.8
1.1.7
1.1.6
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.0
1.0.0-rc1
0.5.2
0.5.1
0.5.0
0.5.0-rc.2
0.5.0-rc.1
0.4.0
0.3.2
0.3.1
0.3.0
0.2.13
0.2.12
0.2.11
0.2.10
0.2.9
0.2.8
0.2.7
retired
0.2.6
0.2.5
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.1.3
Kubernetes API Client for Elixir
Current section
Files
Jump to
Current section
Files
lib/k8s/client/runner/stream/list_request.ex
defmodule K8s.Client.Runner.Stream.ListRequest do
@moduledoc "`:list` `K8s.Operation` encapsulated with pagination and `K8s.Conn`"
@limit 10
@typedoc "opts for `K8s.Client.Runner.Base.run/3`"
@type http_opts_t :: keyword
@typedoc "Pagination continue token"
@type continue_t :: nil | :halt | binary
@typedoc "List operation as a Stream data type"
@type t :: %__MODULE__{
operation: K8s.Operation.t(),
conn: K8s.Conn.t(),
continue: continue_t,
limit: pos_integer,
http_opts: http_opts_t
}
defstruct operation: nil, conn: nil, continue: nil, http_opts: [], limit: @limit
@doc """
Creates a `ListRequest` struct for the next HTTP request from the previous HTTP response
"""
@spec make_next_request(t(), map | :halt) :: t()
def make_next_request(%__MODULE__{} = request, response) do
Map.put(request, :continue, maybe_continue(response))
end
@spec maybe_continue(map | :halt) :: continue_t()
defp maybe_continue(%{"metadata" => %{"continue" => ""}}), do: :halt
defp maybe_continue(%{"metadata" => %{"continue" => cont}}) when is_binary(cont), do: cont
defp maybe_continue(_map), do: :halt
end