palo_alto 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad314eed2154013cd0dd81166c795481debf4762a5d5b5b47f0943d8db612f98
4
- data.tar.gz: 02ba2cb368a2bae0a3bc7c4c121d79628b600df89e70f837a613871e1db041c6
3
+ metadata.gz: be267a4c14845513d0ca0b93dcdf2673829983dbf58c6c321f57817bd30f3d82
4
+ data.tar.gz: 268e375e0f17b1b5eb1a7dea2fb838a7fe55047bfabe66def538f7afdaf8111f
5
5
  SHA512:
6
- metadata.gz: a63062907d61012d713da785791526c167370d39248190a356f17f3bc4392ba3010e9ace8a1bd25fd693914bca6440a97ae03c95ce7d81296c275157299e370c
7
- data.tar.gz: c752bc2dce7f2e325708d4284d74a0c167ae4b623569dd4254a93636fefbf2df0e2f72a247ac4207791c4edcf4c05ef1a0d10d72b95acb703a554d62e6c2d9bb
6
+ metadata.gz: f71277a31b9157ebee6b7045327998e483faa68329158d97d70deca570c5486c86eaf3505458b89275991bae635e8e0bdc99e8115b55356a5fcdf43fc32d96bb
7
+ data.tar.gz: '084b3b801f5c1390dd668bc45f1c29ddbe00202430c2f68baff227c469d8853575bcd14243c03823bb58f25b4175de2d26bf6f64280a56d2b2155d5e06444248'
@@ -436,7 +436,7 @@ module PaloAlto
436
436
  self
437
437
  end
438
438
 
439
- def get(ignore_empty_result: false, xpath: self.to_xpath)
439
+ def get(ignore_empty_result: false, xpath: self.to_xpath, return_only: false)
440
440
  if self.class.superclass == ArrayConfigClass && !@selector
441
441
  raise(InvalidCommandException, "Please use 'get_all' here")
442
442
  end
@@ -454,8 +454,11 @@ module PaloAlto
454
454
  if ignore_empty_result==false
455
455
  raise(ObjectNotPresentException, "empty result: #{payload.inspect}")
456
456
  end
457
+ end
458
+
459
+ if return_only
460
+ data.xpath('//response/result/*')
457
461
  else
458
- #self.parent_instance.dup.create!.clear!.external_set(data.xpath('//response/result').first).first
459
462
  @create_children=true
460
463
  n = data.xpath('//response/result/*')
461
464
 
@@ -466,11 +469,13 @@ module PaloAlto
466
469
  primary_key = get_primary_key(n.first.attribute_nodes, self.class.props)
467
470
  set_array_class_attributes(n.first, primary_key) # primary key, api_attributes
468
471
  end
472
+
473
+ self
474
+ end.tap do
475
+ if XML.debug.include?(:statistics)
476
+ puts "Elapsed for parsing: #{Time.now-start_time} seconds"
477
+ end
469
478
  end
470
- if XML.debug.include?(:statistics)
471
- puts "Elapsed for parsing: #{Time.now-start_time} seconds"
472
- end
473
- self
474
479
  end
475
480
 
476
481
  def get_primary_key(attribute_nodes, props)
@@ -768,23 +773,25 @@ module PaloAlto
768
773
 
769
774
  def set_xpath_from_selector(selector: @selector)
770
775
  xpath = self.parent_instance.child(_section)
771
- k,v=selector.first
776
+ k, v = selector.first
772
777
  obj = xpath.where(PaloAlto.xpath_attr(k.to_sym) == v)
773
778
 
774
779
  @expression = obj.expression
775
780
  @arguments = obj.arguments
776
781
  end
777
782
 
778
- def rename!(new_name)
783
+ def rename!(new_name, internal_only: false)
779
784
  # https://docs.paloaltonetworks.com/pan-os/10-1/pan-os-panorama-api/pan-os-xml-api-request-types/configuration-api/rename-configuration.html
780
- payload = {
781
- type: 'config',
782
- action: 'rename',
783
- xpath: self.to_xpath,
784
- newname: new_name
785
- }
785
+ unless internal_only
786
+ payload = {
787
+ type: 'config',
788
+ action: 'rename',
789
+ xpath: self.to_xpath,
790
+ newname: new_name
791
+ }
786
792
 
787
- result = XML.execute(payload)
793
+ result = XML.execute(payload)
794
+ end
788
795
 
789
796
  # now update also the internal value to the new name
790
797
  self.selector.transform_values!{new_name}
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PaloAlto
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: palo_alto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Roesner
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-08 00:00:00.000000000 Z
11
+ date: 2021-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri