MeshCentral/agents/modules_meshcore_min/amt-wsman.min.js

1 line
8.7 KiB
JavaScript

function WsmanStackCreateService(){var p={_ObjectID:"WSMAN"};p.NextMessageId=1;p.Address="/wsman";p.xmlParser=require("amt-xml");if(arguments.length==1&&typeof(arguments[0]=="object")){var e=arguments[0].transport;if(e){p.comm=new e(arguments[0])}}else{var e=arguments[0];if(e){p.comm=new e(arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6])}}p.PerformAjax=function q(t,r,v,u,s){if(s==null){s=""}p.comm.PerformAjax('<?xml version="1.0" encoding="utf-8"?><Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns="http://www.w3.org/2003/05/soap-envelope" '+s+"><Header><a:Action>"+t,function(w,x,y){if(x!=200){r(p,null,{Header:{HttpError:x}},x,y);return}var z=p.xmlParser.ParseWsman(w);if(!z||z==null){r(p,null,{Header:{HttpError:x}},601,y)}else{r(p,z.Header.ResourceURI,z,200,y)}},v,u)};p.CancelAllQueries=function d(r){p.comm.CancelAllQueries(r)};p.GetNameFromUrl=function(r){var s=r.lastIndexOf("/");return(s==-1)?r:r.substring(s+1)};p.ExecSubscribe=function n(z,t,C,r,B,y,A,w,D,x){var u="",v="",w="";if(D!=null&&x!=null){u='<t:IssuedTokens xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:se="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><t:RequestSecurityTokenResponse><t:TokenType>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken</t:TokenType><t:RequestedSecurityToken><se:UsernameToken><se:Username>'+D+'</se:Username><se:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#PasswordText">'+x+"</se:Password></se:UsernameToken></t:RequestedSecurityToken></t:RequestSecurityTokenResponse></t:IssuedTokens>";v='<w:Auth Profile="http://schemas.dmtf.org/wbem/wsman/1/wsman/secprofile/http/digest"/>'}if(w!=null){w="<a:ReferenceParameters><m:arg>"+w+"</m:arg></a:ReferenceParameters>"}if(t=="PushWithAck"){t="dmtf.org/wbem/wsman/1/wsman/PushWithAck"}else{if(t=="Push"){t="xmlsoap.org/ws/2004/08/eventing/DeliveryModes/Push"}}var s="http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe</a:Action><a:To>"+p.Address+"</a:To><w:ResourceURI>"+z+"</w:ResourceURI><a:MessageID>"+(p.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>"+c(A)+u+'</Header><Body><e:Subscribe><e:Delivery Mode="http://schemas.'+t+'"><e:NotifyTo><a:Address>'+C+"</a:Address>"+w+"</e:NotifyTo>"+v+"</e:Delivery></e:Subscribe>";p.PerformAjax(s+"</Body></Envelope>",r,B,y,'xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing" xmlns:m="http://x.com"')};p.ExecUnSubscribe=function o(u,r,w,t,v){var s="http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe</a:Action><a:To>"+p.Address+"</a:To><w:ResourceURI>"+u+"</w:ResourceURI><a:MessageID>"+(p.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>"+c(v)+"</Header><Body><e:Unsubscribe/>";p.PerformAjax(s+"</Body></Envelope>",r,w,t,'xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing"')};p.ExecPut=function m(v,u,r,x,t,w){var s="http://schemas.xmlsoap.org/ws/2004/09/transfer/Put</a:Action><a:To>"+p.Address+"</a:To><w:ResourceURI>"+v+"</w:ResourceURI><a:MessageID>"+(p.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60.000S</w:OperationTimeout>"+c(w)+"</Header><Body>"+b(v,u);p.PerformAjax(s+"</Body></Envelope>",r,x,t)};p.ExecCreate=function f(x,w,r,z,v,y){var u=p.GetNameFromUrl(x);var s="http://schemas.xmlsoap.org/ws/2004/09/transfer/Create</a:Action><a:To>"+p.Address+"</a:To><w:ResourceURI>"+x+"</w:ResourceURI><a:MessageID>"+(p.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>"+c(y)+"</Header><Body><g:"+u+' xmlns:g="'+x+'">';for(var t in w){s+="<g:"+t+">"+w[t]+"</g:"+t+">"}p.PerformAjax(s+"</g:"+u+"></Body></Envelope>",r,z,v)};p.ExecDelete=function g(v,u,r,w,t){var s="http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete</a:Action><a:To>"+p.Address+"</a:To><w:ResourceURI>"+v+"</w:ResourceURI><a:MessageID>"+(p.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>"+c(u)+"</Header><Body /></Envelope>";p.PerformAjax(s,r,w,t)};p.ExecGet=function i(t,r,u,s){p.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/transfer/Get</a:Action><a:To>"+p.Address+"</a:To><w:ResourceURI>"+t+"</w:ResourceURI><a:MessageID>"+(p.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body /></Envelope>",r,u,s)};p.ExecMethod=function j(y,v,r,t,A,w,z){var s="";for(var u in r){if(r[u]!=null){if(Array.isArray(r[u])){for(var B in r[u]){s+="<r:"+u+">"+r[u][B]+"</r:"+u+">"}}else{s+="<r:"+u+">"+r[u]+"</r:"+u+">"}}}p.ExecMethodXml(y,v,s,t,A,w,z)};p.ExecMethodXml=function k(v,t,r,s,x,u,w){p.PerformAjax(v+"/"+t+"</a:Action><a:To>"+p.Address+"</a:To><w:ResourceURI>"+v+"</w:ResourceURI><a:MessageID>"+(p.NextMessageId++)+"</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>"+c(w)+"</Header><Body><r:"+t+'_INPUT xmlns:r="'+v+'">'+r+"</r:"+t+"_INPUT></Body></Envelope>",s,x,u)};p.ExecEnum=function h(t,r,u,s){p.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate</a:Action><a:To>"+p.Address+"</a:To><w:ResourceURI>"+t+"</w:ResourceURI><a:MessageID>"+(p.NextMessageId++)+'</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body><Enumerate xmlns="http://schemas.xmlsoap.org/ws/2004/09/enumeration" /></Body></Envelope>',r,u,s)};p.ExecPull=function l(u,s,r,v,t){p.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull</a:Action><a:To>"+p.Address+"</a:To><w:ResourceURI>"+u+"</w:ResourceURI><a:MessageID>"+(p.NextMessageId++)+'</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body><Pull xmlns="http://schemas.xmlsoap.org/ws/2004/09/enumeration"><EnumerationContext>'+s+"</EnumerationContext><MaxElements>999</MaxElements><MaxCharacters>99999</MaxCharacters></Pull></Body></Envelope>",r,v,t)};function b(w,u){if(!w||u==null){return""}var s=p.GetNameFromUrl(w);var v="<r:"+s+' xmlns:r="'+w+'">';for(var t in u){if(!u.hasOwnProperty(t)||t.indexOf("__")===0||t.indexOf("@")===0){continue}if(u[t]==null||typeof u[t]==="function"){continue}if(typeof u[t]==="object"&&u[t]["ReferenceParameters"]){v+="<r:"+t+"><a:Address>"+u[t].Address+"</a:Address><a:ReferenceParameters><w:ResourceURI>"+u[t]["ReferenceParameters"]["ResourceURI"]+"</w:ResourceURI><w:SelectorSet>";var x=u[t]["ReferenceParameters"]["SelectorSet"]["Selector"];if(Array.isArray(x)){for(var r=0;r<x.length;r++){v+="<w:Selector"+a(x[r])+">"+x[r]["Value"]+"</w:Selector>"}}else{v+="<w:Selector"+a(x)+">"+x.Value+"</w:Selector>"}v+="</w:SelectorSet></a:ReferenceParameters></r:"+t+">"}else{if(Array.isArray(u[t])){for(var r=0;r<u[t].length;r++){v+="<r:"+t+">"+u[t][r].toString()+"</r:"+t+">"}}else{v+="<r:"+t+">"+u[t].toString()+"</r:"+t+">"}}}v+="</r:"+s+">";return v}function a(r){if(!r){return""}var t=" ";for(var s in r){if(!r.hasOwnProperty(s)||s.indexOf("@")!==0){continue}t+=s.substring(1)+'="'+r[s]+'" '}return t}function c(v){if(!v){return""}if(typeof v=="string"){return v}if(v.InstanceID){return'<w:SelectorSet><w:Selector Name="InstanceID">'+v.InstanceID+"</w:Selector></w:SelectorSet>"}var t="<w:SelectorSet>";for(var s in v){if(!v.hasOwnProperty(s)){continue}t+='<w:Selector Name="'+s+'">';if(v[s]["ReferenceParameters"]){t+="<a:EndpointReference>";t+="<a:Address>"+v[s]["Address"]+"</a:Address><a:ReferenceParameters><w:ResourceURI>"+v[s]["ReferenceParameters"]["ResourceURI"]+"</w:ResourceURI><w:SelectorSet>";var u=v[s]["ReferenceParameters"]["SelectorSet"]["Selector"];if(Array.isArray(u)){for(var r=0;r<u.length;r++){t+="<w:Selector"+a(u[r])+">"+u[r]["Value"]+"</w:Selector>"}}else{t+="<w:Selector"+a(u)+">"+u.Value+"</w:Selector>"}t+="</w:SelectorSet></a:ReferenceParameters></a:EndpointReference>"}else{t+=v[s]}t+="</w:Selector>"}t+="</w:SelectorSet>";return t}return p}module.exports=WsmanStackCreateService;