From 51ad08a8b780c50aa69f28cee3b1fd674c59c5de Mon Sep 17 00:00:00 2001 From: jeff Date: Fri, 14 Mar 2008 04:38:48 +0000 Subject: [PATCH] Initial import of Net-Prizm --- Changes | 15 + MANIFEST | 10 + META.yml | 11 + Makefile.PL | 10 + README | 33 + lib/Net/Prizm.pm | 260 +++++++ lib/Net/Prizm/wsdls/CustomerIfService.wsdl | 459 ++++++++++++ lib/Net/Prizm/wsdls/LogEventIfService.wsdl | 214 ++++++ lib/Net/Prizm/wsdls/NetworkIfService.wsdl | 1096 ++++++++++++++++++++++++++++ t/Net-Prizm.t | 19 + 10 files changed, 2127 insertions(+) create mode 100644 Changes create mode 100644 MANIFEST create mode 100644 META.yml create mode 100644 Makefile.PL create mode 100644 README create mode 100644 lib/Net/Prizm.pm create mode 100644 lib/Net/Prizm/wsdls/CustomerIfService.wsdl create mode 100644 lib/Net/Prizm/wsdls/LogEventIfService.wsdl create mode 100644 lib/Net/Prizm/wsdls/NetworkIfService.wsdl create mode 100644 t/Net-Prizm.t diff --git a/Changes b/Changes new file mode 100644 index 0000000..c14ee27 --- /dev/null +++ b/Changes @@ -0,0 +1,15 @@ + +Revision history for Perl extension Net::Prizm + +0.04 Thu Mar 13 20:15:38 EDT 2008 + -require SOAP::Ltie 0.71 to avoid conflicts with UNIVERSAL::require + +0.03 Tue Feb 20 21:41:46 EST 2007 + -corrected bad encoding (failure to use html entities when required) + of customer_info + +0.02 Fri Dec 29 11:52:40 EST 2006 + -updated to use SOAP::Lite 0.69 + +0.01 Tue Dec 26 23:35:00 EST 2006 + -original version; created by jeff diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..c751ca5 --- /dev/null +++ b/MANIFEST @@ -0,0 +1,10 @@ +Changes +Makefile.PL +MANIFEST +README +lib/Net/Prizm.pm +lib/Net/Prizm/wsdls/CustomerIfService.wsdl +lib/Net/Prizm/wsdls/LogEventIfService.wsdl +lib/Net/Prizm/wsdls/NetworkIfService.wsdl +t/Net-Prizm.t +META.yml Module meta-data (added by MakeMaker) diff --git a/META.yml b/META.yml new file mode 100644 index 0000000..181611b --- /dev/null +++ b/META.yml @@ -0,0 +1,11 @@ +# http://module-build.sourceforge.net/META-spec.html +#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# +name: Net-Prizm +version: 0.03 +version_from: lib/Net/Prizm.pm +installdirs: site +requires: + SOAP::Lite: 0.69 + +distribution_type: module +generated_by: ExtUtils::MakeMaker version 6.17 diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..73074f6 --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,10 @@ +use ExtUtils::MakeMaker; +# See lib/ExtUtils/MakeMaker.pm for details of how to influence +# the contents of the Makefile that is written. +WriteMakefile( + 'NAME' => 'Net::Prizm', + 'ABSTRACT_FROM' => 'lib/Net/Prizm.pm', + 'AUTHOR' => 'Jeff Finucane ', + 'VERSION_FROM' => 'lib/Net/Prizm.pm', # finds $VERSION + 'PREREQ_PM' => { SOAP::Lite => 0.71 }, +); diff --git a/README b/README new file mode 100644 index 0000000..01bd3a3 --- /dev/null +++ b/README @@ -0,0 +1,33 @@ +Net-Prizm version 0.04 +==================== + +THis module implements a client to Motorola's Canopy Prizm Northbound +SOAP interface enabling a perl application to talk to a Prizm server. + +This module is not sponsored or endorsed by Motorola. + +INSTALLATION + +To install this module type the following: + + perl Makefile.PL + make + make test + make install + +DEPENDENCIES + +This module requires these other modules and libraries: + + SOAP::Lite + Prizm WSDL files supplied by Motorola + +COPYRIGHT AND LICENCE + +Copyright (C) 2006 Jeff Finucane + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +Motorola Inc. reserves all rights on its WSDL files. + diff --git a/lib/Net/Prizm.pm b/lib/Net/Prizm.pm new file mode 100644 index 0000000..b2f109d --- /dev/null +++ b/lib/Net/Prizm.pm @@ -0,0 +1,260 @@ +package Net::Prizm; + +use strict; +use vars qw($DEBUG $VERSION @uris %services $AUTOLOAD %schemas); +use SOAP::Lite; + +$VERSION = '0.04'; + +$DEBUG = 0; + +@uris = qw(CustomerIfService NetworkIfService LogEventIfService); + +=head1 NAME + +Net::Prizm - Perl client interface to Motorola Canopy Prizm + +=head1 SYNOPSIS + +use Net::Prizm; +use Net::Prizm qw(CustomerInfo LogEventInfo + ClientDevice ConfigurationTemplate ElementLinkInfo + Network PerformanceData); + +$prizm = new Net::Prizm { url => 'https://prizm.example.net:8443/prizm/nbi', + namespace => 'CustomerIfService', + username => 'prizmuser', + password => 'associatedpassword', + } + +$err_or_som = $prizm->getCustomers(['import_id'], ['50'], ['<']); + +if (ref($err_or_som)){ + my $result = $err_or_som->result; + foreach my $customer (@$result) { + print $customer->contact, "\n"; + } +}else{ + print "$err_or_som\n"; +} + +=head1 DESCRIPTION + +Net::Prizm is a module implementing a Perl interface to Motorola's Canopy +Prizm SOAP interface. It is compatible with version 2.1 of that software +and requires the WSDL from Motorola. + +Net::Prizm enables you to simply access the SOAP interface of your Prizm +server. + +=head1 BASIC USAGE + +Import the Net::Prizm module with + +use Net::Prizm (@list_of_classes); + +Net::Prizm will create any of the following classes for you + +CustomerInfo LogEventInfo PrizmElement ClientDevice ConfigurationTemplate +ElementLinkInfo Network PerformanceData + +=cut + +sub import { + my $class = shift; + my @classes = @_; + my $me = __PACKAGE__; + my (%EXPORT_OK) = map { $_ => 1 } qw( CustomerInfo LogEventInfo PrizmElement + ClientDevice ConfigurationTemplate + ElementLinkInfo Network + PerformanceData ); + + foreach $class (grep { exists( $EXPORT_OK{$_} ) + or die "$_ is not exported by module $me" + } @classes) { + no strict 'refs'; + + *{"$class\::NEW"} = sub { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = { @_ }; + return bless($self, $class); + }; + *{"$class\::AUTOLOAD"} = sub { + my $field = $AUTOLOAD; + $field =~ s/.*://; + return if $field eq 'DESTROY'; + if ( defined($_[1]) ) { + $_[0]->{$field} = $_[1]; + } else { + $_[0]->{$field}; + } + }; + } + + $me =~ s/::/\//g; + $INC{"$me.pm"} =~ /^(.*)\.pm$/; + $me = $1; + for (@uris){ + $schemas{$_} = SOAP::Schema + ->schema_url("file:$me/wsdls/$_.wsdl") + ->parse->services->{$_}; + } + +} + +=head1 CONSTRUCTOR + +=over 4 + +=item new HASHREF + +Creates a new Prizm object. HASHREF should contain the keys url, namespace, +username, and password for the URL of the Prizm SOAP proxy, the namespace +of the methods you would like to call, and the username and password for +basic authentication. + +=cut + +sub new { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = { @_ }; + return bless($self, $class); +} + +=head1 METHODS + +All Prizm methods may be invoked as methods of the Net::Prizm object. +The return value is either the fault string in the event of an error +or a SOAP::SOM object. + +=cut + +sub AUTOLOAD { + my $self = shift; #hmmm... test this? + + my $method = $AUTOLOAD; + $method =~ s/.*://; + return if $method eq 'DESTROY'; + + my $soap = SOAP::Lite + -> autotype(0) + -> readable(1) + -> uri($self->{namespace}) + -> proxy($self->{url}); + + local *SOAP::Transport::HTTP::Client::get_basic_credentials = sub { + return $self->{user} => $self->{password}; + }; + + local *SOAP::Serializer::as_ArrayOf_xsd_string = sub { + my ($self, $value, $name, $type, $attr) = @_; + + $name ||= $self->gen_name; + $self->encode_object(\SOAP::Data->value( + SOAP::Data->name('string' => @{$value})->type('string') + ), $name, $type); + + }; + + local *SOAP::Serializer::as_ArrayOf_xsd_int = sub { + my ($self, $value, $name, $type, $attr) = @_; + + $name ||= $self->gen_name; + $self->encode_object(\SOAP::Data->value( + SOAP::Data->name('int' => @{$value})->type('int') + ), $name, $type); + }; + + local *SOAP::Serializer::as_CustomerInfo = sub { + my ($self, $value, $name, $type, $attr) = @_; + + my $schema = { + 'importId' => 'string', + 'customerId' => 'int', + 'customerName' => 'string', + 'customerType' => 'string', + 'address1' => 'string', + 'address2' => 'string', + 'city' => 'string', + 'state' => 'string', + 'zipCode' => 'string', + 'workPhone' => 'string', + 'homePhone' => 'string', + 'mobilePhone' => 'string', + 'pager' => 'string', + 'email' => 'string', + 'extraFieldNames' => 'impl:ArrayOf_xsd_string', + 'extraFieldValues' => 'impl:ArrayOf_xsd_string', + 'elementIds' => 'impl:ArrayOf_xsd_int', + }; + + my (@result) = (); + foreach my $key (keys %$value){ + my $to_encode = $value->{$key}; + push @result, SOAP::Data->name($key => $to_encode)->type($schema->{$key}); + } + + return $self->encode_object(\SOAP::Data->value( + SOAP::Data->name($name => @result)), $name, + $type, + {'xsi:type' => 'impl:CustomerInfo', %$attr}); + }; + + my $param = 0; + my $som = + $soap->$method( map { + my $paramdata = + $schemas{$self->{namespace}}{$method}{'parameters'}[$param++]; + SOAP::Data->name($paramdata->name => $_ ) + ->type(${[SOAP::Utils::splitqname($paramdata->type)]}[1]) } @_ + ); + + if ($som) { + if ($som->fault){ + return $som->faultstring; + }else{ + return $som; + } + } + + "Net::Prizm failed to $method for $self->{namespace} at " . $self->{url}; +} + + +=back + +=head1 SEE ALSO + + SOAP::Lite, SOAP::SOM + + http://motorola.canopywireless.com/ for information about Canopy and +Prizm. + + http://www.sisd.com/freeside/ for the ISP billing and provisioning system + which provoked the need for this module. + +=head1 BUGS + +No explicit handling of types other than CustomerInfo. +Namespace promiscuous. +Lax handling of arguments and return values. + +Quite probably others. Use at your own risk. + +=head1 AUTHOR AND COPYRIGHT + +Copyright (c) 2006 Jeff Finucane jeff-net-prizm@weasellips.com + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +WDSL files copyright Motorola Inc. which reserves all rights. + +This software is neither authorized, sponsored, endorsed, nor supported +by Motorola Inc. + +=cut + +1; diff --git a/lib/Net/Prizm/wsdls/CustomerIfService.wsdl b/lib/Net/Prizm/wsdls/CustomerIfService.wsdl new file mode 100644 index 0000000..67e908a --- /dev/null +++ b/lib/Net/Prizm/wsdls/CustomerIfService.wsdl @@ -0,0 +1,459 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/Net/Prizm/wsdls/LogEventIfService.wsdl b/lib/Net/Prizm/wsdls/LogEventIfService.wsdl new file mode 100644 index 0000000..b16614a --- /dev/null +++ b/lib/Net/Prizm/wsdls/LogEventIfService.wsdl @@ -0,0 +1,214 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/Net/Prizm/wsdls/NetworkIfService.wsdl b/lib/Net/Prizm/wsdls/NetworkIfService.wsdl new file mode 100644 index 0000000..69e0291 --- /dev/null +++ b/lib/Net/Prizm/wsdls/NetworkIfService.wsdl @@ -0,0 +1,1096 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/t/Net-Prizm.t b/t/Net-Prizm.t new file mode 100644 index 0000000..57c3f67 --- /dev/null +++ b/t/Net-Prizm.t @@ -0,0 +1,19 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl Net-Prizm.t' + +# Not very exciting testing + +use Test; +BEGIN { plan tests => 3 }; +eval "use Net::Prizm"; +ok($@ eq ''); + +no Net::Prizm; +eval "use Net::Prizm qw(PrizmElement)"; +ok($@ eq ''); + +no Net::Prizm; +eval "use Net::Prizm qw(BadClass)"; +ok($@ ne ''); + + -- 2.11.0