1 |
|
-module(mongoose_graphql_domain_admin_mutation). |
2 |
|
-behaviour(mongoose_graphql). |
3 |
|
|
4 |
|
-export([execute/4]). |
5 |
|
|
6 |
|
-ignore_xref([execute/4]). |
7 |
|
|
8 |
|
-import(mongoose_graphql_helper, [format_result/2]). |
9 |
|
|
10 |
|
-include("../mongoose_graphql_types.hrl"). |
11 |
|
|
12 |
|
execute(_Ctx, admin, <<"addDomain">>, #{<<"domain">> := Domain, <<"hostType">> := HostType}) -> |
13 |
10 |
format_result(mongoose_domain_api:insert_domain(Domain, HostType), |
14 |
|
#{domain => Domain, hostType => HostType}); |
15 |
|
execute(_Ctx, admin, <<"removeDomain">>, #{<<"domain">> := Domain, <<"hostType">> := HostType}) -> |
16 |
8 |
format_result(mongoose_domain_api:delete_domain(Domain, HostType), |
17 |
|
#{domain => Domain, hostType => HostType}); |
18 |
|
execute(_Ctx, admin, <<"requestRemoveDomain">>, #{<<"domain">> := Domain, |
19 |
|
<<"hostType">> := HostType}) -> |
20 |
4 |
format_result(mongoose_domain_api:request_delete_domain(Domain, HostType), |
21 |
|
#{domain => Domain, hostType => HostType}); |
22 |
|
execute(_Ctx, admin, <<"enableDomain">>, #{<<"domain">> := Domain}) -> |
23 |
6 |
format_result(mongoose_domain_api:enable_domain(Domain), #{domain => Domain}); |
24 |
|
execute(_Ctx, admin, <<"disableDomain">>, #{<<"domain">> := Domain}) -> |
25 |
6 |
format_result(mongoose_domain_api:disable_domain(Domain), #{domain => Domain}); |
26 |
|
execute(_Ctx, admin, <<"setDomainPassword">>, |
27 |
|
#{<<"domain">> := Domain, <<"password">> := Password}) -> |
28 |
5 |
format_result(mongoose_domain_api:set_domain_password(Domain, Password), #{domain => Domain}); |
29 |
|
execute(_Ctx, admin, <<"deleteDomainPassword">>, #{<<"domain">> := Domain}) -> |
30 |
6 |
format_result(mongoose_domain_api:delete_domain_password(Domain), #{domain => Domain}). |