@@ -4,15 +4,17 @@ defmodule Hex.API.Key do
44 alias Hex.API.Client
55
66 def new ( name , permissions , auth ) do
7- config = Client . config ( auth )
7+ Mix.Tasks.Hex . with_otp_retry ( auth , fn auth_with_otp ->
8+ config = Client . config ( auth_with_otp )
89
9- # Convert permissions to binary map format expected by hex_core
10- permissions =
11- Enum . map ( permissions , fn perm ->
12- Map . new ( perm , fn { k , v } -> { to_string ( k ) , to_string ( v ) } end )
13- end )
10+ # Convert permissions to binary map format expected by hex_core
11+ permissions =
12+ Enum . map ( permissions , fn perm ->
13+ Map . new ( perm , fn { k , v } -> { to_string ( k ) , to_string ( v ) } end )
14+ end )
1415
15- :mix_hex_api_key . add ( config , to_string ( name ) , permissions )
16+ :mix_hex_api_key . add ( config , to_string ( name ) , permissions )
17+ end )
1618 end
1719
1820 def get ( auth ) do
@@ -21,13 +23,17 @@ defmodule Hex.API.Key do
2123 end
2224
2325 def delete ( name , auth ) do
24- config = Client . config ( auth )
25- :mix_hex_api_key . delete ( config , to_string ( name ) )
26+ Mix.Tasks.Hex . with_otp_retry ( auth , fn auth_with_otp ->
27+ config = Client . config ( auth_with_otp )
28+ :mix_hex_api_key . delete ( config , to_string ( name ) )
29+ end )
2630 end
2731
2832 def delete_all ( auth ) do
29- config = Client . config ( auth )
30- :mix_hex_api_key . delete_all ( config )
33+ Mix.Tasks.Hex . with_otp_retry ( auth , fn auth_with_otp ->
34+ config = Client . config ( auth_with_otp )
35+ :mix_hex_api_key . delete_all ( config )
36+ end )
3137 end
3238
3339 defmodule Organization do
@@ -36,15 +42,17 @@ defmodule Hex.API.Key do
3642 alias Hex.API.Client
3743
3844 def new ( organization , name , permissions , auth ) do
39- config = Client . config ( Keyword . put ( auth , :api_organization , to_string ( organization ) ) )
45+ Mix.Tasks.Hex . with_otp_retry ( auth , fn auth_with_otp ->
46+ config = Client . config ( Keyword . put ( auth_with_otp , :api_organization , to_string ( organization ) ) )
4047
41- # Convert permissions to binary map format expected by hex_core
42- permissions =
43- Enum . map ( permissions , fn perm ->
44- Map . new ( perm , fn { k , v } -> { to_string ( k ) , to_string ( v ) } end )
45- end )
48+ # Convert permissions to binary map format expected by hex_core
49+ permissions =
50+ Enum . map ( permissions , fn perm ->
51+ Map . new ( perm , fn { k , v } -> { to_string ( k ) , to_string ( v ) } end )
52+ end )
4653
47- :mix_hex_api_key . add ( config , to_string ( name ) , permissions )
54+ :mix_hex_api_key . add ( config , to_string ( name ) , permissions )
55+ end )
4856 end
4957
5058 def get ( organization , auth ) do
@@ -53,13 +61,17 @@ defmodule Hex.API.Key do
5361 end
5462
5563 def delete ( organization , name , auth ) do
56- config = Client . config ( Keyword . put ( auth , :api_organization , to_string ( organization ) ) )
57- :mix_hex_api_key . delete ( config , to_string ( name ) )
64+ Mix.Tasks.Hex . with_otp_retry ( auth , fn auth_with_otp ->
65+ config = Client . config ( Keyword . put ( auth_with_otp , :api_organization , to_string ( organization ) ) )
66+ :mix_hex_api_key . delete ( config , to_string ( name ) )
67+ end )
5868 end
5969
6070 def delete_all ( organization , auth ) do
61- config = Client . config ( Keyword . put ( auth , :api_organization , to_string ( organization ) ) )
62- :mix_hex_api_key . delete_all ( config )
71+ Mix.Tasks.Hex . with_otp_retry ( auth , fn auth_with_otp ->
72+ config = Client . config ( Keyword . put ( auth_with_otp , :api_organization , to_string ( organization ) ) )
73+ :mix_hex_api_key . delete_all ( config )
74+ end )
6375 end
6476 end
6577end
0 commit comments