Net::Duo::Admin::Phone - Representation of a Duo phone
my $decoded_json = get_json();
my $phone = Net::Duo::Admin::Phone->new($decoded_json);
Perl 5.14 or later and the modules HTTP::Request and HTTP::Response (part of HTTP::Message), JSON, LWP (also known as libwww-perl), Perl6::Slurp, Sub::Install, and URI::Escape (part of URI), all of which are available from CPAN.
A Net::Duo::Admin::Phone object is a Perl representation of a Duo phone as returned by the Duo Admin API, usually via the phones() method or nested in a user returned by the users() method. It contains various information about a phone.
Creates a new phone in Duo and returns the resulting phone as a new Net::Duo::Admin::Phone object. DUO is the Net::Duo object that should be used to perform the creation. DATA is a reference to a hash with the following keys:
The extension. Optional.
The name of the phone. Optional.
The phone number. Optional.
The platform of phone for Duo Mobile, or unknown for a generic phone type. For the list of valid values, see the Duo Admin API documentation. Optional.
The time (in seconds) to wait after the extension is dialed and before the speaking the prompt. Optional.
The time (in seconds) to wait after the number picks up and before dialing the extension. Optional.
The type of the phone. See the "type()" method below for the possible values. Optional.
Creates a new Net::Duo::Admin::Phone object from a full data set. DUO is the Net::Duo object that should be used for any further actions on this object. DATA should be the data structure returned by the Duo REST API for a single user, after JSON decoding.
Creates a new Net::Duo::Admin::Phone by ID. DUO is the Net::Duo object that is used to retrieve the phone from Duo and will be used for any subsequent operations. The ID should be the Duo identifier of the phone. This constructor is distinguished from the previous constructor by checking whether ID is a reference.
Request activation URLs (and optionally an install URL) for this phone. ARGS is an optional reference to a hash whose keys should be chosen from the following:
If set to a true value, request an installation URL for this phone as well as the activation URLs. This is a URL that, when opened, will prompt the user to install Duo Mobile. The default is to not request an installation URL.
The number of seconds these activation URLs should be valid for. The default is 86,400 (one day).
The return value of this method will be a reference to a hash containing the following keys:
Opening this URL with the Duo Mobile app will complete activation.
URL of an image that can be scanned with Duo Mobile to complete activation. Activating with this image or with the activation URL will produce the same result.
Opening this URL on the phone will prompt the user to install Duo Mobile. This will only be present if the install argument is set to a true value.
The number of seconds that the activation code is valid for. Normally this will be the same as the valid_secs argument in the request if it was present, unless Duo rejected the requested validity interval.
Commit all changes made via the set_*() methods to Duo. Until this method is called, any changes made via set_*() are only internal to the object and not reflected in Duo.
After commit(), the internal representation of the object will be refreshed to match the new data returned by the Duo API for that object. Therefore, other fields of the object may change after commit() if some other user has changed other, unrelated fields in the object.
It's best to think of this method as a synchronize operation: changed data is written back, overwriting what's in Duo, and unchanged data may be overwritten by whatever is currently in Duo, if it is different.
Delete this phone from Duo. After successful completion of this call, the Net::Duo::Admin::Phone object should be considered read-only, since no further changes to the object can be meaningfully sent to Duo.
Convert the data stored in the object to JSON and return the results. The resulting JSON should match the JSON that one would get back from the Duo web service when retrieving the same object (plus any changes made locally to the object via set_*() methods). This is primarily intended for debugging dumps or for passing Duo objects to other systems via further JSON APIs.
Generate a new batch of SMS passcodes and send them to the phone in a single SMS message. The number of passcodes sent is a global setting on the Duo account.
Some fields have set_*() methods. Those methods replace the value of the field in its entirety with the new value passed in. This change is only made locally in the object until commit() is called.
Whether the phone has been activated for Duo Mobile.
A list of phone capabilities, chosen from the following values:
The device is activated for Duo Push.
The device can receive phone calls.
The device can receive batches of SMS passcodes.
The extension for this phone, if any.
The name of this phone.
The number for this phone, without any extension.
The unique ID of this phone as generated by Duo on phone creation.
The platform of phone for Duo Mobile, or unknown for a generic phone type. For the list of valid values, see the Duo Admin API documentation.
The time (in seconds) to wait after the extension is dialed and before the speaking the prompt.
The time (in seconds) to wait after the number picks up and before dialing the extension.
Whether SMS passcodes have been sent to this phone.
The type of phone, chosen from unknown, mobile, or landline.
The users associated with this phone as a list of Net::Duo::Admin::User objects.
Russ Allbery <firstname.lastname@example.org>
Copyright 2014 The Board of Trustees of the Leland Stanford Junior University
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Duo Admin API for phones
This module is part of the Net::Duo distribution. The current version of Net::Duo is available from CPAN, or directly from its web site at https://www.eyrie.org/~eagle/software/net-duo/.
To install Net::Duo, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.