k8s_client v0.1.3 K8s.Client.Router

Encapsulates a route map built from kubernetes' swagger operations.

Link to this section Summary

Functions

Creates a route map from a swagger spec

Generates the path for an action

Generates the path for an action

Start a new router. Returns the name of the Router. The default name is :default

Link to this section Functions

Link to this function

build(spec_path_or_spec_map)
build(binary() | map()) :: map()

Creates a route map from a swagger spec.

Examples

iex> K8s.Client.Router.build("priv/custom/simple.json")
%{
  "delete_collection/apps/v1/deployment/namespace" => "/apis/apps/v1/namespaces/{namespace}/deployments",
  "list/apps/v1/deployment/namespace" => "/apis/apps/v1/namespaces/{namespace}/deployments",
  "post/apps/v1/deployment/namespace" => "/apis/apps/v1/namespaces/{namespace}/deployments",
  "delete/apps/v1/deployment/name/namespace" => "/apis/apps/v1/namespaces/{namespace}/deployments/{name}",
  "get/apps/v1/deployment/name/namespace" => "/apis/apps/v1/namespaces/{namespace}/deployments/{name}",
  "patch/apps/v1/deployment/name/namespace" => "/apis/apps/v1/namespaces/{namespace}/deployments/{name}",
  "put/apps/v1/deployment/name/namespace" => "/apis/apps/v1/namespaces/{namespace}/deployments/{name}"
}
Link to this function

path_for(action, map)
path_for(binary(), map()) :: binary() | {:error, binary()}

Generates the path for an action.

Examples

iex> deploy = %{"apiVersion" => "apps/v1", "kind" => "Deployment", "metadata" => %{"namespace" => "default", "name" => "nginx"}}
...> K8s.Client.Router.path_for(:put, deploy)
"/apis/apps/v1/namespaces/default/deployments/nginx"
Link to this function

path_for(action, api_version, kind, opts \\ [])
path_for(binary(), binary(), binary(), keyword(atom())) ::
  binary() | {:error, binary()}

Generates the path for an action.

Examples

iex> K8s.Client.Router.path_for("post", "apps/v1", :deployment, namespace: "default")
"/apis/apps/v1/namespaces/default/deployments"
Link to this function

start(spec_path_or_spec_map, name \\ :default)
start(binary() | map(), atom() | nil) :: atom()

Start a new router. Returns the name of the Router. The default name is :default

Examples

Starting a K8s 1.13 router:

router_name = K8s.Client.Router.start("priv/swagger/1.13.json")

Starting a named K8s 1.10 router:

router_name = K8s.Client.Router.start("priv/swagger/1.10.json", :legacy)