public void Add(FirewallObject firewallObject) { var response = commandFactory.CreateSet(firewallObject).Execute(); if (!response.Status.Equals("success")) { throw new Exception(string.Format("Add Method failed. PANOS error code {0}", response.Status)); } }
// It is possible to call the resulting command against an existing object, in such a case the prior object will be updated, but see below for a special case. // For objects that have a concept of a membership and in cases where the resulting commmand is called against an existing object, // such command will only be able to add members, but NOT remove them. // Use CreateSetMembership to deal with Membership changes public FormUrlEncodedContent CreateSet(FirewallObject firewallObject) { return(new FormUrlEncodedContent(new[] { accessTokenPair, typeConfigPair, new KeyValuePair <string, string>("action", "set"), new KeyValuePair <string, string>( "xpath", string.Format( "/config/devices/entry/vsys/entry[@name='{0}']/{1}/entry[@name='{2}']", vsys, firewallObject.SchemaName, firewallObject.Name)), new KeyValuePair <string, string>("element", firewallObject.ToXml()), })); }