Mattermost/V4/API.pm

filter: Statementstmt 99.5% 234 / 235 Branchbran 100% 2 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 98.8% 88 / 89 Podpod 0.0% 0 / 1 totaltotal 98.1% 326 / 332 CC 4 SCAR 0.9
CC
4
Cov
99%
BUILD
3.0
_new_resource
2.0
_build_config
2.0
CRAP 1.1
« Mattermost/Util/Logger.pm ↑ Summary Mattermost/V4/API/Role/NewRelatedResource.pm »
1 package WebService::Mattermost::V4::API;
2  
3 # ABSTRACT: Mattermost API v4 wrapper.
4  
5 12 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 12 ▶use MooX::HandlesVia;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 12 ▶use Types::Standard qw(ArrayRef Bool InstanceOf Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 12 ▶use WebService::Mattermost::V4::API::Resource::Analytics;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 12 ▶use WebService::Mattermost::V4::API::Resource::Audits;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 12 ▶use WebService::Mattermost::V4::API::Resource::Bots;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 12 ▶use WebService::Mattermost::V4::API::Resource::Brand;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 12 ▶use WebService::Mattermost::V4::API::Resource::Cache;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 12 ▶use WebService::Mattermost::V4::API::Resource::Channel;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 12 ▶use WebService::Mattermost::V4::API::Resource::Channel::Member;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 12 ▶use WebService::Mattermost::V4::API::Resource::Channels;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 12 ▶use WebService::Mattermost::V4::API::Resource::Cluster;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 12 ▶use WebService::Mattermost::V4::API::Resource::Compliance;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 12 ▶use WebService::Mattermost::V4::API::Resource::Compliance::Report;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 12 ▶use WebService::Mattermost::V4::API::Resource::DataRetention;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 12 ▶use WebService::Mattermost::V4::API::Resource::Database;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 12 ▶use WebService::Mattermost::V4::API::Resource::ElasticSearch;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 12 ▶use WebService::Mattermost::V4::API::Resource::Email;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 12 ▶use WebService::Mattermost::V4::API::Resource::Emoji;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 12 ▶use WebService::Mattermost::V4::API::Resource::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 12 ▶use WebService::Mattermost::V4::API::Resource::Files;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 12 ▶use WebService::Mattermost::V4::API::Resource::Job;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 12 ▶use WebService::Mattermost::V4::API::Resource::Jobs;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 12 ▶use WebService::Mattermost::V4::API::Resource::LDAP;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 12 ▶use WebService::Mattermost::V4::API::Resource::Logs;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 12 ▶use WebService::Mattermost::V4::API::Resource::OAuth;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 12 ▶use WebService::Mattermost::V4::API::Resource::OAuth::Application;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 12 ▶use WebService::Mattermost::V4::API::Resource::Plugin;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 12 ▶use WebService::Mattermost::V4::API::Resource::Plugins;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 12 ▶use WebService::Mattermost::V4::API::Resource::Post;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 12 ▶use WebService::Mattermost::V4::API::Resource::Posts;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 12 ▶use WebService::Mattermost::V4::API::Resource::Reactions;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 12 ▶use WebService::Mattermost::V4::API::Resource::Roles;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 12 ▶use WebService::Mattermost::V4::API::Resource::S3;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 12 ▶use WebService::Mattermost::V4::API::Resource::SAML;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 12 ▶use WebService::Mattermost::V4::API::Resource::Schemes;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 12 ▶use WebService::Mattermost::V4::API::Resource::System;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 12 ▶use WebService::Mattermost::V4::API::Resource::Team;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 12 ▶use WebService::Mattermost::V4::API::Resource::Teams;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 12 ▶use WebService::Mattermost::V4::API::Resource::User;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 12 ▶use WebService::Mattermost::V4::API::Resource::Users;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 12 ▶use WebService::Mattermost::V4::API::Resource::Webhook;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 12 ▶use WebService::Mattermost::V4::API::Resource::WebRTC;
Subroutine BEGIN: called CC=1 SCAR=0.0
49 12 ▶use WebService::Mattermost::Helper::Alias 'v4';
Subroutine BEGIN: called CC=1 SCAR=0.0
50  
51 ################################################################################
52  
53 12 has auth_token => (is => 'ro', isa => Str, required => 1);
54 12 has base_url => (is => 'ro', isa => Str, required => 1);
55  
56 12 has authenticate => (is => 'ro', isa => Bool, default => 0);
57 12 has debug => (is => 'ro', isa => Bool, default => 0);
58 41 ▶has resources => (is => 'rw', isa => ArrayRef, default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
59 12 handles_via => 'Array',
60 handles => {
61 add_resource => 'push',
62 });
63  
64 12 has analytics => (is => 'lazy', isa => InstanceOf[v4 'Analytics']);
65 12 has application => (is => 'lazy', isa => InstanceOf[v4 'OAuth::Application']);
66 12 has audits => (is => 'lazy', isa => InstanceOf[v4 'Audits']);
67 12 has bots => (is => 'lazy', isa => InstanceOf[v4 'Bots']);
68 12 has brand => (is => 'lazy', isa => InstanceOf[v4 'Brand']);
69 12 has cache => (is => 'lazy', isa => InstanceOf[v4 'Cache']);
70 12 has channel => (is => 'lazy', isa => InstanceOf[v4 'Channel']);
71 12 has channel_member => (is => 'lazy', isa => InstanceOf[v4 'Channel::Member']);
72 12 has channels => (is => 'lazy', isa => InstanceOf[v4 'Channels']);
73 12 has cluster => (is => 'lazy', isa => InstanceOf[v4 'Cluster']);
74 12 has compliance => (is => 'lazy', isa => InstanceOf[v4 'Compliance']);
75 12 has compliance_report => (is => 'lazy', isa => InstanceOf[v4 'Compliance::Report']);
76 12 has data_retention => (is => 'lazy', isa => InstanceOf[v4 'DataRetention']);
77 12 has database => (is => 'lazy', isa => InstanceOf[v4 'Database']);
78 12 has elasticsearch => (is => 'lazy', isa => InstanceOf[v4 'ElasticSearch']);
79 12 has email => (is => 'lazy', isa => InstanceOf[v4 'Email']);
80 12 has emoji => (is => 'lazy', isa => InstanceOf[v4 'Emoji']);
81 12 has file => (is => 'lazy', isa => InstanceOf[v4 'File']);
82 12 has files => (is => 'lazy', isa => InstanceOf[v4 'Files']);
83 12 has job => (is => 'lazy', isa => InstanceOf[v4 'Job']);
84 12 has jobs => (is => 'lazy', isa => InstanceOf[v4 'Jobs']);
85 12 has ldap => (is => 'lazy', isa => InstanceOf[v4 'LDAP']);
86 12 has logs => (is => 'lazy', isa => InstanceOf[v4 'Logs']);
87 12 has oauth => (is => 'lazy', isa => InstanceOf[v4 'OAuth']);
88 12 has plugin => (is => 'lazy', isa => InstanceOf[v4 'Plugin']);
89 12 has plugins => (is => 'lazy', isa => InstanceOf[v4 'Plugins']);
90 12 has post => (is => 'lazy', isa => InstanceOf[v4 'Post']);
91 12 has posts => (is => 'lazy', isa => InstanceOf[v4 'Posts']);
92 12 has reactions => (is => 'lazy', isa => InstanceOf[v4 'Reactions']);
93 12 has roles => (is => 'lazy', isa => InstanceOf[v4 'Roles']);
94 12 has s3 => (is => 'lazy', isa => InstanceOf[v4 'S3']);
95 12 has saml => (is => 'lazy', isa => InstanceOf[v4 'SAML']);
96 12 has schemes => (is => 'lazy', isa => InstanceOf[v4 'Schemes']);
97 12 has system => (is => 'lazy', isa => InstanceOf[v4 'System']);
98 12 has team => (is => 'lazy', isa => InstanceOf[v4 'Team']);
99 12 has team_channels => (is => 'lazy', isa => InstanceOf[v4 'Team::Channels']);
100 12 has teams => (is => 'lazy', isa => InstanceOf[v4 'Teams']);
101 12 has user => (is => 'lazy', isa => InstanceOf[v4 'User']);
102 12 has users => (is => 'lazy', isa => InstanceOf[v4 'Users']);
103 12 has webhooks => (is => 'lazy', isa => InstanceOf[v4 'Webhook']);
104 12 has webrtc => (is => 'lazy', isa => InstanceOf[v4 'WebRTC']);
105  
106 ################################################################################
107  
108 sub BUILD {
109 41 ▶ my $self = shift;
Subroutine BUILD: called CC=3 SCAR=11.0
Pod undocumented
110  
111 41 foreach my $name (sort $self->meta->get_attribute_list) {
112 1886 my $attr = $self->meta->get_attribute($name);
113  
114 1886 ▶ if ($attr->has_builder) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr->has_builder) 1681 205 1886
115 1681 my $cref = $self->can($name);
116  
117 1681 $self->$cref;
118 }
119 }
120  
121 41 return 1;
122 }
123  
124 ################################################################################
125  
126 sub _new_resource {
127 1681 ▶ my $self = shift;
Subroutine _new_resource: called CC=2 SCAR=7.0
128 1681 my $name = shift;
129 1681 ▶ my $alt_name = shift || lc $name;
Condition66%2/3
shift() || lc $name
l!l&&r!l&&!r
61510660
MC/DC0%0/2
shift() || lc $name
shift() lc $name
Truth table66%2/3
A || B
A= shift()B= lc $name
ABresult
1X1
011
000
130  
131 1681 my $resource = v4($name)->new({
132 api => $self,
133 auth_token => $self->auth_token,
134 base_url => $self->base_url,
135 resource => $alt_name,
136 debug => $self->debug,
137 });
138  
139 1681 $self->add_resource($resource);
140  
141 1681 return $resource;
142 }
143  
144 ################################################################################
145  
146 # The optional second parameter in some of these builders sets the "resource
147 # name", i.e. DataRetention's base resource is "data_retention", not
148 # "dataretention".
149  
150 41 ▶sub _build_analytics { shift->_new_resource('Analytics') }
Subroutine _build_analytics: called CC=1 SCAR=0.0
151 41 ▶sub _build_application { shift->_new_resource('OAuth::Application', 'oauth') }
Subroutine _build_application: called CC=1 SCAR=0.0
152 41 ▶sub _build_audits { shift->_new_resource('Audits') }
Subroutine _build_audits: called CC=1 SCAR=0.0
153 41 ▶sub _build_bots { shift->_new_resource('Bots') }
Subroutine _build_bots: called CC=1 SCAR=0.0
154 41 ▶sub _build_brand { shift->_new_resource('Brand') }
Subroutine _build_brand: called CC=1 SCAR=0.0
155 41 ▶sub _build_cache { shift->_new_resource('Cache', 'caches') }
Subroutine _build_cache: called CC=1 SCAR=0.0
156 41 ▶sub _build_channel { shift->_new_resource('Channel', 'channels') }
Subroutine _build_channel: called CC=1 SCAR=0.0
157 41 ▶sub _build_channel_member { shift->_new_resource('Channel::Member', 'channels') }
Subroutine _build_channel_member: called CC=1 SCAR=0.0
158 41 ▶sub _build_channels { shift->_new_resource('Channels') }
Subroutine _build_channels: called CC=1 SCAR=0.0
159 41 ▶sub _build_cluster { shift->_new_resource('Cluster') }
Subroutine _build_cluster: called CC=1 SCAR=0.0
160 41 ▶sub _build_compliance { shift->_new_resource('Compliance') }
Subroutine _build_compliance: called CC=1 SCAR=0.0
161 41 ▶sub _build_compliance_report { shift->_new_resource('Compliance::Report', 'compliance') }
Subroutine _build_compliance_report: called CC=1 SCAR=0.0
162 0 ▶sub _build_config { shift->_new_resource('Config') }
Subroutine _build_config: not called CC=1 SCAR=6.9
163 41 ▶sub _build_data_retention { shift->_new_resource('DataRetention', 'data_retention') }
Subroutine _build_data_retention: called CC=1 SCAR=0.0
164 41 ▶sub _build_database { shift->_new_resource('Database') }
Subroutine _build_database: called CC=1 SCAR=0.0
165 41 ▶sub _build_elasticsearch { shift->_new_resource('ElasticSearch') }
Subroutine _build_elasticsearch: called CC=1 SCAR=0.0
166 41 ▶sub _build_email { shift->_new_resource('Email') }
Subroutine _build_email: called CC=1 SCAR=0.0
167 41 ▶sub _build_emoji { shift->_new_resource('Emoji') }
Subroutine _build_emoji: called CC=1 SCAR=0.0
168 41 ▶sub _build_files { shift->_new_resource('Files') }
Subroutine _build_files: called CC=1 SCAR=0.0
169 41 ▶sub _build_file { shift->_new_resource('File', 'files') }
Subroutine _build_file: called CC=1 SCAR=0.0
170 41 ▶sub _build_job { shift->_new_resource('Job', 'jobs') }
Subroutine _build_job: called CC=1 SCAR=0.0
171 41 ▶sub _build_jobs { shift->_new_resource('Jobs') }
Subroutine _build_jobs: called CC=1 SCAR=0.0
172 41 ▶sub _build_ldap { shift->_new_resource('LDAP') }
Subroutine _build_ldap: called CC=1 SCAR=0.0
173 41 ▶sub _build_logs { shift->_new_resource('Logs') }
Subroutine _build_logs: called CC=1 SCAR=0.0
174 41 ▶sub _build_oauth { shift->_new_resource('OAuth') }
Subroutine _build_oauth: called CC=1 SCAR=0.0
175 41 ▶sub _build_plugin { shift->_new_resource('Plugin', 'plugins') }
Subroutine _build_plugin: called CC=1 SCAR=0.0
176 41 ▶sub _build_plugins { shift->_new_resource('Plugins') }
Subroutine _build_plugins: called CC=1 SCAR=0.0
177 41 ▶sub _build_post { shift->_new_resource('Post', 'posts') }
Subroutine _build_post: called CC=1 SCAR=0.0
178 41 ▶sub _build_posts { shift->_new_resource('Posts') }
Subroutine _build_posts: called CC=1 SCAR=0.0
179 41 ▶sub _build_reactions { shift->_new_resource('Reactions') }
Subroutine _build_reactions: called CC=1 SCAR=0.0
180 41 ▶sub _build_roles { shift->_new_resource('Roles') }
Subroutine _build_roles: called CC=1 SCAR=0.0
181 41 ▶sub _build_s3 { shift->_new_resource('S3', 'file') }
Subroutine _build_s3: called CC=1 SCAR=0.0
182 41 ▶sub _build_saml { shift->_new_resource('SAML') }
Subroutine _build_saml: called CC=1 SCAR=0.0
183 41 ▶sub _build_schemes { shift->_new_resource('Schemes') }
Subroutine _build_schemes: called CC=1 SCAR=0.0
184 41 ▶sub _build_system { shift->_new_resource('System') }
Subroutine _build_system: called CC=1 SCAR=0.0
185 41 ▶sub _build_team { shift->_new_resource('Team', 'teams') }
Subroutine _build_team: called CC=1 SCAR=0.0
186 41 ▶sub _build_teams { shift->_new_resource('Teams') }
Subroutine _build_teams: called CC=1 SCAR=0.0
187 41 ▶sub _build_team_channels { shift->_new_resource('Team::Channels', 'team') }
Subroutine _build_team_channels: called CC=1 SCAR=0.0
188 41 ▶sub _build_user { shift->_new_resource('User', 'users') }
Subroutine _build_user: called CC=1 SCAR=0.0
189 41 ▶sub _build_users { shift->_new_resource('Users') }
Subroutine _build_users: called CC=1 SCAR=0.0
190 41 ▶sub _build_webhooks { shift->_new_resource('Webhook', 'hooks') }
Subroutine _build_webhooks: called CC=1 SCAR=0.0
191 41 ▶sub _build_webrtc { shift->_new_resource('WebRTC') }
Subroutine _build_webrtc: called CC=1 SCAR=0.0
192  
193 ################################################################################
194  
195 12 1;
196  
197 __END__
198  
199 =pod
200  
201 =encoding UTF-8
202  
203 =head1 NAME
204  
205 WebService::Mattermost::V4::API - Mattermost API v4 wrapper.
206  
207 =head1 VERSION
208  
209 version 0.28
210  
211 =head1 DESCRIPTION
212  
213 Container for API resources.
214  
215 =head2 ATTRIBUTES
216  
217 =over 4
218  
219 =item * C<analytics>
220  
221 See L<WebService::Mattermost::V4::API::Resource::Analytics>
222  
223 =item * C<application>
224  
225 See L<WebService::Mattermost::V4::API::Resource::OAuth::Application>
226  
227 =item * C<audits>
228  
229 See L<WebService::Mattermost::V4::API::Resource::Audits>
230  
231 =item * C<brand>
232  
233 See L<WebService::Mattermost::V4::API::Resource::Brand>.
234  
235 =item * C<bots>
236  
237 See L<WebService::Mattermost::V4::API::Resource::Bots>.
238  
239 =item * C<channels>
240  
241 See L<WebService::Mattermost::V4::API::Resource::Channels>.
242  
243 =item * C<channel>
244  
245 See L<WebService::Mattermost::V4::API::Resource::Channel>.
246  
247 =item * C<channel_member>
248  
249 See L<WebService::Mattermost::V4::API::Resource::Channel::Member>.
250  
251 =item * C<cluster>
252  
253 See L<WebService::Mattermost::V4::API::Resource::Cluster>.
254  
255 =item * C<config>
256  
257 See L<WebService::Mattermost::V4::API::Resource::Config>.
258  
259 =item * C<compliance>
260  
261 See L<WebService::Mattermost::V4::API::Resource::Compliance>.
262  
263 =item * C<compliance_report>
264  
265 See L<WebService::Mattermost::V4::API::Resource::Compliance::Report>.
266  
267 =item * C<data_retention>
268  
269 See L<WebService::Mattermost::V4::API::Resource::DataRetention>.
270  
271 =item * C<database>
272  
273 See L<WebService::Mattermost::V4::API::Resource::Database>.
274  
275 =item * C<elasticsearch>
276  
277 See L<WebService::Mattermost::V4::API::Resource::ElasticSearch>.
278  
279 =item * C<email>
280  
281 See L<WebService::Mattermost::V4::API::Resource::Email>.
282  
283 =item * C<emoji>
284  
285 See L<WebService::Mattermost::V4::API::Resource::Emoji>.
286  
287 =item * C<file>
288  
289 See L<WebService::Mattermost::V4::API::Resource::File>.
290  
291 =item * C<files>
292  
293 See L<WebService::Mattermost::V4::API::Resource::Files>.
294  
295 =item * C<job>
296  
297 See L<WebService::Mattermost::V4::API::Resource::Job>.
298  
299 =item * C<jobs>
300  
301 See L<WebService::Mattermost::V4::API::Resource::Jobs>.
302  
303 =item * C<ldap>
304  
305 See L<WebService::Mattermost::V4::API::Resource::LDAP>.
306  
307 =item * C<logs>
308  
309 See L<WebService::Mattermost::V4::API::Resource::Logs>.
310  
311 =item * C<oauth>
312  
313 See L<WebService::Mattermost::V4::API::Resource::OAuth>.
314  
315 =item * C<plugin>
316  
317 See L<WebService::Mattermost::V4::API::Resource::Plugin>.
318  
319 =item * C<plugins>
320  
321 See L<WebService::Mattermost::V4::API::Resource::Plugins>.
322  
323 =item * C<post>
324  
325 See L<WebService::Mattermost::V4::API::Resource::Post>.
326  
327 =item * C<posts>
328  
329 See L<WebService::Mattermost::V4::API::Resource::Posts>.
330  
331 =item * C<reactions>
332  
333 See L<WebService::Mattermost::V4::API::Resource::Reactions>.
334  
335 =item * C<roles>
336  
337 See L<WebService::Mattermost::V4::API::Resource::Roles>.
338  
339 =item * C<s3>
340  
341 See L<WebService::Mattermost::V4::API::Resource::S3>.
342  
343 =item * C<saml>
344  
345 See L<WebService::Mattermost::V4::API::Resource::SAML>.
346  
347 =item * C<schemes>
348  
349 See L<WebService::Mattermost::V4::API::Resource::Schemes>.
350  
351 =item * C<system>
352  
353 See L<WebService::Mattermost::V4::API::Resource::System>.
354  
355 =item * C<team>
356  
357 See L<WebService::Mattermost::V4::API::Resource::Team>.
358  
359 =item * C<teams>
360  
361 See L<WebService::Mattermost::V4::API::Resource::Teams>.
362  
363 =item * C<user>
364  
365 See L<WebService::Mattermost::V4::API::Resource::User>.
366  
367 =item * C<users>
368  
369 See L<WebService::Mattermost::V4::API::Resource::Users>.
370  
371 =item * C<webhooks>
372  
373 See L<WebService::Mattermost::V4::API::Resource::Webhook>.
374  
375 =item * C<webrtc>
376  
377 See L<WebService::Mattermost::V4::API::Resource::WebRTC>.
378  
379 =back
380  
381 =head1 AUTHOR
382  
383 Mike Jones <mike@netsplit.org.uk>
384  
385 =head1 COPYRIGHT AND LICENSE
386  
387 This software is Copyright (c) 2020 by Mike Jones.
388  
389 This is free software, licensed under:
390  
391 The MIT (X11) License
392  
393 =cut
« Mattermost/Util/Logger.pm ↑ Summary Mattermost/V4/API/Role/NewRelatedResource.pm »