foreman_teamdynamix 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f56e77569cc341af5ed7f645a9b09bbfd3643697
4
- data.tar.gz: 387ee535b3172e53dd88e333a8e1a220991b4823
3
+ metadata.gz: ce914cf3650810a7b8b11a7da6d8fce4300c07e4
4
+ data.tar.gz: 6644dfc9e975f38d77999d98048eb36e9d47b7ad
5
5
  SHA512:
6
- metadata.gz: 0c78e5ba2688f98e86b524781b52bbc8a2f868c53ceaeb3f544ae1a79350d9e1de82598dcda357241019d3a01dc226302a9fe6bc96af38cc0cf9829c3a3a39fb
7
- data.tar.gz: 3ea41c1e3799f75b263d5aa5738bbd411a9c7f790df42a29f2667304f6e5c4b7606e082acc4932998321bb63e78d34c5f30c7039051ab174810a119b48789b57
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: 'https://miamioh.teamdynamix.com/SBTDWebApi/api'
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 by default, as first field labelled as URI.
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
- # always display a link to the asset
19
- fields = [asset_uri]
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
- api_url = SETTINGS[:teamdynamix][:api][:url]
34
- uri = api_url.split('api').first + @asset['Uri']
35
- [_('URI'), link_to(@asset['Uri'], uri, target: '_blank')]
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 + "/#{APP_ID}/assets/#{asset_id}")
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 + "/#{APP_ID}/assets")
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 + "/#{APP_ID}/assets/#{host.teamdynamix_asset_uid}")
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 + "/#{APP_ID}/assets/#{asset_id}")
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 + "/#{APP_ID}/assets/search")
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', 'Bearer ' + @auth_token)
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 + '/auth')
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
@@ -1,3 +1,3 @@
1
1
  module ForemanTeamdynamix
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
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.1.3
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-16 00:00:00.000000000 Z
11
+ date: 2018-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface