sp-seutils 0.0.3 → 0.0.10

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sp-seutils.rb +61 -13
  3. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e18832ba562cb24e3648d453c28eebfa558c9fdf7341aa9f489cf5d173358236
4
- data.tar.gz: 1764bcbccf95fbee492285b644d2451491d05a277382ceeccdf4970644467562
3
+ metadata.gz: 7c67129e6e0aed8d5956e61b8bdf885f3235575ba18b895a2857afeee5429674
4
+ data.tar.gz: ee008084155d2fe2c75edeaa4f82820ac6d4e086c0f9fe7b853e98f843f3c2ed
5
5
  SHA512:
6
- metadata.gz: 59f84d80d3bc418b137874ffc5013ca923e575c6cec990f0a6d1245f846a1f30d2fbf3fe153e0ef8e6b4605f2e74889c625d53621edc5d93d6a0f415be546125
7
- data.tar.gz: a51e75afda9ee24481656434a302ed98d5bba1d1e8413f30d11be3002001801fc9251ff9dc8c1ca110880c40cf1a4fae1327d19ff3a8e7cbcb7c9d12d7048cb9
6
+ metadata.gz: b8c5aa2d03b28c525c443a5d406ae63919ee889b582ef327c9ab492f77f7e937bdf448a93ed6f300e7afdc09d9e2adc8cf2a194da3b250f5db02f46e2f68cd45
7
+ data.tar.gz: dc9e973e3346b0c15fe541bb414ab213c253e0c1792baa94990ff655c4e51d0c06736e374189315fb6b7848df89121744da7718722f00a6b95c1b5654a1084a9
data/lib/sp-seutils.rb CHANGED
@@ -126,6 +126,38 @@ class SeUtils
126
126
  return rest_result
127
127
  end
128
128
 
129
+ #-----------------------------------------------------------------------------#
130
+ # run specified API method ... for v3 etc
131
+ # api must include the entire string if http args are used
132
+ # body is either json or a hash
133
+ #
134
+ def self.api_do(org,api,body,api_method,client_id,client_secret,user,pass,token=nil)
135
+ return nil unless ["patch","put","post","delete"].include? api_method.to_s
136
+ body = JSON.generate(body) if body.is_a? Hash
137
+ base_url = org.split(".identitynow.com").first+".api.identitynow.com"
138
+ url = URI.join(base_url, api).to_s
139
+ token = token || idn_oauth_3(org,client_id,client_secret,user,pass)
140
+ content_type = 'application/json'
141
+ content_type = 'application/json-patch+json' if api_method.to_s == "patch"
142
+ rest_result = nil
143
+ redirected_url = nil
144
+ response = RestClient::Request.new({
145
+ method: api_method.to_sym,
146
+ url: url,
147
+ payload: body,
148
+ timeout: nil,
149
+ headers: {'Authorization' => "Bearer #{token}",
150
+ "Accept"=>"*/*" ,
151
+ 'Content-Type' => content_type,
152
+ 'cache-control' => 'no-cache'
153
+ }
154
+ }).execute do |response, request, result, &block|
155
+ rest_result = handle_rest_response(response, request, result, &block)
156
+ end
157
+ return rest_result
158
+ end
159
+
160
+
129
161
 
130
162
  #-----------------------------------------------------------------------------#
131
163
  # Get a list of apps
@@ -205,7 +237,7 @@ class SeUtils
205
237
  # returns JSON
206
238
  #
207
239
  def self.api_accessprofile_list(org,user,password,client_id,client_secret,token=nil)
208
- api = URI.escape("api/v2/access-profiles")
240
+ api = "api/v2/access-profiles"
209
241
  rest_result = []
210
242
  i = 0
211
243
  loop do
@@ -227,7 +259,7 @@ class SeUtils
227
259
  # returns JSON
228
260
  #
229
261
  def self.api_accessprofile_get(org,user,password,client_id,client_secret,id,token=nil)
230
- api = URI.escape("api/v2/access-profiles/#{id}")
262
+ api = "api/v2/access-profiles/"+id.to_s
231
263
  url = URI.join(org, api).to_s
232
264
  token = token || idn_oauth(org,user,password,client_id,client_secret)
233
265
  rest_result = nil
@@ -242,7 +274,7 @@ class SeUtils
242
274
  # returns JSON
243
275
  #
244
276
  def self.api_workgroups_get(org,user,password,client_id,client_secret,id=nil,token=nil)
245
- api = URI.escape("api/v2/workgroups/#{id}") # hopefully no more than 250 governance groups
277
+ api = "api/v2/workgroups/"+id.to_s # hopefully no more than 250 governance groups
246
278
  url = URI.join(org, api).to_s
247
279
  token = token || idn_oauth(org,user,password,client_id,client_secret)
248
280
  rest_result = nil
@@ -369,11 +401,13 @@ class SeUtils
369
401
  "backUpAttributes", "managerCorrelationRule"].each{|i| args.delete i}
370
402
  ["cloudExternalId", "healthCheckTimeout", "cloudCacheUpdate","acctAggregationEnd",
371
403
  "acctAggregationStart", "hasFullAggregationCompleted", "source-config", "user[]",
372
- "cloudDisplayName", "md5"].each{|i| args["connectorAttributes"].delete i}
404
+ "cloudDisplayName", "md5"].each{|i| args["connectorAttributes"].delete i} if args.keys.include? "connectorAttributes"
373
405
  body = JSON.generate(args)
374
406
  api = "/beta/sources/"
407
+ api = "/beta/sources/?provisionAsCsv=true" if args["type"] == "DelimitedFile"
375
408
  base_url = org.split(".identitynow.com").first+".api.identitynow.com"
376
409
  url = URI.join(base_url, api).to_s
410
+ url = url+""
377
411
  token = token || idn_oauth_3(org,user,pass,client_id,client_secret)
378
412
  rest_result = nil
379
413
  redirected_url = nil
@@ -412,7 +446,7 @@ class SeUtils
412
446
  source_json[k] = "true" if v.is_a? TrueClass
413
447
  source_json[k] = "false" if v.is_a? FalseClass
414
448
  end
415
- source_json["connectorAttributes"]["cloudExternalId"] = source_json["connectorAttributes"]["cloudExternalId"].to_s
449
+ # source_json["connectorAttributes"]["cloudExternalId"] = source_json["connectorAttributes"]["cloudExternalId"].to_s
416
450
 
417
451
  # shouldn't be updating these things... we'll keep the ones from the GET
418
452
  ["type","connector","connectorClass","created", "modified"].each{|i| args.delete i}
@@ -650,11 +684,14 @@ end
650
684
  def self.api_post(org,api,user,password,client_id,client_secret,data=nil,token=nil)
651
685
  api = "api/"+api
652
686
  url = cc_url(URI.join(org, api).to_s)
687
+ data = JSON.generate(data) if data.is_a? Hash
653
688
  rest_result = nil
654
689
  token = token || idn_oauth(org,user,password,client_id,client_secret)
655
690
  redirected_url = nil
656
- RestClient.post(url, data,
657
- {'Authorization' => "Bearer #{token}", 'X-CSRF-Token' => 'nocheck', "Accept"=>"*/*"
691
+ RestClient.post(url, data, {'Authorization' => "Bearer #{token}",
692
+ 'X-CSRF-Token' => 'nocheck',
693
+ "Accept"=>"*/*",
694
+ 'Content-Type' => 'application/json'
658
695
  }) do |response, request, result, &block|
659
696
  rest_result = handle_rest_response(response, request, result, &block)
660
697
  end
@@ -1423,10 +1460,11 @@ end
1423
1460
  #
1424
1461
  def self.api_source_reset(org,user,password,client_id,client_secret,id,query,token=nil)
1425
1462
  api = "api/source/reset/"
1426
- url = cc_url(URI.join(org, api, id, query).to_s).to_s
1463
+ url = cc_url(URI.join(org, api).to_s).to_s+"?id=#{id}"
1427
1464
  token = token || idn_oauth(org,user,password,client_id,client_secret)
1428
1465
  redirected_url = nil
1429
1466
  rest_result = nil
1467
+ wait_for_identity_refresh(org,user,password,client_id,client_secret,token)
1430
1468
  RestClient.post(url, nil,
1431
1469
  {'Authorization' => "Bearer #{token}",'X-CSRF-Token' => 'nocheck' }) do |response, request, result, &block|
1432
1470
  rest_result = handle_rest_response(response,request,result,&block)
@@ -2023,7 +2061,7 @@ end
2023
2061
 
2024
2062
  new_args.chop!
2025
2063
 
2026
- args = URI.escape(new_args)
2064
+ args = URI.encode_www_form_component(new_args)
2027
2065
 
2028
2066
  api = "api/campaign/create"
2029
2067
  url = URI.join(org, api, args).to_s
@@ -2120,9 +2158,19 @@ end
2120
2158
  url = URI.join(org, api).to_s+"?sourceId="+source_id.to_s
2121
2159
  token = token || idn_oauth(org,user,password,client_id,client_secret)
2122
2160
  rest_result = nil
2123
- RestClient.post(url, args, {'Authorization' => "Bearer #{token}",
2124
- 'X-CSRF-Token' => 'nocheck' }) do |response, request, result, &block|
2125
- rest_result = handle_rest_response(response,request,result,&block)
2161
+ body = JSON.generate(args)
2162
+ response = RestClient::Request.new({
2163
+ method: :post,
2164
+ url: url,
2165
+ payload: body,
2166
+ timeout: nil,
2167
+ headers: {'Authorization' => "Bearer #{token}",
2168
+ "Accept"=>"*/*" ,
2169
+ 'Content-Type' => 'application/json',
2170
+ 'cache-control' => 'no-cache'
2171
+ }
2172
+ }).execute do |response, request, result, &block|
2173
+ rest_result = handle_rest_response(response, request, result, &block)
2126
2174
  end
2127
2175
  return rest_result
2128
2176
  end
@@ -2305,7 +2353,7 @@ end
2305
2353
  args = args+k.to_s+"="+v.to_s+"&"
2306
2354
  end
2307
2355
  args.chop!
2308
- return URI.escape(args)
2356
+ return URI.encode_www_form_component(args)
2309
2357
  end
2310
2358
 
2311
2359
  def self.unescape(s)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sp-seutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Karnes
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-17 00:00:00.000000000 Z
11
+ date: 2021-01-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Utilities SailPoint SEs can use to help perform demo system tasks.
14
14
  email: josh.karnes@sailpoint.com
@@ -21,7 +21,7 @@ homepage: https://rubygems.org/gems/sp-seutils
21
21
  licenses:
22
22
  - MIT
23
23
  metadata: {}
24
- post_install_message:
24
+ post_install_message:
25
25
  rdoc_options: []
26
26
  require_paths:
27
27
  - lib
@@ -36,8 +36,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
38
  requirements: []
39
- rubygems_version: 3.0.3
40
- signing_key:
39
+ rubygems_version: 3.2.4
40
+ signing_key:
41
41
  specification_version: 4
42
42
  summary: SailPoint SE Utilities
43
43
  test_files: []