Beispiel #1
0
        /// <summary>
        /// Main section of Set-FirewallRule
        /// </summary>
        protected override void ProcessRecord()
        {
            try
            {
                StringBuilder          requestResource = new StringBuilder();
                VShieldXmlSerialzation xmlSerial       = new VShieldXmlSerialzation();
                var request = new RestRequest(Method.POST);
                SetCertificatePolicy();

                string xmlString = xmlSerial.SerializeObject(SetObject());

                requestResource.AppendFormat("api/1.0/network/{0}/firewall/rules", _InternalPortGroupMofId);
                request.Resource = requestResource.ToString();
                request.AddParameter("application/xml", xmlString, ParameterType.RequestBody);
                var rr_fwrule = _Client.Execute(request);

                if (rr_fwrule.StatusCode != HttpStatusCode.NoContent)
                {
                    WriteWarning(rr_fwrule.ErrorMessage);
                    WriteWarning(rr_fwrule.StatusDescription);
                    WriteWarning(rr_fwrule.Content);
                }
            }
            catch (Exception e) { WriteObject("C-Sharp Exception: " + e); }
        }
        protected override void ProcessRecord()
        {
            try
            {
                StringBuilder requestResource = new StringBuilder();
                VShieldXmlSerialzation xmlSerial = new VShieldXmlSerialzation();
                var request = new RestRequest(Method.POST);
                SetCertificatePolicy();

                string xmlString = xmlSerial.SerializeObject(SetObject());

                requestResource.AppendFormat("api/1.0/network/{0}/dnat/rules", _InternalPortGroupMofId);
                request.Resource = requestResource.ToString();
                request.AddParameter("application/xml", xmlString, ParameterType.RequestBody);
                var rr_natrule = _Client.Execute(request);

                //WriteObject(xmlString);
                WriteWarning(rr_natrule.ErrorMessage);
                WriteWarning(rr_natrule.StatusDescription);
                WriteWarning(rr_natrule.Content);

            }
            catch (Exception e) { WriteObject("C-Sharp Exception: " + e); }
        }