| 1 | package WWW::MailboxOrg::API::Domain; | ||||||||||
| 2 | |||||||||||
| 3 | # ABSTRACT: Domain management API | ||||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use MooX::Singleton; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Params::ValidationCompiler qw(validation_for); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use Types::Standard qw(Str Bool HashRef); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use WWW::MailboxOrg::Types qw(DomainName); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 1 | our $VERSION = '0.001'; | |||||||||
| 13 | |||||||||||
| 14 | 1 | has client => ( | |||||||||
| 15 | is => 'ro', | ||||||||||
| 16 | required => 1, | ||||||||||
| 17 | weak_ref => 1, | ||||||||||
| 18 | ); | ||||||||||
| 19 | |||||||||||
| 20 | sub _rpc { | ||||||||||
| 21 | 0 | ▶ | my ($self, $method, @params) = @_; | ||||||||
|
Subroutine
_rpc: not called CC=2 SCAR=17.9
| |||||||||||
| 22 | 0 | ▶ | my $client = $self->client or croak "No client set"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 0 | return $client->call($method, @params); | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 1 | my %validators = ( | |||||||||
| 27 | add => validation_for( | ||||||||||
| 28 | params => { | ||||||||||
| 29 | account => { type => Str, optional => 0 }, | ||||||||||
| 30 | domain => { type => DomainName, optional => 0 }, | ||||||||||
| 31 | password => { type => Str, optional => 0 }, | ||||||||||
| 32 | context_id => { type => Str, optional => 1 }, | ||||||||||
| 33 | create_new_context_id => { type => Bool, optional => 1 }, | ||||||||||
| 34 | memo => { type => Str, optional => 1 }, | ||||||||||
| 35 | }, | ||||||||||
| 36 | ), | ||||||||||
| 37 | del => validation_for( | ||||||||||
| 38 | params => { | ||||||||||
| 39 | account => { type => Str, optional => 0 }, | ||||||||||
| 40 | domain => { type => DomainName, optional => 0 }, | ||||||||||
| 41 | }, | ||||||||||
| 42 | ), | ||||||||||
| 43 | get => validation_for( | ||||||||||
| 44 | params => { | ||||||||||
| 45 | domain => { type => DomainName, optional => 0 }, | ||||||||||
| 46 | }, | ||||||||||
| 47 | ), | ||||||||||
| 48 | list => validation_for( | ||||||||||
| 49 | params => { | ||||||||||
| 50 | account => { type => Str, optional => 1 }, | ||||||||||
| 51 | filter => { type => Str, optional => 1 }, | ||||||||||
| 52 | }, | ||||||||||
| 53 | ), | ||||||||||
| 54 | set => validation_for( | ||||||||||
| 55 | params => { | ||||||||||
| 56 | domain => { type => DomainName, optional => 0 }, | ||||||||||
| 57 | password => { type => Str, optional => 1 }, | ||||||||||
| 58 | context_id => { type => Str, optional => 1 }, | ||||||||||
| 59 | create_new_context_id => { type => Bool, optional => 1 }, | ||||||||||
| 60 | memo => { type => Str, optional => 1 }, | ||||||||||
| 61 | }, | ||||||||||
| 62 | ), | ||||||||||
| 63 | ); | ||||||||||
| 64 | |||||||||||
| 65 | sub add { | ||||||||||
| 66 | 0 | ▶ | my ($self, %params) = @_; | ||||||||
|
Subroutine
add: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 67 | 0 | my $v = $validators{'add'}; | |||||||||
| 68 | 0 | ▶ | %params = $v->(%params) if $v; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | 0 | return $self->_rpc('domain.add', \%params); | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | sub del { | ||||||||||
| 73 | 0 | ▶ | my ($self, %params) = @_; | ||||||||
|
Subroutine
del: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 74 | 0 | my $v = $validators{'del'}; | |||||||||
| 75 | 0 | ▶ | %params = $v->(%params) if $v; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 76 | 0 | return $self->_rpc('domain.del', \%params); | |||||||||
| 77 | } | ||||||||||
| 78 | |||||||||||
| 79 | sub get { | ||||||||||
| 80 | 0 | ▶ | my ($self, %params) = @_; | ||||||||
|
Subroutine
get: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 81 | 0 | my $v = $validators{'get'}; | |||||||||
| 82 | 0 | ▶ | %params = $v->(%params) if $v; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 83 | 0 | return $self->_rpc('domain.get', \%params); | |||||||||
| 84 | } | ||||||||||
| 85 | |||||||||||
| 86 | sub list { | ||||||||||
| 87 | 0 | ▶ | my ($self, %params) = @_; | ||||||||
|
Subroutine
list: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 88 | 0 | my $v = $validators{'list'}; | |||||||||
| 89 | 0 | ▶ | %params = $v->(%params) if $v; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 90 | 0 | return $self->_rpc('domain.list', \%params); | |||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | sub set { | ||||||||||
| 94 | 0 | ▶ | my ($self, %params) = @_; | ||||||||
|
Subroutine
set: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 95 | 0 | my $v = $validators{'set'}; | |||||||||
| 96 | 0 | ▶ | %params = $v->(%params) if $v; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 97 | 0 | return $self->_rpc('domain.set', \%params); | |||||||||
| 98 | } | ||||||||||
| 99 | |||||||||||
| 100 | 1 | 1; | |||||||||
| 101 | |||||||||||
| 102 | __END__ | ||||||||||
| 103 | |||||||||||
| 104 | =pod | ||||||||||
| 105 | |||||||||||
| 106 | =encoding UTF-8 | ||||||||||
| 107 | |||||||||||
| 108 | =head1 NAME | ||||||||||
| 109 | |||||||||||
| 110 | WWW::MailboxOrg::API::Domain - Domain management API | ||||||||||
| 111 | |||||||||||
| 112 | =head1 VERSION | ||||||||||
| 113 | |||||||||||
| 114 | version 0.001 | ||||||||||
| 115 | |||||||||||
| 116 | =head1 NAME | ||||||||||
| 117 | |||||||||||
| 118 | WWW::MailboxOrg::API::Domain - Domain management API | ||||||||||
| 119 | |||||||||||
| 120 | =head2 add | ||||||||||
| 121 | |||||||||||
| 122 | $api->domain->add( | ||||||||||
| 123 | account => 'admin@example.com', | ||||||||||
| 124 | domain => 'example.com', | ||||||||||
| 125 | password => 'secret123', | ||||||||||
| 126 | context_id => 'optional-context-id', | ||||||||||
| 127 | create_new_context_id => 1, | ||||||||||
| 128 | memo => 'Optional note', | ||||||||||
| 129 | ); | ||||||||||
| 130 | |||||||||||
| 131 | Add a new domain. Required: C<account>, C<domain>, C<password>. | ||||||||||
| 132 | |||||||||||
| 133 | =head2 del | ||||||||||
| 134 | |||||||||||
| 135 | $api->domain->del( | ||||||||||
| 136 | account => 'admin@example.com', | ||||||||||
| 137 | domain => 'example.com', | ||||||||||
| 138 | ); | ||||||||||
| 139 | |||||||||||
| 140 | Delete a domain. | ||||||||||
| 141 | |||||||||||
| 142 | =head2 get | ||||||||||
| 143 | |||||||||||
| 144 | $api->domain->get(domain => 'example.com'); | ||||||||||
| 145 | |||||||||||
| 146 | Get domain details. | ||||||||||
| 147 | |||||||||||
| 148 | =head2 list | ||||||||||
| 149 | |||||||||||
| 150 | $api->domain->list; | ||||||||||
| 151 | $api->domain->list(account => 'admin@example.com'); | ||||||||||
| 152 | |||||||||||
| 153 | List domains. Optional C<account> or C<filter>. | ||||||||||
| 154 | |||||||||||
| 155 | =head2 set | ||||||||||
| 156 | |||||||||||
| 157 | $api->domain->set( | ||||||||||
| 158 | domain => 'example.com', | ||||||||||
| 159 | password => 'newsecret', | ||||||||||
| 160 | context_id => 'new-context-id', | ||||||||||
| 161 | create_new_context_id => 1, | ||||||||||
| 162 | memo => 'Updated note', | ||||||||||
| 163 | ); | ||||||||||
| 164 | |||||||||||
| 165 | Update domain settings. At least C<domain> required. | ||||||||||
| 166 | |||||||||||
| 167 | $api->domain->set( | ||||||||||
| 168 | domain => 'example.com', | ||||||||||
| 169 | password => 'newsecret', | ||||||||||
| 170 | context_id => 'new-context-id', | ||||||||||
| 171 | create_new_context_id => 1, | ||||||||||
| 172 | memo => 'Updated note', | ||||||||||
| 173 | ); | ||||||||||
| 174 | |||||||||||
| 175 | Update domain settings. At least C<domain> required. | ||||||||||
| 176 | |||||||||||
| 177 | =cut | ||||||||||
| 178 | |||||||||||
| 179 | =head1 SUPPORT | ||||||||||
| 180 | |||||||||||
| 181 | =head2 Issues | ||||||||||
| 182 | |||||||||||
| 183 | Please report bugs and feature requests on GitHub at | ||||||||||
| 184 | L<https://github.com/getty/p5-www-mailboxorg/issues>. | ||||||||||
| 185 | |||||||||||
| 186 | =head2 IRC | ||||||||||
| 187 | |||||||||||
| 188 | Join C<#perl-help> on C<irc.perl.org> or message Getty directly. | ||||||||||
| 189 | |||||||||||
| 190 | =head1 CONTRIBUTING | ||||||||||
| 191 | |||||||||||
| 192 | Contributions are welcome! Please fork the repository and submit a pull request. | ||||||||||
| 193 | |||||||||||
| 194 | =head1 AUTHOR | ||||||||||
| 195 | |||||||||||
| 196 | Torsten Raudssus <getty@cpan.org> | ||||||||||
| 197 | |||||||||||
| 198 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 199 | |||||||||||
| 200 | This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> L<https://raudssus.de/>. | ||||||||||
| 201 | |||||||||||
| 202 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 203 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 204 | |||||||||||
| 205 | =cut | ||||||||||