View Source UnkeyElixirSdk (UnkeyElixirSdk v0.1.2)
Documentation for UnkeyElixirSdk
.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Creates an API key for your users
Delete an api key for your users
Start the GenServer Returns {:ok, pid}
Updates the configuration of a key
Verify a key from your users. You only need to send the api key from your user.
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Creates an API key for your users
Returns a map with the key
%{"keyId" => "key_cm9vdCBvZiBnb29kXa", "key" => "xyz_AS5HDkXXPot2MMoPHD8jnL"}
examples
Examples
iex> UnkeyElixirSdk.create_key(%{"apiId" => "myapiid"})
%{"keyId" => "key_cm9vdCBvZiBnb29kXa", "key" => "xyz_AS5HDkXXPot2MMoPHD8jnL"}
iex> UnkeyElixirSdk.create_key(%{ "apiId" => "myapiid", "prefix" => "xyz", "byteLength" => 16, "ownerId" => "glamboyosa", "meta" => %{ "hello" => "world" }, "expires" => 1_686_941_966_471, "ratelimit" => %{ "type" => "fast", "limit" => 10, "refillRate" => 1, "refillInterval" => 1000 }, "remaining" => 5 })
%{"keyId" => "key_cm9vdCBvZiBnb29kXa", "key" => "xyz_AS5HDkXXPot2MMoPHD8jnL"}
@spec revoke_key(binary()) :: :ok
Delete an api key for your users
Returns :ok
examples
Examples
iex> UnkeyElixirSdk.revoke_key("key_cm9vdCBvZiBnb29kXa")
:ok
Start the GenServer Returns {:ok, pid}
examples
Examples
iex> UnkeyElixirSdk.start_link(%{token: "yourtoken"})
`{:ok, pid}`
iex> UnkeyElixirSdk.start_link(%{token: "yourtoken", base_url: "theunkeybaseurl"})
{:ok, pid}
Updates the configuration of a key
Takes in a key_id
argument and a map whose members are optional
but must have at most 1 member present.
%{
"name" => "my_new_key",
"ownerId" => "still_glamboyosa",
"meta" => %{
"hello" => "world"
},
"expires" => 1_686_941_966_471,
"ratelimit" => %{
"type" => "fast",
"limit" => 15,
"refillRate" => 2,
"refillInterval" => 500
},
"remaining" => 3
}
Returns :ok
examples
Examples
iex> UnkeyElixirSdk.update_key("key_cm9vdCBvZiBnb29kXa", %{
"name" => "my_new_key",
"ownerId" => "still_glamboyosa",
"meta" => %{
"hello" => "world"
},
"expires" => 1_686_941_966_471,
"ratelimit" => %{
"type" => "fast",
"limit" => 15,
"refillRate" => 2,
"refillInterval" => 500
},
"remaining" => 3
})
:ok
Verify a key from your users. You only need to send the api key from your user.
Returns a map with whether the key is valid or not. Optionally sends ownerId
and meta
examples
Examples
iex> UnkeyElixirSdk.verify_key("xyz_AS5HDkXXPot2MMoPHD8jnL")
`%{"valid" => true,
"ownerId" => "chronark",
"meta" => %{
"hello" => "world"
}}`