sp-seutils 0.0.2 → 0.0.9

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 +102 -36
  3. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b00d6d780a49c095b8dd0be022c840570fdd84f3884a5fa30f07ffd98574f0e3
4
- data.tar.gz: bbffb16003d9f93c8dde7ded798dab195757e46b5574e682fd16e6e5c1655590
3
+ metadata.gz: 74d5ccc1a712e43ed0540c5863dba44fed1e50d614ee337837230552bf576bda
4
+ data.tar.gz: 483b7e7538c72cae69437ede49557c06deef6451265ca3441207d9440ecb8a7b
5
5
  SHA512:
6
- metadata.gz: 8a59afbfd523b0f95482eed68d944615497d5e3b0b1cb6cab0e3f3cd7f28d4a4290f12be1a3052a2a697a8a9b27ad275313b394bbb922bd0ad8ea380a76bebeb
7
- data.tar.gz: 5d318e31a53927d7fae7bf64270db79b1771e4ccb2612ef31ac75e5b0c4a69ed33ffa4472202085c2a1bcab6d95cf85fe907953913c7f4fbe7f5e27cf2e15b23
6
+ metadata.gz: 993278a52529189d002ce36863976fdc14b6889b038c732f6e05d2b3911d9ad1c947e736d259d23ab0fe416e038ae380e2d1343e3c7783602cb7372f71fc1316
7
+ data.tar.gz: ee1adb1adc91b60e616bf0edd61f2eeb0f10accbf26c68a9f7ad326aa6ca9b99eefe43da22208300b20282518821d41b76dbd71b78deeaab8a5915b2f3684b80
@@ -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}
@@ -489,31 +523,52 @@ class SeUtils
489
523
  #-----------------------------------------------------------------------------#
490
524
  # Get accounts from a source
491
525
  #
492
- def self.api_source_getaccounts(org,user,password,client_id,client_secret,source_id,token=nil)
493
- api = "api/source/getAccounts"
494
-
495
- body = JSON.generate({:id=>source_id})
496
- url = cc_url(URI.join(org, api).to_s)
497
- token = token || idn_oauth(org,user,password,client_id,client_secret)
498
-
499
- rest_result = nil
500
- redirected_url = nil
501
- response = RestClient::Request.new({
502
- method: :get,
503
- url: url,
504
- payload: body,
505
- timeout: nil,
506
- headers: {'Authorization' => "Bearer #{token}",
507
- "Accept"=>"*/*" ,
508
- 'Cache-Control' => 'no-cache',
509
- 'Content-Type' => 'application/json',
510
- 'cache-control' => 'no-cache'
511
- }
512
- }).execute do |response, request, result, &block|
513
- rest_result = handle_rest_response(response, request, result, &block)
514
- end
515
- return rest_result
516
- end
526
+ def self.api_source_getaccounts(org,client_id,client_secret,source_id,token=nil)
527
+ api = "api/source/getAccounts"
528
+
529
+ args = "?id=#{source_id}"
530
+ url = cc_url(URI.join(org, api+args).to_s)
531
+ # puts "executing API GET #{url}"
532
+ token = token || idn_oauth_2(org,client_id,client_secret)
533
+
534
+ rest_result = nil
535
+ redirected_url = nil
536
+ response = RestClient::Request.new({
537
+ method: :get,
538
+ url: url,
539
+ timeout: nil,
540
+ headers: {'Authorization' => "Bearer #{token}",
541
+ "Accept"=>"*/*" ,
542
+ 'cache-control' => 'no-cache'
543
+ }
544
+ }).execute do |response, request, result, &block|
545
+ rest_result = handle_rest_response(response, request, result, &block)
546
+ end
547
+ return rest_result
548
+ end
549
+ # api = "api/source/getAccounts"
550
+
551
+ # body = JSON.generate({:id=>source_id})
552
+ # url = cc_url(URI.join(org, api).to_s)
553
+ # token = token || idn_oauth(org,user,password,client_id,client_secret)
554
+
555
+ # rest_result = nil
556
+ # redirected_url = nil
557
+ # response = RestClient::Request.new({
558
+ # method: :get,
559
+ # url: url,
560
+ # payload: body,
561
+ # timeout: nil,
562
+ # headers: {'Authorization' => "Bearer #{token}",
563
+ # "Accept"=>"*/*" ,
564
+ # 'Content-Type' => 'application/json',
565
+ # 'cache-control' => 'no-cache'
566
+ # }
567
+ # }).execute do |response, request, result, &block|
568
+ # rest_result = handle_rest_response(response, request, result, &block)
569
+ # end
570
+ # return rest_result
571
+ # end
517
572
 
518
573
  #-----------------------------------------------------------------------------#
519
574
  # Get accounts CSV file
@@ -1402,10 +1457,11 @@ class SeUtils
1402
1457
  #
1403
1458
  def self.api_source_reset(org,user,password,client_id,client_secret,id,query,token=nil)
1404
1459
  api = "api/source/reset/"
1405
- url = cc_url(URI.join(org, api, id, query).to_s).to_s
1460
+ url = cc_url(URI.join(org, api).to_s).to_s+"?id=#{id}"
1406
1461
  token = token || idn_oauth(org,user,password,client_id,client_secret)
1407
1462
  redirected_url = nil
1408
1463
  rest_result = nil
1464
+ wait_for_identity_refresh(org,user,password,client_id,client_secret,token)
1409
1465
  RestClient.post(url, nil,
1410
1466
  {'Authorization' => "Bearer #{token}",'X-CSRF-Token' => 'nocheck' }) do |response, request, result, &block|
1411
1467
  rest_result = handle_rest_response(response,request,result,&block)
@@ -2002,7 +2058,7 @@ class SeUtils
2002
2058
 
2003
2059
  new_args.chop!
2004
2060
 
2005
- args = URI.escape(new_args)
2061
+ args = URI.encode_www_form_component(new_args)
2006
2062
 
2007
2063
  api = "api/campaign/create"
2008
2064
  url = URI.join(org, api, args).to_s
@@ -2099,9 +2155,19 @@ class SeUtils
2099
2155
  url = URI.join(org, api).to_s+"?sourceId="+source_id.to_s
2100
2156
  token = token || idn_oauth(org,user,password,client_id,client_secret)
2101
2157
  rest_result = nil
2102
- RestClient.post(url, args, {'Authorization' => "Bearer #{token}",
2103
- 'X-CSRF-Token' => 'nocheck' }) do |response, request, result, &block|
2104
- rest_result = handle_rest_response(response,request,result,&block)
2158
+ body = JSON.generate(args)
2159
+ response = RestClient::Request.new({
2160
+ method: :post,
2161
+ url: url,
2162
+ payload: body,
2163
+ timeout: nil,
2164
+ headers: {'Authorization' => "Bearer #{token}",
2165
+ "Accept"=>"*/*" ,
2166
+ 'Content-Type' => 'application/json',
2167
+ 'cache-control' => 'no-cache'
2168
+ }
2169
+ }).execute do |response, request, result, &block|
2170
+ rest_result = handle_rest_response(response, request, result, &block)
2105
2171
  end
2106
2172
  return rest_result
2107
2173
  end
@@ -2284,7 +2350,7 @@ class SeUtils
2284
2350
  args = args+k.to_s+"="+v.to_s+"&"
2285
2351
  end
2286
2352
  args.chop!
2287
- return URI.escape(args)
2353
+ return URI.encode_www_form_component(args)
2288
2354
  end
2289
2355
 
2290
2356
  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.2
4
+ version: 0.0.9
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-10 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: []