sp-seutils 0.0.5 → 0.0.7

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 +39 -6
  3. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78910d908ffd01e572e76e2e8f30c84a43193b9788a9ebb94d8f41d722ee1282
4
- data.tar.gz: 1ebe4ac519f68ac9f86c59d22e45ad99ea42afbe703914d302adda156738dad1
3
+ metadata.gz: bbd1054feedb226b7502926e6451f215ec2f62accfd8be745175b0cf92be5e06
4
+ data.tar.gz: 43066d0e2dd362b67283d6556ec3efd2e37eba0554746e87bd06595efd4864a9
5
5
  SHA512:
6
- metadata.gz: e1cd2961e1ed65d0cb935a4e58c86ee8b374fe4dad04441467fa5aa267906e3650699978282b82902bd7429da693cdc402f9c9688721d47a6bc483af4934c0d5
7
- data.tar.gz: 42b43df89fc5278e85b9e1e33905c9267b9009a6672e6676b5b899e7f9a051dd423dd09528188a65cb93c9b0dd37bb5d27957c3c55c8a9bcc3cdb05c4de0494c
6
+ metadata.gz: 781cdac94ae2401a189bf21cd63089facad7f038f1be198abcd761341ccc978a20c009148ea423350b8492d062085a9ed2bb5a0fca5ffa984908325aab7e338f
7
+ data.tar.gz: 490ee6136a6f58d2b5092bff2baa967957328613198c726647d4595b76614066244bfbc9fcf8b64014a27b08a2a4f3f51e361a2914aca342da69925b3c8095f3
@@ -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
@@ -1423,10 +1455,11 @@ end
1423
1455
  #
1424
1456
  def self.api_source_reset(org,user,password,client_id,client_secret,id,query,token=nil)
1425
1457
  api = "api/source/reset/"
1426
- url = cc_url(URI.join(org, api, id, query).to_s).to_s
1458
+ url = cc_url(URI.join(org, api).to_s).to_s+"?id=#{id}"
1427
1459
  token = token || idn_oauth(org,user,password,client_id,client_secret)
1428
1460
  redirected_url = nil
1429
1461
  rest_result = nil
1462
+ wait_for_identity_refresh(org,user,password,client_id,client_secret,token)
1430
1463
  RestClient.post(url, nil,
1431
1464
  {'Authorization' => "Bearer #{token}",'X-CSRF-Token' => 'nocheck' }) do |response, request, result, &block|
1432
1465
  rest_result = handle_rest_response(response,request,result,&block)
@@ -2023,7 +2056,7 @@ end
2023
2056
 
2024
2057
  new_args.chop!
2025
2058
 
2026
- args = URI.escape(new_args)
2059
+ args = URI.encode_www_form_component(new_args)
2027
2060
 
2028
2061
  api = "api/campaign/create"
2029
2062
  url = URI.join(org, api, args).to_s
@@ -2305,7 +2338,7 @@ end
2305
2338
  args = args+k.to_s+"="+v.to_s+"&"
2306
2339
  end
2307
2340
  args.chop!
2308
- return URI.escape(args)
2341
+ return URI.encode_www_form_component(args)
2309
2342
  end
2310
2343
 
2311
2344
  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.5
4
+ version: 0.0.7
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-08 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: []