foreman_teamdynamix 0.1.3 → 0.2.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce914cf3650810a7b8b11a7da6d8fce4300c07e4
|
4
|
+
data.tar.gz: 6644dfc9e975f38d77999d98048eb36e9d47b7ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dca0adc273e5c3704a8758db94c02907277e5e572f177d0dc660f22229612f664567da98f1919156e40f3c99d01f1bb312066bacf74fa0a8706e4b42496a096e
|
7
|
+
data.tar.gz: 474ccd4916aafa8714afeed5fffcc6aa26005a6446d8c5856a1ad102b9dbddb78db4f86bac994e087f6447aeaf7d9f1609e2d7cae3b14a5d210c09cc8996138f
|
data/README.md
CHANGED
@@ -23,7 +23,7 @@ Example Configuration
|
|
23
23
|
---
|
24
24
|
:teamdynamix:
|
25
25
|
:api:
|
26
|
-
:url:
|
26
|
+
:url: https://miamioh.teamdynamix.com/SBTDWebApi/api
|
27
27
|
:appId: 741
|
28
28
|
:username: 'xxxxxx'
|
29
29
|
:password: 'xxxxxx'
|
@@ -43,6 +43,7 @@ Example Configuration
|
|
43
43
|
:delete:
|
44
44
|
:StatusId: 642
|
45
45
|
:fields:
|
46
|
+
:url: https://miamioh.teamdynamix.com/SBTDNext/Apps
|
46
47
|
Asset ID: ID
|
47
48
|
Owner: OwningCustomerName
|
48
49
|
Parent Asset: ParentID
|
@@ -62,7 +63,7 @@ Example Configuration
|
|
62
63
|
|
63
64
|
[:fields]
|
64
65
|
* The keys are the display title and the values are the methods that are actually called to produce the value.
|
65
|
-
* A link to the asset in Teamdynamix is displayed
|
66
|
+
* A link to the asset in Teamdynamix is displayed, if url is specified, as first field labeled as URI.
|
66
67
|
* Nested attributes i.e custom attributes can be configured as mentioned in example configuration.
|
67
68
|
* If an attribute or nested attribute does not exist or is not found, it would simply not be displayed.
|
68
69
|
|
@@ -15,8 +15,8 @@ module ForemanTeamdynamix
|
|
15
15
|
|
16
16
|
get_teamdynamix_asset(@host.teamdynamix_asset_uid)
|
17
17
|
|
18
|
-
#
|
19
|
-
fields =
|
18
|
+
# display a link to the asset if url set
|
19
|
+
fields = asset_uri(td_pane_fields)
|
20
20
|
|
21
21
|
td_pane_fields.each do |field_name, asset_attr|
|
22
22
|
asset_attr_val = @asset.key?(asset_attr) ? @asset[asset_attr] : get_nested_attrib_val(asset_attr)
|
@@ -29,10 +29,13 @@ module ForemanTeamdynamix
|
|
29
29
|
|
30
30
|
private
|
31
31
|
|
32
|
-
def asset_uri
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
def asset_uri(td_pane_fields)
|
33
|
+
if (fields_url = td_pane_fields.delete(:url))
|
34
|
+
uri = "#{fields_url}/#{@asset['AppID']}/Assets/AssetDet?AssetID=#{@asset['ID']}"
|
35
|
+
[[_('URI'), link_to(@asset['SerialNumber'], uri, target: '_blank')]]
|
36
|
+
else
|
37
|
+
[]
|
38
|
+
end
|
36
39
|
end
|
37
40
|
|
38
41
|
def get_teamdynamix_asset(asset_id)
|
@@ -20,7 +20,7 @@ class TeamdynamixApi
|
|
20
20
|
|
21
21
|
# returns TeamDynamix.Api.Assets.Asset
|
22
22
|
def get_asset(asset_id)
|
23
|
-
uri = URI.parse(API_URL
|
23
|
+
uri = URI.parse("#{API_URL}/#{APP_ID}/assets/#{asset_id}")
|
24
24
|
rest(:get, uri)
|
25
25
|
end
|
26
26
|
|
@@ -31,23 +31,23 @@ class TeamdynamixApi
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def create_asset(host)
|
34
|
-
uri = URI.parse(API_URL
|
34
|
+
uri = URI.parse("#{API_URL}/#{APP_ID}/assets")
|
35
35
|
rest(:post, uri, create_asset_payload(host))
|
36
36
|
end
|
37
37
|
|
38
38
|
def update_asset(host)
|
39
|
-
uri = URI.parse(API_URL
|
39
|
+
uri = URI.parse("#{API_URL}/#{APP_ID}/assets/#{host.teamdynamix_asset_uid}")
|
40
40
|
rest(:post, uri, update_asset_payload(host))
|
41
41
|
end
|
42
42
|
|
43
43
|
def retire_asset(asset_id)
|
44
|
-
uri = URI.parse(API_URL
|
44
|
+
uri = URI.parse("#{API_URL}/#{APP_ID}/assets/#{asset_id}")
|
45
45
|
rest(:post, uri, retire_asset_payload(asset_id))
|
46
46
|
end
|
47
47
|
|
48
48
|
# Gets a list of assets matching the specified criteria. (IEnumerable(Of TeamDynamix.Api.Assets.Asset))
|
49
49
|
def search_asset(search_params)
|
50
|
-
uri = URI.parse(API_URL
|
50
|
+
uri = URI.parse("#{API_URL}/#{APP_ID}/assets/search")
|
51
51
|
rest(:post, uri, search_params)
|
52
52
|
end
|
53
53
|
|
@@ -65,7 +65,7 @@ class TeamdynamixApi
|
|
65
65
|
req = Net::HTTP::Get.new(uri)
|
66
66
|
end
|
67
67
|
# set headers
|
68
|
-
req.add_field('Authorization',
|
68
|
+
req.add_field('Authorization', "Bearer #{@auth_token}")
|
69
69
|
# send request
|
70
70
|
res = http.start do |http_handler|
|
71
71
|
http_handler.request(req)
|
@@ -75,7 +75,7 @@ class TeamdynamixApi
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def request_token
|
78
|
-
uri = URI.parse(API_URL
|
78
|
+
uri = URI.parse("#{API_URL}/auth")
|
79
79
|
http = Net::HTTP.new(uri.host, uri.port)
|
80
80
|
http.use_ssl = true
|
81
81
|
# set verb
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_teamdynamix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nipendar Tyagi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|