diff options
author | gregor herrmann <gregoa@debian.org> | 2023-06-13 16:59:57 +0200 |
---|---|---|
committer | gregor herrmann <gregoa@debian.org> | 2023-06-13 16:59:57 +0200 |
commit | d0b08e013d2998ee3918629e50e7b8811aadf97b (patch) | |
tree | 59153fba6fc167751e9c5d3f1005bce1fb41d291 | |
parent | f392a2070312ff7248e1470224da9fa257d9df90 (diff) | |
parent | 7e7c0df80884fa95128c866113fbeea0252ff348 (diff) |
Update upstream source from tag 'upstream/0.27'
Update to upstream version '0.27'
with Debian dir 7558b946649a50b87d75f97a76564a87684399eb
-rw-r--r-- | Changes | 17 | ||||
-rw-r--r-- | LICENSE | 2 | ||||
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | META.json | 35 | ||||
-rw-r--r-- | META.yml | 32 | ||||
-rw-r--r-- | README.md | 189 | ||||
-rw-r--r-- | author/config.yml | 3 | ||||
-rw-r--r-- | author/footer.pm | 33 | ||||
-rw-r--r-- | author/header.pm | 2 | ||||
-rw-r--r-- | author/sections/groups.yml | 2 | ||||
-rw-r--r-- | author/sections/merge_requests.yml | 2 | ||||
-rw-r--r-- | author/sections/pipeline_schedules.yml | 1 | ||||
-rw-r--r-- | author/sections/remote_mirrors.yml | 5 | ||||
-rw-r--r-- | author/sections/users.yml | 6 | ||||
-rwxr-xr-x | author/setup-test-container | 14 | ||||
-rw-r--r-- | cpanfile | 22 | ||||
-rw-r--r-- | lib/GitLab/API/v4.pm | 341 | ||||
-rw-r--r-- | lib/GitLab/API/v4/Config.pm | 12 | ||||
-rw-r--r-- | lib/GitLab/API/v4/Constants.pm | 6 | ||||
-rwxr-xr-x | lib/GitLab/API/v4/Mock.pm | 6 | ||||
-rwxr-xr-x | lib/GitLab/API/v4/Mock/Engine.pm | 6 | ||||
-rwxr-xr-x | lib/GitLab/API/v4/Mock/RESTClient.pm | 8 | ||||
-rw-r--r-- | lib/GitLab/API/v4/Paginator.pm | 6 | ||||
-rw-r--r-- | lib/GitLab/API/v4/RESTClient.pm | 18 | ||||
-rw-r--r-- | lib/GitLab/API/v4/WWWClient.pm | 30 | ||||
-rw-r--r-- | minil.toml | 2 | ||||
-rwxr-xr-x | script/gitlab-api-v4 | 10 | ||||
-rwxr-xr-x | t/gitlab-api-v4.t | 4 |
28 files changed, 651 insertions, 164 deletions
@@ -1,5 +1,22 @@ Revision history for Perl extension GitLab-API-v4. +0.27 2023-06-07T20:50:56Z + + - Add run_pipeline_schedule. + - Add share_group_with_group and unshare_group_with_group. + - Add approve_merge_request and unapprove_merge_request + - Add approve_user and reject_user. + - Add ban_user and unban_user. + - Add activate_user and deactivate_user. + - Allow multi-line arguments. + - Use JSON::MaybeXS instead of JSON. + - Add verify_SSL=>1 to HTTP::Tiny to verify https server identity. + - Handle multiple cookies correctly when there is more than one. + - Live tests now run against GitLab CE 16.0.3 (was 11.10.4). + - Add the the remote_mirrors, create_remote_mirror, and + edit_remote_mirror methods. + - Fixed incorrect license messaging in POD. + 0.26 2021-01-30T07:10:57Z - Changed licensing terms to be the same as Perl 5. @@ -1,4 +1,4 @@ -This software is copyright (c) 2019 by Aran Clary Deltac <bluefeet@gmail.com>. +This software is copyright (c) 2014 by Aran Clary Deltac <bluefeet@gmail.com>. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. @@ -57,6 +57,7 @@ author/sections/protected_branches.yml author/sections/protected_tags.yml author/sections/release_links.yml author/sections/releases.yml +author/sections/remote_mirrors.yml author/sections/repositories.yml author/sections/repository_files.yml author/sections/resource_label_events.yml @@ -4,7 +4,7 @@ "Aran Clary Deltac <bluefeet@gmail.com>" ], "dynamic_config" : 0, - "generated_by" : "Minilla/v3.1.11", + "generated_by" : "Minilla/v3.1.21", "license" : [ "perl_5" ], @@ -49,7 +49,8 @@ "HTTP::Tiny" : "0.059", "HTTP::Tiny::Multipart" : "0.05", "IO::Prompter" : "0.004014", - "JSON" : "2.59", + "JSON::MaybeXS" : "1.003007", + "List::Util" : "0", "Log::Any" : "1.703", "Log::Any::Adapter" : "1.703", "Log::Any::Adapter::Screen" : "0.13", @@ -78,39 +79,39 @@ "provides" : { "GitLab::API::v4" : { "file" : "lib/GitLab/API/v4.pm", - "version" : "0.26" + "version" : "0.27" }, "GitLab::API::v4::Config" : { "file" : "lib/GitLab/API/v4/Config.pm", - "version" : "0.26" + "version" : "0.27" }, "GitLab::API::v4::Constants" : { "file" : "lib/GitLab/API/v4/Constants.pm", - "version" : "0.26" + "version" : "0.27" }, "GitLab::API::v4::Mock" : { "file" : "lib/GitLab/API/v4/Mock.pm", - "version" : "0.26" + "version" : "0.27" }, "GitLab::API::v4::Mock::Engine" : { "file" : "lib/GitLab/API/v4/Mock/Engine.pm", - "version" : "0.26" + "version" : "0.27" }, "GitLab::API::v4::Mock::RESTClient" : { "file" : "lib/GitLab/API/v4/Mock/RESTClient.pm", - "version" : "0.26" + "version" : "0.27" }, "GitLab::API::v4::Paginator" : { "file" : "lib/GitLab/API/v4/Paginator.pm", - "version" : "0.26" + "version" : "0.27" }, "GitLab::API::v4::RESTClient" : { "file" : "lib/GitLab/API/v4/RESTClient.pm", - "version" : "0.26" + "version" : "0.27" }, "GitLab::API::v4::WWWClient" : { "file" : "lib/GitLab/API/v4/WWWClient.pm", - "version" : "0.26" + "version" : "0.27" } }, "release_status" : "stable", @@ -120,28 +121,34 @@ }, "homepage" : "https://github.com/bluefeet/GitLab-API-v4", "repository" : { - "url" : "git://github.com/bluefeet/GitLab-API-v4.git", + "type" : "git", + "url" : "https://github.com/bluefeet/GitLab-API-v4.git", "web" : "https://github.com/bluefeet/GitLab-API-v4" } }, - "version" : "0.26", + "version" : "0.27", "x_authority" : "cpan:BLUEFEET", "x_contributors" : [ + "Dan Book <grinnz@grinnz.com>", "Dave Webb <github@d5ve.com>", "Dmitry Frolov <dmitry.frolov@gmail.com>", "Dotan Dimet <dotan@corky.net>", "Graham Knop <haarg@haarg.org>", + "James Wright <jwright@ecstuning.com>", + "Jonathan Taylor <jon@stackhaus.com>", "José Joaquín Atria <jjatria@gmail.com>", "Kieren Diment <kieren.diment@staples.com.au>", "Luc Didry <luc@didry.org>", "Marek R. Sotola <Marek.R.Sotola@nasa.gov>", "Nigel Gregoire <nigelgregoire@gmail.com>", "Simon Ruderich <simon@ruderich.org>", + "Stig Palmquist <git@stig.io>", "Thomas Klausner <domm@plix.at>", + "g0t mi1k <have.you.g0tmi1k@gmail.com>", "gregor herrmann <gregoa@debian.org>", "royce55 <royce@ecs.vuw.ac.nz>", "trunov-ms <trunov.ms@gmail.com>" ], - "x_serialization_backend" : "JSON::PP version 4.02", + "x_serialization_backend" : "JSON::PP version 4.07", "x_static_install" : 1 } @@ -9,7 +9,7 @@ build_requires: configure_requires: Module::Build::Tiny: '0.035' dynamic_config: 0 -generated_by: 'Minilla/v3.1.11, CPAN::Meta::Converter version 2.150010' +generated_by: 'Minilla/v3.1.21, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -28,31 +28,31 @@ no_index: provides: GitLab::API::v4: file: lib/GitLab/API/v4.pm - version: '0.26' + version: '0.27' GitLab::API::v4::Config: file: lib/GitLab/API/v4/Config.pm - version: '0.26' + version: '0.27' GitLab::API::v4::Constants: file: lib/GitLab/API/v4/Constants.pm - version: '0.26' + version: '0.27' GitLab::API::v4::Mock: file: lib/GitLab/API/v4/Mock.pm - version: '0.26' + version: '0.27' GitLab::API::v4::Mock::Engine: file: lib/GitLab/API/v4/Mock/Engine.pm - version: '0.26' + version: '0.27' GitLab::API::v4::Mock::RESTClient: file: lib/GitLab/API/v4/Mock/RESTClient.pm - version: '0.26' + version: '0.27' GitLab::API::v4::Paginator: file: lib/GitLab/API/v4/Paginator.pm - version: '0.26' + version: '0.27' GitLab::API::v4::RESTClient: file: lib/GitLab/API/v4/RESTClient.pm - version: '0.26' + version: '0.27' GitLab::API::v4::WWWClient: file: lib/GitLab/API/v4/WWWClient.pm - version: '0.26' + version: '0.27' requires: Carp: '0' Const::Fast: '0.014' @@ -61,7 +61,8 @@ requires: HTTP::Tiny: '0.059' HTTP::Tiny::Multipart: '0.05' IO::Prompter: '0.004014' - JSON: '2.59' + JSON::MaybeXS: '1.003007' + List::Util: '0' Log::Any: '1.703' Log::Any::Adapter: '1.703' Log::Any::Adapter::Screen: '0.13' @@ -80,21 +81,26 @@ requires: resources: bugtracker: https://github.com/bluefeet/GitLab-API-v4/issues homepage: https://github.com/bluefeet/GitLab-API-v4 - repository: git://github.com/bluefeet/GitLab-API-v4.git -version: '0.26' + repository: https://github.com/bluefeet/GitLab-API-v4.git +version: '0.27' x_authority: cpan:BLUEFEET x_contributors: + - 'Dan Book <grinnz@grinnz.com>' - 'Dave Webb <github@d5ve.com>' - 'Dmitry Frolov <dmitry.frolov@gmail.com>' - 'Dotan Dimet <dotan@corky.net>' - 'Graham Knop <haarg@haarg.org>' + - 'James Wright <jwright@ecstuning.com>' + - 'Jonathan Taylor <jon@stackhaus.com>' - 'José Joaquín Atria <jjatria@gmail.com>' - 'Kieren Diment <kieren.diment@staples.com.au>' - 'Luc Didry <luc@didry.org>' - 'Marek R. Sotola <Marek.R.Sotola@nasa.gov>' - 'Nigel Gregoire <nigelgregoire@gmail.com>' - 'Simon Ruderich <simon@ruderich.org>' + - 'Stig Palmquist <git@stig.io>' - 'Thomas Klausner <domm@plix.at>' + - 'g0t mi1k <have.you.g0tmi1k@gmail.com>' - 'gregor herrmann <gregoa@debian.org>' - 'royce55 <royce@ecs.vuw.ac.nz>' - 'trunov-ms <trunov.ms@gmail.com>' @@ -1463,6 +1463,28 @@ See [https://docs.gitlab.com/ce/api/groups.html](https://docs.gitlab.com/ce/api/ Sends a `DELETE` request to `groups/:group_id/ldap_group_links/:provider/:cn`. +- share\_group\_with\_group + + ``` + $api->share_group_with_group( + $group_id, + \%params, + ); + ``` + + Sends a `POST` request to `groups/:group_id/share`. + +- unshare\_group\_with\_group + + ``` + $api->unshare_group_with_group( + $group_id, + $shared_with_group_id, + ); + ``` + + Sends a `DELETE` request to `groups/:group_id/share/:shared_with_group_id`. + ## Group access requests See [https://docs.gitlab.com/ce/api/access\_requests.html](https://docs.gitlab.com/ce/api/access_requests.html). @@ -2358,6 +2380,30 @@ See [https://docs.gitlab.com/ce/api/merge\_requests.html](https://docs.gitlab.co Sends a `PUT` request to `projects/:project_id/merge_requests/:merge_request_iid/merge` and returns the decoded response content. +- approve\_merge\_request + + ```perl + my $merge_request = $api->approve_merge_request( + $project_id, + $merge_request_iid, + \%params, + ); + ``` + + Sends a `POST` request to `projects/:project_id/merge_requests/:merge_request_iid/approve` and returns the decoded response content. + +- unapprove\_merge\_request + + ```perl + my $merge_request = $api->unapprove_merge_request( + $project_id, + $merge_request_iid, + \%params, + ); + ``` + + Sends a `POST` request to `projects/:project_id/merge_requests/:merge_request_iid/unapprove` and returns the decoded response content. + - cancel\_merge\_when\_pipeline\_succeeds ```perl @@ -3632,6 +3678,17 @@ See [https://docs.gitlab.com/ce/api/pipeline\_schedules.html](https://docs.gitla Sends a `POST` request to `projects/:project_id/pipeline_schedules/:pipeline_schedule_id/take_ownership` and returns the decoded response content. +- run\_pipeline\_schedule + + ```perl + my $variable = $api->run_pipeline_schedule( + $project_id, + $pipeline_schedule_id, + ); + ``` + + Sends a `POST` request to `projects/:project_id/pipeline_schedules/:pipeline_schedule_id/play` and returns the decoded response content. + - delete\_pipeline\_schedule ```perl @@ -4519,6 +4576,43 @@ See [https://docs.gitlab.com/ce/api/releases/links.html](https://docs.gitlab.com Sends a `DELETE` request to `projects/:project_id/releases/:tag_name/assets/links/:link_id` and returns the decoded response content. +## Remote Mirrors + +See [https://docs.gitlab.com/ce/api/remote\_mirrors.html](https://docs.gitlab.com/ce/api/remote_mirrors.html). + +- remote\_mirrors + + ```perl + my $mirrors = $api->remote_mirrors( + $project_id, + ); + ``` + + Sends a `GET` request to `projects/:project_id/remote_mirrors` and returns the decoded response content. + +- create\_remote\_mirror + + ```perl + my $mirror = $api->create_remote_mirror( + $project_id, + \%params, + ); + ``` + + Sends a `POST` request to `projects/:project_id/remote_mirrors` and returns the decoded response content. + +- edit\_remote\_mirror + + ```perl + my $mirror = $api->edit_remote_mirror( + $project_id, + $mirror_id, + \%params, + ); + ``` + + Sends a `PUT` request to `projects/:project_id/remote_mirrors/:mirror_id` and returns the decoded response content. + ## Repositories See [https://docs.gitlab.com/ce/api/repositories.html](https://docs.gitlab.com/ce/api/repositories.html). @@ -5336,6 +5430,66 @@ See [https://docs.gitlab.com/ce/api/users.html](https://docs.gitlab.com/ce/api/u Sends a `POST` request to `users/:user_id/unblock` and returns the decoded response content. +- approve\_user + + ```perl + $api->approve_user( + $user_id, + ); + ``` + + Sends a `POST` request to `users/:user_id/approve`. + +- reject\_user + + ```perl + $api->reject_user( + $user_id, + ); + ``` + + Sends a `POST` request to `users/:user_id/reject`. + +- activate\_user + + ```perl + $api->activate_user( + $user_id, + ); + ``` + + Sends a `POST` request to `users/:user_id/activate`. + +- deactivate\_user + + ```perl + $api->deactivate_user( + $user_id, + ); + ``` + + Sends a `POST` request to `users/:user_id/deactivate`. + +- ban\_user + + ```perl + $api->ban_user( + $user_id, + ); + ``` + + Sends a `POST` request to `users/:user_id/ban`. + +- unban\_user + + ```perl + $api->unban_user( + $user_id, + ); + ``` + + Sends a `POST` request to `users/:user_id/unban`. + - user\_impersonation\_tokens ```perl @@ -5510,17 +5664,15 @@ GitLab-API-v4 GitHub issue tracker: [https://github.com/bluefeet/GitLab-API-v4/issues](https://github.com/bluefeet/GitLab-API-v4/issues) -# ACKNOWLEDGEMENTS +# AUTHOR -Thanks to [ZipRecruiter](https://www.ziprecruiter.com/) -for encouraging their employees to contribute back to the open -source ecosystem. Without their dedication to quality software -development this distribution would not exist. +``` +Aran Clary Deltac <bluefeet@gmail.com> +``` -# AUTHORS +# CONTRIBUTORS ``` -Aran Clary Deltac <bluefeet@gmail.com> Dotan Dimet <dotan@corky.net> Nigel Gregoire <nigelgregoire@gmail.com> trunov-ms <trunov.ms@gmail.com> @@ -5535,21 +5687,14 @@ Kieren Diment <kieren.diment@staples.com.au> Dmitry Frolov <dmitry.frolov@gmail.com> Thomas Klausner <domm@plix.at> Graham Knop <haarg@haarg.org> +Stig Palmquist <git@stig.io> +Dan Book <grinnz@grinnz.com> +James Wright <jwright@ecstuning.com> +Jonathan Taylor <jon@stackhaus.com> +g0t mi1k <have.you.g0tmi1k@gmail.com> ``` -# COPYRIGHT AND LICENSE - -Copyright (C) 2014 Aran Clary Deltac - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. +# LICENSE -You should have received a copy of the GNU General Public License -along with this program. If not, see [http://www.gnu.org/licenses/](http://www.gnu.org/licenses/). +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. diff --git a/author/config.yml b/author/config.yml index 8cd6cbf..ece1689 100644 --- a/author/config.yml +++ b/author/config.yml @@ -150,6 +150,9 @@ sections: - release_links: head: Release Links doc_url: https://docs.gitlab.com/ce/api/releases/links.html +- remote_mirrors: + head: Remote Mirrors + doc_url: https://docs.gitlab.com/ce/api/remote_mirrors.html - repositories: head: Repositories doc_url: https://docs.gitlab.com/ce/api/repositories.html diff --git a/author/footer.pm b/author/footer.pm index cf93f0f..e064014 100644 --- a/author/footer.pm +++ b/author/footer.pm @@ -24,16 +24,12 @@ GitLab-API-v4 GitHub issue tracker: L<https://github.com/bluefeet/GitLab-API-v4/issues> -=head1 ACKNOWLEDGEMENTS +=head1 AUTHOR -Thanks to L<ZipRecruiter|https://www.ziprecruiter.com/> -for encouraging their employees to contribute back to the open -source ecosystem. Without their dedication to quality software -development this distribution would not exist. + Aran Clary Deltac <bluefeet@gmail.com> -=head1 AUTHORS +=head1 CONTRIBUTORS - Aran Clary Deltac <bluefeet@gmail.com> Dotan Dimet <dotan@corky.net> Nigel Gregoire <nigelgregoire@gmail.com> trunov-ms <trunov.ms@gmail.com> @@ -48,23 +44,16 @@ development this distribution would not exist. Dmitry Frolov <dmitry.frolov@gmail.com> Thomas Klausner <domm@plix.at> Graham Knop <haarg@haarg.org> + Stig Palmquist <git@stig.io> + Dan Book <grinnz@grinnz.com> + James Wright <jwright@ecstuning.com> + Jonathan Taylor <jon@stackhaus.com> + g0t mi1k <have.you.g0tmi1k@gmail.com> -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2014 Aran Clary Deltac - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. +=head1 LICENSE -You should have received a copy of the GNU General Public License -along with this program. If not, see L<http://www.gnu.org/licenses/>. +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. =cut diff --git a/author/header.pm b/author/header.pm index 57d45c8..c5389e1 100644 --- a/author/header.pm +++ b/author/header.pm @@ -1,5 +1,5 @@ package GitLab::API::v4; -our $VERSION = '0.25'; +our $VERSION = '0.26'; =encoding utf8 diff --git a/author/sections/groups.yml b/author/sections/groups.yml index 55b126c..5fdee86 100644 --- a/author/sections/groups.yml +++ b/author/sections/groups.yml @@ -11,3 +11,5 @@ - create_ldap_group_link: POST groups/:group_id/ldap_group_links? - delete_ldap_group_link: DELETE groups/:group_id/ldap_group_links/:cn - delete_ldap_provider_group_link: DELETE groups/:group_id/ldap_group_links/:provider/:cn +- share_group_with_group: POST groups/:group_id/share? +- unshare_group_with_group: DELETE groups/:group_id/share/:shared_with_group_id
\ No newline at end of file diff --git a/author/sections/merge_requests.yml b/author/sections/merge_requests.yml index 71d0ef1..ad444d6 100644 --- a/author/sections/merge_requests.yml +++ b/author/sections/merge_requests.yml @@ -8,6 +8,8 @@ - edit_merge_request: merge_request = PUT projects/:project_id/merge_requests/:merge_request_iid? - delete_merge_request: DELETE projects/:project_id/merge_requests/:merge_request_iid - accept_merge_request: merge_request = PUT projects/:project_id/merge_requests/:merge_request_iid/merge? +- approve_merge_request: merge_request = POST projects/:project_id/merge_requests/:merge_request_iid/approve? +- unapprove_merge_request: merge_request = POST projects/:project_id/merge_requests/:merge_request_iid/unapprove? - cancel_merge_when_pipeline_succeeds: merge_request = PUT projects/:project_id/merge_requests/:merge_request_iid/cancel_merge_when_pipeline_succeeds - merge_request_closes_issues: issues = GET projects/:project_id/merge_requests/:merge_request_iid/closes_issues? - subscribe_to_merge_request: merge_request = POST projects/:project_id/merge_requests/:merge_request_iid/subscribe diff --git a/author/sections/pipeline_schedules.yml b/author/sections/pipeline_schedules.yml index 71eeb30..2d7b76d 100644 --- a/author/sections/pipeline_schedules.yml +++ b/author/sections/pipeline_schedules.yml @@ -4,6 +4,7 @@ - create_pipeline_schedule: schedule = POST projects/:project_id/pipeline_schedules? - edit_pipeline_schedule: schedule = PUT projects/:project_id/pipeline_schedules/:pipeline_schedule_id? - take_ownership_of_pipeline_schedule: schedule = POST projects/:project_id/pipeline_schedules/:pipeline_schedule_id/take_ownership +- run_pipeline_schedule: variable = POST projects/:project_id/pipeline_schedules/:pipeline_schedule_id/play - delete_pipeline_schedule: schedule = DELETE projects/:project_id/pipeline_schedules/:pipeline_schedule_id - create_pipeline_schedule_variable: variable = POST projects/:project_id/pipeline_schedules/:pipeline_schedule_id/variables? - edit_pipeline_schedule_variable: variable = PUT projects/:project_id/pipeline_schedules/:pipeline_schedule_id/variables/:variable_key? diff --git a/author/sections/remote_mirrors.yml b/author/sections/remote_mirrors.yml new file mode 100644 index 0000000..c1a9426 --- /dev/null +++ b/author/sections/remote_mirrors.yml @@ -0,0 +1,5 @@ +--- +- remote_mirrors: mirrors = GET projects/:project_id/remote_mirrors +- create_remote_mirror: mirror = POST projects/:project_id/remote_mirrors? +- edit_remote_mirror: mirror = PUT projects/:project_id/remote_mirrors/:mirror_id? + diff --git a/author/sections/users.yml b/author/sections/users.yml index 3940af9..60a8e95 100644 --- a/author/sections/users.yml +++ b/author/sections/users.yml @@ -29,6 +29,12 @@ - delete_user_email: DELETE users/:user_id/emails/:email_id - block_user: success = POST users/:user_id/block - unblock_user: success = POST users/:user_id/unblock +- approve_user: POST users/:user_id/approve +- reject_user: POST users/:user_id/reject +- activate_user: POST users/:user_id/activate +- deactivate_user: POST users/:user_id/deactivate +- ban_user: POST users/:user_id/ban +- unban_user: POST users/:user_id/unban - user_impersonation_tokens: tokens = GET users/:user_id/impersonation_tokens? - user_impersonation_token: token = GET users/:user_id/impersonation_tokens/:impersonation_token_id - create_user_impersonation_token: token = POST users/:user_id/impersonation_tokens? diff --git a/author/setup-test-container b/author/setup-test-container index fe2172a..4eb14e4 100755 --- a/author/setup-test-container +++ b/author/setup-test-container @@ -1,17 +1,17 @@ #!/bin/sh -docker stop test-gitlab-api-v4 +#docker stop test-gitlab-api-v4 sleep 5 -docker run -d --rm \ - -p 80:80 \ - --name test-gitlab-api-v4 \ - gitlab/gitlab-ce:11.10.4-ce.0 +#docker run -d --rm \ +# -p 80:80 \ +# --name test-gitlab-api-v4 \ +# gitlab/gitlab-ce:16.0.3-ce.0 echo 1. Open you browser to: http://localhost \(it may take several minutes for it to respond\) -echo 2. And set a password for the root user. -echo 3. Then login and goto: http://localhost/profile/personal_access_tokens +echo 2. Get the root password with: sudo docker exec -it test-gitlab-api-v4 grep 'Password:' /etc/gitlab/initial_root_password +echo 3. Then login and goto: http://localhost/-/profile/personal_access_tokens echo 4. Create a new private token \(use this token below\). echo 5. Then set the following env vars: echo export GITLAB_API_V4_URL=http://localhost/api/v4 @@ -8,8 +8,8 @@ requires 'Types::Standard' => '1.002001'; requires 'Types::Common::String' => '1.002001'; requires 'Types::Common::Numeric' => '1.002001'; requires 'Log::Any' => '1.703'; -requires 'Carp' => 0; -requires 'JSON' => '2.59'; +requires 'Carp'; +requires 'JSON::MaybeXS' => '1.003007'; # Used by GitLab::API::v4::RESTClient. requires 'HTTP::Tiny' => '0.059'; @@ -17,21 +17,23 @@ requires 'HTTP::Tiny::Multipart' => '0.05'; requires 'URI' => '1.62'; requires 'URI::Escape' => '1.72'; +# Used by GitLab::API::v4::WWWClient. +requires 'List::Util'; + # Used by GitLab::API::v4::Constants. requires 'Const::Fast' => '0.014'; -requires 'Exporter' => 0; +requires 'Exporter'; # Used by gitlab-api-v4 and/or GitLab::API::v4::Config. requires 'Try::Tiny' => '0.28'; -requires 'Getopt::Long' => 0; -requires 'Pod::Usage' => 0; +requires 'Getopt::Long'; +requires 'Pod::Usage'; requires 'Log::Any::Adapter' => '1.703'; requires 'Log::Any::Adapter::Screen' => '0.13'; requires 'Path::Tiny' => '0.079'; requires 'IO::Prompter' => '0.004014'; -on test => sub { - requires 'Test2::V0' => '0.000094'; - requires 'Log::Any::Adapter::TAP' => '0.003003'; - requires 'MIME::Base64' => '3.15'; -}; +test_requires 'Test2::V0' => '0.000094'; +test_requires 'Log::Any::Adapter::TAP' => '0.003003'; +test_requires 'MIME::Base64' => '3.15'; + diff --git a/lib/GitLab/API/v4.pm b/lib/GitLab/API/v4.pm index 1d65d33..eb3dde7 100644 --- a/lib/GitLab/API/v4.pm +++ b/lib/GitLab/API/v4.pm @@ -1,5 +1,5 @@ package GitLab::API::v4; -our $VERSION = '0.26'; +our $VERSION = '0.27'; =encoding utf8 @@ -2898,6 +2898,52 @@ sub delete_ldap_provider_group_link { return; } +=item share_group_with_group + + $api->share_group_with_group( + $group_id, + \%params, + ); + +Sends a C<POST> request to C<groups/:group_id/share>. + +=cut + +sub share_group_with_group { + my $self = shift; + croak 'share_group_with_group must be called with 1 to 2 arguments' if @_ < 1 or @_ > 2; + croak 'The #1 argument ($group_id) to share_group_with_group must be a scalar' if ref($_[0]) or (!defined $_[0]); + croak 'The last argument (\%params) to share_group_with_group must be a hash ref' if defined($_[1]) and ref($_[1]) ne 'HASH'; + my $params = (@_ == 2) ? pop() : undef; + my $options = {}; + $options->{decode} = 0; + $options->{content} = $params if defined $params; + $self->_call_rest_client( 'POST', 'groups/:group_id/share', [@_], $options ); + return; +} + +=item unshare_group_with_group + + $api->unshare_group_with_group( + $group_id, + $shared_with_group_id, + ); + +Sends a C<DELETE> request to C<groups/:group_id/share/:shared_with_group_id>. + +=cut + +sub unshare_group_with_group { + my $self = shift; + croak 'unshare_group_with_group must be called with 2 arguments' if @_ != 2; + croak 'The #1 argument ($group_id) to unshare_group_with_group must be a scalar' if ref($_[0]) or (!defined $_[0]); + croak 'The #2 argument ($shared_with_group_id) to unshare_group_with_group must be a scalar' if ref($_[1]) or (!defined $_[1]); + my $options = {}; + $options->{decode} = 0; + $self->_call_rest_client( 'DELETE', 'groups/:group_id/share/:shared_with_group_id', [@_], $options ); + return; +} + =back =head2 Group access requests @@ -4624,6 +4670,54 @@ sub accept_merge_request { return $self->_call_rest_client( 'PUT', 'projects/:project_id/merge_requests/:merge_request_iid/merge', [@_], $options ); } +=item approve_merge_request + + my $merge_request = $api->approve_merge_request( + $project_id, + $merge_request_iid, + \%params, + ); + +Sends a C<POST> request to C<projects/:project_id/merge_requests/:merge_request_iid/approve> and returns the decoded response content. + +=cut + +sub approve_merge_request { + my $self = shift; + croak 'approve_merge_request must be called with 2 to 3 arguments' if @_ < 2 or @_ > 3; + croak 'The #1 argument ($project_id) to approve_merge_request must be a scalar' if ref($_[0]) or (!defined $_[0]); + croak 'The #2 argument ($merge_request_iid) to approve_merge_request must be a scalar' if ref($_[1]) or (!defined $_[1]); + croak 'The last argument (\%params) to approve_merge_request must be a hash ref' if defined($_[2]) and ref($_[2]) ne 'HASH'; + my $params = (@_ == 3) ? pop() : undef; + my $options = {}; + $options->{content} = $params if defined $params; + return $self->_call_rest_client( 'POST', 'projects/:project_id/merge_requests/:merge_request_iid/approve', [@_], $options ); +} + +=item unapprove_merge_request + + my $merge_request = $api->unapprove_merge_request( + $project_id, + $merge_request_iid, + \%params, + ); + +Sends a C<POST> request to C<projects/:project_id/merge_requests/:merge_request_iid/unapprove> and returns the decoded response content. + +=cut + +sub unapprove_merge_request { + my $self = shift; + croak 'unapprove_merge_request must be called with 2 to 3 arguments' if @_ < 2 or @_ > 3; + croak 'The #1 argument ($project_id) to unapprove_merge_request must be a scalar' if ref($_[0]) or (!defined $_[0]); + croak 'The #2 argument ($merge_request_iid) to unapprove_merge_request must be a scalar' if ref($_[1]) or (!defined $_[1]); + croak 'The last argument (\%params) to unapprove_merge_request must be a hash ref' if defined($_[2]) and ref($_[2]) ne 'HASH'; + my $params = (@_ == 3) ? pop() : undef; + my $options = {}; + $options->{content} = $params if defined $params; + return $self->_call_rest_client( 'POST', 'projects/:project_id/merge_requests/:merge_request_iid/unapprove', [@_], $options ); +} + =item cancel_merge_when_pipeline_succeeds my $merge_request = $api->cancel_merge_when_pipeline_succeeds( @@ -7086,6 +7180,26 @@ sub take_ownership_of_pipeline_schedule { return $self->_call_rest_client( 'POST', 'projects/:project_id/pipeline_schedules/:pipeline_schedule_id/take_ownership', [@_], $options ); } +=item run_pipeline_schedule + + my $variable = $api->run_pipeline_schedule( + $project_id, + $pipeline_schedule_id, + ); + +Sends a C<POST> request to C<projects/:project_id/pipeline_schedules/:pipeline_schedule_id/play> and returns the decoded response content. + +=cut + +sub run_pipeline_schedule { + my $self = shift; + croak 'run_pipeline_schedule must be called with 2 arguments' if @_ != 2; + croak 'The #1 argument ($project_id) to run_pipeline_schedule must be a scalar' if ref($_[0]) or (!defined $_[0]); + croak 'The #2 argument ($pipeline_schedule_id) to run_pipeline_schedule must be a scalar' if ref($_[1]) or (!defined $_[1]); + my $options = {}; + return $self->_call_rest_client( 'POST', 'projects/:project_id/pipeline_schedules/:pipeline_schedule_id/play', [@_], $options ); +} + =item delete_pipeline_schedule my $schedule = $api->delete_pipeline_schedule( @@ -8825,6 +8939,78 @@ sub delete_release_link { =back +=head2 Remote Mirrors + +See L<https://docs.gitlab.com/ce/api/remote_mirrors.html>. + +=over + +=item remote_mirrors + + my $mirrors = $api->remote_mirrors( + $project_id, + ); + +Sends a C<GET> request to C<projects/:project_id/remote_mirrors> and returns the decoded response content. + +=cut + +sub remote_mirrors { + my $self = shift; + croak 'remote_mirrors must be called with 1 arguments' if @_ != 1; + croak 'The #1 argument ($project_id) to remote_mirrors must be a scalar' if ref($_[0]) or (!defined $_[0]); + my $options = {}; + return $self->_call_rest_client( 'GET', 'projects/:project_id/remote_mirrors', [@_], $options ); +} + +=item create_remote_mirror + + my $mirror = $api->create_remote_mirror( + $project_id, + \%params, + ); + +Sends a C<POST> request to C<projects/:project_id/remote_mirrors> and returns the decoded response content. + +=cut + +sub create_remote_mirror { + my $self = shift; + croak 'create_remote_mirror must be called with 1 to 2 arguments' if @_ < 1 or @_ > 2; + croak 'The #1 argument ($project_id) to create_remote_mirror must be a scalar' if ref($_[0]) or (!defined $_[0]); + croak 'The last argument (\%params) to create_remote_mirror must be a hash ref' if defined($_[1]) and ref($_[1]) ne 'HASH'; + my $params = (@_ == 2) ? pop() : undef; + my $options = {}; + $options->{content} = $params if defined $params; + return $self->_call_rest_client( 'POST', 'projects/:project_id/remote_mirrors', [@_], $options ); +} + +=item edit_remote_mirror + + my $mirror = $api->edit_remote_mirror( + $project_id, + $mirror_id, + \%params, + ); + +Sends a C<PUT> request to C<projects/:project_id/remote_mirrors/:mirror_id> and returns the decoded response content. + +=cut + +sub edit_remote_mirror { + my $self = shift; + croak 'edit_remote_mirror must be called with 2 to 3 arguments' if @_ < 2 or @_ > 3; + croak 'The #1 argument ($project_id) to edit_remote_mirror must be a scalar' if ref($_[0]) or (!defined $_[0]); + croak 'The #2 argument ($mirror_id) to edit_remote_mirror must be a scalar' if ref($_[1]) or (!defined $_[1]); + croak 'The last argument (\%params) to edit_remote_mirror must be a hash ref' if defined($_[2]) and ref($_[2]) ne 'HASH'; + my $params = (@_ == 3) ? pop() : undef; + my $options = {}; + $options->{content} = $params if defined $params; + return $self->_call_rest_client( 'PUT', 'projects/:project_id/remote_mirrors/:mirror_id', [@_], $options ); +} + +=back + =head2 Repositories See L<https://docs.gitlab.com/ce/api/repositories.html>. @@ -10445,6 +10631,126 @@ sub unblock_user { return $self->_call_rest_client( 'POST', 'users/:user_id/unblock', [@_], $options ); } +=item approve_user + + $api->approve_user( + $user_id, + ); + +Sends a C<POST> request to C<users/:user_id/approve>. + +=cut + +sub approve_user { + my $self = shift; + croak 'approve_user must be called with 1 arguments' if @_ != 1; + croak 'The #1 argument ($user_id) to approve_user must be a scalar' if ref($_[0]) or (!defined $_[0]); + my $options = {}; + $options->{decode} = 0; + $self->_call_rest_client( 'POST', 'users/:user_id/approve', [@_], $options ); + return; +} + +=item reject_user + + $api->reject_user( + $user_id, + ); + +Sends a C<POST> request to C<users/:user_id/reject>. + +=cut + +sub reject_user { + my $self = shift; + croak 'reject_user must be called with 1 arguments' if @_ != 1; + croak 'The #1 argument ($user_id) to reject_user must be a scalar' if ref($_[0]) or (!defined $_[0]); + my $options = {}; + $options->{decode} = 0; + $self->_call_rest_client( 'POST', 'users/:user_id/reject', [@_], $options ); + return; +} + +=item activate_user + + $api->activate_user( + $user_id, + ); + +Sends a C<POST> request to C<users/:user_id/activate>. + +=cut + +sub activate_user { + my $self = shift; + croak 'activate_user must be called with 1 arguments' if @_ != 1; + croak 'The #1 argument ($user_id) to activate_user must be a scalar' if ref($_[0]) or (!defined $_[0]); + my $options = {}; + $options->{decode} = 0; + $self->_call_rest_client( 'POST', 'users/:user_id/activate', [@_], $options ); + return; +} + +=item deactivate_user + + $api->deactivate_user( + $user_id, + ); + +Sends a C<POST> request to C<users/:user_id/deactivate>. + +=cut + +sub deactivate_user { + my $self = shift; + croak 'deactivate_user must be called with 1 arguments' if @_ != 1; + croak 'The #1 argument ($user_id) to deactivate_user must be a scalar' if ref($_[0]) or (!defined $_[0]); + my $options = {}; + $options->{decode} = 0; + $self->_call_rest_client( 'POST', 'users/:user_id/deactivate', [@_], $options ); + return; +} + +=item ban_user + + $api->ban_user( + $user_id, + ); + +Sends a C<POST> request to C<users/:user_id/ban>. + +=cut + +sub ban_user { + my $self = shift; + croak 'ban_user must be called with 1 arguments' if @_ != 1; + croak 'The #1 argument ($user_id) to ban_user must be a scalar' if ref($_[0]) or (!defined $_[0]); + my $options = {}; + $options->{decode} = 0; + $self->_call_rest_client( 'POST', 'users/:user_id/ban', [@_], $options ); + return; +} + +=item unban_user + + $api->unban_user( + $user_id, + ); + +Sends a C<POST> request to C<users/:user_id/unban>. + +=cut + +sub unban_user { + my $self = shift; + croak 'unban_user must be called with 1 arguments' if @_ != 1; + croak 'The #1 argument ($user_id) to unban_user must be a scalar' if ref($_[0]) or (!defined $_[0]); + my $options = {}; + $options->{decode} = 0; + $self->_call_rest_client( 'POST', 'users/:user_id/unban', [@_], $options ); + return; +} + =item user_impersonation_tokens my $tokens = $api->user_impersonation_tokens( @@ -10772,16 +11078,12 @@ GitLab-API-v4 GitHub issue tracker: L<https://github.com/bluefeet/GitLab-API-v4/issues> -=head1 ACKNOWLEDGEMENTS +=head1 AUTHOR -Thanks to L<ZipRecruiter|https://www.ziprecruiter.com/> -for encouraging their employees to contribute back to the open -source ecosystem. Without their dedication to quality software -development this distribution would not exist. + Aran Clary Deltac <bluefeet@gmail.com> -=head1 AUTHORS +=head1 CONTRIBUTORS - Aran Clary Deltac <bluefeet@gmail.com> Dotan Dimet <dotan@corky.net> Nigel Gregoire <nigelgregoire@gmail.com> trunov-ms <trunov.ms@gmail.com> @@ -10796,23 +11098,16 @@ development this distribution would not exist. Dmitry Frolov <dmitry.frolov@gmail.com> Thomas Klausner <domm@plix.at> Graham Knop <haarg@haarg.org> + Stig Palmquist <git@stig.io> + Dan Book <grinnz@grinnz.com> + James Wright <jwright@ecstuning.com> + Jonathan Taylor <jon@stackhaus.com> + g0t mi1k <have.you.g0tmi1k@gmail.com> -=head1 COPYRIGHT AND LICENSE - -Copyright (C) 2014 Aran Clary Deltac - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. +=head1 LICENSE -You should have received a copy of the GNU General Public License -along with this program. If not, see L<http://www.gnu.org/licenses/>. +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. =cut diff --git a/lib/GitLab/API/v4/Config.pm b/lib/GitLab/API/v4/Config.pm index 4e96268..49aa695 100644 --- a/lib/GitLab/API/v4/Config.pm +++ b/lib/GitLab/API/v4/Config.pm @@ -1,5 +1,5 @@ package GitLab::API::v4::Config; -our $VERSION = '0.26'; +our $VERSION = '0.27'; =encoding utf8 @@ -28,7 +28,7 @@ L</SYNOPSIS>. use Getopt::Long; use IO::Prompter; -use JSON; +use JSON::MaybeXS; use Log::Any qw( $log ); use Path::Tiny; use Types::Common::String -types; @@ -236,9 +236,7 @@ sub configure { '-stdio', '-verbatim', ); - my $json = JSON->new - ->pretty - ->canonical + my $json = JSON::MaybeXS->new(pretty => 1, canonical => 1) ->encode({ $url ? (url=>$url) : (), $private_token ? (private_token=>$private_token) : (), @@ -266,9 +264,9 @@ See L<GitLab::API::v4/SUPPORT>. See L<GitLab::API::v4/AUTHORS>. -=head1 COPYRIGHT AND LICENSE +=head1 LICENSE -See L<GitLab::API::v4/COPYRIGHT AND LICENSE>. +See L<GitLab::API::v4/LICENSE>. =cut diff --git a/lib/GitLab/API/v4/Constants.pm b/lib/GitLab/API/v4/Constants.pm index 071774f..8a0e97e 100644 --- a/lib/GitLab/API/v4/Constants.pm +++ b/lib/GitLab/API/v4/Constants.pm @@ -1,5 +1,5 @@ package GitLab::API::v4::Constants; -our $VERSION = '0.26'; +our $VERSION = '0.27'; =encoding utf8 @@ -153,9 +153,9 @@ See L<GitLab::API::v4/SUPPORT>. See L<GitLab::API::v4/AUTHORS>. -=head1 COPYRIGHT AND LICENSE +=head1 LICENSE -See L<GitLab::API::v4/COPYRIGHT AND LICENSE>. +See L<GitLab::API::v4/LICENSE>. =cut diff --git a/lib/GitLab/API/v4/Mock.pm b/lib/GitLab/API/v4/Mock.pm index 41576ba..63e0e1b 100755 --- a/lib/GitLab/API/v4/Mock.pm +++ b/lib/GitLab/API/v4/Mock.pm @@ -1,5 +1,5 @@ package GitLab::API::v4::Mock; -our $VERSION = '0.26'; +our $VERSION = '0.27'; =encoding utf8 @@ -66,9 +66,9 @@ See L<GitLab::API::v4/SUPPORT>. See L<GitLab::API::v4/AUTHORS>. -=head1 COPYRIGHT AND LICENSE +=head1 LICENSE -See L<GitLab::API::v4/COPYRIGHT AND LICENSE>. +See L<GitLab::API::v4/LICENSE>. =cut diff --git a/lib/GitLab/API/v4/Mock/Engine.pm b/lib/GitLab/API/v4/Mock/Engine.pm index d362a7c..2d6af61 100755 --- a/lib/GitLab/API/v4/Mock/Engine.pm +++ b/lib/GitLab/API/v4/Mock/Engine.pm @@ -1,5 +1,5 @@ package GitLab::API::v4::Mock::Engine; -our $VERSION = '0.26'; +our $VERSION = '0.27'; =encoding utf8 @@ -202,9 +202,9 @@ See L<GitLab::API::v4/SUPPORT>. See L<GitLab::API::v4/AUTHORS>. -=head1 COPYRIGHT AND LICENSE +=head1 LICENSE -See L<GitLab::API::v4/COPYRIGHT AND LICENSE>. +See L<GitLab::API::v4/LICENSE>. =cut diff --git a/lib/GitLab/API/v4/Mock/RESTClient.pm b/lib/GitLab/API/v4/Mock/RESTClient.pm index e432b34..81683dd 100755 --- a/lib/GitLab/API/v4/Mock/RESTClient.pm +++ b/lib/GitLab/API/v4/Mock/RESTClient.pm @@ -1,5 +1,5 @@ package GitLab::API::v4::Mock::RESTClient; -our $VERSION = '0.26'; +our $VERSION = '0.27'; =encoding utf8 @@ -18,7 +18,7 @@ This module is used by L<GitLab::API::v4::Mock>. =cut use GitLab::API::v4::Mock::Engine; -use JSON; +use JSON::MaybeXS; use URI; use Moo; @@ -178,9 +178,9 @@ See L<GitLab::API::v4/SUPPORT>. See L<GitLab::API::v4/AUTHORS>. -=head1 COPYRIGHT AND LICENSE +=head1 LICENSE -See L<GitLab::API::v4/COPYRIGHT AND LICENSE>. +See L<GitLab::API::v4/LICENSE>. =cut diff --git a/lib/GitLab/API/v4/Paginator.pm b/lib/GitLab/API/v4/Paginator.pm index edec535..b911d6d 100644 --- a/lib/GitLab/API/v4/Paginator.pm +++ b/lib/GitLab/API/v4/Paginator.pm @@ -1,5 +1,5 @@ package GitLab::API::v4::Paginator; -our $VERSION = '0.26'; +our $VERSION = '0.27'; =encoding utf8 @@ -222,9 +222,9 @@ See L<GitLab::API::v4/SUPPORT>. See L<GitLab::API::v4/AUTHORS>. -=head1 COPYRIGHT AND LICENSE +=head1 LICENSE -See L<GitLab::API::v4/COPYRIGHT AND LICENSE>. +See L<GitLab::API::v4/LICENSE>. =cut diff --git a/lib/GitLab/API/v4/RESTClient.pm b/lib/GitLab/API/v4/RESTClient.pm index 515e44e..321d163 100644 --- a/lib/GitLab/API/v4/RESTClient.pm +++ b/lib/GitLab/API/v4/RESTClient.pm @@ -1,5 +1,5 @@ package GitLab::API::v4::RESTClient; -our $VERSION = '0.26'; +our $VERSION = '0.27'; =encoding utf8 @@ -9,9 +9,9 @@ GitLab::API::v4::RESTClient - The HTTP client that does the heavy lifting. =head1 DESCRIPTION -Currently this class uses L<HTTP::Tiny> and L<JSON> to do its job. This may -change, and the interface may change, so documentation is lacking in order -to not mislead people. +Currently this class uses L<HTTP::Tiny> and L<JSON::MaybeXS> to do its job. +This may change, and the interface may change, so documentation is lacking in +order to not mislead people. If you do want to customize how this class works then take a look at the source. @@ -40,7 +40,7 @@ and you will have encountered an error when making the request use Carp qw(); use HTTP::Tiny::Multipart; use HTTP::Tiny; -use JSON; +use JSON::MaybeXS; use Log::Any qw( $log ); use Path::Tiny; use Try::Tiny; @@ -102,7 +102,7 @@ has http_tiny => ( isa => InstanceOf[ 'HTTP::Tiny' ], ); sub _build_http_tiny { - return HTTP::Tiny->new(); + return HTTP::Tiny->new( verify_SSL => 1 ); } has json => ( @@ -110,7 +110,7 @@ has json => ( isa => HasMethods[ 'encode', 'decode' ], ); sub _build_json { - return JSON->new->utf8->allow_nonref(); + return JSON::MaybeXS->new(utf8 => 1, allow_nonref => 1); } has http_tiny_request => ( @@ -271,9 +271,9 @@ See L<GitLab::API::v4/SUPPORT>. See L<GitLab::API::v4/AUTHORS>. -=head1 COPYRIGHT AND LICENSE +=head1 LICENSE -See L<GitLab::API::v4/COPYRIGHT AND LICENSE>. +See L<GitLab::API::v4/LICENSE>. =cut diff --git a/lib/GitLab/API/v4/WWWClient.pm b/lib/GitLab/API/v4/WWWClient.pm index cad1752..1718dc6 100644 --- a/lib/GitLab/API/v4/WWWClient.pm +++ b/lib/GitLab/API/v4/WWWClient.pm @@ -1,5 +1,5 @@ package GitLab::API::v4::WWWClient; -our $VERSION = '0.26'; +our $VERSION = '0.27'; =encoding utf8 @@ -27,6 +27,7 @@ This class makes it possible to interact with the GitLab web site. use Carp qw( croak ); use HTTP::Tiny; +use List::Util qw( first ); use Types::Common::String qw( NonEmptySimpleStr ); use Moo; @@ -80,6 +81,7 @@ sub sign_in { my ($self, $username, $password) = @_; my $tiny = HTTP::Tiny->new( + verify_SSL => 1, max_redirect => 0, ); @@ -96,10 +98,13 @@ sub sign_in { m{name="authenticity_token" value="(.+?)"} )[0]; - my $first_session = ( - $load_res->{headers}->{'set-cookie'} =~ - m{_gitlab_session=(.+?);} - )[0]; + + my ($first_session) = do{ + my $set_cookie_headers = $load_res->{headers}->{ 'set-cookie' }; + $set_cookie_headers = [ $set_cookie_headers ] if !ref $set_cookie_headers; + my $value = first { $_ =~ m{^_gitlab_session=(.*)} } @$set_cookie_headers; + $value =~ s{^_gitlab_session=}{}r; + }; my $submit_res = $tiny->post_form( $sign_in_url, @@ -121,10 +126,12 @@ sub sign_in { _croak_res( 'post', $sign_in_url, $submit_res ); - my $second_session = ( - $submit_res->{headers}->{'set-cookie'} =~ - m{_gitlab_session=(.+?);} - )[0]; + my ($second_session) = do{ + my $set_cookie_headers = $submit_res->{headers}->{ 'set-cookie' }; + $set_cookie_headers = [ $set_cookie_headers ] if !ref $set_cookie_headers; + my $value = first { $_ =~ m{^_gitlab_session=(.*)} } @$set_cookie_headers; + $value =~ s{^_gitlab_session=}{}r; + }; my $home_res = $tiny->get( $base_url, @@ -159,6 +166,7 @@ sub get { my ($self, $path) = @_; my $tiny = HTTP::Tiny->new( + verify_SSL => 1, max_redirect => 0, ); @@ -194,9 +202,9 @@ See L<GitLab::API::v4/SUPPORT>. See L<GitLab::API::v4/AUTHORS>. -=head1 COPYRIGHT AND LICENSE +=head1 LICENSE -See L<GitLab::API::v4/COPYRIGHT AND LICENSE>. +See L<GitLab::API::v4/LICENSE>. =cut @@ -1,4 +1,4 @@ name = "GitLab-API-v4" -authority="cpan:BLUEFEET" +authority = "cpan:BLUEFEET" markdown_maker = "Pod::Markdown::Github" license = "perl_5" diff --git a/script/gitlab-api-v4 b/script/gitlab-api-v4 index 8077283..39daa47 100755 --- a/script/gitlab-api-v4 +++ b/script/gitlab-api-v4 @@ -4,7 +4,7 @@ use strictures 2; use GitLab::API::v4::Config; use GitLab::API::v4::Constants qw( :all ); use GitLab::API::v4; -use JSON; +use JSON::MaybeXS; use Log::Any qw( $log ); use Log::Any::Adapter::Screen; use Log::Any::Adapter; @@ -79,7 +79,7 @@ while (@ARGV) { my $arg = shift @ARGV; next if $arg eq '--'; - if ($arg =~ m{^([^:]+):(.*)$}) { + if ($arg =~ m{^([^:]+):(.*)$}s) { my ($key, $value) = ($1, $2); $key =~ s{-}{_}g; @@ -120,7 +120,7 @@ my $data = $api->$method( $data = $data->all() if $all; binmode STDOUT, ':utf8'; -my $json = JSON->new->allow_nonref(); +my $json = JSON::MaybeXS->new(allow_nonref => 1); $json->pretty() if $pretty; $json->canonical() if $canonical; print $json->encode( $data ); @@ -204,14 +204,14 @@ See L<GitLab::API::v4::Paginator/all> for details. --pretty -p -Enables the L<JSON/pretty> feature. +Enables the L<JSON::PP/pretty> feature. =head2 canonical --canonical -c -Enables the L<JSON/canonical> feature. +Enables the L<JSON::PP/canonical> feature. =head1 API METHOD diff --git a/t/gitlab-api-v4.t b/t/gitlab-api-v4.t index 816006c..028e390 100755 --- a/t/gitlab-api-v4.t +++ b/t/gitlab-api-v4.t @@ -5,9 +5,9 @@ use Test2::Require::AuthorTesting; use Test2::V0; use IPC::Cmd qw(); -use JSON qw(); +use JSON::MaybeXS qw(); -my $json = JSON->new->allow_nonref(); +my $json = JSON::MaybeXS->new(allow_nonref => 1); my $project = run('create-project', 'name:test-gitlab-api-v4'); run('delete-project', $project->{id}); |