package gorgone::modules::plugins::newtest::libs::stubs::ManagementConsoleService;

sub SOAP::Serializer::as_SearchMode {
    my $self = shift;
    my($value, $name, $type, $attr) = @_;
    return [$name, {'xsi:type' => 'tns:SearchMode', %$attr}, $value];
}

sub SOAP::Serializer::as_MessageCategory {
    my $self = shift;
    my($value, $name, $type, $attr) = @_;
    return [$name, {'xsi:type' => 'tns:MessageCategory', %$attr}, $value];
}

sub SOAP::Serializer::as_ArrayOfString {
    my $self = shift;
    my($value, $name, $type, $attr) = @_;

    my $args = [];
    foreach (@$value) {
        push @$args, SOAP::Data->new(name => 'string', type => 's:string', attr => {}, prefix => 'tns', value => $_);
    }
    return [$name, {'xsi:type' => 'tns:ArrayOfString', %$attr}, $args];
}

# Generated by SOAP::Lite (v0.712) for Perl -- soaplite.com
# Copyright (C) 2000-2006 Paul Kulchenko, Byrne Reese
# -- generated at [Tue Oct  7 11:04:21 2014]
# -- generated from http://192.168.6.84/nws/managementconsoleservice.asmx?wsdl
my %methods = (
ListInformationRangesFromDWH => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/ListInformationRangesFromDWH',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'mode', type => 'tns:SearchMode', attr => {}),
      SOAP::Data->new(name => 'args', type => 'tns:ArrayOfString', attr => {}),
    ], # end parameters
  }, # end ListInformationRangesFromDWH
ListComponentStatus => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/ListComponentStatus',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'mode', type => 'tns:SearchMode', attr => {}),
      SOAP::Data->new(name => 'args', type => 'tns:ArrayOfString', attr => {}),
    ], # end parameters
  }, # end ListComponentStatus
IsOptionAllowed => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/IsOptionAllowed',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'optionId', type => 's:int', attr => {}),
    ], # end parameters
  }, # end IsOptionAllowed
SendCommand => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/SendCommand',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'commandType', type => 'tns:CommandType', attr => {}),
      SOAP::Data->new(name => 'agentName', type => 's:string', attr => {}),
      SOAP::Data->new(name => 'args', type => 'tns:ArrayOfString', attr => {}),
    ], # end parameters
  }, # end SendCommand
ListInformationRanges => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/ListInformationRanges',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'mode', type => 'tns:SearchMode', attr => {}),
      SOAP::Data->new(name => 'args', type => 'tns:ArrayOfString', attr => {}),
    ], # end parameters
  }, # end ListInformationRanges
ListResources => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/ListResources',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'mode', type => 'tns:SearchMode', attr => {}),
      SOAP::Data->new(name => 'args', type => 'tns:ArrayOfString', attr => {}),
    ], # end parameters
  }, # end ListResources
GetLocationProperties => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/GetLocationProperties',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'locationPath', type => 's:string', attr => {}),
    ], # end parameters
  }, # end GetLocationProperties
ListLocationChildren => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/ListLocationChildren',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'locationPath', type => 's:string', attr => {}),
      SOAP::Data->new(name => 'recursive', type => 's:boolean', attr => {}),
    ], # end parameters
  }, # end ListLocationChildren
ListBusinessChildren => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/ListBusinessChildren',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'businessPath', type => 's:string', attr => {}),
      SOAP::Data->new(name => 'recursive', type => 's:boolean', attr => {}),
    ], # end parameters
  }, # end ListBusinessChildren
GetMeasureProperties => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/GetMeasureProperties',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'measurePath', type => 's:string', attr => {}),
    ], # end parameters
  }, # end GetMeasureProperties
GetBusinessProperties => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/GetBusinessProperties',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'businessPath', type => 's:string', attr => {}),
    ], # end parameters
  }, # end GetBusinessProperties
ListResults => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/ListResults',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'mode', type => 'tns:SearchMode', attr => {}, prefix => 'tns'),
      SOAP::Data->new(name => 'range', type => 's:int', attr => {}, prefix => 'tns'),
      SOAP::Data->new(name => 'args', type => 'tns:ArrayOfString', attr => {}, prefix => 'tns'),
    ], # end parameters
  }, # end ListResults
ListRobotStatus => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/ListRobotStatus',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'mode', type => 'tns:SearchMode', attr => {}),
      SOAP::Data->new(name => 'args', type => 'tns:ArrayOfString', attr => {}),
    ], # end parameters
  }, # end ListRobotStatus
ListAllResults => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/ListAllResults',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'mode', type => 'tns:SearchMode', attr => {}),
      SOAP::Data->new(name => 'start', type => 's:dateTime', attr => {}),
      SOAP::Data->new(name => 'end', type => 's:dateTime', attr => {}),
      SOAP::Data->new(name => 'types', type => 'tns:MeasureType', attr => {}),
      SOAP::Data->new(name => 'args', type => 'tns:ArrayOfString', attr => {}),
    ], # end parameters
  }, # end ListAllResults
ListScenariosStatus => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/ListScenariosStatus',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'businessPath', type => 's:string', attr => {}),
      SOAP::Data->new(name => 'locationPath', type => 's:string', attr => {}),
    ], # end parameters
  }, # end ListScenariosStatus
ListAlarms => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/ListAlarms',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'mode', type => 'tns:SearchMode', attr => {}),
      SOAP::Data->new(name => 'range', type => 's:int', attr => {}),
      SOAP::Data->new(name => 'types', type => 'tns:AlarmType', attr => {}),
      SOAP::Data->new(name => 'levels', type => 'tns:AlarmLevel', attr => {}),
      SOAP::Data->new(name => 'args', type => 'tns:ArrayOfString', attr => {}),
    ], # end parameters
  }, # end ListAlarms
ListScenarios => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/ListScenarios',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'businessPath', type => 's:string', attr => {}),
    ], # end parameters
  }, # end ListScenarios
ListResultChildren => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/ListResultChildren',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'resultId', type => 's:long', attr => {}, prefix => 'tns'),
    ], # end parameters
  }, # end ListResultChildren
GetUserItem => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/GetUserItem',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'login', type => 's:string', attr => {}),
    ], # end parameters
  }, # end GetUserItem
ListCollectorStatus => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/ListCollectorStatus',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'mode', type => 'tns:SearchMode', attr => {}),
      SOAP::Data->new(name => 'args', type => 'tns:ArrayOfString', attr => {}),
    ], # end parameters
  }, # end ListCollectorStatus
GetDiagnostic => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/GetDiagnostic',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'messageId', type => 's:long', attr => {}),
    ], # end parameters
  }, # end GetDiagnostic
LogIn => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/LogIn',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'login', type => 's:string', attr => {}),
      SOAP::Data->new(name => 'password', type => 's:string', attr => {}),
    ], # end parameters
  }, # end LogIn
ListCustomGroupChildren => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/ListCustomGroupChildren',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'customGroupPath', type => 's:string', attr => {}),
      SOAP::Data->new(name => 'recursive', type => 's:boolean', attr => {}),
    ], # end parameters
  }, # end ListCustomGroupChildren
GetCustomGroupProperties => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/GetCustomGroupProperties',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'customGroupPath', type => 's:string', attr => {}),
    ], # end parameters
  }, # end GetCustomGroupProperties
ListMessages => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/ListMessages',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'mode', type => 'tns:SearchMode', attr => {}, prefix => 'tns'),
      SOAP::Data->new(name => 'range', type => 's:int', attr => {}, prefix => 'tns'),
      SOAP::Data->new(name => 'categories', type => 'tns:MessageCategory', attr => {}, prefix => 'tns'),
      SOAP::Data->new(name => 'args', type => 'tns:ArrayOfString', attr => {}, prefix => 'tns'),
    ], # end parameters
  }, # end ListMessages
ListScenarioStatus => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/ListScenarioStatus',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'mode', type => 'tns:SearchMode', attr => {}, prefix => 'tns'),
      SOAP::Data->new(name => 'range', type => 's:int', attr => {}, prefix => 'tns'),
      SOAP::Data->new(name => 'args', type => 'tns:ArrayOfString', attr => {}, prefix => 'tns'),
    ], # end parameters
  }, # end ListScenarioStatus
ListMeasureResults => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/ListMeasureResults',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'measureId', type => 's:string', attr => {}),
      SOAP::Data->new(name => 'locationPath', type => 's:string', attr => {}),
      SOAP::Data->new(name => 'range', type => 's:int', attr => {}),
      SOAP::Data->new(name => 'recursive', type => 's:boolean', attr => {}),
      SOAP::Data->new(name => 'types', type => 'tns:MeasureType', attr => {}),
    ], # end parameters
  }, # end ListMeasureResults
GetUserProperties => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/GetUserProperties',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'login', type => 's:string', attr => {}),
    ], # end parameters
  }, # end GetUserProperties
ListMeasureChildren => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/ListMeasureChildren',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'measureId', type => 's:string', attr => {}),
      SOAP::Data->new(name => 'types', type => 'tns:MeasureType', attr => {}),
      SOAP::Data->new(name => 'recursive', type => 's:boolean', attr => {}),
      SOAP::Data->new(name => 'measurePath', type => 's:string', attr => {}),
      SOAP::Data->new(name => 'recursive', type => 's:boolean', attr => {}),
    ], # end parameters
  }, # end ListMeasureChildren
GetLicenceOptionValue => {
    endpoint => '',
    soapaction => 'http://www.auditec-newtest.com/GetLicenceOptionValue',
    namespace => 'http://www.auditec-newtest.com',
    parameters => [
      SOAP::Data->new(name => 'optionId', type => 's:int', attr => {}),
    ], # end parameters
  }, # end GetLicenceOptionValue
); # end my %methods

use SOAP::Lite;
use gorgone::modules::plugins::newtest::libs::stubs::errors;
use Exporter;
use Carp ();

use vars qw(@ISA $AUTOLOAD @EXPORT_OK %EXPORT_TAGS);
@ISA = qw(Exporter SOAP::Lite);
@EXPORT_OK = (keys %methods);
%EXPORT_TAGS = ('all' => [@EXPORT_OK]);

sub _call {
    my ($self, $method) = (shift, shift);
    my $name = UNIVERSAL::isa($method => 'SOAP::Data') ? $method->name : $method;
    my %method = %{$methods{$name}};
    $self->on_fault(\&gorgone::modules::plugins::newtest::libs::stubs::errors::soapGetBad);
    $self->proxy($method{endpoint} || Carp::croak "No server address (proxy) specified")
        unless $self->proxy;
    my @templates = @{$method{parameters}};
    my @parameters = ();
    foreach my $param (@_) {
        if (@templates) {
            my $template = shift @templates;
            my ($prefix,$typename) = SOAP::Utils::splitqname($template->type);
            my $method = 'as_'.$typename;
            # TODO - if can('as_'.$typename) {...}
            my $result = $self->serializer->$method($param, $template->name, $template->type, $template->attr);
            #print Data::Dumper::Dumper($result);
            push(@parameters, $template->value($result->[2]));
        }
        else {
            push(@parameters, $param);
        }
    }
    $self->endpoint($method{endpoint})
       ->ns($method{namespace})
       ->on_action(sub{qq!"$method{soapaction}"!});
  $self->serializer->register_ns("http://microsoft.com/wsdl/mime/textMatching/","tm");
  $self->serializer->register_ns("http://schemas.xmlsoap.org/wsdl/soap12/","soap12");
  $self->serializer->register_ns("http://schemas.xmlsoap.org/wsdl/mime/","mime");
  $self->serializer->register_ns("http://www.w3.org/2001/XMLSchema","s");
  $self->serializer->register_ns("http://schemas.xmlsoap.org/wsdl/soap/","soap");
  $self->serializer->register_ns("http://schemas.xmlsoap.org/wsdl/","wsdl");
  $self->serializer->register_ns("http://schemas.xmlsoap.org/soap/encoding/","soapenc");
  $self->serializer->register_ns("http://schemas.xmlsoap.org/wsdl/http/","http");
  $self->serializer->register_ns("http://www.auditec-newtest.com","tns");
    my $som = $self->SUPER::call($method => @parameters);
    if ($self->want_som) {
        return $som;
    }
    UNIVERSAL::isa($som => 'SOAP::SOM') ? wantarray ? $som->paramsall : $som->result : $som;
}

sub BEGIN {
    no strict 'refs';
    for my $method (qw(want_som)) {
        my $field = '_' . $method;
        *$method = sub {
            my $self = shift->new;
            @_ ? ($self->{$field} = shift, return $self) : return $self->{$field};
        }
    }
}
no strict 'refs';
for my $method (@EXPORT_OK) {
    my %method = %{$methods{$method}};
    *$method = sub {
        my $self = UNIVERSAL::isa($_[0] => __PACKAGE__)
            ? ref $_[0]
                ? shift # OBJECT
                # CLASS, either get self or create new and assign to self
                : (shift->self || __PACKAGE__->self(__PACKAGE__->new))
            # function call, either get self or create new and assign to self
            : (__PACKAGE__->self || __PACKAGE__->self(__PACKAGE__->new));
        $self->_call($method, @_);
    }
}

sub AUTOLOAD {
    my $method = substr($AUTOLOAD, rindex($AUTOLOAD, '::') + 2);
    return if $method eq 'DESTROY' || $method eq 'want_som';
    die "Unrecognized method '$method'. List of available method(s): @EXPORT_OK\n";
}

1;
