summaryrefslogtreecommitdiff
path: root/src/r3_hex_api_key.erl
blob: 68c0b13b3fe95122d56c947f6a3a63d547c6d457 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
%% Vendored from hex_core v0.5.0, do not edit manually

-module(r3_hex_api_key).
-export([
    list/1,
    get/2,
    add/3,
    delete/2,
    delete_all/1
]).

list(Config) when is_map(Config) ->
    Path = r3_hex_api:build_organization_path(Config, ["keys"]),
    r3_hex_api:get(Config, Path).

get(Config, Name) when is_map(Config) ->
    Path = r3_hex_api:build_organization_path(Config, ["keys", Name]),
    r3_hex_api:get(Config, Path).

add(Config, Name, Permissions) when is_map(Config) ->
    Path = r3_hex_api:build_organization_path(Config, ["keys"]),
    Params = #{<<"name">> => Name, <<"permissions">> => Permissions},
    r3_hex_api:post(Config, Path, Params).

delete(Config, Name) when is_map(Config) ->
    Path = r3_hex_api:build_organization_path(Config, ["keys", Name]),
    r3_hex_api:delete(Config, Path).

delete_all(Config) when is_map(Config) ->
    Path = r3_hex_api:build_organization_path(Config, ["keys"]),
    r3_hex_api:delete(Config, Path).