Debian Codegraph @

src/cloud/azure/common/storageaccount/listfileshares.pm

raw
1 #
2 # Copyright 2024 Centreon (http://www.centreon.com/)
3 #
4 # Centreon is a full-fledged industry-strength solution that meets
5 # the needs in IT infrastructure and application monitoring for
6 # service performance.
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 # http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 #
20
21 package cloud::azure::common::storageaccount::listfileshares;
22
23 use base qw(centreon::plugins::mode);
24
25 use strict;
26 use warnings;
27
28 sub new {
29 my ($class, %options) = @_;
30 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
31 bless $self, $class;
32
33 $options{options}->add_options(arguments =>
34 {
35 "resource-group:s" => { name => 'resource_group' },
36 "storage-account:s" => { name => 'storage_account' },
37 });
38
39 return $self;
40 }
41
42 sub check_options {
43 my ($self, %options) = @_;
44 $self->SUPER::init(%options);
45
46 $self->{api_version} = '2022-05-01';
47 }
48
49 sub manage_selection {
50 my ($self, %options) = @_;
51
52 $self->{fileshares} = $options{custom}->azure_list_file_shares(
53 api_version => $self->{api_version},
54 storage_account => $self->{option_results}->{storage_account},
55 resource_group => $self->{option_results}->{resource_group}
56 );
57 }
58
59 sub run {
60 my ($self, %options) = @_;
61
62 $self->manage_selection(%options);
63 foreach my $fileshare (@{$self->{fileshares}}) {
64
65 $self->{output}->output_add(long_msg => sprintf("[fileshare = %s][resourcegroup = %s][storageaccount = %s]",
66 $fileshare->{name},
67 $self->{option_results}->{resource_group},
68 $self->{option_results}->{storage_account}
69 ));
70 }
71
72 $self->{output}->output_add(severity => 'OK',
73 short_msg => 'List fileshares:');
74 $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
75 $self->{output}->exit();
76 }
77
78 sub disco_format {
79 my ($self, %options) = @_;
80
81 $self->{output}->add_disco_format(elements => ['fileshare', 'resourcegroup', 'storageaccount']);
82 }
83
84 sub disco_show {
85 my ($self, %options) = @_;
86
87 $self->manage_selection(%options);
88 foreach my $fileshare (@{$self->{fileshares}}) {
89
90 $self->{output}->add_disco_entry(
91 fileshare => $fileshare->{name},
92 resourcegroup => $self->{option_results}->{resource_group},
93 storageaccount => $self->{option_results}->{storage_account}
94 );
95 }
96 }
97
98 1;
99
100 __END__
101
102 =head1 MODE
103
104 List fileshares belonging to a given storage account.
105
106 =over 8
107
108 =item B<--resource-group>
109
110 Set resource group.
111
112 =item B<--storage-account>
113
114 Set storage account.
115
116 =back
117
118 =cut