Modules

hex_api_key hex_api_package hex_api_package_owner hex_api_release hex_api_user hex_core hex_http hex_pb_names hex_pb_package hex_pb_signed hex_pb_versions hex_registry hex_repo hex_tarball

Module hex_api_key

Data Types

api_permission()


api_permission() = #{domain => api, resource => read | write}

permission()


permission() = api_permission() | repo_permission() | repos_permission()

repo_permission()


repo_permission() = #{domain => repository, resource => binary()}

repos_permission()


repos_permission() = #{domain => repositories}

Function Index

add/3 Adds a new API or repository key.
delete/2 Deletes an API or repository key.
delete_all/1 Deletes all API and repository keys associated with the account.
get/2 Gets an API or repository key by name.
list/1 Lists the user's or organization's API and repository keys.

Function Details

add/3


add(Config::hex_core:config(), Name::binary(), Permissions::[permission()]) -> hex_api:response()

Adds a new API or repository key.

Examples:

  > hex_api_key:add(hex_core:default_config(), <<"test">>, [...]).
  {ok, {200, ..., #{
      <<"authing_key">> => true,
      <<"inserted_at">> => <<"2019-02-27T11:15:32Z">>,
      <<"last_use">> =>
          #{<<"ip">> => <<"1.2.3.4">>,
            <<"used_at">> => <<"2019-02-27T14:38:54Z">>,
            <<"user_agent">> => <<"hex_core/0.5.0 (httpc) (OTP/21) (erts/10.2)">>},
      <<"name">> => <<"hex_core">>,
      <<"permissions">> => [#{<<"domain">> => <<"api">>,<<"resource">> => <<"read">>}],
      <<"revoked_at">> => nil,
      <<"updated_at">> => <<"2019-02-27T14:38:54Z">>,
      <<"url">> => <<"https://hex.pm/api/keys/test">>},
      }}}

delete/2


delete(Config::hex_core:config(), Name::binary()) -> hex_api:response()

Deletes an API or repository key.

Examples:

  > hex_api_key:delete(hex_core:default_config(), <<"test">>).
  {ok, {200, ..., #{
      <<"authing_key">> => true,
      <<"inserted_at">> => <<"2019-02-27T11:15:32Z">>,
      <<"last_use">> =>
          #{<<"ip">> => <<"1.2.3.4">>,
            <<"used_at">> => <<"2019-02-27T14:38:54Z">>,
            <<"user_agent">> => <<"hex_core/0.5.0 (httpc) (OTP/21) (erts/10.2)">>},
      <<"name">> => <<"hex_core">>,
      <<"permissions">> => [#{<<"domain">> => <<"api">>,<<"resource">> => <<"read">>}],
      <<"revoked_at">> => nil,
      <<"updated_at">> => <<"2019-02-27T14:38:54Z">>,
      <<"url">> => <<"https://hex.pm/api/keys/test">>},
      }}}

delete_all/1


delete_all(Config::hex_core:config()) -> hex_api:response()

Deletes all API and repository keys associated with the account.

Examples:

  > hex_api_key:delete_all(hex_core:default_config()).
  {ok, {200, ..., [#{
      <<"authing_key">> => true,
      <<"inserted_at">> => <<"2019-02-27T11:15:32Z">>,
      <<"last_use">> =>
          #{<<"ip">> => <<"1.2.3.4">>,
            <<"used_at">> => <<"2019-02-27T14:38:54Z">>,
            <<"user_agent">> => <<"hex_core/0.5.0 (httpc) (OTP/21) (erts/10.2)">>},
      <<"name">> => <<"hex_core">>,
      <<"permissions">> => [#{<<"domain">> => <<"api">>,<<"resource">> => <<"read">>}],
      <<"revoked_at">> => nil,
      <<"updated_at">> => <<"2019-02-27T14:38:54Z">>,
      <<"url">> => <<"https://hex.pm/api/keys/test">>},
      }]}}

get/2


get(Config::hex_core:config(), Name::binary()) -> hex_api:response()

Gets an API or repository key by name.

Examples:

  > hex_api_key:get(hex_core:default_config(), <<"test">>).
  {ok, {200, ..., #{
      <<"authing_key">> => true,
      <<"inserted_at">> => <<"2019-02-27T11:15:32Z">>,
      <<"last_use">> =>
          #{<<"ip">> => <<"1.2.3.4">>,
            <<"used_at">> => <<"2019-02-27T14:38:54Z">>,
            <<"user_agent">> => <<"hex_core/0.5.0 (httpc) (OTP/21) (erts/10.2)">>},
      <<"name">> => <<"hex_core">>,
      <<"permissions">> => [#{<<"domain">> => <<"api">>,<<"resource">> => <<"read">>}],
      <<"revoked_at">> => nil,
      <<"updated_at">> => <<"2019-02-27T14:38:54Z">>,
      <<"url">> => <<"https://hex.pm/api/keys/test">>},
      }}}

list/1


list(Config::hex_core:config()) -> hex_api:response()

Lists the user's or organization's API and repository keys.

Examples:

  > hex_api_key:list(hex_core:default_config()).
  {ok, {200, ..., [#{
      <<"authing_key">> => true,
      <<"inserted_at">> => <<"2019-02-27T11:15:32Z">>,
      <<"last_use">> =>
          #{<<"ip">> => <<"1.2.3.4">>,
            <<"used_at">> => <<"2019-02-27T14:38:54Z">>,
            <<"user_agent">> => <<"hex_core/0.5.0 (httpc) (OTP/21) (erts/10.2)">>},
      <<"name">> => <<"hex_core">>,
      <<"permissions">> => [#{<<"domain">> => <<"api">>,<<"resource">> => <<"read">>}],
      <<"revoked_at">> => nil,
      <<"updated_at">> => <<"2019-02-27T14:38:54Z">>,
      <<"url">> => <<"https://hex.pm/api/keys/test">>},
      }]}}