Codebase list libcloudflare-client-perl / upstream/latest
Import original source of CloudFlare-Client 0.55.4 Florian Schlichting 5 years ago
41 changed file(s) with 1992 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 Revision history for CloudFlare-Client
1
2 v0.55.4 2016-03-26
3 - tweaks
4 - fix commit message
5 - test all the perls in Travis
6 - change weaver.ini to work with changes to Test::Synopsis
7
8 v0.55.3 2015-05-01
9 - really fix auto tagging...
10
11 v0.55.2 2015-04-30
12 - fix auto git tagging on release
13
14 v0.55.1 2015-04-30
15 - switch to a V-string
16
17 0.05_5 2015-04-27
18 - use docker containers in TravisCI
19 - update test targets in TravisCI
20 - start providing a cpanfile
21 - BREAKING: switch to AUTOLOAD dispatch with all arguments as a hash
22 - tidy code into my latest coding style
23 - no longer clean up pre-reqs list
24
25 0.05_4 2015-02-07
26 - Change release tag format and travis stuff
27 - Test::RequiresInternet for upstream existence check
28 - Handle test dependencies better
29
30 0.05_3 2015-02-06
31 - Optimise "feature" usages
32 - Add build branch
33 - JSON::Any is deprecated, use JSON::MaybeXS instead
34
35 0.05_2 2015-02-05
36 - Drop auto date based prereq versions
37 - Add TravisCI testing
38 - Improve tests
39 - Make all POD weaved
40 - Rework dist.ini
41 - Remove vestigial bovine
42
43 0.05_1 2015-02-03
44 - Bump to more modern Perl (5.16)
45 - Don't load unneeded dzil modules
46 - Use ::Git::GatherDir
47 - Move to GitHub
48 - Fix cpan testers failure
49 - bits and bobs
50 - Update repo info - git repo split
51
52 0.04 2014-08-26
53 - Bump to stable
54
55 0.03_9 2014-08-18
56 - Reinstate more liberal dep pruning
57 - Trim more cruft from pod
58 - Add homepage to meta
59 - Add no indirect 'fatal'
60 - Add git meta correctly
61
62 0.03_8 2014-08-17
63 - Make upstream test an author test and remove guards
64 - Tidy imports
65 - Immutiblise
66
67 0.03_7 2014-08-16
68 - Moo -> Moose because CPAN tests are still failing
69
70 0.03_6 2014-08-15
71 - Moo::Lax -> Moo because CPAN tests are still failing
72
73 0.03_5 2014-08-15
74 - Unloosen dependency removal to see if it stops CPAN tests exploding
75
76 0.03_4 2014-08-14
77 - No longer depend on Test::Moose or Moose
78 - Use Moo::Lax in tests
79
80 0.03_3 2014-08-13
81 - Loosen dependancy removal during builds to try and group more
82 - Require newer Type::Utils because of a bug
83 - Moo::Lax because we don't want fatal warnings
84
85 0.03_2 2014-08-12
86 - Try to improve upstream test for CPAN testers
87 - Tidy code a bit
88 - Port to Moo
89 - Port to use Type::Tiny
90
91 0.03_1 2014-08-08
92 - Fix some exception tests on older Mooses by actually escaping brackets in
93 regexes, should make Strawberry Perl happier
94 - Try harder to test for HTTPS connectivity when testing upstream existence
95 and make sure it is required for install
96 - Method::Signatures -> Kavorka
97 - Tidy distribution a bit
98
99 0.03_0 2014-08-02
100 - Improve compatibility, in particular testing, for CPAN Testers
101 - Tidy code a bit
102
103 0.03 2014-07-31
104 - Add a test for upstream connectivity that won't break on CPAN testers
105 - Perl requirement dropped to 5.014
106 - Tidy code and make it more robust
107 - Extensive testing of the API using Test::LWP::UserAgent
108 - Require at least one zone as an argument to zoneCheck
109 - Use Test::Exception rather than own stuff
110 - Get rid of upstream testing, they fail at CPAN Testers
111
112 0.02 2014-07-16
113 - Fix issues that prevent CPAN indexing
114 - Package with Dist::Zilla
115
116 0.01 2014-07-10
117 - First version, released on an unsuspecting world.
0 This is the Perl distribution CloudFlare-Client.
1
2 Installing CloudFlare-Client is straightforward.
3
4 ## Installation with cpanm
5
6 If you have cpanm, you only need one line:
7
8 % cpanm CloudFlare::Client
9
10 If you are installing into a system-wide directory, you may need to pass the
11 "-S" flag to cpanm, which uses sudo to install the module:
12
13 % cpanm -S CloudFlare::Client
14
15 ## Installing with the CPAN shell
16
17 Alternatively, if your CPAN shell is set up, you should just be able to do:
18
19 % cpan CloudFlare::Client
20
21 ## Manual installation
22
23 As a last resort, you can manually install it. Download the tarball, untar it,
24 then build it:
25
26 % perl Makefile.PL
27 % make && make test
28
29 Then install it:
30
31 % make install
32
33 If you are installing into a system-wide directory, you may need to run:
34
35 % sudo make install
36
37 ## Documentation
38
39 CloudFlare-Client documentation is available as POD.
40 You can run perldoc from a shell to read the documentation:
41
42 % perldoc CloudFlare::Client
0 This software is Copyright (c) 2016 by Peter Roberts.
1
2 This is free software, licensed under:
3
4 The MIT (X11) License
5
6 The MIT License
7
8 Permission is hereby granted, free of charge, to any person
9 obtaining a copy of this software and associated
10 documentation files (the "Software"), to deal in the Software
11 without restriction, including without limitation the rights to
12 use, copy, modify, merge, publish, distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to
14 whom the Software is furnished to do so, subject to the
15 following conditions:
16
17 The above copyright notice and this permission notice shall
18 be included in all copies or substantial portions of the
19 Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT
22 WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 PURPOSE AND NONINFRINGEMENT. IN NO EVENT
26 SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
29 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 CONNECTION WITH THE SOFTWARE OR THE USE OR
31 OTHER DEALINGS IN THE SOFTWARE.
0 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.043.
1 Changes
2 INSTALL
3 LICENSE
4 MANIFEST
5 META.json
6 META.yml
7 Makefile.PL
8 README
9 cpanfile
10 lib/CloudFlare/Client.pm
11 lib/CloudFlare/Client/Exception/Connection.pm
12 lib/CloudFlare/Client/Exception/Upstream.pm
13 lib/CloudFlare/Client/Types.pm
14 t/00-compile.t
15 t/01-Exception-Connection.t
16 t/01-Exception-Upstream.t
17 t/01-Types.t
18 t/01-failure-connecting.t
19 t/01-failure-upstream.t
20 t/01-main.t
21 t/01-success.t
22 t/author-01-upstream-existence.t
23 t/author-clean-namespaces.t
24 t/author-critic.t
25 t/author-eol.t
26 t/author-mojibake.t
27 t/author-no-tabs.t
28 t/author-pod-coverage.t
29 t/author-pod-syntax.t
30 t/author-test-version.t
31 t/release-cpan-changes.t
32 t/release-dist-manifest.t
33 t/release-distmeta.t
34 t/release-fixme.t
35 t/release-kwalitee.t
36 t/release-meta-json.t
37 t/release-minimum-version.t
38 t/release-pod-linkcheck.t
39 t/release-portability.t
40 t/release-synopsis.t
41 t/release-unused-vars.t
0 {
1 "abstract" : "Object Orientated Interface to CloudFlare client API",
2 "author" : [
3 "Peter Roberts <me+dev@peter-r.co.uk>"
4 ],
5 "dynamic_config" : 0,
6 "generated_by" : "Dist::Zilla version 5.043, CPAN::Meta::Converter version 2.150005",
7 "license" : [
8 "mit"
9 ],
10 "meta-spec" : {
11 "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
12 "version" : 2
13 },
14 "name" : "CloudFlare-Client",
15 "prereqs" : {
16 "configure" : {
17 "requires" : {
18 "ExtUtils::MakeMaker" : "0"
19 }
20 },
21 "develop" : {
22 "requires" : {
23 "Pod::Coverage::TrustPod" : "0",
24 "Test::CPAN::Changes" : "0.19",
25 "Test::CPAN::Meta" : "0",
26 "Test::CPAN::Meta::JSON" : "0.16",
27 "Test::CleanNamespaces" : "0.15",
28 "Test::EOL" : "0",
29 "Test::Kwalitee" : "1.21",
30 "Test::Mojibake" : "0",
31 "Test::More" : "0.88",
32 "Test::NoTabs" : "0",
33 "Test::Pod" : "1.41",
34 "Test::Pod::Coverage" : "1.08",
35 "Test::Pod::LinkCheck" : "0",
36 "Test::Synopsis" : "0",
37 "Test::Version" : "1"
38 }
39 },
40 "runtime" : {
41 "requires" : {
42 "JSON::MaybeXS" : "0",
43 "Kavorka" : "0",
44 "LWP::Protocol::https" : "6.02",
45 "LWP::UserAgent" : "6.02",
46 "Moose" : "0",
47 "MooseX::StrictConstructor" : "0",
48 "Readonly" : "0",
49 "Throwable::Error" : "0",
50 "Type::Library" : "0",
51 "Type::Utils" : "0.039_12",
52 "Types::Standard" : "0",
53 "indirect" : "0",
54 "mro" : "0",
55 "namespace::autoclean" : "0",
56 "perl" : "5.014",
57 "strict" : "0",
58 "warnings" : "0"
59 }
60 },
61 "test" : {
62 "requires" : {
63 "File::Spec" : "0",
64 "HTTP::Response" : "0",
65 "IO::Handle" : "0",
66 "IPC::Open3" : "0",
67 "IPC::System::Simple" : "0",
68 "JSON::Any" : "0",
69 "Test::CPAN::Meta::JSON" : "0",
70 "Test::Exception" : "0",
71 "Test::LWP::UserAgent" : "0",
72 "Test::Moose" : "0",
73 "Test::More" : "0",
74 "Test::RequiresInternet" : "0",
75 "Test::TypeTiny" : "0",
76 "Try::Tiny" : "0",
77 "blib" : "1.01"
78 }
79 }
80 },
81 "provides" : {
82 "CloudFlare::Client" : {
83 "file" : "lib/CloudFlare/Client.pm",
84 "version" : "v0.55.4"
85 },
86 "CloudFlare::Client::Exception::Connection" : {
87 "file" : "lib/CloudFlare/Client/Exception/Connection.pm",
88 "version" : "v0.55.4"
89 },
90 "CloudFlare::Client::Exception::Upstream" : {
91 "file" : "lib/CloudFlare/Client/Exception/Upstream.pm",
92 "version" : "v0.55.4"
93 },
94 "CloudFlare::Client::Types" : {
95 "file" : "lib/CloudFlare/Client/Types.pm",
96 "version" : "v0.55.4"
97 }
98 },
99 "release_status" : "stable",
100 "resources" : {
101 "bugtracker" : {
102 "web" : "https://github.com/pwr22/cloudflare-client/issues"
103 },
104 "homepage" : "https://metacpan.org/pod/CloudFlare::Client",
105 "repository" : {
106 "type" : "git",
107 "url" : "git://github.com/pwr22/cloudflare-client.git",
108 "web" : "https://github.com/pwr22/cloudflare-client"
109 }
110 },
111 "version" : "v0.55.4",
112 "x_contributors" : [
113 "Peter Roberts <me+github@peter-r.co.uk>"
114 ]
115 }
116
0 ---
1 abstract: 'Object Orientated Interface to CloudFlare client API'
2 author:
3 - 'Peter Roberts <me+dev@peter-r.co.uk>'
4 build_requires:
5 File::Spec: '0'
6 HTTP::Response: '0'
7 IO::Handle: '0'
8 IPC::Open3: '0'
9 IPC::System::Simple: '0'
10 JSON::Any: '0'
11 Test::CPAN::Meta::JSON: '0'
12 Test::Exception: '0'
13 Test::LWP::UserAgent: '0'
14 Test::Moose: '0'
15 Test::More: '0'
16 Test::RequiresInternet: '0'
17 Test::TypeTiny: '0'
18 Try::Tiny: '0'
19 blib: '1.01'
20 configure_requires:
21 ExtUtils::MakeMaker: '0'
22 dynamic_config: 0
23 generated_by: 'Dist::Zilla version 5.043, CPAN::Meta::Converter version 2.150005'
24 license: mit
25 meta-spec:
26 url: http://module-build.sourceforge.net/META-spec-v1.4.html
27 version: '1.4'
28 name: CloudFlare-Client
29 provides:
30 CloudFlare::Client:
31 file: lib/CloudFlare/Client.pm
32 version: v0.55.4
33 CloudFlare::Client::Exception::Connection:
34 file: lib/CloudFlare/Client/Exception/Connection.pm
35 version: v0.55.4
36 CloudFlare::Client::Exception::Upstream:
37 file: lib/CloudFlare/Client/Exception/Upstream.pm
38 version: v0.55.4
39 CloudFlare::Client::Types:
40 file: lib/CloudFlare/Client/Types.pm
41 version: v0.55.4
42 requires:
43 JSON::MaybeXS: '0'
44 Kavorka: '0'
45 LWP::Protocol::https: '6.02'
46 LWP::UserAgent: '6.02'
47 Moose: '0'
48 MooseX::StrictConstructor: '0'
49 Readonly: '0'
50 Throwable::Error: '0'
51 Type::Library: '0'
52 Type::Utils: 0.039_12
53 Types::Standard: '0'
54 indirect: '0'
55 mro: '0'
56 namespace::autoclean: '0'
57 perl: '5.014'
58 strict: '0'
59 warnings: '0'
60 resources:
61 bugtracker: https://github.com/pwr22/cloudflare-client/issues
62 homepage: https://metacpan.org/pod/CloudFlare::Client
63 repository: git://github.com/pwr22/cloudflare-client.git
64 version: v0.55.4
65 x_contributors:
66 - 'Peter Roberts <me+github@peter-r.co.uk>'
0 # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.043.
1 use strict;
2 use warnings;
3
4 use 5.014;
5
6 use ExtUtils::MakeMaker;
7
8 my %WriteMakefileArgs = (
9 "ABSTRACT" => "Object Orientated Interface to CloudFlare client API",
10 "AUTHOR" => "Peter Roberts <me+dev\@peter-r.co.uk>",
11 "CONFIGURE_REQUIRES" => {
12 "ExtUtils::MakeMaker" => 0
13 },
14 "DISTNAME" => "CloudFlare-Client",
15 "LICENSE" => "mit",
16 "MIN_PERL_VERSION" => "5.014",
17 "NAME" => "CloudFlare::Client",
18 "PREREQ_PM" => {
19 "JSON::MaybeXS" => 0,
20 "Kavorka" => 0,
21 "LWP::Protocol::https" => "6.02",
22 "LWP::UserAgent" => "6.02",
23 "Moose" => 0,
24 "MooseX::StrictConstructor" => 0,
25 "Readonly" => 0,
26 "Throwable::Error" => 0,
27 "Type::Library" => 0,
28 "Type::Utils" => "0.039_12",
29 "Types::Standard" => 0,
30 "indirect" => 0,
31 "mro" => 0,
32 "namespace::autoclean" => 0,
33 "strict" => 0,
34 "warnings" => 0
35 },
36 "TEST_REQUIRES" => {
37 "File::Spec" => 0,
38 "HTTP::Response" => 0,
39 "IO::Handle" => 0,
40 "IPC::Open3" => 0,
41 "IPC::System::Simple" => 0,
42 "JSON::Any" => 0,
43 "Test::CPAN::Meta::JSON" => 0,
44 "Test::Exception" => 0,
45 "Test::LWP::UserAgent" => 0,
46 "Test::Moose" => 0,
47 "Test::More" => 0,
48 "Test::RequiresInternet" => 0,
49 "Test::TypeTiny" => 0,
50 "Try::Tiny" => 0,
51 "blib" => "1.01"
52 },
53 "VERSION" => "v0.55.4",
54 "test" => {
55 "TESTS" => "t/*.t"
56 }
57 );
58
59
60 my %FallbackPrereqs = (
61 "File::Spec" => 0,
62 "HTTP::Response" => 0,
63 "IO::Handle" => 0,
64 "IPC::Open3" => 0,
65 "IPC::System::Simple" => 0,
66 "JSON::Any" => 0,
67 "JSON::MaybeXS" => 0,
68 "Kavorka" => 0,
69 "LWP::Protocol::https" => "6.02",
70 "LWP::UserAgent" => "6.02",
71 "Moose" => 0,
72 "MooseX::StrictConstructor" => 0,
73 "Readonly" => 0,
74 "Test::CPAN::Meta::JSON" => 0,
75 "Test::Exception" => 0,
76 "Test::LWP::UserAgent" => 0,
77 "Test::Moose" => 0,
78 "Test::More" => 0,
79 "Test::RequiresInternet" => 0,
80 "Test::TypeTiny" => 0,
81 "Throwable::Error" => 0,
82 "Try::Tiny" => 0,
83 "Type::Library" => 0,
84 "Type::Utils" => "0.039_12",
85 "Types::Standard" => 0,
86 "blib" => "1.01",
87 "indirect" => 0,
88 "mro" => 0,
89 "namespace::autoclean" => 0,
90 "strict" => 0,
91 "warnings" => 0
92 );
93
94
95 unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
96 delete $WriteMakefileArgs{TEST_REQUIRES};
97 delete $WriteMakefileArgs{BUILD_REQUIRES};
98 $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
99 }
100
101 delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
102 unless eval { ExtUtils::MakeMaker->VERSION(6.52) };
103
104 WriteMakefile(%WriteMakefileArgs);
0
1
2 This archive contains the distribution CloudFlare-Client,
3 version v0.55.4:
4
5 Object Orientated Interface to CloudFlare client API
6
7 This software is Copyright (c) 2016 by Peter Roberts.
8
9 This is free software, licensed under:
10
11 The MIT (X11) License
12
13
14 This README file was generated by Dist::Zilla::Plugin::Readme v5.043.
15
0 requires "JSON::MaybeXS" => "0";
1 requires "Kavorka" => "0";
2 requires "LWP::Protocol::https" => "6.02";
3 requires "LWP::UserAgent" => "6.02";
4 requires "Moose" => "0";
5 requires "MooseX::StrictConstructor" => "0";
6 requires "Readonly" => "0";
7 requires "Throwable::Error" => "0";
8 requires "Type::Library" => "0";
9 requires "Type::Utils" => "0.039_12";
10 requires "Types::Standard" => "0";
11 requires "indirect" => "0";
12 requires "mro" => "0";
13 requires "namespace::autoclean" => "0";
14 requires "perl" => "5.014";
15 requires "strict" => "0";
16 requires "warnings" => "0";
17
18 on 'test' => sub {
19 requires "File::Spec" => "0";
20 requires "HTTP::Response" => "0";
21 requires "IO::Handle" => "0";
22 requires "IPC::Open3" => "0";
23 requires "IPC::System::Simple" => "0";
24 requires "JSON::Any" => "0";
25 requires "Test::CPAN::Meta::JSON" => "0";
26 requires "Test::Exception" => "0";
27 requires "Test::LWP::UserAgent" => "0";
28 requires "Test::Moose" => "0";
29 requires "Test::More" => "0";
30 requires "Test::RequiresInternet" => "0";
31 requires "Test::TypeTiny" => "0";
32 requires "Try::Tiny" => "0";
33 requires "blib" => "1.01";
34 };
35
36 on 'configure' => sub {
37 requires "ExtUtils::MakeMaker" => "0";
38 };
39
40 on 'develop' => sub {
41 requires "Pod::Coverage::TrustPod" => "0";
42 requires "Test::CPAN::Changes" => "0.19";
43 requires "Test::CPAN::Meta" => "0";
44 requires "Test::CPAN::Meta::JSON" => "0.16";
45 requires "Test::CleanNamespaces" => "0.15";
46 requires "Test::EOL" => "0";
47 requires "Test::Kwalitee" => "1.21";
48 requires "Test::Mojibake" => "0";
49 requires "Test::More" => "0.88";
50 requires "Test::NoTabs" => "0";
51 requires "Test::Pod" => "1.41";
52 requires "Test::Pod::Coverage" => "1.08";
53 requires "Test::Pod::LinkCheck" => "0";
54 requires "Test::Synopsis" => "0";
55 requires "Test::Version" => "1";
56 };
0 package CloudFlare::Client::Exception::Connection;
1 # ABSTRACT: CloudFlare API Connection Exception
2
3 use strict; use warnings; no indirect 'fatal'; use namespace::autoclean;
4 use mro 'c3';
5
6 use Readonly;
7 use Moose; use MooseX::StrictConstructor;
8 use Types::Standard 'Str';
9
10 our $VERSION = 'v0.55.4'; # VERSION
11
12 extends 'Throwable::Error';
13
14 has status => (
15 is => 'ro',
16 isa => Str,
17 required => 1,);
18
19 __PACKAGE__->meta->make_immutable;
20 1; # End of CloudFlare::Client::Exception::Connection
21
22 __END__
23
24 =pod
25
26 =encoding UTF-8
27
28 =head1 NAME
29
30 CloudFlare::Client::Exception::Connection - CloudFlare API Connection Exception
31
32 =head1 VERSION
33
34 version v0.55.4
35
36 =head1 SYNOPSIS
37
38 use CloudFlare::Client::Exception::Connection;
39
40 CloudFlare::Client::Exception::Connection::->throw(
41 message => 'HTTPS connection failure',
42 status => '404',
43 );
44
45 my $e = CloudFlare::Client::Exception::Connection::->new(
46 message => 'HTTPS connection failure',
47 status => '404',
48 );
49 $e->throw;
50
51 =head1 ATTRIBUTES
52
53 =head2 message
54
55 The error message thrown upstream, readonly
56
57 =head2 status
58
59 The status code for the connection failure, readonly
60
61 =head1 METHODS
62
63 =head2 throw
64
65 On the class, throw a new exception
66
67 CloudFlare::Client::Exception::Connection::->throw(
68 message => 'HTTPS connection failure',
69 status => '404',
70 );
71 ...
72
73 On an instance, throw that exception
74
75 $e->throw;
76
77 =head2 new
78
79 Construct a new exception
80
81 my $e = CloudFlare::Client::Exception::Connection::->throw(
82 message => 'HTTPS connection failure',
83 errorcode => '404',
84 );
85
86 =head1 SEE ALSO
87
88 Please see those modules/websites for more information related to this module.
89
90 =over 4
91
92 =item *
93
94 L<CloudFlare::Client|CloudFlare::Client>
95
96 =back
97
98 =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
99
100 =head1 SUPPORT
101
102 =head2 Perldoc
103
104 You can find documentation for this module with the perldoc command.
105
106 perldoc CloudFlare::Client
107
108 =head2 Websites
109
110 The following websites have more information about this module, and may be of help to you. As always,
111 in addition to those websites please use your favorite search engine to discover more resources.
112
113 =over 4
114
115 =item *
116
117 MetaCPAN
118
119 A modern, open-source CPAN search engine, useful to view POD in HTML format.
120
121 L<http://metacpan.org/release/CloudFlare-Client>
122
123 =back
124
125 =head2 Email
126
127 You can email the author of this module at C<me+dev@peter-r.co.uk> asking for help with any problems you have.
128
129 =head2 Source Code
130
131 The code is open to the world, and available for you to hack on. Please feel free to browse it and play
132 with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
133 from your repository :)
134
135 L<https://github.com/pwr22/cloudflare-client>
136
137 git clone git://github.com/pwr22/cloudflare-client.git
138
139 =head1 BUGS
140
141 Please report any bugs or feature requests on the bugtracker website
142 https://github.com/pwr22/cloudflare-client/issues
143
144 When submitting a bug or request, please include a test-file or a
145 patch to an existing test-file that illustrates the bug or desired
146 feature.
147
148 =head1 AUTHOR
149
150 Peter Roberts <me+dev@peter-r.co.uk>
151
152 =head1 COPYRIGHT AND LICENSE
153
154 This software is Copyright (c) 2016 by Peter Roberts.
155
156 This is free software, licensed under:
157
158 The MIT (X11) License
159
160 =cut
0 package CloudFlare::Client::Exception::Upstream;
1 # ABSTRACT: Upstream CloudFlare API Exception
2
3 use strict; use warnings; no indirect 'FATAL'; use namespace::autoclean;
4 use mro 'c3';
5
6 use Readonly;
7 use Moose; use MooseX::StrictConstructor;
8 use CloudFlare::Client::Types 'ErrorCode';
9
10 our $VERSION = 'v0.55.4'; # VERSION
11
12 extends 'Throwable::Error';
13
14 has errorCode => (
15 is => 'ro',
16 isa => ErrorCode,);
17
18 __PACKAGE__->meta->make_immutable;
19 1; # End of CloudFlare::Client::Exception::Upstream
20
21 __END__
22
23 =pod
24
25 =encoding UTF-8
26
27 =head1 NAME
28
29 CloudFlare::Client::Exception::Upstream - Upstream CloudFlare API Exception
30
31 =head1 VERSION
32
33 version v0.55.4
34
35 =head1 SYNOPSIS
36
37 use CloudFlare::Client::Exception::Upstream;
38
39 CloudFlare::Client::Exception::Upstream::->throw(
40 message => 'Bad things occured',
41 errorCode => 'E_MAXAPI',
42 );
43
44 my $e = CloudFlare::Client::Exception::Upstream::->new(
45 message => 'Bad things happened',
46 errorcode => 'E_MAXAPI',
47 );
48 $e->throw;
49
50 =head1 ATTRIBUTES
51
52 =head2 message
53
54 The error message thrown upstream, readonly
55
56 =head2 errorCode
57
58 The error code thrown upstream, readonly. Valid values are undef,
59 E_UNAUTH, E_INVLDINPUT or E_MAXAPI. Readonly
60
61 =head1 METHODS
62
63 =head2 throw
64
65 On the class, throw a new exception
66
67 CloudFlare::Client::Exception::Upstream::->throw(
68 message => 'Bad things occured',
69 errorCode => 'E_MAXAPI',
70 );
71 ...
72
73 On an instance, throw that exception
74
75 $e->throw;
76
77 =head2 new
78
79 Construct a new exception
80
81 my $e = CloudFlare::Client::Exception::Upstream::->new(
82 message => 'Bad things happened',
83 errorcode => 'E_MAXAPI',
84 );
85
86 =head1 SEE ALSO
87
88 Please see those modules/websites for more information related to this module.
89
90 =over 4
91
92 =item *
93
94 L<CloudFlare::Client|CloudFlare::Client>
95
96 =back
97
98 =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
99
100 =head1 SUPPORT
101
102 =head2 Perldoc
103
104 You can find documentation for this module with the perldoc command.
105
106 perldoc CloudFlare::Client
107
108 =head2 Websites
109
110 The following websites have more information about this module, and may be of help to you. As always,
111 in addition to those websites please use your favorite search engine to discover more resources.
112
113 =over 4
114
115 =item *
116
117 MetaCPAN
118
119 A modern, open-source CPAN search engine, useful to view POD in HTML format.
120
121 L<http://metacpan.org/release/CloudFlare-Client>
122
123 =back
124
125 =head2 Email
126
127 You can email the author of this module at C<me+dev@peter-r.co.uk> asking for help with any problems you have.
128
129 =head2 Source Code
130
131 The code is open to the world, and available for you to hack on. Please feel free to browse it and play
132 with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
133 from your repository :)
134
135 L<https://github.com/pwr22/cloudflare-client>
136
137 git clone git://github.com/pwr22/cloudflare-client.git
138
139 =head1 BUGS
140
141 Please report any bugs or feature requests on the bugtracker website
142 https://github.com/pwr22/cloudflare-client/issues
143
144 When submitting a bug or request, please include a test-file or a
145 patch to an existing test-file that illustrates the bug or desired
146 feature.
147
148 =head1 AUTHOR
149
150 Peter Roberts <me+dev@peter-r.co.uk>
151
152 =head1 COPYRIGHT AND LICENSE
153
154 This software is Copyright (c) 2016 by Peter Roberts.
155
156 This is free software, licensed under:
157
158 The MIT (X11) License
159
160 =cut
0 package CloudFlare::Client::Types;
1 # ABSTRACT: Types for Cloudflare::Client
2
3 use strict; use warnings; no indirect 'fatal'; use namespace::autoclean;
4
5 use Type::Library -base, -declare => qw( CFCode ErrorCode);
6 # Theres a bug about using undef as a hashref before this version
7 use Type::Utils 0.039_12 -all;
8 use Types::Standard qw( Enum Maybe);
9 use Readonly;
10
11 our $VERSION = 'v0.55.4'; # VERSION
12
13 class_type 'LWP::UserAgent';
14 declare CFCode, as Enum[qw( E_UNAUTH E_INVLDINPUT E_MAXAPI)];
15 declare ErrorCode, as Maybe[CFCode];
16
17 1; # End of CloudFlare::Client::Types
18
19 __END__
20
21 =pod
22
23 =encoding UTF-8
24
25 =head1 NAME
26
27 CloudFlare::Client::Types - Types for Cloudflare::Client
28
29 =head1 VERSION
30
31 version v0.55.4
32
33 =head1 SYNOPSIS
34
35 use CloudFlare::Client::Types 'ErrorCode';
36
37 =head1 SEE ALSO
38
39 Please see those modules/websites for more information related to this module.
40
41 =over 4
42
43 =item *
44
45 L<CloudFlare::Client|CloudFlare::Client>
46
47 =back
48
49 =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
50
51 =head1 SUPPORT
52
53 =head2 Perldoc
54
55 You can find documentation for this module with the perldoc command.
56
57 perldoc CloudFlare::Client
58
59 =head2 Websites
60
61 The following websites have more information about this module, and may be of help to you. As always,
62 in addition to those websites please use your favorite search engine to discover more resources.
63
64 =over 4
65
66 =item *
67
68 MetaCPAN
69
70 A modern, open-source CPAN search engine, useful to view POD in HTML format.
71
72 L<http://metacpan.org/release/CloudFlare-Client>
73
74 =back
75
76 =head2 Email
77
78 You can email the author of this module at C<me+dev@peter-r.co.uk> asking for help with any problems you have.
79
80 =head2 Source Code
81
82 The code is open to the world, and available for you to hack on. Please feel free to browse it and play
83 with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
84 from your repository :)
85
86 L<https://github.com/pwr22/cloudflare-client>
87
88 git clone git://github.com/pwr22/cloudflare-client.git
89
90 =head1 BUGS
91
92 Please report any bugs or feature requests on the bugtracker website
93 https://github.com/pwr22/cloudflare-client/issues
94
95 When submitting a bug or request, please include a test-file or a
96 patch to an existing test-file that illustrates the bug or desired
97 feature.
98
99 =head1 AUTHOR
100
101 Peter Roberts <me+dev@peter-r.co.uk>
102
103 =head1 COPYRIGHT AND LICENSE
104
105 This software is Copyright (c) 2016 by Peter Roberts.
106
107 This is free software, licensed under:
108
109 The MIT (X11) License
110
111 =cut
0 package CloudFlare::Client;
1 # ABSTRACT: Object Orientated Interface to CloudFlare client API
2
3 # Or Kavorka will explode
4 use 5.014;
5 use strict; use warnings; no indirect 'fatal'; use namespace::autoclean;
6 use mro 'c3';
7
8 use Readonly;
9 use Moose; use MooseX::StrictConstructor;
10 use Types::Standard 'Str';
11 use CloudFlare::Client::Types 'LWPUserAgent';
12 use Kavorka;
13
14 use CloudFlare::Client::Exception::Connection;
15 use CloudFlare::Client::Exception::Upstream;
16 use LWP::UserAgent 6.02;
17 # This isn't used directly but we want the dependency
18 use LWP::Protocol::https 6.02;
19 use JSON::MaybeXS;
20
21 our $VERSION = 'v0.55.4'; # VERSION
22
23 # CF credentials
24 has '_user' => (
25 is => 'ro',
26 isa => Str,
27 required => 1,
28 init_arg => 'user',);
29 has '_key' => (
30 is => 'ro',
31 isa => Str,
32 required => 1,
33 init_arg => 'apikey',);
34
35 Readonly my $UA_STRING => "CloudFlare::Client/$CloudFlare::Client::VERSION";
36 sub _buildUa {
37 Readonly my $ua => LWP::UserAgent::->new;
38 $ua->agent($UA_STRING);
39 return $ua;}
40 has '_ua' => (
41 is => 'ro',
42 isa => LWPUserAgent,
43 init_arg => undef,
44 builder => '_buildUa',);
45
46 # Calls through to the CF API, can throw exceptions under ::Exception::
47 Readonly my $CF_URL => 'https://www.cloudflare.com/api_json.html';
48 method _apiCall ( $act is ro, %args is ro ) {
49 # query cloudflare
50 Readonly my $res => $self->_ua->post( $CF_URL, {
51 %args,
52 # global args
53 # override user specified
54 tkn => $self->_key,
55 email => $self->_user,
56 a => $act,});
57 # Handle connection errors
58 CloudFlare::Client::Exception::Connection::->throw(
59 status => $res->status_line,
60 message => 'HTTPS request failed',)
61 unless $res->is_success;
62 # Handle errors from CF
63 Readonly my $info => decode_json($res->decoded_content);
64 CloudFlare::Client::Exception::Upstream::->throw(
65 errorCode => $info->{err_code},
66 message => $info->{msg},)
67 unless $info->{result} eq 'success';
68
69 return $info->{response};}
70
71 # all API calls are implemented through autoloading, the action is the method
72 method AUTOLOAD {
73 our $AUTOLOAD;
74 # pull action out of f.q. method name
75 my $act = $AUTOLOAD =~ s/.*:://r;
76 return $self->_apiCall( $act, @_ );}
77
78 __PACKAGE__->meta->make_immutable;
79 1; # End of CloudFlare::Client
80
81 __END__
82
83 =pod
84
85 =encoding UTF-8
86
87 =head1 NAME
88
89 CloudFlare::Client - Object Orientated Interface to CloudFlare client API
90
91 =head1 VERSION
92
93 version v0.55.4
94
95 =for test_synopsis my ( $CF_USER, $CF_KEY, $ZONE, $INTERVAL);
96
97 =head1 SYNOPSIS
98
99 use CloudFlare::Client;
100
101 my $api = CloudFlare::Client::->new(
102 user => $CF_USER,
103 apikey => $CF_KEY,);
104 $api->stats( z => $ZONE, interval => $INTERVAL);
105 ...
106
107 =head1 OVERVIEW
108
109 Please see the documentation at
110 L<https://www.cloudflare.com/docs/client-api.html> for information on the
111 CloudFlare client API and its arguments. API actions are mapped to methods of
112 the same name and arguments are passed in as a hash with keys as given in the
113 docs
114
115 Successful API calls return the response section from the upstream JSON
116 API. Failures for whatever reason throw exceptions under the
117 CloudFlare::Client::Exception:: namespace
118
119 =head1 METHODS
120
121 =head2 new
122
123 Construct a new API object
124
125 my $api = CloudFlare::Client::->new(
126 user => $CF_USER,
127 apikey => $CF_KEY);
128
129 =head1 SEE ALSO
130
131 Please see those modules/websites for more information related to this module.
132
133 =over 4
134
135 =item *
136
137 L<Mojo::Cloudflare|Mojo::Cloudflare>
138
139 =item *
140
141 L<WebService::CloudFlare::Host|WebService::CloudFlare::Host>
142
143 =back
144
145 =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
146
147 =head1 SUPPORT
148
149 =head2 Perldoc
150
151 You can find documentation for this module with the perldoc command.
152
153 perldoc CloudFlare::Client
154
155 =head2 Websites
156
157 The following websites have more information about this module, and may be of help to you. As always,
158 in addition to those websites please use your favorite search engine to discover more resources.
159
160 =over 4
161
162 =item *
163
164 MetaCPAN
165
166 A modern, open-source CPAN search engine, useful to view POD in HTML format.
167
168 L<http://metacpan.org/release/CloudFlare-Client>
169
170 =back
171
172 =head2 Email
173
174 You can email the author of this module at C<me+dev@peter-r.co.uk> asking for help with any problems you have.
175
176 =head2 Source Code
177
178 The code is open to the world, and available for you to hack on. Please feel free to browse it and play
179 with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
180 from your repository :)
181
182 L<https://github.com/pwr22/cloudflare-client>
183
184 git clone git://github.com/pwr22/cloudflare-client.git
185
186 =head1 BUGS
187
188 Please report any bugs or feature requests on the bugtracker website
189 https://github.com/pwr22/cloudflare-client/issues
190
191 When submitting a bug or request, please include a test-file or a
192 patch to an existing test-file that illustrates the bug or desired
193 feature.
194
195 =head1 ACKNOWLEDGEMENTS
196
197 Thanks to CloudFlare providing an awesome free service with an API
198
199 =head1 CONTRIBUTOR
200
201 =for stopwords Peter Roberts
202
203 Peter Roberts <me+github@peter-r.co.uk>
204
205 =head1 AUTHOR
206
207 Peter Roberts <me+dev@peter-r.co.uk>
208
209 =head1 COPYRIGHT AND LICENSE
210
211 This software is Copyright (c) 2016 by Peter Roberts.
212
213 This is free software, licensed under:
214
215 The MIT (X11) License
216
217 =cut
0 use 5.006;
1 use strict;
2 use warnings;
3
4 # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.054
5
6 use Test::More;
7
8 plan tests => 4 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
9
10 my @module_files = (
11 'CloudFlare/Client.pm',
12 'CloudFlare/Client/Exception/Connection.pm',
13 'CloudFlare/Client/Exception/Upstream.pm',
14 'CloudFlare/Client/Types.pm'
15 );
16
17
18
19 # no fake home requested
20
21 my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib';
22
23 use File::Spec;
24 use IPC::Open3;
25 use IO::Handle;
26
27 open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!";
28
29 my @warnings;
30 for my $lib (@module_files)
31 {
32 # see L<perlfaq8/How can I capture STDERR from an external command?>
33 my $stderr = IO::Handle->new;
34
35 my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]");
36 binmode $stderr, ':crlf' if $^O eq 'MSWin32';
37 my @_warnings = <$stderr>;
38 waitpid($pid, 0);
39 is($?, 0, "$lib loaded ok");
40
41 shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
42 and not eval { require blib; blib->VERSION('1.01') };
43
44 if (@_warnings)
45 {
46 warn @_warnings;
47 push @warnings, @_warnings;
48 }
49 }
50
51
52
53 is(scalar(@warnings), 0, 'no warnings found')
54 or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING};
55
56
0 #!perl -T
1 use strict; use warnings; no indirect 'fatal'; use namespace::autoclean;
2
3 use Test::More; use Test::Moose; use Test::Exception;
4 use Try::Tiny;
5 use Readonly;
6
7 use CloudFlare::Client::Exception::Connection;
8
9 plan tests => 8;
10
11 # Test for superclass
12 Readonly my $CLASS => 'CloudFlare::Client::Exception::Connection';
13 isa_ok( $CLASS, 'Throwable::Error', 'Class superclass');
14 # Test for status accessor
15 can_ok( $CLASS, 'status');
16 # Tests for moose
17 Readonly my $MSG => 'Doesn\'t Matter';
18 Readonly my $STATUS => '404';
19 meta_ok($CLASS);
20 has_attribute_ok( $CLASS, 'status', 'status attribute');
21 my $e = try { $CLASS->new( message => $MSG, status => $STATUS)};
22 meta_ok($e);
23
24 # Construction
25 # with status
26 lives_and { new_ok( $CLASS => [ message => $MSG, status => $STATUS])}
27 "construction works with status attr";
28 # Missing message attr
29 throws_ok { $CLASS->new(status => $STATUS)}
30 qr/^Attribute \(message\) is required/,
31 'Construction with missing message attr dies';
32 # Extra attr
33 throws_ok { $CLASS->new( message => $MSG, status => $STATUS, extra => 'arg')}
34 qr/^Found unknown attribute\(s\)/,
35 'construction with extra attr throws exception';
0 #!perl -T
1 use strict; use warnings; no indirect 'fatal'; use namespace::autoclean;
2
3 use Readonly;
4 use Test::More;
5 use Test::Exception;
6
7 use CloudFlare::Client::Exception::Upstream;
8
9 plan tests => 7;
10 Readonly my $MSG => 'Doesn\'t Matter';
11
12 # Test for superclass
13 Readonly my $CLASS => 'CloudFlare::Client::Exception::Upstream';
14 isa_ok( $CLASS, 'Throwable::Error', 'Class superclass correct');
15 # Test for errorCode accessor
16 can_ok( $CLASS, 'errorCode');
17
18 # Construction
19 # Valid error code
20 lives_and { new_ok( $CLASS => [ message => $MSG, errorCode => 'E_MAXAPI'])}
21 "construction with valid EC works";
22 # No error code
23 lives_and { new_ok( $CLASS => [ message => $MSG])}
24 "construction with no EC works";
25 # Invalid error code
26 throws_ok { $CLASS->new( message => $MSG, errorCode => 'E_NOTSPECD')}
27 qr/Attribute \(errorCode\) does not pass the type constraint/,
28 'construction with invalid EC fails';
29 # Missing message attr
30 throws_ok { $CLASS->new } qr/Attribute \(message\) is required/,
31 'Construction with missing message attr dies';
32 # Extra attr
33 throws_ok { $CLASS->new(message => $MSG, extra => 'arg')}
34 qr/^Found unknown attribute\(s\)/,
35 'construction with extra attr throws exception';
0 #!perl -T
1 use strict; use warnings; no indirect 'fatal'; use namespace::autoclean;
2
3 use Readonly;
4
5 use Test::More;
6 use Test::TypeTiny;
7 use CloudFlare::Client::Types qw( CFCode ErrorCode);
8
9 plan tests => 9;
10 Readonly my $INVLD_CODE => 'E_NTSPCD';
11 Readonly my @CF_CODES => qw( E_UNAUTH E_INVLDINPUT E_MAXAPI);
12 Readonly my @ERR_CODES => (undef, @CF_CODES);
13
14 # Test CFCode
15 should_pass( $_, CFCode, "$_ is a CFCode") foreach @CF_CODES;
16 should_fail( $INVLD_CODE, CFCode, 'E_NTSPCD is not a CFCode');
17
18 # Test ErrorCode
19 { no warnings 'uninitialized';
20 should_pass($_, ErrorCode, "$_ is a ErrorCode") foreach @ERR_CODES}
21 should_fail( $INVLD_CODE, ErrorCode, 'E_NTSPCD is not an ErrorCode');
0 #!perl -T
1
2 # This file aims to test the failure of an API call when a
3 # connection cannot be made
4 package CloudFlare::Client::Test;
5
6 use strict; use warnings; no indirect 'fatal'; use namespace::autoclean;
7 use mro 'c3';
8
9 use Readonly;
10 use Try::Tiny;
11 use Moose; use MooseX::StrictConstructor;
12
13 use Test::More;
14 use Test::Exception;
15 use Test::LWP::UserAgent;
16
17 plan tests => 1;
18
19 extends 'CloudFlare::Client';
20
21 # Override the real user agent with a mocked one
22 # It will always fail to connect
23 sub _buildUa { Test::LWP::UserAgent::->new }
24 __PACKAGE__->meta->make_immutable;
25
26 # Test upstream failures
27 # Catch potential failure
28 Readonly my $API => try {
29 CloudFlare::Client::Test::->new( user => 'user', apikey => 'KEY')}
30 catch { diag $_ };
31 # Valid values
32 Readonly my $ZONE => 'zone.co.uk';
33 Readonly my $ITRVL => 20;
34 throws_ok { $API->action( z => $ZONE, interval => $ITRVL )}
35 'CloudFlare::Client::Exception::Connection',
36 "methods die with a connection error";
0 #!perl -T
1
2 # This file aims to test the failure of an API call
3 package CloudFlare::Client::Test;
4
5 use strict; use warnings; no indirect 'fatal'; use namespace::autoclean;
6 use mro 'c3';
7
8 use Readonly;
9 use Try::Tiny;
10 use Moose; use MooseX::StrictConstructor;
11
12 use Test::More;
13 use Test::Exception;
14 use Test::LWP::UserAgent;
15 use HTTP::Response;
16 use JSON::Any;
17
18 plan tests => 1;
19
20 extends 'CloudFlare::Client';
21
22 # Build a simple error response
23 # Error code
24 Readonly my $ERR_CODE => 'E_UNAUTH';
25 # Full response content
26 Readonly my $CNT => { result => 'error',
27 err_code => $ERR_CODE,
28 msg => 'something',};
29 # Reponse from server
30 Readonly my $RSP => HTTP::Response::->new(200);
31 $RSP->content(JSON::Any::->objToJson($CNT));
32
33 # Override the real user agent with a mocked one
34 # It will always return the error response $RSP
35 sub _buildUa {
36 Readonly my $ua => Test::LWP::UserAgent::->new;
37 $ua->map_response( qr{www.cloudflare.com/api_json.html}, $RSP);
38 return $ua;}
39 __PACKAGE__->meta->make_immutable;
40
41 # Test upstream failure
42 # Catch potential failure
43 Readonly my $API => try {
44 CloudFlare::Client::Test::->new( user => 'user', apikey => 'KEY')}
45 catch { diag $_ };
46 # Valid values
47 Readonly my $ZONE => 'zone.co.uk';
48 Readonly my $ITRVL => 20;
49 throws_ok { $API->action( z => $ZONE, interval => $ITRVL )}
50 'CloudFlare::Client::Exception::Upstream',
51 "methods die with an invalid response";
0 #!perl -T
1
2 # Aims to test basic usage of CloudFlare::Client
3 use strict; use warnings; no indirect 'fatal'; use namespace::autoclean;
4
5 use Readonly;
6 use Try::Tiny;
7
8 use Test::More; use Test::Moose; use Test::Exception;
9 use CloudFlare::Client;
10
11 plan tests => 9;
12 Readonly my $USER => 'blah';
13 Readonly my $KEY => 'blah';
14
15 # Moose tests
16 Readonly my $CLASS => 'CloudFlare::Client';
17 meta_ok($CLASS);
18 for my $attr (qw/ _user _key _ua/) {
19 has_attribute_ok( $CLASS, $attr)}
20 lives_and { meta_ok( $CLASS->new( user => $USER, apikey => $KEY))}
21 "Instance has meta";
22
23 # Construction
24 lives_and { new_ok($CLASS, [ user => $USER, apikey => $KEY])}
25 "construction with valid credentials works";
26 # Work around Moose versions
27 if($Moose::VERSION >= 2.1101) {
28 # Missing user
29 Readonly my $MISS_ARG_E => 'Moose::Exception::AttributeIsRequired';
30 throws_ok { $CLASS->new( apikey => $KEY) } $MISS_ARG_E,
31 "construction with missing user attribute throws exception";
32 # Missing apikey
33 throws_ok { $CLASS->new( user => $USER) } $MISS_ARG_E,
34 "construction with missing apikey attribute throws exception";
35 # Extra attr
36 throws_ok { $CLASS->new( user => $USER, apikey => $KEY, extra => 'arg')}
37 'Moose::Exception::Legacy',
38 "construction with extra attribute throws exception"}
39 # Old Mooses throw strings
40 else { # Missing message attr
41 throws_ok { $CLASS->new( apikey => $KEY) }
42 qr/^Attribute \(_user\) is required/,
43 'Construction with missing user attr dies';
44 # Missing apikey attr
45 throws_ok { $CLASS->new( user => $USER) }
46 qr/^Attribute \(_key\) is required/,
47 'Construction with missing apikey attr dies';
48 # Extra attr
49 throws_ok { $CLASS->new( user => $USER, apikey => $KEY, extra => 'arg')}
50 qr/^Found unknown attribute\(s\)/,
51 'construction with extra attr throws exception';}
0 #!perl -T
1
2 # This file aims to test the correct functioning of all API calls
3 package CloudFlare::Client::Test;
4
5 use strict; use warnings; use mro 'c3'; use namespace::autoclean;
6
7 use Readonly;
8 use Try::Tiny;
9 use Moose; use MooseX::StrictConstructor;
10
11 use Test::More; use Test::Exception; use Test::LWP::UserAgent;
12 use HTTP::Response;
13 use JSON::Any;
14
15 plan tests => 1;
16
17 extends 'CloudFlare::Client';
18
19 # Build a simple valid response
20 # Response payload
21 Readonly my $RSP_PL => { val => 1};
22 # Full response
23 Readonly my $CNT_DATA => { result => 'success', response => $RSP_PL};
24 # Reponse from server
25 Readonly my $CNT_RSP => HTTP::Response::->new(200);
26 $CNT_RSP->content(JSON::Any::->objToJson($CNT_DATA));
27
28 # Override the real user agent with a mocked one
29 # It will always return the valid response $CNT_RSP
30 sub _buildUa {
31 Readonly my $ua => Test::LWP::UserAgent::->new;
32 $ua->map_response( qr{www.cloudflare.com/api_json.html},
33 $CNT_RSP);
34 return $ua;}
35 __PACKAGE__->meta->make_immutable;
36
37 # Catch potential failure
38 Readonly my $API => try {
39 CloudFlare::Client::Test::->new( user => 'user', apikey => 'KEY')}
40 catch { diag $_ };
41 # Valid values
42 Readonly my $ZONE => 'zone.co.uk';
43 Readonly my $ITRVL => 20;
44 lives_and { is_deeply $API->action( zone => $ZONE, interval => $ITRVL),
45 $RSP_PL}
46 "action works";
0 #!perl -T
1
2 BEGIN {
3 unless ($ENV{AUTHOR_TESTING}) {
4 require Test::More;
5 Test::More::plan(skip_all => 'these tests are for testing by the author');
6 }
7 }
8
9
10 use strict; use warnings; no indirect 'fatal'; use namespace::autoclean;
11
12 use Readonly;
13 use Test::More;
14 use Test::Exception;
15 use Test::RequiresInternet;
16
17 use CloudFlare::Client;
18
19 plan tests => 1;
20
21 # Check we can hit the service and it fails our call
22 throws_ok { Readonly my $api => CloudFlare::Client::->new( user => 'user',
23 apikey => 'KEY');
24 # Picked because takes no args
25 $api->zoneLoadMulti } 'CloudFlare::Client::Exception::Upstream',
26 'Upstream service exists and responds'
0
1 BEGIN {
2 unless ($ENV{AUTHOR_TESTING}) {
3 require Test::More;
4 Test::More::plan(skip_all => 'these tests are for testing by the author');
5 }
6 }
7
8 use strict;
9 use warnings;
10
11 # this test was generated with Dist::Zilla::Plugin::Test::CleanNamespaces 0.006
12
13 use Test::More 0.94;
14 use Test::CleanNamespaces 0.15;
15
16 subtest all_namespaces_clean => sub { all_namespaces_clean() };
17
18 done_testing;
0 #!perl
1
2 BEGIN {
3 unless ($ENV{AUTHOR_TESTING}) {
4 require Test::More;
5 Test::More::plan(skip_all => 'these tests are for testing by the author');
6 }
7 }
8
9
10 use strict;
11 use warnings;
12
13 use Test::More;
14 use English qw(-no_match_vars);
15
16 eval "use Test::Perl::Critic";
17 plan skip_all => 'Test::Perl::Critic required to criticise code' if $@;
18 Test::Perl::Critic->import( -profile => "perlcritic.rc" ) if -e "perlcritic.rc";
19 all_critic_ok();
0
1 BEGIN {
2 unless ($ENV{AUTHOR_TESTING}) {
3 require Test::More;
4 Test::More::plan(skip_all => 'these tests are for testing by the author');
5 }
6 }
7
8 use strict;
9 use warnings;
10
11 # this test was generated with Dist::Zilla::Plugin::Test::EOL 0.18
12
13 use Test::More 0.88;
14 use Test::EOL;
15
16 my @files = (
17 'lib/CloudFlare/Client.pm',
18 'lib/CloudFlare/Client/Exception/Connection.pm',
19 'lib/CloudFlare/Client/Exception/Upstream.pm',
20 'lib/CloudFlare/Client/Types.pm',
21 't/00-compile.t',
22 't/01-Exception-Connection.t',
23 't/01-Exception-Upstream.t',
24 't/01-Types.t',
25 't/01-failure-connecting.t',
26 't/01-failure-upstream.t',
27 't/01-main.t',
28 't/01-success.t'
29 );
30
31 eol_unix_ok($_, { trailing_whitespace => 1 }) foreach @files;
32 done_testing;
0 #!perl
1
2 BEGIN {
3 unless ($ENV{AUTHOR_TESTING}) {
4 require Test::More;
5 Test::More::plan(skip_all => 'these tests are for testing by the author');
6 }
7 }
8
9
10 use strict;
11 use warnings qw(all);
12
13 use Test::More;
14 use Test::Mojibake;
15
16 all_files_encoding_ok();
0
1 BEGIN {
2 unless ($ENV{AUTHOR_TESTING}) {
3 require Test::More;
4 Test::More::plan(skip_all => 'these tests are for testing by the author');
5 }
6 }
7
8 use strict;
9 use warnings;
10
11 # this test was generated with Dist::Zilla::Plugin::Test::NoTabs 0.15
12
13 use Test::More 0.88;
14 use Test::NoTabs;
15
16 my @files = (
17 'lib/CloudFlare/Client.pm',
18 'lib/CloudFlare/Client/Exception/Connection.pm',
19 'lib/CloudFlare/Client/Exception/Upstream.pm',
20 'lib/CloudFlare/Client/Types.pm',
21 't/00-compile.t',
22 't/01-Exception-Connection.t',
23 't/01-Exception-Upstream.t',
24 't/01-Types.t',
25 't/01-failure-connecting.t',
26 't/01-failure-upstream.t',
27 't/01-main.t',
28 't/01-success.t'
29 );
30
31 notabs_ok($_) foreach @files;
32 done_testing;
0 #!perl
1
2 BEGIN {
3 unless ($ENV{AUTHOR_TESTING}) {
4 require Test::More;
5 Test::More::plan(skip_all => 'these tests are for testing by the author');
6 }
7 }
8
9 # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests.
10
11 use Test::Pod::Coverage 1.08;
12 use Pod::Coverage::TrustPod;
13
14 all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' });
0 #!perl
1
2 BEGIN {
3 unless ($ENV{AUTHOR_TESTING}) {
4 require Test::More;
5 Test::More::plan(skip_all => 'these tests are for testing by the author');
6 }
7 }
8
9 # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests.
10 use strict; use warnings;
11 use Test::More;
12 use Test::Pod 1.41;
13
14 all_pod_files_ok();
0
1 BEGIN {
2 unless ($ENV{AUTHOR_TESTING}) {
3 require Test::More;
4 Test::More::plan(skip_all => 'these tests are for testing by the author');
5 }
6 }
7
8 use strict;
9 use warnings;
10 use Test::More;
11
12 # generated by Dist::Zilla::Plugin::Test::Version 1.05
13 use Test::Version;
14
15 my @imports = qw( version_all_ok );
16
17 my $params = {
18 is_strict => 0,
19 has_version => 1,
20 multiple => 0,
21
22 };
23
24 push @imports, $params
25 if version->parse( $Test::Version::VERSION ) >= version->parse('1.002');
26
27
28 Test::Version->import(@imports);
29
30 version_all_ok;
31 done_testing;
0 #!perl
1
2 BEGIN {
3 unless ($ENV{RELEASE_TESTING}) {
4 require Test::More;
5 Test::More::plan(skip_all => 'these tests are for release candidate testing');
6 }
7 }
8
9
10 use strict;
11 use warnings;
12
13 use Test::More 0.96 tests => 2;
14 use_ok('Test::CPAN::Changes');
15 subtest 'changes_ok' => sub {
16 changes_file_ok('Changes');
17 };
18 done_testing();
0 #!perl
1
2 BEGIN {
3 unless ($ENV{RELEASE_TESTING}) {
4 require Test::More;
5 Test::More::plan(skip_all => 'these tests are for release candidate testing');
6 }
7 }
8
9
10 use Test::More;
11
12 eval "use Test::DistManifest";
13 plan skip_all => "Test::DistManifest required for testing the manifest"
14 if $@;
15 manifest_ok();
0 #!perl
1
2 BEGIN {
3 unless ($ENV{RELEASE_TESTING}) {
4 require Test::More;
5 Test::More::plan(skip_all => 'these tests are for release candidate testing');
6 }
7 }
8
9 # This file was automatically generated by Dist::Zilla::Plugin::MetaTests.
10
11 use Test::CPAN::Meta;
12
13 meta_yaml_ok();
0 #!perl
1
2 BEGIN {
3 unless ($ENV{RELEASE_TESTING}) {
4 require Test::More;
5 Test::More::plan(skip_all => 'these tests are for release candidate testing');
6 }
7 }
8
9
10 # This test is generated by Dist::Zilla::Plugin::Test::Fixme
11 use strict;
12 use warnings;
13
14 use Test::Fixme;
15 run_tests();
0
1 BEGIN {
2 unless ($ENV{RELEASE_TESTING}) {
3 require Test::More;
4 Test::More::plan(skip_all => 'these tests are for release candidate testing');
5 }
6 }
7
8 # this test was generated with Dist::Zilla::Plugin::Test::Kwalitee 2.12
9 use strict;
10 use warnings;
11 use Test::More 0.88;
12 use Test::Kwalitee 1.21 'kwalitee_ok';
13
14 kwalitee_ok();
15
16 done_testing;
0 #!perl
1
2 BEGIN {
3 unless ($ENV{RELEASE_TESTING}) {
4 require Test::More;
5 Test::More::plan(skip_all => 'these tests are for release candidate testing');
6 }
7 }
8
9
10 use Test::CPAN::Meta::JSON;
11 meta_json_ok();
0 #!perl
1
2 BEGIN {
3 unless ($ENV{RELEASE_TESTING}) {
4 require Test::More;
5 Test::More::plan(skip_all => 'these tests are for release candidate testing');
6 }
7 }
8
9
10 use Test::More;
11
12 eval "use Test::MinimumVersion";
13 plan skip_all => "Test::MinimumVersion required for testing minimum versions"
14 if $@;
15 all_minimum_version_from_metayml_ok();
0 #!perl
1
2 BEGIN {
3 unless ($ENV{RELEASE_TESTING}) {
4 require Test::More;
5 Test::More::plan(skip_all => 'these tests are for release candidate testing');
6 }
7 }
8
9
10 use strict;
11 use warnings;
12 use Test::More;
13
14 foreach my $env_skip ( qw(
15 SKIP_POD_LINKCHECK
16 ) ){
17 plan skip_all => "\$ENV{$env_skip} is set, skipping"
18 if $ENV{$env_skip};
19 }
20
21 eval "use Test::Pod::LinkCheck";
22 if ( $@ ) {
23 plan skip_all => 'Test::Pod::LinkCheck required for testing POD';
24 }
25 else {
26 Test::Pod::LinkCheck->new->all_pod_ok;
27 }
0 #!perl
1
2 BEGIN {
3 unless ($ENV{RELEASE_TESTING}) {
4 require Test::More;
5 Test::More::plan(skip_all => 'these tests are for release candidate testing');
6 }
7 }
8
9
10 use strict;
11 use warnings;
12
13 use Test::More;
14
15 eval 'use Test::Portability::Files';
16 plan skip_all => 'Test::Portability::Files required for testing portability'
17 if $@;
18
19 run_tests();
0 #!perl
1
2 BEGIN {
3 unless ($ENV{RELEASE_TESTING}) {
4 require Test::More;
5 Test::More::plan(skip_all => 'these tests are for release candidate testing');
6 }
7 }
8
9
10 use Test::Synopsis;
11
12 all_synopsis_ok();
0 #!perl
1
2 BEGIN {
3 unless ($ENV{RELEASE_TESTING}) {
4 require Test::More;
5 Test::More::plan(skip_all => 'these tests are for release candidate testing');
6 }
7 }
8
9
10 use Test::More 0.96 tests => 1;
11 eval { require Test::Vars };
12
13 SKIP: {
14 skip 1 => 'Test::Vars required for testing for unused vars'
15 if $@;
16 Test::Vars->import;
17
18 subtest 'unused vars' => sub {
19 all_vars_ok();
20 };
21 };