API-Name
view release on metacpan or search on metacpan
% cpanm -S API::Name
## Installing with the CPAN shell
Alternatively, if your CPAN shell is set up, you should just be able to do:
% cpan API::Name
## Manual installation
As a last resort, you can manually install it. Download the tarball, untar it,
then build it:
% perl Makefile.PL
% make && make test
Then install it:
% make install
If you are installing into a system-wide directory, you may need to run:
software and to any other program whose authors commit to using it.
You can use it for your programs, too.
When we speak of free software, we are referring to freedom, not
price. Specifically, the General Public License is designed to make
sure that you have the freedom to give away or sell copies of free
software, that you receive source code or can get it if you want it,
that you can change the software or use pieces of it in new free
programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of a such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must tell them their rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any program or other work which
contains a notice placed by the copyright holder saying it may be
distributed under the terms of this General Public License. The
"Program", below, refers to any such program or work, and a "work based
on the Program" means either the Program or any work containing the
Program or a portion of it, either verbatim or with modifications. Each
licensee is addressed as "you".
1. You may copy and distribute verbatim copies of the Program's source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this
General Public License and to the absence of any warranty; and give any
other recipients of the Program a copy of this General Public License
along with the Program. You may charge a fee for the physical act of
transferring a copy.
exchange for a fee.
Mere aggregation of another independent work with the Program (or its
derivative) on a volume of a storage or distribution medium does not bring
the other work under the scope of these terms.
3. You may copy and distribute the Program (or a portion or derivative of
it, under Paragraph 2) in object code or executable form under the terms of
Paragraphs 1 and 2 above provided that you also do one of the following:
a) accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of
Paragraphs 1 and 2 above; or,
b) accompany it with a written offer, valid for at least three
years, to give any third party free (except for a nominal charge
for the cost of distribution) a complete machine-readable copy of the
corresponding source code, to be distributed under the terms of
Paragraphs 1 and 2 above; or,
c) accompany it with the information you received as to where the
corresponding source code may be obtained. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form alone.)
Source code for a work means the preferred form of the work for making
modifications to it. For an executable file, complete source code means
all the source code for all modules it contains; but, as a special
exception, it need not include source code for modules which are standard
libraries that accompany the operating system on which the executable
file runs, or for standard header files or definitions files that
accompany that operating system.
4. You may not copy, modify, sublicense, distribute or transfer the
Program except as expressly provided under this General Public License.
Any attempt otherwise to copy, modify, sublicense, distribute or transfer
the Program is void, and will automatically terminate your rights to use
the Program under this License. However, parties who have received
copies, or rights to use copies, from you under this General Public
License will not have their licenses terminated so long as such parties
remain in full compliance.
5. By copying, distributing or modifying the Program (or any work based
on the Program) you indicate your acceptance of this license to do so,
and all its terms and conditions.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these
terms and conditions. You may not impose any further restrictions on the
recipients' exercise of the rights granted herein.
7. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of the license which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
the license, you may choose any version ever published by the Free Software
Foundation.
8. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License. Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items--whatever suits your
program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
program `Gnomovision' (a program to direct compilers to make passes
at assemblers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
That's all there is to it!
--- The Artistic License 1.0 ---
This software is Copyright (c) 2014 by Al Newkirk.
This is free software, licensed under:
- "Reasonable copying fee" is whatever you can justify on the basis of media
cost, duplication charges, time of people involved, and so on. (You will
not be required to justify it to the Copyright Holder, but only to the
computing community at large as a market that must bear the fee.)
- "Freely Available" means that no fee is charged for the item itself, though
there may be fees involved in handling the item. It also means that
recipients of the item may redistribute it under the same conditions they
received it.
1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.
2. You may apply bug fixes, portability fixes and other modifications derived
from the Public Domain or from the Copyright Holder. A Package modified in such
a way shall still be considered the Standard Version.
3. You may otherwise modify your copy of this Package in any way, provided that
you insert a prominent notice in each changed file stating how and when you
changed that file, and provided that you do at least ONE of the following:
4. You may distribute the programs of this Package in object code or executable
form, provided that you do at least ONE of the following:
a) distribute a Standard Version of the executables and library files,
together with instructions (in the manual page or equivalent) on where to
get the Standard Version.
b) accompany the distribution with the machine-readable source of the Package
with your modifications.
c) accompany any non-standard executables with their corresponding Standard
Version executables, giving the non-standard executables non-standard
names, and clearly documenting the differences in manual pages (or
equivalent), together with instructions on where to get the Standard
Version.
d) make other distribution arrangements with the Copyright Holder.
5. You may charge a reasonable copying fee for any distribution of this
Package. You may charge any fee you choose for support of this Package. You
may not charge a fee for this Package itself. However, you may distribute this
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : 2
},
"name" : "API-Name",
"prereqs" : {
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"runtime" : {
"requires" : {
"API::Client" : "0.03",
"Data::Object" : "0.57",
"Mojolicious" : "6.22",
"perl" : "v5.14.0"
}
},
"test" : {
"requires" : {
"perl" : "v5.14.0"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/alnewkirk/API-Name/issues"
},
"homepage" : "http://metacpan.org/release/API-Name/",
"repository" : {
"type" : "git",
"url" : "git://github.com/alnewkirk/API-Name.git",
"web" : "https://github.com/alnewkirk/API-Name"
}
},
README.mkdn view on Meta::CPAN
my $name = API::Name->new(
user => 'USER',
token => 'TOKEN',
identifier => 'APPLICATION NAME',
);
$name->debug(1);
$name->fatal(1);
my $domain = $name->domains(get => 'example.com');
my $results = $domain->fetch;
# after some introspection
$domain->update( ... );
# DESCRIPTION
This distribution provides an object-oriented thin-client library for
interacting with the Name ([https://www.name.com](https://www.name.com)) API. For usage and
documentation information visit [https://www.name.com/reseller/API-documentation](https://www.name.com/reseller/API-documentation).
API::Name is derived from [API::Client](https://metacpan.org/pod/API::Client) and inherits all of it's
functionality. Please read the documentation for API::Client for more usage
information.
# ATTRIBUTES
## token
$name->token;
$name->token('TOKEN');
README.mkdn view on Meta::CPAN
$name->identifier('IDENTIFIER');
The identifier attribute should be set to a string that identifies your
application.
## debug
$name->debug;
$name->debug(1);
The debug attribute if true prints HTTP requests and responses to standard out.
## fatal
$name->fatal;
$name->fatal(1);
The fatal attribute if true promotes 4xx and 5xx server response codes to
exceptions, a [API::Client::Exception](https://metacpan.org/pod/API::Client::Exception) object.
## retries
$name->retries;
$name->retries(10);
The retries attribute determines how many times an HTTP request should be
retried if a 4xx or 5xx response is received. This attribute defaults to 0.
## timeout
$name->timeout;
$name->timeout(5);
The timeout attribute determines how long an HTTP connection should be kept
alive. This attribute defaults to 10.
## url
README.mkdn view on Meta::CPAN
$name->user_agent;
$name->user_agent(Mojo::UserAgent->new);
The user\_agent attribute set the pre-configured UserAgent object that will be
used in all HTTP requests. This attribute expects a [Mojo::UserAgent](https://metacpan.org/pod/Mojo::UserAgent) object.
# METHODS
## action
my $result = $name->action($verb, %args);
# e.g.
$name->action('head', %args); # HEAD request
$name->action('options', %args); # OPTIONS request
$name->action('patch', %args); # PATCH request
The action method issues a request to the API resource represented by the
object. The first parameter will be used as the HTTP request method. The
arguments, expected to be a list of key/value pairs, will be included in the
request if the key is either `data` or `query`.
## create
my $results = $name->create(%args);
# or
$name->POST(%args);
The create method issues a `POST` request to the API resource represented by
the object. The arguments, expected to be a list of key/value pairs, will be
included in the request if the key is either `data` or `query`.
## delete
my $results = $name->delete(%args);
# or
$name->DELETE(%args);
The delete method issues a `DELETE` request to the API resource represented by
the object. The arguments, expected to be a list of key/value pairs, will be
included in the request if the key is either `data` or `query`.
## fetch
my $results = $name->fetch(%args);
# or
$name->GET(%args);
The fetch method issues a `GET` request to the API resource represented by the
object. The arguments, expected to be a list of key/value pairs, will be
included in the request if the key is either `data` or `query`.
## update
my $results = $name->update(%args);
# or
$name->PUT(%args);
The update method issues a `PUT` request to the API resource represented by
the object. The arguments, expected to be a list of key/value pairs, will be
included in the request if the key is either `data` or `query`.
# RESOURCES
## account
$name->account;
The account method returns a new instance representative of the API
_account_ resource requested. This method accepts a list of path
segments which will be used in the HTTP request. The following documentation
can be used to find more information. [https://www.name.com/reseller/API-documentation](https://www.name.com/reseller/API-documentation).
## dns
$name->dns;
The dns method returns a new instance representative of the API
_dns_ resource requested. This method accepts a list of path
segments which will be used in the HTTP request. The following documentation
can be used to find more information. [https://www.name.com/reseller/API-documentation](https://www.name.com/reseller/API-documentation).
## domain
$name->domain;
The domain method returns a new instance representative of the API
_domain_ resource requested. This method accepts a list of path
segments which will be used in the HTTP request. The following documentation
can be used to find more information. [https://www.name.com/reseller/API-documentation](https://www.name.com/reseller/API-documentation).
## host
$name->host;
The host method returns a new instance representative of the API
_host_ resource requested. This method accepts a list of path
segments which will be used in the HTTP request. The following documentation
can be used to find more information. [https://www.name.com/reseller/API-documentation](https://www.name.com/reseller/API-documentation).
## login
$name->login;
The login method returns a new instance representative of the API
_login_ resource requested. This method accepts a list of path
segments which will be used in the HTTP request. The following documentation
can be used to find more information. [https://www.name.com/reseller/API-documentation](https://www.name.com/reseller/API-documentation).
## logout
$name->logout;
The logout method returns a new instance representative of the API
_logout_ resource requested. This method accepts a list of path
segments which will be used in the HTTP request. The following documentation
can be used to find more information. [https://www.name.com/reseller/API-documentation](https://www.name.com/reseller/API-documentation).
## order
$name->order;
The order method returns a new instance representative of the API
_order_ resource requested. This method accepts a list of path
segments which will be used in the HTTP request. The following documentation
can be used to find more information. [https://www.name.com/reseller/API-documentation](https://www.name.com/reseller/API-documentation).
# AUTHOR
Al Newkirk <anewkirk@ana.io>
# COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Al Newkirk.
This is free software; you can redistribute it and/or modify it under
requires "API::Client" => "0.03";
requires "Data::Object" => "0.57";
requires "Mojolicious" => "6.22";
requires "perl" => "v5.14.0";
on 'test' => sub {
requires "perl" => "v5.14.0";
};
on 'configure' => sub {
requires "ExtUtils::MakeMaker" => "0";
};
lib/API/Name.pm view on Meta::CPAN
# ABSTRACT: Name.com API Client
package API::Name;
use Data::Object::Class;
use Data::Object::Signatures;
use Data::Object::Library qw(
Str
);
extends 'API::Client';
our $VERSION = '0.06'; # VERSION
our $DEFAULT_URL = "https://www.name.com";
lib/API/Name.pm view on Meta::CPAN
my $user = $self->user;
my $token = $self->token;
# default headers
$headers->header('Content-Type' => 'application/json');
$headers->header('Api-Username' => $user);
$headers->header('Api-Token' => $token);
}
method resource (@segments) {
# build new resource instance
my $instance = __PACKAGE__->new(
debug => $self->debug,
fatal => $self->fatal,
retries => $self->retries,
timeout => $self->timeout,
user_agent => $self->user_agent,
identifier => $self->identifier,
token => $self->token,
user => $self->user,
version => $self->version,
);
# resource locator
my $url = $instance->url;
# modify resource locator if possible
$url->path(join '/', $self->url->path, @segments);
# return resource instance
return $instance;
}
1;
__END__
=pod
lib/API/Name.pm view on Meta::CPAN
my $name = API::Name->new(
user => 'USER',
token => 'TOKEN',
identifier => 'APPLICATION NAME',
);
$name->debug(1);
$name->fatal(1);
my $domain = $name->domains(get => 'example.com');
my $results = $domain->fetch;
# after some introspection
$domain->update( ... );
=head1 DESCRIPTION
This distribution provides an object-oriented thin-client library for
interacting with the Name (L<https://www.name.com>) API. For usage and
documentation information visit L<https://www.name.com/reseller/API-documentation>.
API::Name is derived from L<API::Client> and inherits all of it's
functionality. Please read the documentation for API::Client for more usage
information.
=head1 ATTRIBUTES
=head2 token
$name->token;
$name->token('TOKEN');
lib/API/Name.pm view on Meta::CPAN
$name->identifier('IDENTIFIER');
The identifier attribute should be set to a string that identifies your
application.
=head2 debug
$name->debug;
$name->debug(1);
The debug attribute if true prints HTTP requests and responses to standard out.
=head2 fatal
$name->fatal;
$name->fatal(1);
The fatal attribute if true promotes 4xx and 5xx server response codes to
exceptions, a L<API::Client::Exception> object.
=head2 retries
$name->retries;
$name->retries(10);
The retries attribute determines how many times an HTTP request should be
retried if a 4xx or 5xx response is received. This attribute defaults to 0.
=head2 timeout
$name->timeout;
$name->timeout(5);
The timeout attribute determines how long an HTTP connection should be kept
alive. This attribute defaults to 10.
=head2 url
lib/API/Name.pm view on Meta::CPAN
$name->user_agent;
$name->user_agent(Mojo::UserAgent->new);
The user_agent attribute set the pre-configured UserAgent object that will be
used in all HTTP requests. This attribute expects a L<Mojo::UserAgent> object.
=head1 METHODS
=head2 action
my $result = $name->action($verb, %args);
# e.g.
$name->action('head', %args); # HEAD request
$name->action('options', %args); # OPTIONS request
$name->action('patch', %args); # PATCH request
The action method issues a request to the API resource represented by the
object. The first parameter will be used as the HTTP request method. The
arguments, expected to be a list of key/value pairs, will be included in the
request if the key is either C<data> or C<query>.
=head2 create
my $results = $name->create(%args);
# or
$name->POST(%args);
The create method issues a C<POST> request to the API resource represented by
the object. The arguments, expected to be a list of key/value pairs, will be
included in the request if the key is either C<data> or C<query>.
=head2 delete
my $results = $name->delete(%args);
# or
$name->DELETE(%args);
The delete method issues a C<DELETE> request to the API resource represented by
the object. The arguments, expected to be a list of key/value pairs, will be
included in the request if the key is either C<data> or C<query>.
=head2 fetch
my $results = $name->fetch(%args);
# or
$name->GET(%args);
The fetch method issues a C<GET> request to the API resource represented by the
object. The arguments, expected to be a list of key/value pairs, will be
included in the request if the key is either C<data> or C<query>.
=head2 update
my $results = $name->update(%args);
# or
$name->PUT(%args);
The update method issues a C<PUT> request to the API resource represented by
the object. The arguments, expected to be a list of key/value pairs, will be
included in the request if the key is either C<data> or C<query>.
=head1 RESOURCES
=head2 account
$name->account;
The account method returns a new instance representative of the API
I<account> resource requested. This method accepts a list of path
segments which will be used in the HTTP request. The following documentation
can be used to find more information. L<https://www.name.com/reseller/API-documentation>.
=head2 dns
$name->dns;
The dns method returns a new instance representative of the API
I<dns> resource requested. This method accepts a list of path
segments which will be used in the HTTP request. The following documentation
can be used to find more information. L<https://www.name.com/reseller/API-documentation>.
=head2 domain
$name->domain;
The domain method returns a new instance representative of the API
I<domain> resource requested. This method accepts a list of path
segments which will be used in the HTTP request. The following documentation
can be used to find more information. L<https://www.name.com/reseller/API-documentation>.
=head2 host
$name->host;
The host method returns a new instance representative of the API
I<host> resource requested. This method accepts a list of path
segments which will be used in the HTTP request. The following documentation
can be used to find more information. L<https://www.name.com/reseller/API-documentation>.
=head2 login
$name->login;
The login method returns a new instance representative of the API
I<login> resource requested. This method accepts a list of path
segments which will be used in the HTTP request. The following documentation
can be used to find more information. L<https://www.name.com/reseller/API-documentation>.
=head2 logout
$name->logout;
The logout method returns a new instance representative of the API
I<logout> resource requested. This method accepts a list of path
segments which will be used in the HTTP request. The following documentation
can be used to find more information. L<https://www.name.com/reseller/API-documentation>.
=head2 order
$name->order;
The order method returns a new instance representative of the API
I<order> resource requested. This method accepts a list of path
segments which will be used in the HTTP request. The following documentation
can be used to find more information. L<https://www.name.com/reseller/API-documentation>.
=head1 AUTHOR
Al Newkirk <anewkirk@ana.io>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Al Newkirk.
This is free software; you can redistribute it and/or modify it under
( run in 0.965 second using v1.01-cache-2.11-cpan-49f99fa48dc )