lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Subaccount/Cmd/Create.pm

filter: Statementstmt 100% 29 / 29 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 88.3% 38 / 43 CC 5 SCAR 12.2
CC
5
Cov
89%
execute
5.3
BEGIN
1.0
BEGIN
1.0
CRAP 3.4
« lib/WWW/Hetzner/Cloud/LoadBalancer.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/Sshkey.pm »
1 package WWW::Hetzner::CLI::Cmd::StorageBox::Cmd::Subaccount::Cmd::Create;
2 # ABSTRACT: Create a Storage Box subaccount
3  
4 1 our $VERSION = '0.102';
5  
6 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use MooX::Cmd;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use MooX::Options protect_argv => 0, usage_string => 'USAGE: hcloud.pl storage-box subaccount create --home-directory <dir> --password <password> [--name <name>] [--description <description>] <storage-box>';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use WWW::Hetzner::Storage::API::Subaccounts;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 with 'WWW::Hetzner::CLI::Role::WaitsForAction';
11  
12  
13 1 option home_directory => (
14 is => 'ro',
15 format => 's',
16 required => 1,
17 doc => 'Subaccount home directory',
18 );
19  
20 1 option password => (
21 is => 'ro',
22 format => 's',
23 required => 1,
24 doc => 'Subaccount password (input only)',
25 );
26  
27 1 option name => (
28 is => 'ro',
29 format => 's',
30 doc => 'Subaccount display name',
31 );
32  
33 1 option description => (
34 is => 'ro',
35 format => 's',
36 doc => 'Subaccount description',
37 );
38  
39 1 ▶sub execute {
Subroutine execute: called CC=5 SCAR=16.6
Pod undocumented
40 1 my ($self, $args, $chain) = @_;
41 1 ▶ my $id = $args->[0] or die "Usage: hcloud.pl storage-box subaccount create <storage-box>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $id = $args->[0] or die "Usage: hcloud.pl storage-box subaccount create <storage-box>\n" 1 0 1
42  
43 1 my %params = (
44 home_directory => $self->home_directory,
45 password => $self->password,
46 );
47 1 ▶ $params{name} = $self->name if defined $self->name;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->name 0 1 1
48 1 ▶ $params{description} = $self->description if defined $self->description;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->description 0 1 1
49  
50 1 print "Creating subaccount for Storage Box $id...\n";
51 1 my $subaccounts = WWW::Hetzner::Storage::API::Subaccounts->new(
52 client => $chain->[0]->storage,
53 storage_box_id => $id,
54 );
55 1 my $subaccount = $subaccounts->create(%params);
56 1 $self->handle_action($subaccount->action);
57 1 ▶ print $self->no_wait ? "Subaccount creation requested.\n" : "Subaccount created.\n";
Branch: 1 branch
BranchTrueFalseTotal
$self->no_wait ? : 0 1 1
58 }
59  
60 1 1;
61  
62 __END__
« lib/WWW/Hetzner/Cloud/LoadBalancer.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/Sshkey.pm »