annon_ktl v0.2.7 Annon.Controller.Context

This module provides API to manage contexts.

By default, context information is stored in ~/.config/annonktl/context.json, this this path can be overridden by setting ANNONKTL_CONTEXT environment variable.

Link to this section Summary

Functions

Create or update context and set it as current

Fetch context by name

Fetch current context

Remove context by name

Set current context

Link to this section Functions

Link to this function apply_context(name, management_endpoint)

Create or update context and set it as current.

Examples

iex> apply_context("my_context", "http://example.com/")
:ok
Link to this function fetch_context(name)

Fetch context by name.

Examples

iex> fetch_context("my_context")
{:ok, %{"name" => "my_context", "management_endpoint" => "http://example.com/"}}

iex> fetch_context("not_exists")
:error
Link to this function get_current_context()

Fetch current context.

Examples

iex> get_current_context()
{:ok, %{"name" => "my_context", "management_endpoint" => "http://example.com/"}}

iex> get_current_context()
:error
Link to this function remove_context(name)

Remove context by name.

Examples

iex> remove_context("my_context")
:ok
Link to this function set_current_context(name)

Set current context.

Examples

iex> set_current_context("my_context")
:ok

iex> set_current_context("not_exists")
:error