forked from loafle/openapi-generator-original
Merge pull request #870 from wing328/perl_cli_support
[Perl] Add CLI config options and code enhancement
This commit is contained in:
@@ -7,16 +7,16 @@ import io.swagger.codegen.SupportingFile;
|
||||
import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.MapProperty;
|
||||
import io.swagger.models.properties.Property;
|
||||
import io.swagger.codegen.CliOption;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String invokerPackage = "SwaggerClient";
|
||||
protected String groupId = "io.swagger";
|
||||
protected String artifactId = "swagger-client";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String moduleName = "SwaggerClient";
|
||||
protected String moduleVersion = "1.0.0";
|
||||
|
||||
public PerlClientCodegen() {
|
||||
super();
|
||||
@@ -26,8 +26,6 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
apiTemplateFiles.put("api.mustache", ".pm");
|
||||
templateDir = "perl";
|
||||
|
||||
typeMapping.clear();
|
||||
languageSpecificPrimitives.clear();
|
||||
|
||||
reservedWords = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
@@ -44,11 +42,7 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
)
|
||||
);
|
||||
|
||||
additionalProperties.put("invokerPackage", invokerPackage);
|
||||
additionalProperties.put("groupId", groupId);
|
||||
additionalProperties.put("artifactId", artifactId);
|
||||
additionalProperties.put("artifactVersion", artifactVersion);
|
||||
|
||||
languageSpecificPrimitives.clear();
|
||||
languageSpecificPrimitives.add("int");
|
||||
languageSpecificPrimitives.add("double");
|
||||
languageSpecificPrimitives.add("string");
|
||||
@@ -58,6 +52,7 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
languageSpecificPrimitives.add("HASH");
|
||||
languageSpecificPrimitives.add("object");
|
||||
|
||||
typeMapping.clear();
|
||||
typeMapping.put("integer", "int");
|
||||
typeMapping.put("long", "int");
|
||||
typeMapping.put("float", "double");
|
||||
@@ -71,9 +66,31 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("map", "HASH");
|
||||
typeMapping.put("object", "object");
|
||||
|
||||
supportingFiles.add(new SupportingFile("ApiClient.mustache", ("lib/WWW/" + invokerPackage).replace('/', File.separatorChar), "ApiClient.pm"));
|
||||
supportingFiles.add(new SupportingFile("Configuration.mustache", ("lib/WWW/" + invokerPackage).replace('/', File.separatorChar), "Configuration.pm"));
|
||||
supportingFiles.add(new SupportingFile("BaseObject.mustache", ("lib/WWW/" + invokerPackage).replace('/', File.separatorChar), "Object/BaseObject.pm"));
|
||||
cliOptions.clear();
|
||||
cliOptions.add(new CliOption("moduleName", "perl module name (convention: CamelCase), default: SwaggerClient"));
|
||||
cliOptions.add(new CliOption("moduleVersion", "perl module version, default: 1.0.0"));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (additionalProperties.containsKey("moduleVersion")) {
|
||||
moduleVersion = (String) additionalProperties.get("moduleVersion");
|
||||
} else {
|
||||
additionalProperties.put("moduleVersion", moduleVersion);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey("moduleName")) {
|
||||
moduleName = (String) additionalProperties.get("moduleName");
|
||||
} else {
|
||||
additionalProperties.put("moduleName", moduleName);
|
||||
}
|
||||
|
||||
supportingFiles.add(new SupportingFile("ApiClient.mustache", ("lib/WWW/" + moduleName).replace('/', File.separatorChar), "ApiClient.pm"));
|
||||
supportingFiles.add(new SupportingFile("Configuration.mustache", ("lib/WWW/" + moduleName).replace('/', File.separatorChar), "Configuration.pm"));
|
||||
supportingFiles.add(new SupportingFile("BaseObject.mustache", ("lib/WWW/" + moduleName).replace('/', File.separatorChar), "Object/BaseObject.pm"));
|
||||
}
|
||||
|
||||
public CodegenType getTag() {
|
||||
@@ -95,11 +112,11 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return (outputFolder + "/lib/WWW/" + invokerPackage + apiPackage()).replace('/', File.separatorChar);
|
||||
return (outputFolder + "/lib/WWW/" + moduleName + apiPackage()).replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return (outputFolder + "/lib/WWW/" + invokerPackage + modelPackage()).replace('/', File.separatorChar);
|
||||
return (outputFolder + "/lib/WWW/" + moduleName + modelPackage()).replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package WWW::{{invokerPackage}}::ApiClient;
|
||||
package WWW::{{moduleName}}::ApiClient;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
@@ -18,18 +18,18 @@ use Log::Any qw($log);
|
||||
use Carp;
|
||||
use Module::Runtime qw(use_module);
|
||||
|
||||
use WWW::{{invokerPackage}}::Configuration;
|
||||
use WWW::{{moduleName}}::Configuration;
|
||||
|
||||
sub new
|
||||
{
|
||||
my $class = shift;
|
||||
my (%args) = (
|
||||
'ua' => LWP::UserAgent->new,
|
||||
'base_url' => '{{basePath}}',
|
||||
@_
|
||||
);
|
||||
|
||||
return bless \%args, $class;
|
||||
my $class = shift;
|
||||
my (%args) = (
|
||||
'ua' => LWP::UserAgent->new,
|
||||
'base_url' => '{{basePath}}',
|
||||
@_
|
||||
);
|
||||
|
||||
return bless \%args, $class;
|
||||
}
|
||||
|
||||
# Set the user agent of the API client
|
||||
@@ -37,8 +37,8 @@ sub new
|
||||
# @param string $user_agent The user agent of the API client
|
||||
#
|
||||
sub set_user_agent {
|
||||
my ($self, $user_agent) = @_;
|
||||
$self->{http_user_agent}= $user_agent;
|
||||
my ($self, $user_agent) = @_;
|
||||
$self->{http_user_agent}= $user_agent;
|
||||
}
|
||||
|
||||
# Set timeout
|
||||
@@ -46,11 +46,11 @@ sub set_user_agent {
|
||||
# @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
|
||||
#
|
||||
sub set_timeout {
|
||||
my ($self, $seconds) = @_;
|
||||
if (!looks_like_number($seconds)) {
|
||||
croak('Timeout variable must be numeric.');
|
||||
}
|
||||
$self->{http_timeout} = $seconds;
|
||||
my ($self, $seconds) = @_;
|
||||
if (!looks_like_number($seconds)) {
|
||||
croak('Timeout variable must be numeric.');
|
||||
}
|
||||
$self->{http_timeout} = $seconds;
|
||||
}
|
||||
|
||||
# make the HTTP request
|
||||
@@ -61,71 +61,71 @@ sub set_timeout {
|
||||
# @param array $headerParams parameters to be place in request header
|
||||
# @return mixed
|
||||
sub call_api {
|
||||
my $self = shift;
|
||||
my ($resource_path, $method, $query_params, $post_params, $header_params, $body_data, $auth_settings) = @_;
|
||||
|
||||
# update parameters based on authentication settings
|
||||
$self->update_params_for_auth($header_params, $query_params, $auth_settings);
|
||||
|
||||
|
||||
my $_url = $self->{base_url} . $resource_path;
|
||||
|
||||
# build query
|
||||
if (%$query_params) {
|
||||
$_url = ($_url . '?' . eval { URI::Query->new($query_params)->stringify });
|
||||
}
|
||||
|
||||
|
||||
# body data
|
||||
$body_data = to_json($body_data->to_hash) if defined $body_data && $body_data->can('to_hash'); # model to json string
|
||||
my $_body_data = %$post_params ? $post_params : $body_data;
|
||||
|
||||
# Make the HTTP request
|
||||
my $_request;
|
||||
if ($method eq 'POST') {
|
||||
# multipart
|
||||
$header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ?
|
||||
'form-data' : $header_params->{'Content-Type'};
|
||||
|
||||
$_request = POST($_url, %$header_params, Content => $_body_data);
|
||||
|
||||
}
|
||||
elsif ($method eq 'PUT') {
|
||||
# multipart
|
||||
$header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ?
|
||||
'form-data' : $header_params->{'Content-Type'};
|
||||
|
||||
$_request = PUT($_url, %$header_params, Content => $_body_data);
|
||||
|
||||
}
|
||||
elsif ($method eq 'GET') {
|
||||
my $headers = HTTP::Headers->new(%$header_params);
|
||||
$_request = GET($_url, %$header_params);
|
||||
}
|
||||
elsif ($method eq 'HEAD') {
|
||||
my $headers = HTTP::Headers->new(%$header_params);
|
||||
$_request = HEAD($_url,%$header_params);
|
||||
}
|
||||
elsif ($method eq 'DELETE') { #TODO support form data
|
||||
my $headers = HTTP::Headers->new(%$header_params);
|
||||
$_request = DELETE($_url, %$headers);
|
||||
}
|
||||
elsif ($method eq 'PATCH') { #TODO
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
$self->{ua}->timeout($self->{http_timeout} || $WWW::{{invokerPackage}}::Configuration::http_timeout);
|
||||
$self->{ua}->agent($self->{http_user_agent} || $WWW::{{invokerPackage}}::Configuration::http_user_agent);
|
||||
my $self = shift;
|
||||
my ($resource_path, $method, $query_params, $post_params, $header_params, $body_data, $auth_settings) = @_;
|
||||
|
||||
# update parameters based on authentication settings
|
||||
$self->update_params_for_auth($header_params, $query_params, $auth_settings);
|
||||
|
||||
|
||||
my $_url = $self->{base_url} . $resource_path;
|
||||
|
||||
# build query
|
||||
if (%$query_params) {
|
||||
$_url = ($_url . '?' . eval { URI::Query->new($query_params)->stringify });
|
||||
}
|
||||
|
||||
|
||||
# body data
|
||||
$body_data = to_json($body_data->to_hash) if defined $body_data && $body_data->can('to_hash'); # model to json string
|
||||
my $_body_data = %$post_params ? $post_params : $body_data;
|
||||
|
||||
# Make the HTTP request
|
||||
my $_request;
|
||||
if ($method eq 'POST') {
|
||||
# multipart
|
||||
$header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ?
|
||||
'form-data' : $header_params->{'Content-Type'};
|
||||
|
||||
$_request = POST($_url, %$header_params, Content => $_body_data);
|
||||
|
||||
}
|
||||
elsif ($method eq 'PUT') {
|
||||
# multipart
|
||||
$header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ?
|
||||
'form-data' : $header_params->{'Content-Type'};
|
||||
|
||||
$_request = PUT($_url, %$header_params, Content => $_body_data);
|
||||
|
||||
}
|
||||
elsif ($method eq 'GET') {
|
||||
my $headers = HTTP::Headers->new(%$header_params);
|
||||
$_request = GET($_url, %$header_params);
|
||||
}
|
||||
elsif ($method eq 'HEAD') {
|
||||
my $headers = HTTP::Headers->new(%$header_params);
|
||||
$_request = HEAD($_url,%$header_params);
|
||||
}
|
||||
elsif ($method eq 'DELETE') { #TODO support form data
|
||||
my $headers = HTTP::Headers->new(%$header_params);
|
||||
$_request = DELETE($_url, %$headers);
|
||||
}
|
||||
elsif ($method eq 'PATCH') { #TODO
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
$self->{ua}->timeout($self->{http_timeout} || $WWW::{{moduleName}}::Configuration::http_timeout);
|
||||
$self->{ua}->agent($self->{http_user_agent} || $WWW::{{moduleName}}::Configuration::http_user_agent);
|
||||
|
||||
my $_response = $self->{ua}->request($_request);
|
||||
|
||||
unless ($_response->is_success) {
|
||||
croak("API Exception(".$_response->code."): ".$_response->message);
|
||||
}
|
||||
|
||||
return $_response->content;
|
||||
|
||||
my $_response = $self->{ua}->request($_request);
|
||||
|
||||
unless ($_response->is_success) {
|
||||
croak("API Exception(".$_response->code."): ".$_response->message);
|
||||
}
|
||||
|
||||
return $_response->content;
|
||||
|
||||
}
|
||||
|
||||
# Take value and turn it into a string suitable for inclusion in
|
||||
@@ -180,13 +180,13 @@ sub to_form_value {
|
||||
# @param string $value the value of the parameter
|
||||
# @return string the header string
|
||||
sub to_string {
|
||||
my ($self, $value) = @_;
|
||||
if (ref($value) eq "DateTime") { # datetime in ISO8601 format
|
||||
return $value->datetime();
|
||||
}
|
||||
else {
|
||||
return $value;
|
||||
}
|
||||
my ($self, $value) = @_;
|
||||
if (ref($value) eq "DateTime") { # datetime in ISO8601 format
|
||||
return $value->datetime();
|
||||
}
|
||||
else {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
# Deserialize a JSON string into an object
|
||||
@@ -196,55 +196,55 @@ sub to_string {
|
||||
# @return object an instance of $class
|
||||
sub deserialize
|
||||
{
|
||||
my ($self, $class, $data) = @_;
|
||||
$log->debugf("deserializing %s for %s", $data, $class);
|
||||
|
||||
if (not defined $data) {
|
||||
return undef;
|
||||
} elsif ( (substr($class, 0, 5)) eq 'HASH[') { #hash
|
||||
if ($class =~ /^HASH\[(.*),(.*)\]$/) {
|
||||
my ($key_type, $type) = ($1, $2);
|
||||
my %hash;
|
||||
my $decoded_data = decode_json $data;
|
||||
foreach my $key (keys %$decoded_data) {
|
||||
if (ref $decoded_data->{$key} eq 'HASH') {
|
||||
$hash{$key} = $self->deserialize($type, encode_json $decoded_data->{$key});
|
||||
my ($self, $class, $data) = @_;
|
||||
$log->debugf("deserializing %s for %s", $data, $class);
|
||||
|
||||
if (not defined $data) {
|
||||
return undef;
|
||||
} elsif ( (substr($class, 0, 5)) eq 'HASH[') { #hash
|
||||
if ($class =~ /^HASH\[(.*),(.*)\]$/) {
|
||||
my ($key_type, $type) = ($1, $2);
|
||||
my %hash;
|
||||
my $decoded_data = decode_json $data;
|
||||
foreach my $key (keys %$decoded_data) {
|
||||
if (ref $decoded_data->{$key} eq 'HASH') {
|
||||
$hash{$key} = $self->deserialize($type, encode_json $decoded_data->{$key});
|
||||
} else {
|
||||
$hash{$key} = $self->deserialize($type, $decoded_data->{$key});
|
||||
}
|
||||
}
|
||||
return \%hash;
|
||||
} else {
|
||||
$hash{$key} = $self->deserialize($type, $decoded_data->{$key});
|
||||
#TODO log error
|
||||
}
|
||||
|
||||
} elsif ( (substr($class, 0, 6)) eq 'ARRAY[' ) { # array of data
|
||||
return $data if $data eq '[]'; # return if empty array
|
||||
|
||||
my $_sub_class = substr($class, 6, -1);
|
||||
my $_json_data = decode_json $data;
|
||||
my @_values = ();
|
||||
foreach my $_value (@$_json_data) {
|
||||
if (ref $_value eq 'ARRAY') {
|
||||
push @_values, $self->deserialize($_sub_class, encode_json $_value);
|
||||
} else {
|
||||
push @_values, $self->deserialize($_sub_class, $_value);
|
||||
}
|
||||
}
|
||||
return \@_values;
|
||||
} elsif ($class eq 'DateTime') {
|
||||
return DateTime->from_epoch(epoch => str2time($data));
|
||||
} elsif (grep /^$class$/, ('string', 'int', 'float', 'bool', 'object')) {
|
||||
return $data;
|
||||
} else { # model
|
||||
my $_instance = use_module("WWW::{{moduleName}}::Object::$class")->new;
|
||||
if (ref $data eq "HASH") {
|
||||
return $_instance->from_hash($data);
|
||||
} else { # string, need to json decode first
|
||||
return $_instance->from_hash(decode_json $data);
|
||||
}
|
||||
}
|
||||
return \%hash;
|
||||
} else {
|
||||
#TODO log error
|
||||
}
|
||||
|
||||
} elsif ( (substr($class, 0, 6)) eq 'ARRAY[' ) { # array of data
|
||||
return $data if $data eq '[]'; # return if empty array
|
||||
|
||||
my $_sub_class = substr($class, 6, -1);
|
||||
my $_json_data = decode_json $data;
|
||||
my @_values = ();
|
||||
foreach my $_value (@$_json_data) {
|
||||
if (ref $_value eq 'ARRAY') {
|
||||
push @_values, $self->deserialize($_sub_class, encode_json $_value);
|
||||
} else {
|
||||
push @_values, $self->deserialize($_sub_class, $_value);
|
||||
}
|
||||
}
|
||||
return \@_values;
|
||||
} elsif ($class eq 'DateTime') {
|
||||
return DateTime->from_epoch(epoch => str2time($data));
|
||||
} elsif (grep /^$class$/, ('string', 'int', 'float', 'bool', 'object')) {
|
||||
return $data;
|
||||
} else { # model
|
||||
my $_instance = use_module("WWW::SwaggerClient::Object::$class")->new;
|
||||
if (ref $data eq "HASH") {
|
||||
return $_instance->from_hash($data);
|
||||
} else { # string, need to json decode first
|
||||
return $_instance->from_hash(decode_json $data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
# return 'Accept' based on an array of accept provided
|
||||
@@ -252,16 +252,16 @@ sub deserialize
|
||||
# @return String Accept (e.g. application/json)
|
||||
sub select_header_accept
|
||||
{
|
||||
my ($self, @header) = @_;
|
||||
|
||||
if (@header == 0 || (@header == 1 && $header[0] eq '')) {
|
||||
return undef;
|
||||
} elsif (grep(/^application\/json$/i, @header)) {
|
||||
return 'application/json';
|
||||
} else {
|
||||
return join(',', @header);
|
||||
}
|
||||
|
||||
my ($self, @header) = @_;
|
||||
|
||||
if (@header == 0 || (@header == 1 && $header[0] eq '')) {
|
||||
return undef;
|
||||
} elsif (grep(/^application\/json$/i, @header)) {
|
||||
return 'application/json';
|
||||
} else {
|
||||
return join(',', @header);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# return the content type based on an array of content-type provided
|
||||
@@ -269,16 +269,16 @@ sub select_header_accept
|
||||
# @return String Content-Type (e.g. application/json)
|
||||
sub select_header_content_type
|
||||
{
|
||||
my ($self, @header) = @_;
|
||||
|
||||
if (@header == 0 || (@header == 1 && $header[0] eq '')) {
|
||||
return 'application/json'; # default to application/json
|
||||
} elsif (grep(/^application\/json$/i, @header)) {
|
||||
return 'application/json';
|
||||
} else {
|
||||
return join(',', @header);
|
||||
}
|
||||
|
||||
my ($self, @header) = @_;
|
||||
|
||||
if (@header == 0 || (@header == 1 && $header[0] eq '')) {
|
||||
return 'application/json'; # default to application/json
|
||||
} elsif (grep(/^application\/json$/i, @header)) {
|
||||
return 'application/json';
|
||||
} else {
|
||||
return join(',', @header);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Get API key (with prefix if set)
|
||||
@@ -287,10 +287,10 @@ sub select_header_content_type
|
||||
sub get_api_key_with_prefix
|
||||
{
|
||||
my ($self, $api_key) = @_;
|
||||
if ($WWW::{{invokerPackage}}::Configuration::api_key_prefix->{$api_key}) {
|
||||
return $WWW::{{invokerPackage}}::Configuration::api_key_prefix->{$api_key}." ".$WWW::{{invokerPackage}}::Configuration::api_key->{$api_key};
|
||||
if ($WWW::{{moduleName}}::Configuration::api_key_prefix->{$api_key}) {
|
||||
return $WWW::{{moduleName}}::Configuration::api_key_prefix->{$api_key}." ".$WWW::{{moduleName}}::Configuration::api_key->{$api_key};
|
||||
} else {
|
||||
return $WWW::{{invokerPackage}}::Configuration::api_key->{$api_key};
|
||||
return $WWW::{{moduleName}}::Configuration::api_key->{$api_key};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,24 +300,24 @@ sub get_api_key_with_prefix
|
||||
# @param array $queryParams query parameters (by ref)
|
||||
# @param array $authSettings array of authentication scheme (e.g ['api_key'])
|
||||
sub update_params_for_auth {
|
||||
my ($self, $header_params, $query_params, $auth_settings) = @_;
|
||||
|
||||
return if (!defined($auth_settings) || scalar(@$auth_settings) == 0);
|
||||
|
||||
# one endpoint can have more than 1 auth settings
|
||||
foreach my $auth (@$auth_settings) {
|
||||
# determine which one to use
|
||||
if (!defined($auth)) {
|
||||
my ($self, $header_params, $query_params, $auth_settings) = @_;
|
||||
|
||||
return if (!defined($auth_settings) || scalar(@$auth_settings) == 0);
|
||||
|
||||
# one endpoint can have more than 1 auth settings
|
||||
foreach my $auth (@$auth_settings) {
|
||||
# determine which one to use
|
||||
if (!defined($auth)) {
|
||||
}
|
||||
{{#authMethods}}elsif ($auth eq '{{name}}') {
|
||||
{{#isApiKey}}{{#isKeyInHeader}}$header_params->{'{{keyParamName}}'} = $self->get_api_key_with_prefix('{{keyParamName}}');{{/isKeyInHeader}}{{#isKeyInQuery}}$query_params->{'{{keyParamName}}'} = $self->get_api_key_with_prefix('{{keyParamName}}');{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}$header_params->{'Authorization'} = 'Basic '.encode_base64($WWW::{{moduleName}}::Configuration::username.":".$WWW::{{moduleName}}::Configuration::password);{{/isBasic}}
|
||||
{{#isOAuth}}# TODO support oauth{{/isOAuth}}
|
||||
}
|
||||
{{/authMethods}}
|
||||
else {
|
||||
# TODO show warning about security definition not found
|
||||
}
|
||||
}
|
||||
{{#authMethods}}elsif ($auth eq '{{name}}') {
|
||||
{{#isApiKey}}{{#isKeyInHeader}}$header_params->{'{{keyParamName}}'} = $self->get_api_key_with_prefix('{{keyParamName}}');{{/isKeyInHeader}}{{#isKeyInQuery}}$query_params->{'{{keyParamName}}'} = $self->get_api_key_with_prefix('{{keyParamName}}');{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}$header_params->{'Authorization'} = 'Basic '.encode_base64($WWW::{{invokerPackage}}::Configuration::username.":".$WWW::{{invokerPackage}}::Configuration::password);{{/isBasic}}
|
||||
{{#isOAuth}}# TODO support oauth{{/isOAuth}}
|
||||
}
|
||||
{{/authMethods}}
|
||||
else {
|
||||
# TODO show warning about security definition not found
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package WWW::{{invokerPackage}}::Object::BaseObject;
|
||||
package WWW::{{moduleName}}::Object::BaseObject;
|
||||
|
||||
require 5.6.0;
|
||||
use strict;
|
||||
@@ -21,56 +21,56 @@ use DateTime;
|
||||
|
||||
# return json string
|
||||
sub to_hash {
|
||||
return decode_json(JSON->new->convert_blessed->encode( shift ));
|
||||
return decode_json(JSON->new->convert_blessed->encode( shift ));
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
my $_data = {};
|
||||
foreach my $_key (keys $self->get_attribute_map) {
|
||||
if (defined $self->{$_key}) {
|
||||
$_data->{$self->get_attribute_map->{$_key}} = $self->{$_key};
|
||||
my $self = shift;
|
||||
my $_data = {};
|
||||
foreach my $_key (keys $self->get_attribute_map) {
|
||||
if (defined $self->{$_key}) {
|
||||
$_data->{$self->get_attribute_map->{$_key}} = $self->{$_key};
|
||||
}
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
return $_data;
|
||||
}
|
||||
|
||||
# from json string
|
||||
sub from_hash {
|
||||
my ($self, $hash) = @_;
|
||||
# loop through attributes and use swagger_types to deserialize the data
|
||||
while ( my ($_key, $_type) = each $self->get_swagger_types ) {
|
||||
if ($_type =~ /^array\[/i) { # array
|
||||
my $_subclass = substr($_type, 6, -1);
|
||||
my @_array = ();
|
||||
foreach my $_element (@{$hash->{$self->get_attribute_map->{$_key}}}) {
|
||||
push @_array, $self->_deserialize($_subclass, $_element);
|
||||
}
|
||||
$self->{$_key} = \@_array;
|
||||
} elsif (defined $hash->{$_key}) { #hash(model), primitive, datetime
|
||||
$self->{$_key} = $self->_deserialize($_type, $hash->{$_key});
|
||||
} else {
|
||||
$log->debugf("warning: %s not defined\n", $_key);
|
||||
my ($self, $hash) = @_;
|
||||
# loop through attributes and use swagger_types to deserialize the data
|
||||
while ( my ($_key, $_type) = each $self->get_swagger_types ) {
|
||||
if ($_type =~ /^array\[/i) { # array
|
||||
my $_subclass = substr($_type, 6, -1);
|
||||
my @_array = ();
|
||||
foreach my $_element (@{$hash->{$self->get_attribute_map->{$_key}}}) {
|
||||
push @_array, $self->_deserialize($_subclass, $_element);
|
||||
}
|
||||
$self->{$_key} = \@_array;
|
||||
} elsif (defined $hash->{$_key}) { #hash(model), primitive, datetime
|
||||
$self->{$_key} = $self->_deserialize($_type, $hash->{$_key});
|
||||
} else {
|
||||
$log->debugf("warning: %s not defined\n", $_key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $self;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
# deserialize non-array data
|
||||
sub _deserialize {
|
||||
my ($self, $type, $data) = @_;
|
||||
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||
|
||||
if ($type eq 'DateTime') {
|
||||
return DateTime->from_epoch(epoch => str2time($data));
|
||||
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||
return $data;
|
||||
} else { # hash(model)
|
||||
my $_instance = eval "WWW::{{invokerPackage}}::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
my ($self, $type, $data) = @_;
|
||||
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||
|
||||
if ($type eq 'DateTime') {
|
||||
return DateTime->from_epoch(epoch => str2time($data));
|
||||
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||
return $data;
|
||||
} else { # hash(model)
|
||||
my $_instance = eval "WWW::{{moduleName}}::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package WWW::{{invokerPackage}}::Configuration;
|
||||
package WWW::{{moduleName}}::Configuration;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
@@ -7,6 +7,8 @@ use utf8;
|
||||
use Log::Any qw($log);
|
||||
use Carp;
|
||||
|
||||
use constant VERSION => '{{moduleVersion}}';
|
||||
|
||||
# class/static variables
|
||||
our $api_client;
|
||||
our $http_timeout = 180;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# NOTE: This class is auto generated by the swagger code generator program.
|
||||
# Do not edit the class manually.
|
||||
#
|
||||
package WWW::{{invokerPackage}}::{{classname}};
|
||||
package WWW::{{moduleName}}::{{classname}};
|
||||
|
||||
require 5.6.0;
|
||||
use strict;
|
||||
@@ -27,18 +27,12 @@ use Exporter;
|
||||
use Carp qw( croak );
|
||||
use Log::Any qw($log);
|
||||
|
||||
use WWW::{{invokerPackage}}::ApiClient;
|
||||
use WWW::{{invokerPackage}}::Configuration;
|
||||
|
||||
{{#operations}}
|
||||
our @EXPORT_OK = qw(
|
||||
{{#operation}}{{{nickname}}}
|
||||
{{/operation}}
|
||||
);
|
||||
use WWW::{{moduleName}}::ApiClient;
|
||||
use WWW::{{moduleName}}::Configuration;
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $default_api_client = $WWW::{{invokerPackage}}::Configuration::api_client ? $WWW::{{invokerPackage}}::Configuration::api_client : WWW::{{invokerPackage}}::ApiClient->new;
|
||||
my $default_api_client = $WWW::{{moduleName}}::Configuration::api_client ? $WWW::{{moduleName}}::Configuration::api_client : WWW::{{moduleName}}::ApiClient->new;
|
||||
my (%self) = (
|
||||
'api_client' => $default_api_client,
|
||||
@_
|
||||
@@ -52,89 +46,90 @@ sub new {
|
||||
bless \%self, $class;
|
||||
|
||||
}
|
||||
{{#operations}}
|
||||
|
||||
{{#operation}}
|
||||
#
|
||||
# {{{nickname}}}
|
||||
#
|
||||
# {{{summary}}}
|
||||
#
|
||||
{{#allParams}} # @param {{dataType}} ${{paramName}} {{description}} {{^optional}}(required){{/optional}}{{#optional}}(optional){{/optional}}
|
||||
{{/allParams}} # @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||
#
|
||||
sub {{nickname}} {
|
||||
my ($self, %args) = @_;
|
||||
{{#operation}}
|
||||
#
|
||||
# {{{nickname}}}
|
||||
#
|
||||
# {{{summary}}}
|
||||
#
|
||||
{{#allParams}}# @param {{dataType}} ${{paramName}} {{description}} {{^optional}}(required){{/optional}}{{#optional}}(optional){{/optional}}
|
||||
{{/allParams}}# @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||
#
|
||||
sub {{nickname}} {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
{{#allParams}}{{#required}}
|
||||
# verify the required parameter '{{paramName}}' is set
|
||||
unless (exists $args{'{{paramName}}'}) {
|
||||
croak("Missing the required parameter '{{paramName}}' when calling {{nickname}}");
|
||||
}
|
||||
{{/required}}{{/allParams}}
|
||||
{{#allParams}}{{#required}}
|
||||
# verify the required parameter '{{paramName}}' is set
|
||||
unless (exists $args{'{{paramName}}'}) {
|
||||
croak("Missing the required parameter '{{paramName}}' when calling {{nickname}}");
|
||||
}
|
||||
{{/required}}{{/allParams}}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '{{path}}';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
# parse inputs
|
||||
my $_resource_path = '{{path}}';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
my $_method = '{{httpMethod}}';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
my $_method = '{{httpMethod}}';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept({{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}});
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept({{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}});
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type({{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}});
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type({{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}});
|
||||
|
||||
{{#queryParams}}# query params
|
||||
if ( exists $args{'{{paramName}}'}) {
|
||||
{{#queryParams}}# query params
|
||||
if ( exists $args{'{{paramName}}'}) {
|
||||
$query_params->{'{{baseName}}'} = $self->{api_client}->to_query_value($args{'{{paramName}}'});
|
||||
}{{/queryParams}}
|
||||
{{#headerParams}}# header params
|
||||
if ( exists $args{'{{paramName}}'}) {
|
||||
}{{/queryParams}}
|
||||
{{#headerParams}}# header params
|
||||
if ( exists $args{'{{paramName}}'}) {
|
||||
$header_params->{'{{baseName}}'} = $self->{api_client}->to_header_value($args{'{{paramName}}'});
|
||||
}{{/headerParams}}
|
||||
{{#pathParams}}# path params
|
||||
if ( exists $args{'{{paramName}}'}) {
|
||||
}{{/headerParams}}
|
||||
{{#pathParams}}# path params
|
||||
if ( exists $args{'{{paramName}}'}) {
|
||||
my $_base_variable = "{" . "{{baseName}}" . "}";
|
||||
my $_base_value = $self->{api_client}->to_path_value($args{'{{paramName}}'});
|
||||
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
||||
}{{/pathParams}}
|
||||
{{#formParams}}# form params
|
||||
if ( exists $args{'{{paramName}}'} ) {
|
||||
}{{/pathParams}}
|
||||
{{#formParams}}# form params
|
||||
if ( exists $args{'{{paramName}}'} ) {
|
||||
{{#isFile}}$form_params->{'{{baseName}}'} = [] unless defined $form_params->{'{{baseName}}'};
|
||||
push $form_params->{'{{baseName}}'}, $args{'{{paramName}}'};
|
||||
{{/isFile}}
|
||||
{{^isFile}}$form_params->{'{{baseName}}'} = $self->{api_client}->to_form_value($args{'{{paramName}}'});
|
||||
{{/isFile}}
|
||||
}{{/formParams}}
|
||||
my $_body_data;
|
||||
{{#bodyParams}}# body params
|
||||
if ( exists $args{'{{paramName}}'}) {
|
||||
}{{/formParams}}
|
||||
my $_body_data;
|
||||
{{#bodyParams}}# body params
|
||||
if ( exists $args{'{{paramName}}'}) {
|
||||
$_body_data = $args{'{{paramName}}'};
|
||||
}{{/bodyParams}}
|
||||
}{{/bodyParams}}
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}];
|
||||
|
||||
# make the API Call
|
||||
{{#returnType}}my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
if (!$response) {
|
||||
# make the API Call
|
||||
{{#returnType}}my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
if (!$response) {
|
||||
return;
|
||||
}
|
||||
my $_response_object = $self->{api_client}->deserialize('{{returnType}}', $response);
|
||||
return $_response_object;{{/returnType}}
|
||||
{{^returnType}}$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
{{/returnType}}
|
||||
}
|
||||
{{/operation}}
|
||||
}
|
||||
my $_response_object = $self->{api_client}->deserialize('{{returnType}}', $response);
|
||||
return $_response_object;{{/returnType}}
|
||||
{{^returnType}}$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
{{/returnType}}
|
||||
}
|
||||
{{/operation}}
|
||||
{{newline}}
|
||||
{{/operations}}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
package WWW::{{invokerPackage}}::Object::{{classname}};
|
||||
package WWW::{{moduleName}}::Object::{{classname}};
|
||||
|
||||
require 5.6.0;
|
||||
use strict;
|
||||
@@ -13,7 +13,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
use base "WWW::{{invokerPackage}}::Object::BaseObject";
|
||||
use base "WWW::{{moduleName}}::Object::BaseObject";
|
||||
|
||||
#
|
||||
#{{description}}
|
||||
@@ -22,13 +22,13 @@ use base "WWW::{{invokerPackage}}::Object::BaseObject";
|
||||
#
|
||||
|
||||
my $swagger_types = {
|
||||
{{#vars}}'{{name}}' => '{{{datatype}}}'{{#hasMore}},
|
||||
{{/hasMore}}{{/vars}}
|
||||
{{#vars}}'{{name}}' => '{{{datatype}}}'{{#hasMore}},
|
||||
{{/hasMore}}{{/vars}}
|
||||
};
|
||||
|
||||
my $attribute_map = {
|
||||
{{#vars}}'{{name}}' => '{{baseName}}'{{#hasMore}},
|
||||
{{/hasMore}}{{/vars}}
|
||||
{{#vars}}'{{name}}' => '{{baseName}}'{{#hasMore}},
|
||||
{{/hasMore}}{{/vars}}
|
||||
};
|
||||
|
||||
# new object
|
||||
@@ -45,12 +45,12 @@ sub new {
|
||||
|
||||
# get swagger type of the attribute
|
||||
sub get_swagger_types {
|
||||
return $swagger_types;
|
||||
return $swagger_types;
|
||||
}
|
||||
|
||||
# get attribute mappping
|
||||
sub get_attribute_map {
|
||||
return $attribute_map;
|
||||
return $attribute_map;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -22,14 +22,14 @@ use WWW::SwaggerClient::Configuration;
|
||||
|
||||
sub new
|
||||
{
|
||||
my $class = shift;
|
||||
my (%args) = (
|
||||
'ua' => LWP::UserAgent->new,
|
||||
'base_url' => 'http://petstore.swagger.io/v2',
|
||||
@_
|
||||
);
|
||||
|
||||
return bless \%args, $class;
|
||||
my $class = shift;
|
||||
my (%args) = (
|
||||
'ua' => LWP::UserAgent->new,
|
||||
'base_url' => 'http://petstore.swagger.io/v2',
|
||||
@_
|
||||
);
|
||||
|
||||
return bless \%args, $class;
|
||||
}
|
||||
|
||||
# Set the user agent of the API client
|
||||
@@ -37,8 +37,8 @@ sub new
|
||||
# @param string $user_agent The user agent of the API client
|
||||
#
|
||||
sub set_user_agent {
|
||||
my ($self, $user_agent) = @_;
|
||||
$self->{http_user_agent}= $user_agent;
|
||||
my ($self, $user_agent) = @_;
|
||||
$self->{http_user_agent}= $user_agent;
|
||||
}
|
||||
|
||||
# Set timeout
|
||||
@@ -46,11 +46,11 @@ sub set_user_agent {
|
||||
# @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
|
||||
#
|
||||
sub set_timeout {
|
||||
my ($self, $seconds) = @_;
|
||||
if (!looks_like_number($seconds)) {
|
||||
croak('Timeout variable must be numeric.');
|
||||
}
|
||||
$self->{http_timeout} = $seconds;
|
||||
my ($self, $seconds) = @_;
|
||||
if (!looks_like_number($seconds)) {
|
||||
croak('Timeout variable must be numeric.');
|
||||
}
|
||||
$self->{http_timeout} = $seconds;
|
||||
}
|
||||
|
||||
# make the HTTP request
|
||||
@@ -61,71 +61,71 @@ sub set_timeout {
|
||||
# @param array $headerParams parameters to be place in request header
|
||||
# @return mixed
|
||||
sub call_api {
|
||||
my $self = shift;
|
||||
my ($resource_path, $method, $query_params, $post_params, $header_params, $body_data, $auth_settings) = @_;
|
||||
|
||||
# update parameters based on authentication settings
|
||||
$self->update_params_for_auth($header_params, $query_params, $auth_settings);
|
||||
|
||||
|
||||
my $_url = $self->{base_url} . $resource_path;
|
||||
|
||||
# build query
|
||||
if (%$query_params) {
|
||||
$_url = ($_url . '?' . eval { URI::Query->new($query_params)->stringify });
|
||||
}
|
||||
|
||||
|
||||
# body data
|
||||
$body_data = to_json($body_data->to_hash) if defined $body_data && $body_data->can('to_hash'); # model to json string
|
||||
my $_body_data = %$post_params ? $post_params : $body_data;
|
||||
|
||||
# Make the HTTP request
|
||||
my $_request;
|
||||
if ($method eq 'POST') {
|
||||
# multipart
|
||||
$header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ?
|
||||
'form-data' : $header_params->{'Content-Type'};
|
||||
|
||||
$_request = POST($_url, %$header_params, Content => $_body_data);
|
||||
|
||||
}
|
||||
elsif ($method eq 'PUT') {
|
||||
# multipart
|
||||
$header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ?
|
||||
'form-data' : $header_params->{'Content-Type'};
|
||||
|
||||
$_request = PUT($_url, %$header_params, Content => $_body_data);
|
||||
|
||||
}
|
||||
elsif ($method eq 'GET') {
|
||||
my $headers = HTTP::Headers->new(%$header_params);
|
||||
$_request = GET($_url, %$header_params);
|
||||
}
|
||||
elsif ($method eq 'HEAD') {
|
||||
my $headers = HTTP::Headers->new(%$header_params);
|
||||
$_request = HEAD($_url,%$header_params);
|
||||
}
|
||||
elsif ($method eq 'DELETE') { #TODO support form data
|
||||
my $headers = HTTP::Headers->new(%$header_params);
|
||||
$_request = DELETE($_url, %$headers);
|
||||
}
|
||||
elsif ($method eq 'PATCH') { #TODO
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
$self->{ua}->timeout($self->{http_timeout} || $WWW::SwaggerClient::Configuration::http_timeout);
|
||||
$self->{ua}->agent($self->{http_user_agent} || $WWW::SwaggerClient::Configuration::http_user_agent);
|
||||
my $self = shift;
|
||||
my ($resource_path, $method, $query_params, $post_params, $header_params, $body_data, $auth_settings) = @_;
|
||||
|
||||
# update parameters based on authentication settings
|
||||
$self->update_params_for_auth($header_params, $query_params, $auth_settings);
|
||||
|
||||
|
||||
my $_url = $self->{base_url} . $resource_path;
|
||||
|
||||
# build query
|
||||
if (%$query_params) {
|
||||
$_url = ($_url . '?' . eval { URI::Query->new($query_params)->stringify });
|
||||
}
|
||||
|
||||
|
||||
# body data
|
||||
$body_data = to_json($body_data->to_hash) if defined $body_data && $body_data->can('to_hash'); # model to json string
|
||||
my $_body_data = %$post_params ? $post_params : $body_data;
|
||||
|
||||
# Make the HTTP request
|
||||
my $_request;
|
||||
if ($method eq 'POST') {
|
||||
# multipart
|
||||
$header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ?
|
||||
'form-data' : $header_params->{'Content-Type'};
|
||||
|
||||
$_request = POST($_url, %$header_params, Content => $_body_data);
|
||||
|
||||
}
|
||||
elsif ($method eq 'PUT') {
|
||||
# multipart
|
||||
$header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ?
|
||||
'form-data' : $header_params->{'Content-Type'};
|
||||
|
||||
$_request = PUT($_url, %$header_params, Content => $_body_data);
|
||||
|
||||
}
|
||||
elsif ($method eq 'GET') {
|
||||
my $headers = HTTP::Headers->new(%$header_params);
|
||||
$_request = GET($_url, %$header_params);
|
||||
}
|
||||
elsif ($method eq 'HEAD') {
|
||||
my $headers = HTTP::Headers->new(%$header_params);
|
||||
$_request = HEAD($_url,%$header_params);
|
||||
}
|
||||
elsif ($method eq 'DELETE') { #TODO support form data
|
||||
my $headers = HTTP::Headers->new(%$header_params);
|
||||
$_request = DELETE($_url, %$headers);
|
||||
}
|
||||
elsif ($method eq 'PATCH') { #TODO
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
$self->{ua}->timeout($self->{http_timeout} || $WWW::SwaggerClient::Configuration::http_timeout);
|
||||
$self->{ua}->agent($self->{http_user_agent} || $WWW::SwaggerClient::Configuration::http_user_agent);
|
||||
|
||||
my $_response = $self->{ua}->request($_request);
|
||||
|
||||
unless ($_response->is_success) {
|
||||
croak("API Exception(".$_response->code."): ".$_response->message);
|
||||
}
|
||||
|
||||
return $_response->content;
|
||||
|
||||
my $_response = $self->{ua}->request($_request);
|
||||
|
||||
unless ($_response->is_success) {
|
||||
croak("API Exception(".$_response->code."): ".$_response->message);
|
||||
}
|
||||
|
||||
return $_response->content;
|
||||
|
||||
}
|
||||
|
||||
# Take value and turn it into a string suitable for inclusion in
|
||||
@@ -180,13 +180,13 @@ sub to_form_value {
|
||||
# @param string $value the value of the parameter
|
||||
# @return string the header string
|
||||
sub to_string {
|
||||
my ($self, $value) = @_;
|
||||
if (ref($value) eq "DateTime") { # datetime in ISO8601 format
|
||||
return $value->datetime();
|
||||
}
|
||||
else {
|
||||
return $value;
|
||||
}
|
||||
my ($self, $value) = @_;
|
||||
if (ref($value) eq "DateTime") { # datetime in ISO8601 format
|
||||
return $value->datetime();
|
||||
}
|
||||
else {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
# Deserialize a JSON string into an object
|
||||
@@ -196,55 +196,55 @@ sub to_string {
|
||||
# @return object an instance of $class
|
||||
sub deserialize
|
||||
{
|
||||
my ($self, $class, $data) = @_;
|
||||
$log->debugf("deserializing %s for %s", $data, $class);
|
||||
|
||||
if (not defined $data) {
|
||||
return undef;
|
||||
} elsif ( (substr($class, 0, 5)) eq 'HASH[') { #hash
|
||||
if ($class =~ /^HASH\[(.*),(.*)\]$/) {
|
||||
my ($key_type, $type) = ($1, $2);
|
||||
my %hash;
|
||||
my $decoded_data = decode_json $data;
|
||||
foreach my $key (keys %$decoded_data) {
|
||||
if (ref $decoded_data->{$key} eq 'HASH') {
|
||||
$hash{$key} = $self->deserialize($type, encode_json $decoded_data->{$key});
|
||||
my ($self, $class, $data) = @_;
|
||||
$log->debugf("deserializing %s for %s", $data, $class);
|
||||
|
||||
if (not defined $data) {
|
||||
return undef;
|
||||
} elsif ( (substr($class, 0, 5)) eq 'HASH[') { #hash
|
||||
if ($class =~ /^HASH\[(.*),(.*)\]$/) {
|
||||
my ($key_type, $type) = ($1, $2);
|
||||
my %hash;
|
||||
my $decoded_data = decode_json $data;
|
||||
foreach my $key (keys %$decoded_data) {
|
||||
if (ref $decoded_data->{$key} eq 'HASH') {
|
||||
$hash{$key} = $self->deserialize($type, encode_json $decoded_data->{$key});
|
||||
} else {
|
||||
$hash{$key} = $self->deserialize($type, $decoded_data->{$key});
|
||||
}
|
||||
}
|
||||
return \%hash;
|
||||
} else {
|
||||
$hash{$key} = $self->deserialize($type, $decoded_data->{$key});
|
||||
#TODO log error
|
||||
}
|
||||
|
||||
} elsif ( (substr($class, 0, 6)) eq 'ARRAY[' ) { # array of data
|
||||
return $data if $data eq '[]'; # return if empty array
|
||||
|
||||
my $_sub_class = substr($class, 6, -1);
|
||||
my $_json_data = decode_json $data;
|
||||
my @_values = ();
|
||||
foreach my $_value (@$_json_data) {
|
||||
if (ref $_value eq 'ARRAY') {
|
||||
push @_values, $self->deserialize($_sub_class, encode_json $_value);
|
||||
} else {
|
||||
push @_values, $self->deserialize($_sub_class, $_value);
|
||||
}
|
||||
}
|
||||
return \@_values;
|
||||
} elsif ($class eq 'DateTime') {
|
||||
return DateTime->from_epoch(epoch => str2time($data));
|
||||
} elsif (grep /^$class$/, ('string', 'int', 'float', 'bool', 'object')) {
|
||||
return $data;
|
||||
} else { # model
|
||||
my $_instance = use_module("WWW::SwaggerClient::Object::$class")->new;
|
||||
if (ref $data eq "HASH") {
|
||||
return $_instance->from_hash($data);
|
||||
} else { # string, need to json decode first
|
||||
return $_instance->from_hash(decode_json $data);
|
||||
}
|
||||
}
|
||||
return \%hash;
|
||||
} else {
|
||||
#TODO log error
|
||||
}
|
||||
|
||||
} elsif ( (substr($class, 0, 6)) eq 'ARRAY[' ) { # array of data
|
||||
return $data if $data eq '[]'; # return if empty array
|
||||
|
||||
my $_sub_class = substr($class, 6, -1);
|
||||
my $_json_data = decode_json $data;
|
||||
my @_values = ();
|
||||
foreach my $_value (@$_json_data) {
|
||||
if (ref $_value eq 'ARRAY') {
|
||||
push @_values, $self->deserialize($_sub_class, encode_json $_value);
|
||||
} else {
|
||||
push @_values, $self->deserialize($_sub_class, $_value);
|
||||
}
|
||||
}
|
||||
return \@_values;
|
||||
} elsif ($class eq 'DateTime') {
|
||||
return DateTime->from_epoch(epoch => str2time($data));
|
||||
} elsif (grep /^$class$/, ('string', 'int', 'float', 'bool', 'object')) {
|
||||
return $data;
|
||||
} else { # model
|
||||
my $_instance = use_module("WWW::SwaggerClient::Object::$class")->new;
|
||||
if (ref $data eq "HASH") {
|
||||
return $_instance->from_hash($data);
|
||||
} else { # string, need to json decode first
|
||||
return $_instance->from_hash(decode_json $data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
# return 'Accept' based on an array of accept provided
|
||||
@@ -252,16 +252,16 @@ sub deserialize
|
||||
# @return String Accept (e.g. application/json)
|
||||
sub select_header_accept
|
||||
{
|
||||
my ($self, @header) = @_;
|
||||
|
||||
if (@header == 0 || (@header == 1 && $header[0] eq '')) {
|
||||
return undef;
|
||||
} elsif (grep(/^application\/json$/i, @header)) {
|
||||
return 'application/json';
|
||||
} else {
|
||||
return join(',', @header);
|
||||
}
|
||||
|
||||
my ($self, @header) = @_;
|
||||
|
||||
if (@header == 0 || (@header == 1 && $header[0] eq '')) {
|
||||
return undef;
|
||||
} elsif (grep(/^application\/json$/i, @header)) {
|
||||
return 'application/json';
|
||||
} else {
|
||||
return join(',', @header);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# return the content type based on an array of content-type provided
|
||||
@@ -269,16 +269,16 @@ sub select_header_accept
|
||||
# @return String Content-Type (e.g. application/json)
|
||||
sub select_header_content_type
|
||||
{
|
||||
my ($self, @header) = @_;
|
||||
|
||||
if (@header == 0 || (@header == 1 && $header[0] eq '')) {
|
||||
return 'application/json'; # default to application/json
|
||||
} elsif (grep(/^application\/json$/i, @header)) {
|
||||
return 'application/json';
|
||||
} else {
|
||||
return join(',', @header);
|
||||
}
|
||||
|
||||
my ($self, @header) = @_;
|
||||
|
||||
if (@header == 0 || (@header == 1 && $header[0] eq '')) {
|
||||
return 'application/json'; # default to application/json
|
||||
} elsif (grep(/^application\/json$/i, @header)) {
|
||||
return 'application/json';
|
||||
} else {
|
||||
return join(',', @header);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Get API key (with prefix if set)
|
||||
@@ -288,9 +288,9 @@ sub get_api_key_with_prefix
|
||||
{
|
||||
my ($self, $api_key) = @_;
|
||||
if ($WWW::SwaggerClient::Configuration::api_key_prefix->{$api_key}) {
|
||||
return $WWW::SwaggerClient::Configuration::api_key_prefix->{$api_key}." ".$WWW::SwaggerClient::Configuration::api_key->{$api_key};
|
||||
return $WWW::SwaggerClient::Configuration::api_key_prefix->{$api_key}." ".$WWW::SwaggerClient::Configuration::api_key->{$api_key};
|
||||
} else {
|
||||
return $WWW::SwaggerClient::Configuration::api_key->{$api_key};
|
||||
return $WWW::SwaggerClient::Configuration::api_key->{$api_key};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,28 +300,28 @@ sub get_api_key_with_prefix
|
||||
# @param array $queryParams query parameters (by ref)
|
||||
# @param array $authSettings array of authentication scheme (e.g ['api_key'])
|
||||
sub update_params_for_auth {
|
||||
my ($self, $header_params, $query_params, $auth_settings) = @_;
|
||||
|
||||
return if (!defined($auth_settings) || scalar(@$auth_settings) == 0);
|
||||
|
||||
# one endpoint can have more than 1 auth settings
|
||||
foreach my $auth (@$auth_settings) {
|
||||
# determine which one to use
|
||||
if (!defined($auth)) {
|
||||
}
|
||||
elsif ($auth eq 'api_key') {
|
||||
$header_params->{'api_key'} = $self->get_api_key_with_prefix('api_key');
|
||||
my ($self, $header_params, $query_params, $auth_settings) = @_;
|
||||
|
||||
return if (!defined($auth_settings) || scalar(@$auth_settings) == 0);
|
||||
|
||||
# one endpoint can have more than 1 auth settings
|
||||
foreach my $auth (@$auth_settings) {
|
||||
# determine which one to use
|
||||
if (!defined($auth)) {
|
||||
}
|
||||
elsif ($auth eq 'api_key') {
|
||||
$header_params->{'api_key'} = $self->get_api_key_with_prefix('api_key');
|
||||
|
||||
}
|
||||
elsif ($auth eq 'petstore_auth') {
|
||||
|
||||
# TODO support oauth
|
||||
}
|
||||
|
||||
else {
|
||||
# TODO show warning about security definition not found
|
||||
}
|
||||
}
|
||||
elsif ($auth eq 'petstore_auth') {
|
||||
|
||||
# TODO support oauth
|
||||
}
|
||||
|
||||
else {
|
||||
# TODO show warning about security definition not found
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ use utf8;
|
||||
use Log::Any qw($log);
|
||||
use Carp;
|
||||
|
||||
use constant VERSION => '1.0.0';
|
||||
|
||||
# class/static variables
|
||||
our $api_client;
|
||||
our $http_timeout = 180;
|
||||
|
||||
@@ -21,56 +21,56 @@ use DateTime;
|
||||
|
||||
# return json string
|
||||
sub to_hash {
|
||||
return decode_json(JSON->new->convert_blessed->encode( shift ));
|
||||
return decode_json(JSON->new->convert_blessed->encode( shift ));
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
my $_data = {};
|
||||
foreach my $_key (keys $self->get_attribute_map) {
|
||||
if (defined $self->{$_key}) {
|
||||
$_data->{$self->get_attribute_map->{$_key}} = $self->{$_key};
|
||||
my $self = shift;
|
||||
my $_data = {};
|
||||
foreach my $_key (keys $self->get_attribute_map) {
|
||||
if (defined $self->{$_key}) {
|
||||
$_data->{$self->get_attribute_map->{$_key}} = $self->{$_key};
|
||||
}
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
return $_data;
|
||||
}
|
||||
|
||||
# from json string
|
||||
sub from_hash {
|
||||
my ($self, $hash) = @_;
|
||||
# loop through attributes and use swagger_types to deserialize the data
|
||||
while ( my ($_key, $_type) = each $self->get_swagger_types ) {
|
||||
if ($_type =~ /^array\[/i) { # array
|
||||
my $_subclass = substr($_type, 6, -1);
|
||||
my @_array = ();
|
||||
foreach my $_element (@{$hash->{$self->get_attribute_map->{$_key}}}) {
|
||||
push @_array, $self->_deserialize($_subclass, $_element);
|
||||
}
|
||||
$self->{$_key} = \@_array;
|
||||
} elsif (defined $hash->{$_key}) { #hash(model), primitive, datetime
|
||||
$self->{$_key} = $self->_deserialize($_type, $hash->{$_key});
|
||||
} else {
|
||||
$log->debugf("warning: %s not defined\n", $_key);
|
||||
my ($self, $hash) = @_;
|
||||
# loop through attributes and use swagger_types to deserialize the data
|
||||
while ( my ($_key, $_type) = each $self->get_swagger_types ) {
|
||||
if ($_type =~ /^array\[/i) { # array
|
||||
my $_subclass = substr($_type, 6, -1);
|
||||
my @_array = ();
|
||||
foreach my $_element (@{$hash->{$self->get_attribute_map->{$_key}}}) {
|
||||
push @_array, $self->_deserialize($_subclass, $_element);
|
||||
}
|
||||
$self->{$_key} = \@_array;
|
||||
} elsif (defined $hash->{$_key}) { #hash(model), primitive, datetime
|
||||
$self->{$_key} = $self->_deserialize($_type, $hash->{$_key});
|
||||
} else {
|
||||
$log->debugf("warning: %s not defined\n", $_key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $self;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
# deserialize non-array data
|
||||
sub _deserialize {
|
||||
my ($self, $type, $data) = @_;
|
||||
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||
|
||||
if ($type eq 'DateTime') {
|
||||
return DateTime->from_epoch(epoch => str2time($data));
|
||||
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||
return $data;
|
||||
} else { # hash(model)
|
||||
my $_instance = eval "WWW::SwaggerClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
my ($self, $type, $data) = @_;
|
||||
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||
|
||||
if ($type eq 'DateTime') {
|
||||
return DateTime->from_epoch(epoch => str2time($data));
|
||||
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||
return $data;
|
||||
} else { # hash(model)
|
||||
my $_instance = eval "WWW::SwaggerClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -20,13 +20,13 @@ use base "WWW::SwaggerClient::Object::BaseObject";
|
||||
#
|
||||
|
||||
my $swagger_types = {
|
||||
'id' => 'int',
|
||||
'name' => 'string'
|
||||
'id' => 'int',
|
||||
'name' => 'string'
|
||||
};
|
||||
|
||||
my $attribute_map = {
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
};
|
||||
|
||||
# new object
|
||||
@@ -44,12 +44,12 @@ sub new {
|
||||
|
||||
# get swagger type of the attribute
|
||||
sub get_swagger_types {
|
||||
return $swagger_types;
|
||||
return $swagger_types;
|
||||
}
|
||||
|
||||
# get attribute mappping
|
||||
sub get_attribute_map {
|
||||
return $attribute_map;
|
||||
return $attribute_map;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -20,21 +20,21 @@ use base "WWW::SwaggerClient::Object::BaseObject";
|
||||
#
|
||||
|
||||
my $swagger_types = {
|
||||
'id' => 'int',
|
||||
'pet_id' => 'int',
|
||||
'quantity' => 'int',
|
||||
'ship_date' => 'DateTime',
|
||||
'status' => 'string',
|
||||
'complete' => 'boolean'
|
||||
'id' => 'int',
|
||||
'pet_id' => 'int',
|
||||
'quantity' => 'int',
|
||||
'ship_date' => 'DateTime',
|
||||
'status' => 'string',
|
||||
'complete' => 'boolean'
|
||||
};
|
||||
|
||||
my $attribute_map = {
|
||||
'id' => 'id',
|
||||
'pet_id' => 'petId',
|
||||
'quantity' => 'quantity',
|
||||
'ship_date' => 'shipDate',
|
||||
'status' => 'status',
|
||||
'complete' => 'complete'
|
||||
'id' => 'id',
|
||||
'pet_id' => 'petId',
|
||||
'quantity' => 'quantity',
|
||||
'ship_date' => 'shipDate',
|
||||
'status' => 'status',
|
||||
'complete' => 'complete'
|
||||
};
|
||||
|
||||
# new object
|
||||
@@ -60,12 +60,12 @@ sub new {
|
||||
|
||||
# get swagger type of the attribute
|
||||
sub get_swagger_types {
|
||||
return $swagger_types;
|
||||
return $swagger_types;
|
||||
}
|
||||
|
||||
# get attribute mappping
|
||||
sub get_attribute_map {
|
||||
return $attribute_map;
|
||||
return $attribute_map;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -20,21 +20,21 @@ use base "WWW::SwaggerClient::Object::BaseObject";
|
||||
#
|
||||
|
||||
my $swagger_types = {
|
||||
'id' => 'int',
|
||||
'category' => 'Category',
|
||||
'name' => 'string',
|
||||
'photo_urls' => 'ARRAY[string]',
|
||||
'tags' => 'ARRAY[Tag]',
|
||||
'status' => 'string'
|
||||
'id' => 'int',
|
||||
'category' => 'Category',
|
||||
'name' => 'string',
|
||||
'photo_urls' => 'ARRAY[string]',
|
||||
'tags' => 'ARRAY[Tag]',
|
||||
'status' => 'string'
|
||||
};
|
||||
|
||||
my $attribute_map = {
|
||||
'id' => 'id',
|
||||
'category' => 'category',
|
||||
'name' => 'name',
|
||||
'photo_urls' => 'photoUrls',
|
||||
'tags' => 'tags',
|
||||
'status' => 'status'
|
||||
'id' => 'id',
|
||||
'category' => 'category',
|
||||
'name' => 'name',
|
||||
'photo_urls' => 'photoUrls',
|
||||
'tags' => 'tags',
|
||||
'status' => 'status'
|
||||
};
|
||||
|
||||
# new object
|
||||
@@ -60,12 +60,12 @@ sub new {
|
||||
|
||||
# get swagger type of the attribute
|
||||
sub get_swagger_types {
|
||||
return $swagger_types;
|
||||
return $swagger_types;
|
||||
}
|
||||
|
||||
# get attribute mappping
|
||||
sub get_attribute_map {
|
||||
return $attribute_map;
|
||||
return $attribute_map;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -20,13 +20,13 @@ use base "WWW::SwaggerClient::Object::BaseObject";
|
||||
#
|
||||
|
||||
my $swagger_types = {
|
||||
'id' => 'int',
|
||||
'name' => 'string'
|
||||
'id' => 'int',
|
||||
'name' => 'string'
|
||||
};
|
||||
|
||||
my $attribute_map = {
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
};
|
||||
|
||||
# new object
|
||||
@@ -44,12 +44,12 @@ sub new {
|
||||
|
||||
# get swagger type of the attribute
|
||||
sub get_swagger_types {
|
||||
return $swagger_types;
|
||||
return $swagger_types;
|
||||
}
|
||||
|
||||
# get attribute mappping
|
||||
sub get_attribute_map {
|
||||
return $attribute_map;
|
||||
return $attribute_map;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -20,25 +20,25 @@ use base "WWW::SwaggerClient::Object::BaseObject";
|
||||
#
|
||||
|
||||
my $swagger_types = {
|
||||
'id' => 'int',
|
||||
'username' => 'string',
|
||||
'first_name' => 'string',
|
||||
'last_name' => 'string',
|
||||
'email' => 'string',
|
||||
'password' => 'string',
|
||||
'phone' => 'string',
|
||||
'user_status' => 'int'
|
||||
'id' => 'int',
|
||||
'username' => 'string',
|
||||
'first_name' => 'string',
|
||||
'last_name' => 'string',
|
||||
'email' => 'string',
|
||||
'password' => 'string',
|
||||
'phone' => 'string',
|
||||
'user_status' => 'int'
|
||||
};
|
||||
|
||||
my $attribute_map = {
|
||||
'id' => 'id',
|
||||
'username' => 'username',
|
||||
'first_name' => 'firstName',
|
||||
'last_name' => 'lastName',
|
||||
'email' => 'email',
|
||||
'password' => 'password',
|
||||
'phone' => 'phone',
|
||||
'user_status' => 'userStatus'
|
||||
'id' => 'id',
|
||||
'username' => 'username',
|
||||
'first_name' => 'firstName',
|
||||
'last_name' => 'lastName',
|
||||
'email' => 'email',
|
||||
'password' => 'password',
|
||||
'phone' => 'phone',
|
||||
'user_status' => 'userStatus'
|
||||
};
|
||||
|
||||
# new object
|
||||
@@ -68,12 +68,12 @@ sub new {
|
||||
|
||||
# get swagger type of the attribute
|
||||
sub get_swagger_types {
|
||||
return $swagger_types;
|
||||
return $swagger_types;
|
||||
}
|
||||
|
||||
# get attribute mappping
|
||||
sub get_attribute_map {
|
||||
return $attribute_map;
|
||||
return $attribute_map;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -30,18 +30,6 @@ use Log::Any qw($log);
|
||||
use WWW::SwaggerClient::ApiClient;
|
||||
use WWW::SwaggerClient::Configuration;
|
||||
|
||||
our @EXPORT_OK = qw(
|
||||
update_pet
|
||||
add_pet
|
||||
find_pets_by_status
|
||||
find_pets_by_tags
|
||||
get_pet_by_id
|
||||
update_pet_with_form
|
||||
delete_pet
|
||||
upload_file
|
||||
|
||||
);
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $default_api_client = $WWW::SwaggerClient::Configuration::api_client ? $WWW::SwaggerClient::Configuration::api_client : WWW::SwaggerClient::ApiClient->new;
|
||||
@@ -59,481 +47,472 @@ sub new {
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# update_pet
|
||||
#
|
||||
# Update an existing pet
|
||||
#
|
||||
# @param Pet $body Pet object that needs to be added to the store (required)
|
||||
# @return void
|
||||
#
|
||||
sub update_pet {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
#
|
||||
# update_pet
|
||||
#
|
||||
# Update an existing pet
|
||||
#
|
||||
# @param Pet $body Pet object that needs to be added to the store (required)
|
||||
# @return void
|
||||
#
|
||||
sub update_pet {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
my $_method = 'PUT';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_method = 'PUT';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json', 'application/xml');
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json', 'application/xml');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
# body params
|
||||
if ( exists $args{'body'}) {
|
||||
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
# body params
|
||||
if ( exists $args{'body'}) {
|
||||
$_body_data = $args{'body'};
|
||||
}
|
||||
}
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = ['petstore_auth'];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = ['petstore_auth'];
|
||||
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# add_pet
|
||||
#
|
||||
# Add a new pet to the store
|
||||
#
|
||||
# @param Pet $body Pet object that needs to be added to the store (required)
|
||||
# @return void
|
||||
#
|
||||
sub add_pet {
|
||||
my ($self, %args) = @_;
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
#
|
||||
# add_pet
|
||||
#
|
||||
# Add a new pet to the store
|
||||
#
|
||||
# @param Pet $body Pet object that needs to be added to the store (required)
|
||||
# @return void
|
||||
#
|
||||
sub add_pet {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json', 'application/xml');
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json', 'application/xml');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
# body params
|
||||
if ( exists $args{'body'}) {
|
||||
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
# body params
|
||||
if ( exists $args{'body'}) {
|
||||
$_body_data = $args{'body'};
|
||||
}
|
||||
}
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = ['petstore_auth'];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = ['petstore_auth'];
|
||||
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# find_pets_by_status
|
||||
#
|
||||
# Finds Pets by status
|
||||
#
|
||||
# @param ARRAY[string] $status Status values that need to be considered for filter (required)
|
||||
# @return ARRAY[Pet]
|
||||
#
|
||||
sub find_pets_by_status {
|
||||
my ($self, %args) = @_;
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
#
|
||||
# find_pets_by_status
|
||||
#
|
||||
# Finds Pets by status
|
||||
#
|
||||
# @param ARRAY[string] $status Status values that need to be considered for filter (required)
|
||||
# @return ARRAY[Pet]
|
||||
#
|
||||
sub find_pets_by_status {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet/findByStatus';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet/findByStatus';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
# query params
|
||||
if ( exists $args{'status'}) {
|
||||
# query params
|
||||
if ( exists $args{'status'}) {
|
||||
$query_params->{'status'} = $self->{api_client}->to_query_value($args{'status'});
|
||||
}
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = ['petstore_auth'];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = ['petstore_auth'];
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
if (!$response) {
|
||||
# make the API Call
|
||||
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
if (!$response) {
|
||||
return;
|
||||
}
|
||||
my $_response_object = $self->{api_client}->deserialize('ARRAY[Pet]', $response);
|
||||
return $_response_object;
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# find_pets_by_tags
|
||||
#
|
||||
# Finds Pets by tags
|
||||
#
|
||||
# @param ARRAY[string] $tags Tags to filter by (required)
|
||||
# @return ARRAY[Pet]
|
||||
#
|
||||
sub find_pets_by_tags {
|
||||
my ($self, %args) = @_;
|
||||
}
|
||||
my $_response_object = $self->{api_client}->deserialize('ARRAY[Pet]', $response);
|
||||
return $_response_object;
|
||||
|
||||
}
|
||||
#
|
||||
# find_pets_by_tags
|
||||
#
|
||||
# Finds Pets by tags
|
||||
#
|
||||
# @param ARRAY[string] $tags Tags to filter by (required)
|
||||
# @return ARRAY[Pet]
|
||||
#
|
||||
sub find_pets_by_tags {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet/findByTags';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet/findByTags';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
# query params
|
||||
if ( exists $args{'tags'}) {
|
||||
# query params
|
||||
if ( exists $args{'tags'}) {
|
||||
$query_params->{'tags'} = $self->{api_client}->to_query_value($args{'tags'});
|
||||
}
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = ['petstore_auth'];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = ['petstore_auth'];
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
if (!$response) {
|
||||
# make the API Call
|
||||
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
if (!$response) {
|
||||
return;
|
||||
}
|
||||
my $_response_object = $self->{api_client}->deserialize('ARRAY[Pet]', $response);
|
||||
return $_response_object;
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# get_pet_by_id
|
||||
#
|
||||
# Find pet by ID
|
||||
#
|
||||
# @param int $pet_id ID of pet that needs to be fetched (required)
|
||||
# @return Pet
|
||||
#
|
||||
sub get_pet_by_id {
|
||||
my ($self, %args) = @_;
|
||||
}
|
||||
my $_response_object = $self->{api_client}->deserialize('ARRAY[Pet]', $response);
|
||||
return $_response_object;
|
||||
|
||||
}
|
||||
#
|
||||
# get_pet_by_id
|
||||
#
|
||||
# Find pet by ID
|
||||
#
|
||||
# @param int $pet_id ID of pet that needs to be fetched (required)
|
||||
# @return Pet
|
||||
#
|
||||
sub get_pet_by_id {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
# verify the required parameter 'pet_id' is set
|
||||
unless (exists $args{'pet_id'}) {
|
||||
croak("Missing the required parameter 'pet_id' when calling get_pet_by_id");
|
||||
}
|
||||
|
||||
|
||||
# verify the required parameter 'pet_id' is set
|
||||
unless (exists $args{'pet_id'}) {
|
||||
croak("Missing the required parameter 'pet_id' when calling get_pet_by_id");
|
||||
}
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet/{petId}';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet/{petId}';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if ( exists $args{'pet_id'}) {
|
||||
|
||||
|
||||
# path params
|
||||
if ( exists $args{'pet_id'}) {
|
||||
my $_base_variable = "{" . "petId" . "}";
|
||||
my $_base_value = $self->{api_client}->to_path_value($args{'pet_id'});
|
||||
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
||||
}
|
||||
|
||||
my $_body_data;
|
||||
|
||||
}
|
||||
|
||||
my $_body_data;
|
||||
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = ['api_key', 'petstore_auth'];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = ['api_key', 'petstore_auth'];
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
if (!$response) {
|
||||
# make the API Call
|
||||
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
if (!$response) {
|
||||
return;
|
||||
}
|
||||
my $_response_object = $self->{api_client}->deserialize('Pet', $response);
|
||||
return $_response_object;
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# update_pet_with_form
|
||||
#
|
||||
# Updates a pet in the store with form data
|
||||
#
|
||||
# @param string $pet_id ID of pet that needs to be updated (required)
|
||||
# @param string $name Updated name of the pet (required)
|
||||
# @param string $status Updated status of the pet (required)
|
||||
# @return void
|
||||
#
|
||||
sub update_pet_with_form {
|
||||
my ($self, %args) = @_;
|
||||
}
|
||||
my $_response_object = $self->{api_client}->deserialize('Pet', $response);
|
||||
return $_response_object;
|
||||
|
||||
}
|
||||
#
|
||||
# update_pet_with_form
|
||||
#
|
||||
# Updates a pet in the store with form data
|
||||
#
|
||||
# @param string $pet_id ID of pet that needs to be updated (required)
|
||||
# @param string $name Updated name of the pet (required)
|
||||
# @param string $status Updated status of the pet (required)
|
||||
# @return void
|
||||
#
|
||||
sub update_pet_with_form {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
# verify the required parameter 'pet_id' is set
|
||||
unless (exists $args{'pet_id'}) {
|
||||
croak("Missing the required parameter 'pet_id' when calling update_pet_with_form");
|
||||
}
|
||||
|
||||
|
||||
# verify the required parameter 'pet_id' is set
|
||||
unless (exists $args{'pet_id'}) {
|
||||
croak("Missing the required parameter 'pet_id' when calling update_pet_with_form");
|
||||
}
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet/{petId}';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet/{petId}';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if ( exists $args{'pet_id'}) {
|
||||
|
||||
|
||||
# path params
|
||||
if ( exists $args{'pet_id'}) {
|
||||
my $_base_variable = "{" . "petId" . "}";
|
||||
my $_base_value = $self->{api_client}->to_path_value($args{'pet_id'});
|
||||
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
||||
}
|
||||
# form params
|
||||
if ( exists $args{'name'} ) {
|
||||
}
|
||||
# form params
|
||||
if ( exists $args{'name'} ) {
|
||||
|
||||
$form_params->{'name'} = $self->{api_client}->to_form_value($args{'name'});
|
||||
|
||||
}# form params
|
||||
if ( exists $args{'status'} ) {
|
||||
}# form params
|
||||
if ( exists $args{'status'} ) {
|
||||
|
||||
$form_params->{'status'} = $self->{api_client}->to_form_value($args{'status'});
|
||||
|
||||
}
|
||||
my $_body_data;
|
||||
|
||||
}
|
||||
my $_body_data;
|
||||
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = ['petstore_auth'];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = ['petstore_auth'];
|
||||
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# delete_pet
|
||||
#
|
||||
# Deletes a pet
|
||||
#
|
||||
# @param string $api_key (required)
|
||||
# @param int $pet_id Pet id to delete (required)
|
||||
# @return void
|
||||
#
|
||||
sub delete_pet {
|
||||
my ($self, %args) = @_;
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
#
|
||||
# delete_pet
|
||||
#
|
||||
# Deletes a pet
|
||||
#
|
||||
# @param string $api_key (required)
|
||||
# @param int $pet_id Pet id to delete (required)
|
||||
# @return void
|
||||
#
|
||||
sub delete_pet {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
# verify the required parameter 'pet_id' is set
|
||||
unless (exists $args{'pet_id'}) {
|
||||
croak("Missing the required parameter 'pet_id' when calling delete_pet");
|
||||
}
|
||||
|
||||
|
||||
# verify the required parameter 'pet_id' is set
|
||||
unless (exists $args{'pet_id'}) {
|
||||
croak("Missing the required parameter 'pet_id' when calling delete_pet");
|
||||
}
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet/{petId}';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet/{petId}';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
my $_method = 'DELETE';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
my $_method = 'DELETE';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
# header params
|
||||
if ( exists $args{'api_key'}) {
|
||||
|
||||
# header params
|
||||
if ( exists $args{'api_key'}) {
|
||||
$header_params->{'api_key'} = $self->{api_client}->to_header_value($args{'api_key'});
|
||||
}
|
||||
# path params
|
||||
if ( exists $args{'pet_id'}) {
|
||||
}
|
||||
# path params
|
||||
if ( exists $args{'pet_id'}) {
|
||||
my $_base_variable = "{" . "petId" . "}";
|
||||
my $_base_value = $self->{api_client}->to_path_value($args{'pet_id'});
|
||||
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
||||
}
|
||||
|
||||
my $_body_data;
|
||||
|
||||
}
|
||||
|
||||
my $_body_data;
|
||||
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = ['petstore_auth'];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = ['petstore_auth'];
|
||||
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# upload_file
|
||||
#
|
||||
# uploads an image
|
||||
#
|
||||
# @param int $pet_id ID of pet to update (required)
|
||||
# @param string $additional_metadata Additional data to pass to server (required)
|
||||
# @param file $file file to upload (required)
|
||||
# @return void
|
||||
#
|
||||
sub upload_file {
|
||||
my ($self, %args) = @_;
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
#
|
||||
# upload_file
|
||||
#
|
||||
# uploads an image
|
||||
#
|
||||
# @param int $pet_id ID of pet to update (required)
|
||||
# @param string $additional_metadata Additional data to pass to server (required)
|
||||
# @param file $file file to upload (required)
|
||||
# @return void
|
||||
#
|
||||
sub upload_file {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
# verify the required parameter 'pet_id' is set
|
||||
unless (exists $args{'pet_id'}) {
|
||||
croak("Missing the required parameter 'pet_id' when calling upload_file");
|
||||
}
|
||||
|
||||
|
||||
# verify the required parameter 'pet_id' is set
|
||||
unless (exists $args{'pet_id'}) {
|
||||
croak("Missing the required parameter 'pet_id' when calling upload_file");
|
||||
}
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet/{petId}/uploadImage';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet/{petId}/uploadImage';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('multipart/form-data');
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('multipart/form-data');
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if ( exists $args{'pet_id'}) {
|
||||
|
||||
|
||||
# path params
|
||||
if ( exists $args{'pet_id'}) {
|
||||
my $_base_variable = "{" . "petId" . "}";
|
||||
my $_base_value = $self->{api_client}->to_path_value($args{'pet_id'});
|
||||
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
||||
}
|
||||
# form params
|
||||
if ( exists $args{'additional_metadata'} ) {
|
||||
}
|
||||
# form params
|
||||
if ( exists $args{'additional_metadata'} ) {
|
||||
|
||||
$form_params->{'additionalMetadata'} = $self->{api_client}->to_form_value($args{'additional_metadata'});
|
||||
|
||||
}# form params
|
||||
if ( exists $args{'file'} ) {
|
||||
}# form params
|
||||
if ( exists $args{'file'} ) {
|
||||
$form_params->{'file'} = [] unless defined $form_params->{'file'};
|
||||
push $form_params->{'file'}, $args{'file'};
|
||||
|
||||
|
||||
}
|
||||
my $_body_data;
|
||||
|
||||
}
|
||||
my $_body_data;
|
||||
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = ['petstore_auth'];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = ['petstore_auth'];
|
||||
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
@@ -30,14 +30,6 @@ use Log::Any qw($log);
|
||||
use WWW::SwaggerClient::ApiClient;
|
||||
use WWW::SwaggerClient::Configuration;
|
||||
|
||||
our @EXPORT_OK = qw(
|
||||
get_inventory
|
||||
place_order
|
||||
get_order_by_id
|
||||
delete_order
|
||||
|
||||
);
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $default_api_client = $WWW::SwaggerClient::Configuration::api_client ? $WWW::SwaggerClient::Configuration::api_client : WWW::SwaggerClient::ApiClient->new;
|
||||
@@ -55,230 +47,225 @@ sub new {
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# get_inventory
|
||||
#
|
||||
# Returns pet inventories by status
|
||||
#
|
||||
# @return HASH[string,int]
|
||||
#
|
||||
sub get_inventory {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
#
|
||||
# get_inventory
|
||||
#
|
||||
# Returns pet inventories by status
|
||||
#
|
||||
# @return HASH[string,int]
|
||||
#
|
||||
sub get_inventory {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/store/inventory';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/store/inventory';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = ['api_key'];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = ['api_key'];
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
if (!$response) {
|
||||
# make the API Call
|
||||
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
if (!$response) {
|
||||
return;
|
||||
}
|
||||
my $_response_object = $self->{api_client}->deserialize('HASH[string,int]', $response);
|
||||
return $_response_object;
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# place_order
|
||||
#
|
||||
# Place an order for a pet
|
||||
#
|
||||
# @param Order $body order placed for purchasing the pet (required)
|
||||
# @return Order
|
||||
#
|
||||
sub place_order {
|
||||
my ($self, %args) = @_;
|
||||
}
|
||||
my $_response_object = $self->{api_client}->deserialize('HASH[string,int]', $response);
|
||||
return $_response_object;
|
||||
|
||||
}
|
||||
#
|
||||
# place_order
|
||||
#
|
||||
# Place an order for a pet
|
||||
#
|
||||
# @param Order $body order placed for purchasing the pet (required)
|
||||
# @return Order
|
||||
#
|
||||
sub place_order {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/store/order';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
# parse inputs
|
||||
my $_resource_path = '/store/order';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
# body params
|
||||
if ( exists $args{'body'}) {
|
||||
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
# body params
|
||||
if ( exists $args{'body'}) {
|
||||
$_body_data = $args{'body'};
|
||||
}
|
||||
}
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
if (!$response) {
|
||||
# make the API Call
|
||||
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
if (!$response) {
|
||||
return;
|
||||
}
|
||||
my $_response_object = $self->{api_client}->deserialize('Order', $response);
|
||||
return $_response_object;
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# get_order_by_id
|
||||
#
|
||||
# Find purchase order by ID
|
||||
#
|
||||
# @param string $order_id ID of pet that needs to be fetched (required)
|
||||
# @return Order
|
||||
#
|
||||
sub get_order_by_id {
|
||||
my ($self, %args) = @_;
|
||||
}
|
||||
my $_response_object = $self->{api_client}->deserialize('Order', $response);
|
||||
return $_response_object;
|
||||
|
||||
}
|
||||
#
|
||||
# get_order_by_id
|
||||
#
|
||||
# Find purchase order by ID
|
||||
#
|
||||
# @param string $order_id ID of pet that needs to be fetched (required)
|
||||
# @return Order
|
||||
#
|
||||
sub get_order_by_id {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
# verify the required parameter 'order_id' is set
|
||||
unless (exists $args{'order_id'}) {
|
||||
croak("Missing the required parameter 'order_id' when calling get_order_by_id");
|
||||
}
|
||||
|
||||
|
||||
# verify the required parameter 'order_id' is set
|
||||
unless (exists $args{'order_id'}) {
|
||||
croak("Missing the required parameter 'order_id' when calling get_order_by_id");
|
||||
}
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/store/order/{orderId}';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
# parse inputs
|
||||
my $_resource_path = '/store/order/{orderId}';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if ( exists $args{'order_id'}) {
|
||||
|
||||
|
||||
# path params
|
||||
if ( exists $args{'order_id'}) {
|
||||
my $_base_variable = "{" . "orderId" . "}";
|
||||
my $_base_value = $self->{api_client}->to_path_value($args{'order_id'});
|
||||
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
||||
}
|
||||
|
||||
my $_body_data;
|
||||
|
||||
}
|
||||
|
||||
my $_body_data;
|
||||
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
if (!$response) {
|
||||
# make the API Call
|
||||
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
if (!$response) {
|
||||
return;
|
||||
}
|
||||
my $_response_object = $self->{api_client}->deserialize('Order', $response);
|
||||
return $_response_object;
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# delete_order
|
||||
#
|
||||
# Delete purchase order by ID
|
||||
#
|
||||
# @param string $order_id ID of the order that needs to be deleted (required)
|
||||
# @return void
|
||||
#
|
||||
sub delete_order {
|
||||
my ($self, %args) = @_;
|
||||
}
|
||||
my $_response_object = $self->{api_client}->deserialize('Order', $response);
|
||||
return $_response_object;
|
||||
|
||||
}
|
||||
#
|
||||
# delete_order
|
||||
#
|
||||
# Delete purchase order by ID
|
||||
#
|
||||
# @param string $order_id ID of the order that needs to be deleted (required)
|
||||
# @return void
|
||||
#
|
||||
sub delete_order {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
# verify the required parameter 'order_id' is set
|
||||
unless (exists $args{'order_id'}) {
|
||||
croak("Missing the required parameter 'order_id' when calling delete_order");
|
||||
}
|
||||
|
||||
|
||||
# verify the required parameter 'order_id' is set
|
||||
unless (exists $args{'order_id'}) {
|
||||
croak("Missing the required parameter 'order_id' when calling delete_order");
|
||||
}
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/store/order/{orderId}';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
# parse inputs
|
||||
my $_resource_path = '/store/order/{orderId}';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
my $_method = 'DELETE';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
my $_method = 'DELETE';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if ( exists $args{'order_id'}) {
|
||||
|
||||
|
||||
# path params
|
||||
if ( exists $args{'order_id'}) {
|
||||
my $_base_variable = "{" . "orderId" . "}";
|
||||
my $_base_value = $self->{api_client}->to_path_value($args{'order_id'});
|
||||
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
||||
}
|
||||
|
||||
my $_body_data;
|
||||
|
||||
}
|
||||
|
||||
my $_body_data;
|
||||
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
@@ -30,18 +30,6 @@ use Log::Any qw($log);
|
||||
use WWW::SwaggerClient::ApiClient;
|
||||
use WWW::SwaggerClient::Configuration;
|
||||
|
||||
our @EXPORT_OK = qw(
|
||||
create_user
|
||||
create_users_with_array_input
|
||||
create_users_with_list_input
|
||||
login_user
|
||||
logout_user
|
||||
get_user_by_name
|
||||
update_user
|
||||
delete_user
|
||||
|
||||
);
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $default_api_client = $WWW::SwaggerClient::Configuration::api_client ? $WWW::SwaggerClient::Configuration::api_client : WWW::SwaggerClient::ApiClient->new;
|
||||
@@ -59,446 +47,437 @@ sub new {
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# create_user
|
||||
#
|
||||
# Create user
|
||||
#
|
||||
# @param User $body Created user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub create_user {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
#
|
||||
# create_user
|
||||
#
|
||||
# Create user
|
||||
#
|
||||
# @param User $body Created user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub create_user {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/user';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/user';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
# body params
|
||||
if ( exists $args{'body'}) {
|
||||
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
# body params
|
||||
if ( exists $args{'body'}) {
|
||||
$_body_data = $args{'body'};
|
||||
}
|
||||
}
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# create_users_with_array_input
|
||||
#
|
||||
# Creates list of users with given input array
|
||||
#
|
||||
# @param ARRAY[User] $body List of user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub create_users_with_array_input {
|
||||
my ($self, %args) = @_;
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
#
|
||||
# create_users_with_array_input
|
||||
#
|
||||
# Creates list of users with given input array
|
||||
#
|
||||
# @param ARRAY[User] $body List of user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub create_users_with_array_input {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/createWithArray';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/createWithArray';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
# body params
|
||||
if ( exists $args{'body'}) {
|
||||
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
# body params
|
||||
if ( exists $args{'body'}) {
|
||||
$_body_data = $args{'body'};
|
||||
}
|
||||
}
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# create_users_with_list_input
|
||||
#
|
||||
# Creates list of users with given input array
|
||||
#
|
||||
# @param ARRAY[User] $body List of user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub create_users_with_list_input {
|
||||
my ($self, %args) = @_;
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
#
|
||||
# create_users_with_list_input
|
||||
#
|
||||
# Creates list of users with given input array
|
||||
#
|
||||
# @param ARRAY[User] $body List of user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub create_users_with_list_input {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/createWithList';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/createWithList';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
# body params
|
||||
if ( exists $args{'body'}) {
|
||||
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
# body params
|
||||
if ( exists $args{'body'}) {
|
||||
$_body_data = $args{'body'};
|
||||
}
|
||||
}
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# login_user
|
||||
#
|
||||
# Logs user into the system
|
||||
#
|
||||
# @param string $username The user name for login (required)
|
||||
# @param string $password The password for login in clear text (required)
|
||||
# @return string
|
||||
#
|
||||
sub login_user {
|
||||
my ($self, %args) = @_;
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
#
|
||||
# login_user
|
||||
#
|
||||
# Logs user into the system
|
||||
#
|
||||
# @param string $username The user name for login (required)
|
||||
# @param string $password The password for login in clear text (required)
|
||||
# @return string
|
||||
#
|
||||
sub login_user {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/login';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/login';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
# query params
|
||||
if ( exists $args{'username'}) {
|
||||
# query params
|
||||
if ( exists $args{'username'}) {
|
||||
$query_params->{'username'} = $self->{api_client}->to_query_value($args{'username'});
|
||||
}# query params
|
||||
if ( exists $args{'password'}) {
|
||||
}# query params
|
||||
if ( exists $args{'password'}) {
|
||||
$query_params->{'password'} = $self->{api_client}->to_query_value($args{'password'});
|
||||
}
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
if (!$response) {
|
||||
# make the API Call
|
||||
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
if (!$response) {
|
||||
return;
|
||||
}
|
||||
my $_response_object = $self->{api_client}->deserialize('string', $response);
|
||||
return $_response_object;
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# logout_user
|
||||
#
|
||||
# Logs out current logged in user session
|
||||
#
|
||||
# @return void
|
||||
#
|
||||
sub logout_user {
|
||||
my ($self, %args) = @_;
|
||||
}
|
||||
my $_response_object = $self->{api_client}->deserialize('string', $response);
|
||||
return $_response_object;
|
||||
|
||||
}
|
||||
#
|
||||
# logout_user
|
||||
#
|
||||
# Logs out current logged in user session
|
||||
#
|
||||
# @return void
|
||||
#
|
||||
sub logout_user {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/logout';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/logout';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
my $_body_data;
|
||||
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# get_user_by_name
|
||||
#
|
||||
# Get user by user name
|
||||
#
|
||||
# @param string $username The name that needs to be fetched. Use user1 for testing. (required)
|
||||
# @return User
|
||||
#
|
||||
sub get_user_by_name {
|
||||
my ($self, %args) = @_;
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
#
|
||||
# get_user_by_name
|
||||
#
|
||||
# Get user by user name
|
||||
#
|
||||
# @param string $username The name that needs to be fetched. Use user1 for testing. (required)
|
||||
# @return User
|
||||
#
|
||||
sub get_user_by_name {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
# verify the required parameter 'username' is set
|
||||
unless (exists $args{'username'}) {
|
||||
croak("Missing the required parameter 'username' when calling get_user_by_name");
|
||||
}
|
||||
|
||||
|
||||
# verify the required parameter 'username' is set
|
||||
unless (exists $args{'username'}) {
|
||||
croak("Missing the required parameter 'username' when calling get_user_by_name");
|
||||
}
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/{username}';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/{username}';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if ( exists $args{'username'}) {
|
||||
|
||||
|
||||
# path params
|
||||
if ( exists $args{'username'}) {
|
||||
my $_base_variable = "{" . "username" . "}";
|
||||
my $_base_value = $self->{api_client}->to_path_value($args{'username'});
|
||||
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
||||
}
|
||||
|
||||
my $_body_data;
|
||||
|
||||
}
|
||||
|
||||
my $_body_data;
|
||||
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
|
||||
# make the API Call
|
||||
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
if (!$response) {
|
||||
# make the API Call
|
||||
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
if (!$response) {
|
||||
return;
|
||||
}
|
||||
my $_response_object = $self->{api_client}->deserialize('User', $response);
|
||||
return $_response_object;
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# update_user
|
||||
#
|
||||
# Updated user
|
||||
#
|
||||
# @param string $username name that need to be deleted (required)
|
||||
# @param User $body Updated user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub update_user {
|
||||
my ($self, %args) = @_;
|
||||
}
|
||||
my $_response_object = $self->{api_client}->deserialize('User', $response);
|
||||
return $_response_object;
|
||||
|
||||
}
|
||||
#
|
||||
# update_user
|
||||
#
|
||||
# Updated user
|
||||
#
|
||||
# @param string $username name that need to be deleted (required)
|
||||
# @param User $body Updated user object (required)
|
||||
# @return void
|
||||
#
|
||||
sub update_user {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
# verify the required parameter 'username' is set
|
||||
unless (exists $args{'username'}) {
|
||||
croak("Missing the required parameter 'username' when calling update_user");
|
||||
}
|
||||
|
||||
|
||||
# verify the required parameter 'username' is set
|
||||
unless (exists $args{'username'}) {
|
||||
croak("Missing the required parameter 'username' when calling update_user");
|
||||
}
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/{username}';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/{username}';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
my $_method = 'PUT';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
my $_method = 'PUT';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if ( exists $args{'username'}) {
|
||||
|
||||
|
||||
# path params
|
||||
if ( exists $args{'username'}) {
|
||||
my $_base_variable = "{" . "username" . "}";
|
||||
my $_base_value = $self->{api_client}->to_path_value($args{'username'});
|
||||
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
||||
}
|
||||
|
||||
my $_body_data;
|
||||
# body params
|
||||
if ( exists $args{'body'}) {
|
||||
}
|
||||
|
||||
my $_body_data;
|
||||
# body params
|
||||
if ( exists $args{'body'}) {
|
||||
$_body_data = $args{'body'};
|
||||
}
|
||||
}
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# delete_user
|
||||
#
|
||||
# Delete user
|
||||
#
|
||||
# @param string $username The name that needs to be deleted (required)
|
||||
# @return void
|
||||
#
|
||||
sub delete_user {
|
||||
my ($self, %args) = @_;
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
#
|
||||
# delete_user
|
||||
#
|
||||
# Delete user
|
||||
#
|
||||
# @param string $username The name that needs to be deleted (required)
|
||||
# @return void
|
||||
#
|
||||
sub delete_user {
|
||||
my ($self, %args) = @_;
|
||||
|
||||
|
||||
# verify the required parameter 'username' is set
|
||||
unless (exists $args{'username'}) {
|
||||
croak("Missing the required parameter 'username' when calling delete_user");
|
||||
}
|
||||
|
||||
|
||||
# verify the required parameter 'username' is set
|
||||
unless (exists $args{'username'}) {
|
||||
croak("Missing the required parameter 'username' when calling delete_user");
|
||||
}
|
||||
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/{username}';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/{username}';
|
||||
$_resource_path =~ s/{format}/json/; # default format to json
|
||||
|
||||
my $_method = 'DELETE';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
my $_method = 'DELETE';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
# 'Accept' and 'Content-Type' header
|
||||
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
|
||||
if ($_header_accept) {
|
||||
$header_params->{'Accept'} = $_header_accept;
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
}
|
||||
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||
|
||||
|
||||
|
||||
# path params
|
||||
if ( exists $args{'username'}) {
|
||||
|
||||
|
||||
# path params
|
||||
if ( exists $args{'username'}) {
|
||||
my $_base_variable = "{" . "username" . "}";
|
||||
my $_base_value = $self->{api_client}->to_path_value($args{'username'});
|
||||
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
||||
}
|
||||
|
||||
my $_body_data;
|
||||
|
||||
}
|
||||
|
||||
my $_body_data;
|
||||
|
||||
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
# authentication setting, if any
|
||||
my $auth_settings = [];
|
||||
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
# make the API Call
|
||||
|
||||
$self->{api_client}->call_api($_resource_path, $_method,
|
||||
$query_params, $form_params,
|
||||
$header_params, $_body_data, $auth_settings);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
Reference in New Issue
Block a user