# `Bonny.API.CRD`
[🔗](https://github.com/coryodaniel/bonny/blob/v1.5.0/lib/bonny/api/crd.ex#L1)

A Custom Resource Definition.

The `%Bonny.API.CRD{}` struct contains the fields `group`, `resource_type`,
`scope` and `version`. New definitions can be created directly, using the
`new!/1` function.

# `names_t`

```elixir
@type names_t() :: %{
  :singular =&gt; binary(),
  :plural =&gt; binary(),
  :kind =&gt; binary(),
  optional(:shortNames) =&gt; [binary()]
}
```

Defines the names section of the CRD.

- `plural`: name to be used in the URL: /apis/<group>/<version>/<plural> - e.g. crontabs
- `singular`: singular name to be used as an alias on the CLI and for display - e.g. crontab
- `kind`: is normally the CamelCased singular type. Your resource manifests use this. - e.g. CronTab
- `shortnames`: allow shorter string to match your resource on the CLI - e.g. [ct]

# `t`

```elixir
@type t() :: %Bonny.API.CRD{
  group: binary(),
  names: names_t(),
  scope: :Namespaced | :Cluster,
  versions: [module()]
}
```

A Custom Resource Definition.

- `scope`: either Namespaced or Cluster
- `group`: group name to use for REST API: /apis/<group>/<version>, defaults to the group in config.exs
- `names`: see `names_t`
- `versions`: list of API Version modules for this Resource, defaults to the versions in config.exs

# `fetch`

# `get`

# `get_and_update`

# `kind_to_names`

```elixir
@spec kind_to_names(binary(), [binary()]) :: names_t()
```

Build a map of names form the given kind.

### Examples

    iex> Bonny.API.CRD.kind_to_names("SomeKind")
    %{singular: "somekind", plural: "somekinds", kind: "SomeKind", shortNames: []}

  The `:inflex` library is used to generate the plural form.

    iex> Bonny.API.CRD.kind_to_names("Hero")
    %{singular: "hero", plural: "heroes", kind: "Hero", shortNames: []}

  Accepts an optional list of abbreviations as second argument.

    iex> Bonny.API.CRD.kind_to_names("SomeKind", ["sk", "some"])
    %{singular: "somekind", plural: "somekinds", kind: "SomeKind", shortNames: ["sk", "some"]}

# `new!`

```elixir
@spec new!(keyword()) :: t()
```

Creates a new %Bonny.API.CRD{} struct from the given values. `:scope` is
optional and defaults to `:Namespaced`.

# `to_manifest`

```elixir
@spec to_manifest(t()) :: map()
```

Converts the internally used structure to a map representing a kubernetes CRD manifest.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
