Current section
Files
Jump to
Current section
Files
lib/hexoku/api/account/keys.ex
defmodule Hexoku.API.Account.Keys do
alias Hexoku.Request
@moduledoc """
Keys represent public SSH keys associated with an account and are used to
authorize accounts as they are performing git operations.
## Attributes
<dl>
<dt>id</dt> <dd>unique identifier of item generated by Heroku</dd>
<dt>comment</dt> <dd>comment on the key</dd>
<dt>email</dt> <dd><b>deprecated.</b> Please refer to ‘comment’ instead</dd>
<dt>fingerprint</dt> <dd>a unique identifying string based on contents</dd>
<dt>public_key</dt> <dd>full public_key as uploaded</dd>
<dt>created_at</dt> <dd>when item was created</dd>
<dt>updated_at</dt> <dd>when item was last modified</dd>
</dl>
For more info read the [Heroku API Reference](https://devcenter.heroku.com/articles/platform-api-reference#key)
"""
@doc """
List existing keys.
## Examples
client |> Hexoku.API.Account.Keys.list()
"""
@spec list(Hexoku.Client.t) :: [Map.t]
def list(client), do: Request.get(client, "/account/keys")
@doc """
Info for existing key.
## Examples
client |> Hexoku.API.Account.Keys.info("01234567-89ab-cdef-0123-456789abcdef")
"""
@spec info(Hexoku.Client.t, binary) :: Map.t
def info(client, key_id_or_fingerprint), do: Request.get(client, "/account/keys/#{key_id_or_fingerprint}")
@doc """
Create a new key.
## Examples
client |> Hexoku.API.Account.Keys.create("ssh-rsa AAAAB3NzaC1ycVc/../839Uv username@example.com")
"""
@spec create(Hexoku.Client.t, binary) :: Map.t
def create(client, public_key), do: Request.post(client, "/account/keys", %{public_key: public_key})
@doc """
Delete an existing key.
## Examples
client |> Hexoku.API.Account.Keys.delete("01234567-89ab-cdef-0123-456789abcdef")
"""
@spec delete(Hexoku.Client.t, binary) :: Map.t
def delete(client, key_id_or_fingerprint), do: Request.delete(client, "/account/keys/#{key_id_or_fingerprint}")
end