Skip to content

Latest commit

 

History

History
109 lines (67 loc) · 3.24 KB

LCP::POST.md

File metadata and controls

109 lines (67 loc) · 3.24 KB

NAME

LCP - Lib CIM (Common Information Model) Perl Post

SYNOPSIS

use LCP;
# setting the options for the agent
my $options={
'username'=>'someuser',
'password'=>'somepassword',
'protocol'=>'http',
'Method'=>'POST'
};
# initializing the agent
my $agent=LCP::Agent->new('localhost',$options);
#Creating a session
my $session=LCP::Session->new($agent);
# creating a new query
my $query=LCP::Query->new();
# Constructing a simple Enumerate classes query against root/cimv2
$query->EnumerateClasses('root/cimv2');
# Posting the query
my $post=LCP::Post->new($session,$query);
my $tree;
# Parse if the query executed properly
if (defined $post and $post->success){
  print "post executed\n";
  #Parsing the query
  my $parser=LCP::SimpleParser->new($post->get_raw_xml);
  # returning a multi dimensional hash of the results
  my $tree=$parser->buildtree;
}

DESCRIPTION

LCP::Post executes a POST or M-POST of a query generated by LCP::Query Class against a WBEM server with the options specified in an instance of the LCP::Session class.

EXPORT

This is an OO Class and as such exports nothing

Methods

  • new

    $post=LCP::Post->new($session,$query);

    The new method creates and executes a POST or M-POST of a query against the WBEM server. It requires 2 parameters and returns a accessor upon successful execution of the query. The first required parameter is the accessor for a instance of LCP::Session The second required parameter is the accessor to the instance of LCP::Query with the query you want to execute.

    You may reuse the same query to repeatedly against multiple instances of LCP::Post, and each time it will execute the query identically except the message id number will increment each time.

    Upon successful posting of the query and reception of a response this method returns an accessor to the results, but its important for the user to know that this class does not validate the content of the response at this time only if a response was received.

  • get_raw_xml

    $xml=$post->get_raw_xml

    get_raw_xml returns the unparsed XML response from the WBEM server

  • success

    $post->success

    returns a Boolean result of a query Note: at this time this method only returns true it the WBEM server responds with a 200 or 207 code it does not parse the XML for error messages embedded in the response.

  • suppressWarnings

    Call suppressWarnings() you would prefer to keep the constructor from printing to STDOUT if there are errors.

    You can get any warning by calling getLastWarning() if suppressWarnings() has been called.

Advanced Tuning Notes

LCP::Post utilizes HTTP::Request to execute the POST or M-POST operation. The accessor handle for the instance of HTTP::Request may be used for the time via the 

SEE ALSO

LWP - Lib WWW Perl

HTTP::Request

DMTF DSP0200

DMTF DSP0201

DMTF DSP0004

AUTHOR

Paul Robert Marino, <code@TheMarino.net

COPYRIGHT AND LICENSE

Copyright (C) 2011 by Paul Robert Marino

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.