ruby_phpipam 0.2.0 → 0.3.0
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 +4 -4
- data/README.md +10 -10
- data/lib/ruby_phpipam/address.rb +29 -0
- data/lib/ruby_phpipam/version.rb +1 -1
- data/ruby_phpipam.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e682b180b4cb525a1bdf91eed61ce5a3a79085d
|
4
|
+
data.tar.gz: 62240b166a6df6f72af3e8223754330c9e0060fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db2f880f2d45121c1acb528406f75593b44f2d7f772eb6162148a7edf3b7fe357260b8506a1162c41a4795ee82cead9acc36cac64046c093c345a1243a861dd7
|
7
|
+
data.tar.gz: a6d4c8bafb66f400f44161dea65c022b40fe36de4f0fa8e2132e699392fc5ad3c5826fac20c32cffd0d8bb3e19fe371ab8f242c3d9477959d3c8cf933bed8776
|
data/README.md
CHANGED
@@ -13,9 +13,9 @@ gem 'ruby_phpipam'
|
|
13
13
|
|
14
14
|
```
|
15
15
|
|
16
|
-
|
16
|
+
Or execute:
|
17
17
|
|
18
|
-
$
|
18
|
+
$ gem install ruby_phpipam
|
19
19
|
|
20
20
|
|
21
21
|
## Usage
|
@@ -65,9 +65,14 @@ all_subnets(mask) Get all posible subnets (CIDR) Array of strings
|
|
65
65
|
|
66
66
|
#### Address
|
67
67
|
```
|
68
|
-
self.get(id)
|
69
|
-
self.
|
70
|
-
|
68
|
+
self.get(id) Get address by ID Address object
|
69
|
+
self.get_by_tag(tagId) Get addresses by tagId Array of address objects
|
70
|
+
self.ping(id) Check status of address Boolean telling if address is reachable
|
71
|
+
self.search(id, hostname, subnetId) Searches for addresses by Address object or array of address objects
|
72
|
+
IP (in a specific subnet
|
73
|
+
if given) or hostname
|
74
|
+
self.first_free(subnetId) Get first usable IP String
|
75
|
+
online? Check status of address Boolean telling if address is reachable
|
71
76
|
```
|
72
77
|
|
73
78
|
## Pending API endpoints
|
@@ -98,14 +103,9 @@ DELETE /api/my_app/subnets/{id}/permissions/ Removes all permission
|
|
98
103
|
|
99
104
|
### Addresses Endpoints
|
100
105
|
```
|
101
|
-
GET /api/my_app/addresses/{ip}/{subnetId}/ Returns address from subnet by ip address
|
102
|
-
GET /api/my_app/addresses/search/{ip}/ Searches for addresses in database, returns multiple if found
|
103
|
-
GET /api/my_app/addresses/search_hostname/{hostname}/ Searches for addresses in database by hostname, returns multiple if found
|
104
|
-
GET /api/my_app/addresses/first_free/{subnetId}/ Returns first available address (subnetId can be provided with parameters)
|
105
106
|
GET /api/my_app/addresses/custom_fields/ Returns custom fields
|
106
107
|
GET /api/my_app/addresses/tags/ Returns all tags
|
107
108
|
GET /api/my_app/addresses/tags/{id}/ Returns specific tag
|
108
|
-
GET /api/my_app/addresses/tags/{id}/addresses/ Returns addresses for specific tag
|
109
109
|
POST /api/my_app/addresses/ Creates new address
|
110
110
|
POST /api/my_app/addresses/first_free/{subnetId}/ Creates new address in subnets – first available (subnetId can be provided with parameters)
|
111
111
|
PATCH /api/my_app/addresses/{id}/ Updates address
|
data/lib/ruby_phpipam/address.rb
CHANGED
@@ -28,6 +28,13 @@ module RubyPhpipam
|
|
28
28
|
Address.new(RubyPhpipam::Query.get("/addresses/#{id}/"))
|
29
29
|
end
|
30
30
|
|
31
|
+
def self.get_by_tag(tagId)
|
32
|
+
addresses = RubyPhpipam::Query.get_array("/addresses/tags/#{tagId}/addresses/")
|
33
|
+
addresses.map do |address|
|
34
|
+
self.new(address)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
31
38
|
def self.ping(id)
|
32
39
|
response = RubyPhpipam::Query.get("/addresses/#{id}/ping/")
|
33
40
|
|
@@ -38,6 +45,28 @@ module RubyPhpipam
|
|
38
45
|
end
|
39
46
|
end
|
40
47
|
|
48
|
+
def self.search(ip:nil, hostname:nil, subnetId:nil)
|
49
|
+
if !ip.nil?
|
50
|
+
if subnetId.nil?
|
51
|
+
addresses = RubyPhpipam::Query.get_array("/addresses/search/#{ip}/")
|
52
|
+
else
|
53
|
+
address = RubyPhpipam::Query.get("/addresses/#{ip}/#{subnetId}/")
|
54
|
+
end
|
55
|
+
else
|
56
|
+
addresses = RubyPhpipam::Query.get_array("/addresses/search_hostname/#{hostname}/")
|
57
|
+
end
|
58
|
+
|
59
|
+
return (address ? self.new(address) : nil) if subnetId
|
60
|
+
|
61
|
+
addresses.map do |address|
|
62
|
+
self.new(address)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.first_free(subnetId)
|
67
|
+
RubyPhpipam::Query.get("/addresses/first_free/#{subnetId}/")
|
68
|
+
end
|
69
|
+
|
41
70
|
def online?
|
42
71
|
RubyPhpipam::Address.ping(@id)
|
43
72
|
end
|
data/lib/ruby_phpipam/version.rb
CHANGED
data/ruby_phpipam.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = "Ruby wrapper for the phpipam API"
|
13
13
|
spec.description = "Ruby wrapper for the phpipam API"
|
14
|
-
spec.homepage = "https://github.com/AminArria/
|
14
|
+
spec.homepage = "https://github.com/AminArria/ruby_phpipam"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_phpipam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amin Arria
|
@@ -135,7 +135,7 @@ files:
|
|
135
135
|
- lib/ruby_phpipam/subnet.rb
|
136
136
|
- lib/ruby_phpipam/version.rb
|
137
137
|
- ruby_phpipam.gemspec
|
138
|
-
homepage: https://github.com/AminArria/
|
138
|
+
homepage: https://github.com/AminArria/ruby_phpipam
|
139
139
|
licenses:
|
140
140
|
- MIT
|
141
141
|
metadata: {}
|