Aura.APIKeys (Aura v0.9.3)
View SourceService module for interacting with Hex API keys
๐ Resources
- ๐ Hex
- ๐ Hex API Specifications
- ๐พ hexpm/hex_core
- ๐พ hexpm/hexpm
- ๐ฌ Contact the maintainer (he's happy to help!)
Summary
Functions
Creates a new API key
Deletes all API keys for the authenticated requester
Deletes an API key for the authenticated requester, given a key_name
Grabs API key information associated with a given key_name
Grabs info about the requester's API key(s)
Functions
@spec create_api_key( key_name :: Aura.Common.api_key_name(), username :: Aura.Common.username(), password :: String.t(), allow_write :: boolean(), opts :: list() ) :: {:ok, Aura.Model.HexAPIKey.t()} | {:error, any()}
Creates a new API key
๐ท๏ธ Params
- password :: password for this user
- opts.org ::
Aura.Common.org_name/0
- key_name ::
Aura.Common.api_key_name/0
- username ::
Aura.Common.username/0
- allow_write :: whether the key has
write
permissions on theapi
domain. Default:false
โคต๏ธ Returns
โ On Success
{:ok, %HexAPIKey{...}}
โ On Failure
{:error, (some error)}
๐ฉโ๐ป API Details
Method | Path | Controller | Action |
---|---|---|---|
POST | /keys | KeyController | :create |
POST | /orgs/opts[:org] /keys | KeyController | :create |
Deletes all API keys for the authenticated requester
๐ท๏ธ Params
- opts :: option parameters used to modify requests
โคต๏ธ Returns
โ On Success
:ok
โ On Failure
{:error, (some error)}
๐ป Examples
iex> alias Aura.APIKeys
iex> opts = [repo_url: "http://localhost:4000/api"]
iex> APIKeys.delete_all_api_keys(opts)
:ok
๐ฉโ๐ป API Details
Method | Path | Controller | Action |
---|---|---|---|
DELETE | /keys | KeyController | :delete_all |
DELETE | /orgs/opts[:org] /keys | KeyController | :delete_all |
@spec delete_api_key(key_name :: Aura.Common.api_key_name(), opts :: list()) :: :ok | {:error, any()}
Deletes an API key for the authenticated requester, given a key_name
๐ท๏ธ Params
- opts.org ::
Aura.Common.org_name/0
- key_name ::
Aura.Common.api_key_name/0
โคต๏ธ Returns
โ On Success
:ok
โ On Failure
{:error, (some error)}
๐ป Examples
iex> alias Aura.APIKeys
iex> opts = [repo_url: "http://localhost:4000/api"]
iex> {:ok, [key | _]} = APIKeys.list_api_keys(opts)
iex> APIKeys.delete_api_key(key.name, opts)
:ok
๐ฉโ๐ป API Details
Method | Path | Controller | Action |
---|---|---|---|
DELETE | /keys/:key_name | KeyController | :delete |
DELETE | /orgs/opts[:org] /keys/:key_name | KeyController | :delete |
@spec get_api_key(key_name :: Aura.Common.api_key_name(), opts :: list()) :: {:ok, Aura.Model.HexAPIKey.t()} | {:error, any()}
Grabs API key information associated with a given key_name
๐ท๏ธ Params
- opts.org ::
Aura.Common.org_name/0
- key_name ::
Aura.Common.api_key_name/0
โคต๏ธ Returns
โ On Success
{:ok, %HexAPIKey{...}}
โ On Failure
{:error, (some error)}
๐ป Examples
iex> alias Aura.APIKeys
iex> opts = [repo_url: "http://localhost:4000/api"]
iex> {:ok, keys} = APIKeys.list_api_keys(opts)
iex> keys |> Enum.map(fn key -> {:ok, _k} = APIKeys.get_api_key(key.name, opts) end)
๐ฉโ๐ป API Details
Method | Path | Controller | Action |
---|---|---|---|
GET | /keys/:key_name | KeyController | :show |
GET | /orgs/opts[:org] /keys/:key_name | KeyController | :show |
@spec list_api_keys(opts :: list()) :: {:ok, [Aura.Model.HexAPIKey.t()]} | {:error, any()}
Grabs info about the requester's API key(s)
๐ท๏ธ Params
- opts.org ::
Aura.Common.org_name/0
โคต๏ธ Returns
โ On Success
{:ok, [%HexAPIKey{...}]}
โ On Failure
{:error, (some error)}
๐ป Examples
iex> alias Aura.APIKeys
iex> repo_url = "http://localhost:4000/api"
iex> {:ok, keys} = APIKeys.list_api_keys(repo_url: repo_url)
iex> Enum.empty?(keys)
false
๐ฉโ๐ป API Details
Method | Path | Controller | Action |
---|---|---|---|
GET | /keys | KeyController | :index |
GET | /orgs/opts[:org] /keys | KeyController | :index |