Fastly/PublishApi.pm untested

filter: Statementstmt 0.0% 0 / 64 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 98 CC 7 SCAR 28.1
CC
7
Cov
0%
publish
42.0
new
6.0
BEGIN
2.0
CRAP 16.6
1 =begin comment
2  
3 Fastly API
4  
5 Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The API is organized into collections of endpoints that allow manipulation of objects related to Fastly services and accounts. For the most accurate and up-to-date API reference content, visit our [Developer Hub](https://www.fastly.com/documentation/reference/api/)
6  
7 The version of the API Spec document: 1.0.0
8 Contact: oss@fastly.com
9  
10 =end comment
11  
12 =cut
13  
14 #
15 # NOTE: This class is auto generated.
16 # Do not edit the class manually.
17 #
18 package WebService::Fastly::PublishApi;
19  
20 require 5.6.0;
21 use strict;
22 use warnings;
23 use utf8;
24 use Exporter;
25 use Carp qw( croak );
26 use Log::Any qw($log);
27  
28 use WebService::Fastly::ApiClient;
29  
30 use base "Class::Data::Inheritable";
31  
32 __PACKAGE__->mk_classdata('method_documentation' => {});
33  
34 sub new {
35 my $class = shift;
36 my $api_client;
37  
38 if ($_[0] && ref $_[0] && ref $_[0] eq 'WebService::Fastly::ApiClient' ) {
39 $api_client = $_[0];
40 } else {
41 $api_client = WebService::Fastly::ApiClient->new(@_);
42 }
43  
44 bless { api_client => $api_client }, $class;
45  
46 }
47  
48  
49 #
50 # publish
51 #
52 # Send messages to Fanout subscribers
53 #
54 # @param string $service_id Alphanumeric string identifying the service. (required)
55 # @param PublishRequest $publish_request (optional)
56 {
57 my $params = {
58 'service_id' => {
59 data_type => 'string',
60 description => 'Alphanumeric string identifying the service.',
61 required => '1',
62 },
63 'publish_request' => {
64 data_type => 'PublishRequest',
65 description => '',
66 required => '0',
67 },
68 };
69 __PACKAGE__->method_documentation->{ 'publish' } = {
70 summary => 'Send messages to Fanout subscribers',
71 params => $params,
72 returns => 'string',
73 };
74 }
75 # @return string
76 #
77 sub publish {
78 my ($self, %args) = @_;
79  
80 # verify the required parameter 'service_id' is set
81 unless (exists $args{'service_id'}) {
82 croak("Missing the required parameter 'service_id' when calling publish");
83 }
84  
85 # parse inputs
86 my $_resource_path = '/service/{service_id}/publish/';
87  
88 my $_method = 'POST';
89 my $query_params = {};
90 my $header_params = {};
91 my $form_params = {};
92  
93 # 'Accept' and 'Content-Type' header
94 my $_header_accept = $self->{api_client}->select_header_accept('text/plain');
95 if ($_header_accept) {
96 $header_params->{'Accept'} = $_header_accept;
97 }
98 $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');
99  
100 # path params
101 if ( exists $args{'service_id'}) {
102 my $_base_variable = "{" . "service_id" . "}";
103 my $_base_value = $self->{api_client}->to_path_value($args{'service_id'});
104 $_resource_path =~ s/$_base_variable/$_base_value/g;
105 }
106  
107 my $_body_data;
108 # body params
109 if ( exists $args{'publish_request'}) {
110 $_body_data = $args{'publish_request'};
111 }
112  
113 # authentication setting, if any
114 my $auth_settings = [qw(token )];
115  
116 # make the API Call
117 my $response = $self->{api_client}->call_api($_resource_path, $_method,
118 $query_params, $form_params,
119 $header_params, $_body_data, $auth_settings);
120 if (!$response) {
121 return;
122 }
123 my $_response_object = $self->{api_client}->deserialize('string', $response);
124 return $_response_object;
125 }
126  
127 1;