line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::DataDog::User; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
53625
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use base qw( WebService::DataDog ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
329
|
|
7
|
1
|
|
|
1
|
|
7
|
use Carp qw( carp croak ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
47
|
|
8
|
1
|
|
|
1
|
|
4
|
use Data::Dumper; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
9
|
1
|
|
|
1
|
|
4
|
use Try::Tiny; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
179
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
WebService::DataDog::User - Interface to User functions in DataDog's API. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 VERSION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Version 1.0.3 |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '1.0.3'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
This module allows you interact with the user endpoint of the DataDog API. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Per DataDog: "You can invite users to join DataDog using the API." |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 METHODS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 invite() |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Invite users to join the Datadog service. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $user = $datadog->build('User'); |
39
|
|
|
|
|
|
|
$user->invite( |
40
|
|
|
|
|
|
|
emails => $email_list, # A list of 1+ email addresses |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Example: |
44
|
|
|
|
|
|
|
$user->invite( |
45
|
|
|
|
|
|
|
emails => [ 'user@example.com', 'user2@emailme.com' ] |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Parameters: |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=over 4 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item * emails |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
List of email addresses that should receive invitations. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=back |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub invite |
61
|
|
|
|
|
|
|
{ |
62
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
63
|
0
|
|
|
|
|
|
my $verbose = $self->verbose(); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Check for mandatory parameters |
66
|
0
|
|
|
|
|
|
foreach my $arg ( qw( emails ) ) |
67
|
|
|
|
|
|
|
{ |
68
|
0
|
0
|
0
|
|
|
|
croak "ERROR - Argument '$arg' is required for invite()." |
69
|
|
|
|
|
|
|
if !defined( $args{$arg} ) || ( $args{$arg} eq '' ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
|
if ( defined $args{'emails'} ) |
73
|
|
|
|
|
|
|
{ |
74
|
0
|
0
|
|
|
|
|
if ( !Data::Validate::Type::is_arrayref( $args{'emails'} ) ) |
75
|
|
|
|
|
|
|
{ |
76
|
0
|
|
|
|
|
|
croak "ERROR - invalid 'emails' value. Must be an arrayref."; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
my $url = $WebService::DataDog::API_ENDPOINT . 'invite_users'; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my $data = { |
84
|
|
|
|
|
|
|
emails => $args{'emails'}, |
85
|
|
|
|
|
|
|
}; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my $response = $self->_send_request( |
88
|
|
|
|
|
|
|
method => 'POST', |
89
|
|
|
|
|
|
|
url => $url, |
90
|
|
|
|
|
|
|
data => $data, |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
|
93
|
0
|
0
|
|
|
|
|
if ( !defined($response) ) |
94
|
|
|
|
|
|
|
{ |
95
|
0
|
|
|
|
|
|
croak "Fatal error. No response"; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
return $response; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |