View Source Bonny.API.ResourceEndpoint (bonny v1.4.0)
Defines the API Endpoint for a Kubernetes resource.
The struct contains the fields group
, resource_type
, scope
and version
.
New definitions can be created directly or using the new!/1
function.
Summary
Types
A Resource API Definition. Also see Kubernetes API terminology.
Functions
Creates a new %Bonny.API.ResourceEndpoint{} struct from the given values. :scope
is
optional and defaults to :Namespaced
.
Creates a new %Bonny.API.ResourceEndpoint{} struct from apiVersion
and kind
.
The scope can be passed as a third optional parameter.
Gets apiVersion of the actual resources.
Types
@type t() :: %Bonny.API.ResourceEndpoint{ group: binary() | nil, resource_type: binary(), scope: :Namespaced | :Cluster, version: binary() }
A Resource API Definition. Also see Kubernetes API terminology.
group
: The API group used for REST API: /apis/<group>/<version>, e.g. "apps" or "example.com"resource_type
: The plural form of the resource namescope
::Namespaced
or:Cluster
- defaults to:Namespaced
version
: The API version used for REST API: /apis/<group>/<version>, e.g. "v1" or "v1alpha1"
Functions
Creates a new %Bonny.API.ResourceEndpoint{} struct from the given values. :scope
is
optional and defaults to :Namespaced
.
Creates a new %Bonny.API.ResourceEndpoint{} struct from apiVersion
and kind
.
The scope can be passed as a third optional parameter.
Examples
iex> Bonny.API.ResourceEndpoint.new!("apps/v1", "Deployment")
%Bonny.API.ResourceEndpoint{group: "apps", resource_type: "deployments", scope: :Namespaced, version: "v1"}
iex> Bonny.API.ResourceEndpoint.new!("v1", "Pod")
%Bonny.API.ResourceEndpoint{group: nil, resource_type: "pods", scope: :Namespaced, version: "v1"}
iex> Bonny.API.ResourceEndpoint.new!("rbac.authorization.k8s.io/v1", "ClusterRoleBinding", :Cluster)
%Bonny.API.ResourceEndpoint{group: "rbac.authorization.k8s.io", resource_type: "clusterrolebindings", scope: :Cluster, version: "v1"}
iex> Bonny.API.ResourceEndpoint.new!("foo/bar/v1", "ClusterRoleBinding", :Cluster)
** (ArgumentError) The api_version "foo/bar/v1" cannot be parsed. It contains more than one slash (/).
Gets apiVersion of the actual resources.
Examples
Returns apiVersion for an operator
iex> Bonny.API.ResourceEndpoint.resource_api_version(%Bonny.API.ResourceEndpoint{group: "hello.example.com", version: "v1", scope: :namespaced, resource_type: "foos"})
"hello.example.com/v1"
Returns apiVersion for apps
resources
iex> Bonny.API.ResourceEndpoint.resource_api_version(%Bonny.API.ResourceEndpoint{group: "apps", version: "v1", scope: :namespaced, resource_type: "foos"})
"apps/v1"
Returns apiVersion for core
resources
iex> Bonny.API.ResourceEndpoint.resource_api_version(%Bonny.API.ResourceEndpoint{group: "", version: "v1", scope: :namespaced, resource_type: "foos"})
"v1"
iex> Bonny.API.ResourceEndpoint.resource_api_version(%Bonny.API.ResourceEndpoint{group: nil, version: "v1", scope: :namespaced, resource_type: "foos"})
"v1"