Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

60 lignes
2.2 KiB

  1. %% Vendored from hex_core v0.5.0, do not edit manually
  2. -module(r3_hex_api_release).
  3. -export([
  4. delete/3,
  5. get/3,
  6. publish/2,
  7. retire/4,
  8. unretire/3
  9. ]).
  10. %% @doc
  11. %% Gets package release.
  12. %%
  13. %% Examples:
  14. %%
  15. %% ```
  16. %% > r3_hex_api:get_release(<<"package">>, <<"1.0.0">>, r3_hex_core:default_config()).
  17. %% {ok, {200, ..., #{
  18. %% <<"version">> => <<"1.0.0">>,
  19. %% <<"meta">> => #{
  20. %% <<"description">> => ...,
  21. %% <<"licenses">> => ...,
  22. %% <<"links">> => ...,
  23. %% <<"maintainers">> => ...
  24. %% },
  25. %% ...}}}
  26. %% '''
  27. %% @end
  28. get(Config, Name, Version) when is_binary(Name) and is_binary(Version) and is_map(Config) ->
  29. Path = r3_hex_api:build_repository_path(Config, ["packages", Name, "releases", Version]),
  30. r3_hex_api:get(Config, Path).
  31. publish(Config, Tarball) when is_binary(Tarball) and is_map(Config) ->
  32. Path = r3_hex_api:build_repository_path(Config, ["publish"]),
  33. TarballContentType = "application/octet-stream",
  34. Config2 = put_header(<<"content-length">>, integer_to_binary(byte_size(Tarball)), Config),
  35. Body = {TarballContentType, Tarball},
  36. r3_hex_api:post(Config2, Path, Body).
  37. delete(Config, Name, Version) when is_binary(Name) and is_binary(Version) and is_map(Config) ->
  38. Path = r3_hex_api:build_repository_path(Config, ["packages", Name, "releases", Version]),
  39. r3_hex_api:delete(Config, Path).
  40. retire(Config, Name, Version, Params) when is_binary(Name) and is_binary(Version) and is_map(Config) ->
  41. Path = r3_hex_api:build_repository_path(Config, ["packages", Name, "releases", Version, "retire"]),
  42. r3_hex_api:post(Config, Path, Params).
  43. unretire(Config, Name, Version) when is_binary(Name) and is_binary(Version) and is_map(Config) ->
  44. Path = r3_hex_api:build_repository_path(Config, ["packages", Name, "releases", Version, "retire"]),
  45. r3_hex_api:delete(Config, Path).
  46. %%====================================================================
  47. %% Internal functions
  48. %%====================================================================
  49. put_header(Name, Value, Config) ->
  50. Headers = maps:get(http_headers, Config, #{}),
  51. Headers2 = maps:put(Name, Value, Headers),
  52. maps:put(http_headers, Headers2, Config).