oktakit 0.2.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/probots.yml +2 -0
- data/.github/workflows/ci.yml +27 -0
- data/.gitignore +1 -1
- data/.rubocop.yml +7 -79
- data/.ruby-version +1 -0
- data/.travis.yml +3 -5
- data/CHANGELOG.md +16 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/Gemfile +5 -3
- data/Gemfile.lock +101 -0
- data/README.md +12 -4
- data/dev.yml +1 -5
- data/lib/oktakit/client/apps.rb +16 -0
- data/lib/oktakit/client/group_rules.rb +115 -0
- data/lib/oktakit/client/schemas.rb +64 -0
- data/lib/oktakit/client/users.rb +75 -19
- data/lib/oktakit/client.rb +28 -23
- data/lib/oktakit/error.rb +5 -5
- data/lib/oktakit/response/raise_error.rb +1 -1
- data/lib/oktakit/version.rb +1 -1
- data/lib/oktakit.rb +2 -2
- data/oktakit.gemspec +6 -6
- metadata +16 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3fa09f58e951595b1e743df9a7fa8584254ec16c81444a4b961ae2c0f3cdfd4f
|
4
|
+
data.tar.gz: 04b21c8abfd412194f11ed3fbf5798e9de7cdda4bf878a51cb742c126d930f2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0997c60e8dc44671eaa2422dc8863b4cb0441191829d1c012c7fc1c9fbbb943f59546cc027eef4dda2af774829cc5056950f072fdf5ef3f667a6b2810ce1836c'
|
7
|
+
data.tar.gz: 23e3a86d6bf5c928fa1d480b54340be3384722d7904ddd8df4885891b85a7ce52a48906dc39614e7b385ee939623cd34a71f825d49e1f50879f1c0f59a5e7476
|
data/.github/probots.yml
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
branches:
|
9
|
+
- master
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
build:
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
name: Ruby ${{ matrix.ruby }}
|
15
|
+
strategy:
|
16
|
+
matrix:
|
17
|
+
ruby: [2.6, 2.7, 3.0, 3.1]
|
18
|
+
steps:
|
19
|
+
- name: Check out code
|
20
|
+
uses: actions/checkout@v2
|
21
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
25
|
+
bundler-cache: true
|
26
|
+
- name: Ruby tests
|
27
|
+
run: bundle exec rspec
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,88 +1,16 @@
|
|
1
1
|
# This file strictly follows the rules defined in the Ruby style guide:
|
2
2
|
# http://shopify.github.io/ruby-style-guide/
|
3
|
+
inherit_gem:
|
4
|
+
rubocop-shopify: rubocop.yml
|
3
5
|
|
4
6
|
AllCops:
|
5
|
-
TargetRubyVersion: 2.
|
7
|
+
TargetRubyVersion: 2.6
|
8
|
+
SuggestExtensions: false
|
6
9
|
|
7
|
-
|
10
|
+
# Allow .ruby-version and spec.required_ruby_version to differ
|
11
|
+
# to run a newer Ruby version for Rubocop, but don't force users to upgrade
|
12
|
+
Gemspec/RequiredRubyVersion:
|
8
13
|
Enabled: false
|
9
14
|
|
10
|
-
Lint/AssignmentInCondition:
|
11
|
-
Enabled: false
|
12
|
-
|
13
|
-
Style/Documentation:
|
14
|
-
Enabled: false
|
15
|
-
|
16
|
-
Style/MultilineOperationIndentation:
|
17
|
-
Enabled: false
|
18
|
-
|
19
|
-
Style/AlignParameters:
|
20
|
-
EnforcedStyle: with_fixed_indentation
|
21
|
-
|
22
|
-
Style/FirstParameterIndentation:
|
23
|
-
EnforcedStyle: consistent
|
24
|
-
|
25
|
-
Style/TrailingCommaInLiteral:
|
26
|
-
Enabled: false
|
27
|
-
|
28
|
-
Style/SignalException:
|
29
|
-
EnforcedStyle: only_raise
|
30
|
-
|
31
|
-
Style/NumericLiterals:
|
32
|
-
Enabled: false
|
33
|
-
|
34
|
-
Style/CaseIndentation:
|
35
|
-
EnforcedStyle: end
|
36
|
-
|
37
|
-
Style/IndentHash:
|
38
|
-
EnforcedStyle: consistent
|
39
|
-
|
40
|
-
Style/WordArray:
|
41
|
-
Enabled: false
|
42
|
-
|
43
|
-
Metrics/AbcSize:
|
44
|
-
Enabled: false
|
45
|
-
|
46
|
-
Metrics/CyclomaticComplexity:
|
47
|
-
Enabled: false
|
48
|
-
|
49
|
-
Style/StringLiterals:
|
50
|
-
Enabled: false
|
51
|
-
|
52
|
-
Metrics/LineLength:
|
53
|
-
Max: 120
|
54
|
-
|
55
|
-
Metrics/ClassLength:
|
56
|
-
Enabled: false
|
57
|
-
|
58
|
-
Metrics/MethodLength:
|
59
|
-
Enabled: false
|
60
|
-
|
61
|
-
Metrics/BlockLength:
|
62
|
-
Exclude:
|
63
|
-
- "**/*_spec.rb"
|
64
|
-
|
65
|
-
Metrics/ParameterLists:
|
66
|
-
Max: 5
|
67
|
-
CountKeywordArgs: false
|
68
|
-
|
69
|
-
Metrics/PerceivedComplexity:
|
70
|
-
Enabled: false
|
71
|
-
|
72
|
-
Lint/EndAlignment:
|
73
|
-
EnforcedStyleAlignWith: variable
|
74
|
-
|
75
15
|
Style/FrozenStringLiteralComment:
|
76
16
|
Enabled: false
|
77
|
-
|
78
|
-
Style/Alias:
|
79
|
-
EnforcedStyle: prefer_alias_method
|
80
|
-
|
81
|
-
Style/MutableConstant:
|
82
|
-
Enabled: false
|
83
|
-
|
84
|
-
Performance/Casecmp:
|
85
|
-
Enabled: false
|
86
|
-
|
87
|
-
Style/GuardClause:
|
88
|
-
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.6
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [v0.3.2] - 2022-06-30
|
4
|
+
- [Fix 'Faraday::Connection#authorization' deprecation warning](https://github.com/Shopify/oktakit/pull/56)
|
5
|
+
|
6
|
+
## [v0.3.1] - 2022-01-20
|
7
|
+
- [Reverts a breaking change that caused errors to be raised for non-2xx responses](https://github.com/Shopify/oktakit/pull/54)
|
8
|
+
|
9
|
+
## [v0.3.0] - 2022-01-20
|
10
|
+
- [Adds support for Ruby 3](https://github.com/Shopify/oktakit/pull/42)
|
11
|
+
- [Adds support for user reactivation endpoint](https://github.com/Shopify/oktakit/pull/47)
|
12
|
+
- [Adds support for app user schema operations endpoint](https://github.com/Shopify/oktakit/pull/32)
|
13
|
+
- [Makes custom error details available](https://github.com/Shopify/oktakit/pull/48)
|
14
|
+
|
15
|
+
## [v0.2.1] - 2021-10-14
|
16
|
+
- Adds support for [Group Rule operations](https://developer.okta.com/docs/reference/api/groups/#group-rule-operations)
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
9
|
+
level of experience, education, socio-economic status, nationality, personal
|
10
|
+
appearance, race, religion, or sexual identity and orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at security@shopify.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
72
|
+
|
73
|
+
[homepage]: https://www.contributor-covenant.org
|
74
|
+
|
75
|
+
For answers to common questions about this code of conduct, see
|
76
|
+
https://www.contributor-covenant.org/faq
|
data/Gemfile
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
source 'https://rubygems.org'
|
2
3
|
|
3
4
|
gem 'byebug'
|
4
5
|
gem 'rake'
|
5
|
-
gem 'rubocop'
|
6
6
|
gem 'yard'
|
7
7
|
|
8
8
|
group :test do
|
9
|
-
gem '
|
10
|
-
gem '
|
9
|
+
gem 'rubocop'
|
10
|
+
gem 'rubocop-shopify', require: false
|
11
|
+
gem 'rspec', '~> 3.10'
|
12
|
+
gem 'vcr', '~> 6.0'
|
11
13
|
end
|
12
14
|
|
13
15
|
gemspec
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
oktakit (0.3.2)
|
5
|
+
sawyer (~> 0.8.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.8.0)
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
|
+
ast (2.4.2)
|
13
|
+
byebug (11.1.3)
|
14
|
+
diff-lcs (1.4.4)
|
15
|
+
faraday (1.9.3)
|
16
|
+
faraday-em_http (~> 1.0)
|
17
|
+
faraday-em_synchrony (~> 1.0)
|
18
|
+
faraday-excon (~> 1.1)
|
19
|
+
faraday-httpclient (~> 1.0)
|
20
|
+
faraday-multipart (~> 1.0)
|
21
|
+
faraday-net_http (~> 1.0)
|
22
|
+
faraday-net_http_persistent (~> 1.0)
|
23
|
+
faraday-patron (~> 1.0)
|
24
|
+
faraday-rack (~> 1.0)
|
25
|
+
faraday-retry (~> 1.0)
|
26
|
+
ruby2_keywords (>= 0.0.4)
|
27
|
+
faraday-em_http (1.0.0)
|
28
|
+
faraday-em_synchrony (1.0.0)
|
29
|
+
faraday-excon (1.1.0)
|
30
|
+
faraday-httpclient (1.0.1)
|
31
|
+
faraday-multipart (1.0.3)
|
32
|
+
multipart-post (>= 1.2, < 3)
|
33
|
+
faraday-net_http (1.0.1)
|
34
|
+
faraday-net_http_persistent (1.2.0)
|
35
|
+
faraday-patron (1.0.0)
|
36
|
+
faraday-rack (1.0.0)
|
37
|
+
faraday-retry (1.0.3)
|
38
|
+
multipart-post (2.1.1)
|
39
|
+
parallel (1.21.0)
|
40
|
+
parser (3.0.3.2)
|
41
|
+
ast (~> 2.4.1)
|
42
|
+
public_suffix (4.0.6)
|
43
|
+
rainbow (3.0.0)
|
44
|
+
rake (13.0.6)
|
45
|
+
regexp_parser (2.2.0)
|
46
|
+
rexml (3.2.5)
|
47
|
+
rspec (3.10.0)
|
48
|
+
rspec-core (~> 3.10.0)
|
49
|
+
rspec-expectations (~> 3.10.0)
|
50
|
+
rspec-mocks (~> 3.10.0)
|
51
|
+
rspec-core (3.10.1)
|
52
|
+
rspec-support (~> 3.10.0)
|
53
|
+
rspec-expectations (3.10.1)
|
54
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
+
rspec-support (~> 3.10.0)
|
56
|
+
rspec-mocks (3.10.2)
|
57
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
58
|
+
rspec-support (~> 3.10.0)
|
59
|
+
rspec-support (3.10.3)
|
60
|
+
rubocop (1.23.0)
|
61
|
+
parallel (~> 1.10)
|
62
|
+
parser (>= 3.0.0.0)
|
63
|
+
rainbow (>= 2.2.2, < 4.0)
|
64
|
+
regexp_parser (>= 1.8, < 3.0)
|
65
|
+
rexml
|
66
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
67
|
+
ruby-progressbar (~> 1.7)
|
68
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
69
|
+
rubocop-ast (1.15.0)
|
70
|
+
parser (>= 3.0.1.1)
|
71
|
+
rubocop-shopify (2.3.0)
|
72
|
+
rubocop (~> 1.22)
|
73
|
+
ruby-progressbar (1.11.0)
|
74
|
+
ruby2_keywords (0.0.5)
|
75
|
+
sawyer (0.8.2)
|
76
|
+
addressable (>= 2.3.5)
|
77
|
+
faraday (> 0.8, < 2.0)
|
78
|
+
unicode-display_width (2.1.0)
|
79
|
+
vcr (6.0.0)
|
80
|
+
webrick (1.7.0)
|
81
|
+
yard (0.9.27)
|
82
|
+
webrick (~> 1.7.0)
|
83
|
+
|
84
|
+
PLATFORMS
|
85
|
+
-darwin-21
|
86
|
+
arm64-darwin-21
|
87
|
+
x86_64-linux
|
88
|
+
|
89
|
+
DEPENDENCIES
|
90
|
+
bundler
|
91
|
+
byebug
|
92
|
+
oktakit!
|
93
|
+
rake
|
94
|
+
rspec (~> 3.10)
|
95
|
+
rubocop
|
96
|
+
rubocop-shopify
|
97
|
+
vcr (~> 6.0)
|
98
|
+
yard
|
99
|
+
|
100
|
+
BUNDLED WITH
|
101
|
+
2.2.22
|
data/README.md
CHANGED
@@ -15,11 +15,13 @@ gem 'oktakit'
|
|
15
15
|
|
16
16
|
And then execute:
|
17
17
|
|
18
|
-
|
18
|
+
```sh
|
19
|
+
bundle
|
20
|
+
```
|
19
21
|
|
20
22
|
## Usage
|
21
23
|
|
22
|
-
`Oktakit` follows similar patterns as found in [`Octokit`](https://github.com/octokit/octokit.rb). So if you are familiar with
|
24
|
+
`Oktakit` follows similar patterns as found in [`Octokit`](https://github.com/octokit/octokit.rb). So if you are familiar with Octokit, then you should feel right at home.
|
23
25
|
|
24
26
|
```ruby
|
25
27
|
client = Oktakit.new(token: 't0k3n', organization: 'my-great-org')
|
@@ -32,7 +34,8 @@ To work with the Okta sandbox (`<organization>.oktapreview.com`), set the `api_e
|
|
32
34
|
client = Oktakit.new(token: 't0k3n', api_endpoint: 'https://my-great-org.oktapreview.com/api/v1')
|
33
35
|
```
|
34
36
|
|
35
|
-
|
37
|
+
### Pagination
|
38
|
+
|
36
39
|
Pass the `paginate` flag as options for any `get` action for Oktakit to autopaginate the response for you.
|
37
40
|
|
38
41
|
```ruby
|
@@ -59,8 +62,13 @@ The [API Test Client](https://developer.okta.com/docs/api/getting_started/api_te
|
|
59
62
|
|
60
63
|
## Contributing
|
61
64
|
|
62
|
-
1. Fork it ( https://github.com/shopify/oktakit/fork )
|
65
|
+
1. Fork it ( <https://github.com/shopify/oktakit/fork> )
|
63
66
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
64
67
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
65
68
|
4. Push to the branch (`git push origin my-new-feature`)
|
66
69
|
5. Create a new Pull Request
|
70
|
+
|
71
|
+
### Contributor License Agreement
|
72
|
+
|
73
|
+
New contributors will be required to sign [Shopify's Contributor License Agreement (CLA)](https://cla.shopify.com/).
|
74
|
+
There are two versions of the CLA: one for individuals and one for organizations.
|
data/dev.yml
CHANGED
data/lib/oktakit/client/apps.rb
CHANGED
@@ -176,6 +176,22 @@ module Oktakit
|
|
176
176
|
get("/apps/#{id}/users", options)
|
177
177
|
end
|
178
178
|
|
179
|
+
# List Applications Assigned to User
|
180
|
+
#
|
181
|
+
# @params user_id [string] User ID
|
182
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
183
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
184
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
185
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
186
|
+
# @param options [Hash] Optional. Body params for request.
|
187
|
+
# @return [Array<Sawyer::Resource>] Array of Applications Assigned to User
|
188
|
+
# @see https://developer.okta.com/docs/api/resources/apps#list-applications-assigned-to-user
|
189
|
+
# @example
|
190
|
+
# Oktakit.list_applications_assigned_to_user('<user_id>')
|
191
|
+
def list_applications_assigned_to_user(user_id, options = {})
|
192
|
+
get("/apps?filter=user.id+eq+\"#{user_id}\"&expand=user/#{user_id}", options)
|
193
|
+
end
|
194
|
+
|
179
195
|
# Update Application Credentials for Assigned User
|
180
196
|
#
|
181
197
|
# @params app_id [string] Application ID
|
@@ -0,0 +1,115 @@
|
|
1
|
+
module Oktakit
|
2
|
+
class Client
|
3
|
+
module GroupRules
|
4
|
+
# Add Group Rule
|
5
|
+
#
|
6
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
7
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
8
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
9
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
10
|
+
# @param options [Hash] Optional. Body params for request.
|
11
|
+
# @return [Hash<Sawyer::Resource>] The created Group Rule.
|
12
|
+
# @see https://developer.okta.com/docs/reference/api/groups/#create-group-rule
|
13
|
+
# @example
|
14
|
+
# Oktakit.add_group_rule
|
15
|
+
def add_group_rule(options = {})
|
16
|
+
post('/groups/rules', options)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Get Group Rule
|
20
|
+
#
|
21
|
+
# @params id [string] Group Rule ID
|
22
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
23
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
24
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
25
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
26
|
+
# @param options [Hash] Optional. Body params for request.
|
27
|
+
# @return [Hash<Sawyer::Resource>] Fetched Group Rule
|
28
|
+
# @see https://developer.okta.com/docs/reference/api/groups/#get-group-rule
|
29
|
+
# @example
|
30
|
+
# Oktakit.get_group_rule('id')
|
31
|
+
def get_group_rule(id, options = {})
|
32
|
+
get("/groups/rules/#{id}", options)
|
33
|
+
end
|
34
|
+
|
35
|
+
# List Group Rules
|
36
|
+
#
|
37
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
38
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
39
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
40
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
41
|
+
# @param options [Hash] Optional. Body params for request.
|
42
|
+
# @return [Array<Sawyer::Resource>] Array of Group Rules
|
43
|
+
# @see https://developer.okta.com/docs/reference/api/groups/#list-group-rules
|
44
|
+
# @example
|
45
|
+
# Oktakit.list_group_rules
|
46
|
+
def list_group_rules(options = {})
|
47
|
+
get('/groups/rules', options)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Update Group Rule
|
51
|
+
#
|
52
|
+
# @params id [string] Group Rule ID
|
53
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
54
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
55
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
56
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
57
|
+
# @param options [Hash] Optional. Body params for request.
|
58
|
+
# @return [Hash<Sawyer::Resource>] Updated Group Rule
|
59
|
+
# @see https://developer.okta.com/docs/reference/api/groups/#update-group-rule
|
60
|
+
# @example
|
61
|
+
# Oktakit.update_group_rule('id')
|
62
|
+
def update_group_rule(id, options = {})
|
63
|
+
put("/groups/rules/#{id}", options)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Remove Group Rule
|
67
|
+
#
|
68
|
+
# @params id [string] Group ID
|
69
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
70
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
71
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
72
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
73
|
+
# @param options [Hash] Optional. Body params for request.
|
74
|
+
# @return HTTP 202 Accepted
|
75
|
+
# @see https://developer.okta.com/docs/reference/api/groups/#delete-a-group-rule
|
76
|
+
# @example
|
77
|
+
# Oktakit.remove_group_rule('id')
|
78
|
+
def remove_group_rule(id, options = {})
|
79
|
+
delete("/groups/rules/#{id}", options)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Activate Group Rule
|
83
|
+
#
|
84
|
+
# @params id [string] Group ID
|
85
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
86
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
87
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
88
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
89
|
+
# @param options [Hash] Optional. Body params for request.
|
90
|
+
# @return HTTP 204 No Content
|
91
|
+
# @see https://developer.okta.com/docs/reference/api/groups/#activate-a-group-rule
|
92
|
+
# @example
|
93
|
+
# Oktakit.activate_group_rule('id')
|
94
|
+
def activate_group_rule(id, options = {})
|
95
|
+
post("/groups/rules/#{id}/lifecycle/activate", options)
|
96
|
+
end
|
97
|
+
|
98
|
+
# Deactivate Group Rule
|
99
|
+
#
|
100
|
+
# @params id [string] Group ID
|
101
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
102
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
103
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
104
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
105
|
+
# @param options [Hash] Optional. Body params for request.
|
106
|
+
# @return HTTP 204 No Content
|
107
|
+
# @see https://developer.okta.com/docs/reference/api/groups/#deactivate-a-group-rule
|
108
|
+
# @example
|
109
|
+
# Oktakit.deactivate_group_rule('id')
|
110
|
+
def deactivate_group_rule(id, options = {})
|
111
|
+
post("/groups/rules/#{id}/lifecycle/deactivate", options)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -60,6 +60,70 @@ module Oktakit
|
|
60
60
|
def remove_property_from_user_profile_schema(options = {})
|
61
61
|
post('/meta/schemas/user/default', options)
|
62
62
|
end
|
63
|
+
|
64
|
+
# Get App User Schema
|
65
|
+
#
|
66
|
+
# @params id [string] Application ID
|
67
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
68
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
69
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
70
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
71
|
+
# @param options [Hash] Optional. Body params for request.
|
72
|
+
# @return [Hash<Sawyer::Resource>] User Schema
|
73
|
+
# @see https://developer.okta.com/docs/reference/api/schemas/#get-app-user-schema
|
74
|
+
# @example
|
75
|
+
# Oktakit.get_app_user_schema('id')
|
76
|
+
def get_app_user_schema(id, options = {})
|
77
|
+
get("/meta/schemas/apps/#{id}/default", options)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Add Property to App User Profile Schema
|
81
|
+
#
|
82
|
+
# @params id [string] Application ID
|
83
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
84
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
85
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
86
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
87
|
+
# @param options [Hash] Optional. Body params for request.
|
88
|
+
# @return [Hash<Sawyer::Resource>] User Schema
|
89
|
+
# @see https://developer.okta.com/docs/reference/api/schemas/#add-property-to-app-user-profile-schema
|
90
|
+
# @example
|
91
|
+
# Oktakit.add_property_to_app_user_profile_schema('id')
|
92
|
+
def add_property_to_app_user_profile_schema(id, options = {})
|
93
|
+
post("/meta/schemas/apps/#{id}/default", options)
|
94
|
+
end
|
95
|
+
|
96
|
+
# Update App User Profile Schema property
|
97
|
+
#
|
98
|
+
# @params id [string] Application ID
|
99
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
100
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
101
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
102
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
103
|
+
# @param options [Hash] Optional. Body params for request.
|
104
|
+
# @return [Hash<Sawyer::Resource>] User Schema
|
105
|
+
# @see https://developer.okta.com/docs/reference/api/schemas/#update-app-user-profile-schema-property
|
106
|
+
# @example
|
107
|
+
# Oktakit.update_app_user_profile_schema_property('id')
|
108
|
+
def update_app_user_profile_schema_property(id, options = {})
|
109
|
+
post("/meta/schemas/apps/#{id}/default", options)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Remove property from App User Profile Schema
|
113
|
+
#
|
114
|
+
# @params id [string] Application ID
|
115
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
116
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
117
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
118
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
119
|
+
# @param options [Hash] Optional. Body params for request.
|
120
|
+
# @return [Hash<Sawyer::Resource>] User Schema
|
121
|
+
# @see https://developer.okta.com/docs/reference/api/schemas/#remove-property-from-app-user-profile-schema
|
122
|
+
# @example
|
123
|
+
# Oktakit.remove_property_from_app_user_profile_schema('id')
|
124
|
+
def remove_property_from_app_user_profile_schema(id, options = {})
|
125
|
+
post("/meta/schemas/apps/#{id}/default", options)
|
126
|
+
end
|
63
127
|
end
|
64
128
|
end
|
65
129
|
end
|
data/lib/oktakit/client/users.rb
CHANGED
@@ -9,7 +9,7 @@ module Oktakit
|
|
9
9
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
10
10
|
# @param options [Hash] Optional. Body params for request.
|
11
11
|
# @return [Hash<Sawyer::Resource>] Returns the created User.
|
12
|
-
# @see
|
12
|
+
# @see https://developer.okta.com/docs/api/resources/users#create-user
|
13
13
|
# @example
|
14
14
|
# Oktakit.create_user
|
15
15
|
def create_user(options = {})
|
@@ -25,7 +25,7 @@ module Oktakit
|
|
25
25
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
26
26
|
# @param options [Hash] Optional. Body params for request.
|
27
27
|
# @return [Hash<Sawyer::Resource>] Fetched User
|
28
|
-
# @see
|
28
|
+
# @see https://developer.okta.com/docs/api/resources/users#get-user
|
29
29
|
# @example
|
30
30
|
# Oktakit.get_user('id')
|
31
31
|
def get_user(id, options = {})
|
@@ -40,7 +40,7 @@ module Oktakit
|
|
40
40
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
41
41
|
# @param options [Hash] Optional. Body params for request.
|
42
42
|
# @return [Array<Sawyer::Resource>] Array of User
|
43
|
-
# @see
|
43
|
+
# @see https://developer.okta.com/docs/api/resources/users#list-users
|
44
44
|
# @example
|
45
45
|
# Oktakit.list_users
|
46
46
|
def list_users(options = {})
|
@@ -54,13 +54,18 @@ module Oktakit
|
|
54
54
|
# @param options[:headers] [Hash] Optional. Header params for the request.
|
55
55
|
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
56
56
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
57
|
+
# @param options[:partial] [Boolean] Indicates a partial update, in which case POST will be used instead of PUT
|
57
58
|
# @param options [Hash] Optional. Body params for request.
|
58
59
|
# @return [Hash<Sawyer::Resource>] Updated User
|
59
|
-
# @see
|
60
|
+
# @see https://developer.okta.com/docs/api/resources/users#update-user
|
60
61
|
# @example
|
61
62
|
# Oktakit.update_user('id')
|
62
63
|
def update_user(id, options = {})
|
63
|
-
|
64
|
+
if options.delete(:partial)
|
65
|
+
post("/users/#{id}", options)
|
66
|
+
else
|
67
|
+
put("/users/#{id}", options)
|
68
|
+
end
|
64
69
|
end
|
65
70
|
|
66
71
|
# Update Profile
|
@@ -72,7 +77,7 @@ module Oktakit
|
|
72
77
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
73
78
|
# @param options [Hash] Optional. Body params for request.
|
74
79
|
# @return [Hash<Sawyer::Resource>] Updated User
|
75
|
-
# @see
|
80
|
+
# @see https://developer.okta.com/docs/api/resources/users#update-profile
|
76
81
|
# @example
|
77
82
|
# Oktakit.update_profile('id')
|
78
83
|
def update_profile(id, options = {})
|
@@ -87,7 +92,7 @@ module Oktakit
|
|
87
92
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
88
93
|
# @param options [Hash] Optional. Body params for request.
|
89
94
|
# @return [Array<Sawyer::Resource>] Array of App Links
|
90
|
-
# @see
|
95
|
+
# @see https://developer.okta.com/docs/api/resources/users#get-assigned-app-links
|
91
96
|
# @example
|
92
97
|
# Oktakit.get_assigned_app_links('id')
|
93
98
|
def get_assigned_app_links(id, options = {})
|
@@ -103,7 +108,7 @@ module Oktakit
|
|
103
108
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
104
109
|
# @param options [Hash] Optional. Body params for request.
|
105
110
|
# @return [Array<Sawyer::Resource>] Array of Groups
|
106
|
-
# @see
|
111
|
+
# @see https://developer.okta.com/docs/api/resources/users#get-member-groups
|
107
112
|
# @example
|
108
113
|
# Oktakit.get_member_groups('id')
|
109
114
|
def get_member_groups(id, options = {})
|
@@ -119,13 +124,31 @@ module Oktakit
|
|
119
124
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
120
125
|
# @param options [Hash] Optional. Body params for request.
|
121
126
|
# @return [Hash<Sawyer::Resource>] Returns empty object by default. If sendEmail is false, a user activation link.
|
122
|
-
# @see
|
127
|
+
# @see https://developer.okta.com/docs/api/resources/users#activate-user
|
123
128
|
# @example
|
124
129
|
# Oktakit.activate_user('id')
|
125
130
|
def activate_user(id, options = {})
|
126
131
|
post("/users/#{id}/lifecycle/activate", options)
|
127
132
|
end
|
128
133
|
|
134
|
+
# Reactivate User
|
135
|
+
#
|
136
|
+
# @params id [string] User ID
|
137
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
138
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
139
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
140
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
141
|
+
# @param options [Hash] Optional. Body params for request.
|
142
|
+
# @return [Hash<Sawyer::Resource>].
|
143
|
+
# @note The user must be in a PROVISIONED status
|
144
|
+
# @see https://developer.okta.com/docs/reference/api/users/#reactivate-user
|
145
|
+
# @example
|
146
|
+
# Oktakit.reactivate_user('id')
|
147
|
+
|
148
|
+
def reactivate_user(id, options = {})
|
149
|
+
post("/users/#{id}/lifecycle/reactivate", options)
|
150
|
+
end
|
151
|
+
|
129
152
|
# Deactivate User
|
130
153
|
#
|
131
154
|
# @params id [string] User ID
|
@@ -135,13 +158,31 @@ module Oktakit
|
|
135
158
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
136
159
|
# @param options [Hash] Optional. Body params for request.
|
137
160
|
# @return [Hash<Sawyer::Resource>] Returns an empty object.
|
138
|
-
# @see
|
161
|
+
# @see https://developer.okta.com/docs/api/resources/users#deactivate-user
|
139
162
|
# @example
|
140
163
|
# Oktakit.deactivate_user('id')
|
141
164
|
def deactivate_user(id, options = {})
|
142
165
|
post("/users/#{id}/lifecycle/deactivate", options)
|
143
166
|
end
|
144
167
|
|
168
|
+
# Delete User
|
169
|
+
#
|
170
|
+
# @params id [string] User ID
|
171
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
172
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
173
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
174
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
175
|
+
# @param options [Hash] Optional. Body params for the request.
|
176
|
+
# @return 204 'No Content'
|
177
|
+
# @note Deletes a user permanently. This operation can only be performed on users that have a DEPROVISIONED status. This action cannot be recovered!
|
178
|
+
# This operation on a user that hasn't been deactivated causes that user to be deactivated. A second delete operation is required to delete the user.
|
179
|
+
# @see https://developer.okta.com/docs/reference/api/users/#delete-user
|
180
|
+
# @example
|
181
|
+
# Oktakit.delete_user('id')
|
182
|
+
def delete_user(id, options = {})
|
183
|
+
delete("/users/#{id}", options)
|
184
|
+
end
|
185
|
+
|
145
186
|
# Suspend User
|
146
187
|
#
|
147
188
|
# @params id [string] User ID
|
@@ -151,7 +192,7 @@ module Oktakit
|
|
151
192
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
152
193
|
# @param options [Hash] Optional. Body params for request.
|
153
194
|
# @return [Hash<Sawyer::Resource>] Returns an empty object.
|
154
|
-
# @see
|
195
|
+
# @see https://developer.okta.com/docs/api/resources/users#suspend-user
|
155
196
|
# @example
|
156
197
|
# Oktakit.suspend_user('id')
|
157
198
|
def suspend_user(id, options = {})
|
@@ -167,7 +208,7 @@ module Oktakit
|
|
167
208
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
168
209
|
# @param options [Hash] Optional. Body params for request.
|
169
210
|
# @return [Hash<Sawyer::Resource>] Returns an empty object. Returns an empty object.
|
170
|
-
# @see
|
211
|
+
# @see https://developer.okta.com/docs/api/resources/users#unsuspend-user
|
171
212
|
# @example
|
172
213
|
# Oktakit.unsuspend_user('id')
|
173
214
|
def unsuspend_user(id, options = {})
|
@@ -183,7 +224,7 @@ module Oktakit
|
|
183
224
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
184
225
|
# @param options [Hash] Optional. Body params for request.
|
185
226
|
# @return [Hash<Sawyer::Resource>] Returns an empty object
|
186
|
-
# @see http://developer.okta.com/docs/api/resources/users
|
227
|
+
# @see http://developer.okta.com/docs/api/resources/users#unlock-user
|
187
228
|
# @example
|
188
229
|
# Oktakit.unlock_user('id')
|
189
230
|
def unlock_user(id, options = {})
|
@@ -199,7 +240,7 @@ module Oktakit
|
|
199
240
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
200
241
|
# @param options [Hash] Optional. Body params for request.
|
201
242
|
# @return [Hash<Sawyer::Resource>] Returns an empty object by default. If sendEmail is false a password reset link
|
202
|
-
# @see
|
243
|
+
# @see https://developer.okta.com/docs/api/resources/users#reset-password
|
203
244
|
# @example
|
204
245
|
# Oktakit.reset_password('id')
|
205
246
|
def reset_password(id, options = {})
|
@@ -215,7 +256,7 @@ module Oktakit
|
|
215
256
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
216
257
|
# @param options [Hash] Optional. Body params for request.
|
217
258
|
# @return [Hash<Sawyer::Resource>] Returns the user by default. If tempPassword is true, a temporary password.
|
218
|
-
# @see
|
259
|
+
# @see https://developer.okta.com/docs/api/resources/users#expire-password
|
219
260
|
# @example
|
220
261
|
# Oktakit.expire_password('id')
|
221
262
|
def expire_password(id, options = {})
|
@@ -231,7 +272,7 @@ module Oktakit
|
|
231
272
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
232
273
|
# @param options [Hash] Optional. Body params for request.
|
233
274
|
# @return [Hash<Sawyer::Resource>] Returns an empty object by default.
|
234
|
-
# @see
|
275
|
+
# @see https://developer.okta.com/docs/api/resources/users#reset-factors
|
235
276
|
# @example
|
236
277
|
# Oktakit.reset_factors('id')
|
237
278
|
def reset_factors(id, options = {})
|
@@ -247,7 +288,7 @@ module Oktakit
|
|
247
288
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
248
289
|
# @param options [Hash] Optional. Body params for request.
|
249
290
|
# @return [Hash<Sawyer::Resource>] Returns an empty object by default. If sendEmail is false a password reset link
|
250
|
-
# @see
|
291
|
+
# @see https://developer.okta.com/docs/api/resources/users#forgot-password
|
251
292
|
# @example
|
252
293
|
# Oktakit.forgot_password('id')
|
253
294
|
def forgot_password(id, options = {})
|
@@ -263,7 +304,7 @@ module Oktakit
|
|
263
304
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
264
305
|
# @param options [Hash] Optional. Body params for request.
|
265
306
|
# @return [Hash<Sawyer::Resource>] Credentials of the user
|
266
|
-
# @see
|
307
|
+
# @see https://developer.okta.com/docs/api/resources/users#change-password
|
267
308
|
# @example
|
268
309
|
# Oktakit.change_password('id')
|
269
310
|
def change_password(id, options = {})
|
@@ -279,12 +320,27 @@ module Oktakit
|
|
279
320
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
280
321
|
# @param options [Hash] Optional. Body params for request.
|
281
322
|
# @return [Hash<Sawyer::Resource>] Credentials of the user
|
282
|
-
# @see
|
323
|
+
# @see https://developer.okta.com/docs/api/resources/users#change-recovery-question
|
283
324
|
# @example
|
284
325
|
# Oktakit.change_recovery_question('id')
|
285
326
|
def change_recovery_question(id, options = {})
|
286
327
|
post("/users/#{id}/credentials/change_recovery_question", options)
|
287
328
|
end
|
329
|
+
|
330
|
+
# Clear user sessions
|
331
|
+
#
|
332
|
+
# @params id [string] User ID
|
333
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
334
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
335
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
336
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
337
|
+
# @param options [Hash] Optional. Body params for the request.
|
338
|
+
# @return 204 'No Content'
|
339
|
+
# @see https://developer.okta.com/docs/api/resources/users#user-sessions
|
340
|
+
# Oktakit.clear_user_sessions('id')
|
341
|
+
def clear_user_sessions(id, options = {})
|
342
|
+
delete("/users/#{id}/sessions", options)
|
343
|
+
end
|
288
344
|
end
|
289
345
|
end
|
290
346
|
end
|
data/lib/oktakit/client.rb
CHANGED
@@ -5,6 +5,7 @@ require 'oktakit/client/apps'
|
|
5
5
|
require 'oktakit/client/events'
|
6
6
|
require 'oktakit/client/factors'
|
7
7
|
require 'oktakit/client/groups'
|
8
|
+
require 'oktakit/client/group_rules'
|
8
9
|
require 'oktakit/client/identity_providers'
|
9
10
|
require 'oktakit/client/schemas'
|
10
11
|
require 'oktakit/client/templates'
|
@@ -17,6 +18,7 @@ module Oktakit
|
|
17
18
|
include Events
|
18
19
|
include Factors
|
19
20
|
include Groups
|
21
|
+
include GroupRules
|
20
22
|
include IdentityProviders
|
21
23
|
include Schemas
|
22
24
|
include Templates
|
@@ -27,26 +29,27 @@ module Oktakit
|
|
27
29
|
|
28
30
|
# Default Faraday middleware stack
|
29
31
|
MIDDLEWARE = RACK_BUILDER_CLASS.new do |builder|
|
30
|
-
builder.use
|
31
|
-
builder.adapter
|
32
|
+
builder.use(Oktakit::Response::RaiseError)
|
33
|
+
builder.adapter(Faraday.default_adapter)
|
32
34
|
end
|
33
35
|
|
34
|
-
def initialize(token
|
36
|
+
def initialize(token: nil, access_token: nil, organization: nil, api_endpoint: nil)
|
35
37
|
if organization.nil? && api_endpoint.nil?
|
36
38
|
raise ArgumentError, "Please provide either the organization or the api_endpoint argument"
|
37
39
|
end
|
38
40
|
|
41
|
+
if (token.nil? && access_token.nil?) || (token && access_token)
|
42
|
+
raise ArgumentError, "Please provide either the token or the access_token argument"
|
43
|
+
end
|
44
|
+
|
39
45
|
@token = token
|
46
|
+
@access_token = access_token
|
40
47
|
@organization = organization
|
41
48
|
@api_endpoint = api_endpoint
|
42
49
|
end
|
43
50
|
|
44
51
|
def api_endpoint
|
45
|
-
|
46
|
-
@api_endpoint
|
47
|
-
else
|
48
|
-
"https://#{@organization.downcase}.okta.com/api/v1"
|
49
|
-
end
|
52
|
+
@api_endpoint || "https://#{@organization.downcase}.okta.com/api/v1"
|
50
53
|
end
|
51
54
|
|
52
55
|
# Make a HTTP GET request
|
@@ -67,16 +70,16 @@ module Oktakit
|
|
67
70
|
accept: options.delete(:accept),
|
68
71
|
content_type: options.delete(:content_type),
|
69
72
|
paginate: should_paginate,
|
70
|
-
data: options
|
73
|
+
data: options,
|
71
74
|
}
|
72
75
|
|
73
|
-
resp, status, next_page = request
|
76
|
+
resp, status, next_page = request(:get, url, **request_options)
|
74
77
|
|
75
78
|
# If request succeeded and we should paginate, then automatically traverse all next_pages
|
76
79
|
if status == 200 && should_paginate
|
77
80
|
all_objs = [resp]
|
78
81
|
while next_page
|
79
|
-
resp, status, next_page = request
|
82
|
+
resp, status, next_page = request(:get, next_page, **request_options)
|
80
83
|
break unless status == 200 # Return early if page request fails
|
81
84
|
|
82
85
|
all_objs << resp
|
@@ -97,9 +100,9 @@ module Oktakit
|
|
97
100
|
# @param options [Hash] Optional. Body params for request.
|
98
101
|
# @return [Sawyer::Resource]
|
99
102
|
def post(url, options = {})
|
100
|
-
request
|
103
|
+
request(:post, url, query: options.delete(:query), headers: options.delete(:headers),
|
101
104
|
accept: options.delete(:accept), content_type: options.delete(:content_type),
|
102
|
-
data: options
|
105
|
+
data: options)
|
103
106
|
end
|
104
107
|
|
105
108
|
# Make a HTTP PUT request
|
@@ -112,9 +115,9 @@ module Oktakit
|
|
112
115
|
# @param options [Hash] Optional. Body params for request.
|
113
116
|
# @return [Sawyer::Resource]
|
114
117
|
def put(url, options = {})
|
115
|
-
request
|
118
|
+
request(:put, url, query: options.delete(:query), headers: options.delete(:headers),
|
116
119
|
accept: options.delete(:accept), content_type: options.delete(:content_type),
|
117
|
-
data: options
|
120
|
+
data: options)
|
118
121
|
end
|
119
122
|
|
120
123
|
# Make a HTTP PATCH request
|
@@ -127,9 +130,9 @@ module Oktakit
|
|
127
130
|
# @param options [Hash] Optional. Body params for request.
|
128
131
|
# @return [Sawyer::Resource]
|
129
132
|
def patch(url, options = {})
|
130
|
-
request
|
133
|
+
request(:patch, url, query: options.delete(:query), headers: options.delete(:headers),
|
131
134
|
accept: options.delete(:accept), content_type: options.delete(:content_type),
|
132
|
-
data: options
|
135
|
+
data: options)
|
133
136
|
end
|
134
137
|
|
135
138
|
# Make a HTTP DELETE request
|
@@ -142,9 +145,9 @@ module Oktakit
|
|
142
145
|
# @param options [Hash] Optional. Body params for request.
|
143
146
|
# @return [Sawyer::Resource]
|
144
147
|
def delete(url, options = {})
|
145
|
-
request
|
148
|
+
request(:delete, url, query: options.delete(:query), headers: options.delete(:headers),
|
146
149
|
accept: options.delete(:accept), content_type: options.delete(:content_type),
|
147
|
-
data: options
|
150
|
+
data: options)
|
148
151
|
end
|
149
152
|
|
150
153
|
# Make a HTTP HEAD request
|
@@ -157,9 +160,9 @@ module Oktakit
|
|
157
160
|
# @param options [Hash] Optional. Body params for request.
|
158
161
|
# @return [Sawyer::Resource]
|
159
162
|
def head(url, options = {})
|
160
|
-
request
|
163
|
+
request(:head, url, query: options.delete(:query), headers: options.delete(:headers),
|
161
164
|
accept: options.delete(:accept), content_type: options.delete(:content_type),
|
162
|
-
data: options
|
165
|
+
data: options)
|
163
166
|
end
|
164
167
|
|
165
168
|
attr_reader :last_response
|
@@ -182,11 +185,12 @@ module Oktakit
|
|
182
185
|
end
|
183
186
|
|
184
187
|
def sawyer_agent
|
185
|
-
@
|
188
|
+
@sawyer_agent ||= Sawyer::Agent.new(api_endpoint, sawyer_options) do |http|
|
186
189
|
http.headers[:accept] = 'application/json'
|
187
190
|
http.headers[:content_type] = 'application/json'
|
188
191
|
http.headers[:user_agent] = "Oktakit v#{Oktakit::VERSION}"
|
189
|
-
http.authorization
|
192
|
+
http.headers[:authorization] = "SSWS #{@token}" if @token
|
193
|
+
http.headers[:authorization] = "Bearer #{@access_token}" if @access_token
|
190
194
|
end
|
191
195
|
end
|
192
196
|
|
@@ -199,6 +203,7 @@ module Oktakit
|
|
199
203
|
|
200
204
|
def absolute_to_relative_url(next_ref)
|
201
205
|
return unless next_ref
|
206
|
+
|
202
207
|
next_ref.href.sub(api_endpoint, '')
|
203
208
|
end
|
204
209
|
end
|
data/lib/oktakit/error.rb
CHANGED
@@ -8,7 +8,7 @@ module Oktakit
|
|
8
8
|
# @return [Oktakit::Error]
|
9
9
|
def self.from_response(response)
|
10
10
|
status = response[:status].to_i
|
11
|
-
if klass = error(status)
|
11
|
+
if (klass = error(status))
|
12
12
|
klass.new(response)
|
13
13
|
end
|
14
14
|
end
|
@@ -41,19 +41,19 @@ module Oktakit
|
|
41
41
|
# Array of validation errors
|
42
42
|
# @return [Array<Hash>] Error info
|
43
43
|
def errors
|
44
|
-
if data
|
44
|
+
if data&.is_a?(Hash)
|
45
45
|
data[:errors] || []
|
46
46
|
else
|
47
47
|
[]
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
private
|
52
|
-
|
53
51
|
def data
|
54
52
|
@data ||= parse_data
|
55
53
|
end
|
56
54
|
|
55
|
+
private
|
56
|
+
|
57
57
|
def parse_data
|
58
58
|
body = @response[:body]
|
59
59
|
return if body.empty?
|
@@ -89,7 +89,7 @@ module Oktakit
|
|
89
89
|
|
90
90
|
def redact_url(url_string)
|
91
91
|
%w[client_secret access_token].each do |token|
|
92
|
-
url_string.gsub!(/#{token}=\S+/, "#{token}=(redacted)") if url_string.include?
|
92
|
+
url_string.gsub!(/#{token}=\S+/, "#{token}=(redacted)") if url_string.include?(token)
|
93
93
|
end
|
94
94
|
url_string
|
95
95
|
end
|
data/lib/oktakit/version.rb
CHANGED
data/lib/oktakit.rb
CHANGED
data/oktakit.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
lib = File.expand_path('
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
require 'oktakit/version'
|
4
4
|
|
@@ -9,16 +9,16 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.email = ['graeme.johnson@shopify.com', 'julian@shopify.com']
|
10
10
|
|
11
11
|
spec.summary = 'Ruby toolkit for working with the Okta API'
|
12
|
-
spec.homepage = 'https://github.com/
|
12
|
+
spec.homepage = 'https://github.com/Shopify/oktakit'
|
13
13
|
spec.license = 'MIT'
|
14
14
|
|
15
|
-
spec.files =
|
15
|
+
spec.files = %x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
16
|
spec.bindir = 'exe'
|
17
17
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
|
-
spec.required_ruby_version = '>= 2.
|
20
|
+
spec.required_ruby_version = '>= 2.6'
|
21
21
|
|
22
|
-
spec.add_dependency
|
23
|
-
spec.add_development_dependency
|
22
|
+
spec.add_dependency('sawyer', '~> 0.8.1')
|
23
|
+
spec.add_development_dependency('bundler')
|
24
24
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oktakit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Graeme Johnson
|
8
8
|
- Julian Nadeau
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-06-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sawyer
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
|
-
description:
|
42
|
+
description:
|
43
43
|
email:
|
44
44
|
- graeme.johnson@shopify.com
|
45
45
|
- julian@shopify.com
|
@@ -47,11 +47,17 @@ executables: []
|
|
47
47
|
extensions: []
|
48
48
|
extra_rdoc_files: []
|
49
49
|
files:
|
50
|
+
- ".github/probots.yml"
|
51
|
+
- ".github/workflows/ci.yml"
|
50
52
|
- ".gitignore"
|
51
53
|
- ".rspec"
|
52
54
|
- ".rubocop.yml"
|
55
|
+
- ".ruby-version"
|
53
56
|
- ".travis.yml"
|
57
|
+
- CHANGELOG.md
|
58
|
+
- CODE_OF_CONDUCT.md
|
54
59
|
- Gemfile
|
60
|
+
- Gemfile.lock
|
55
61
|
- LICENSE.txt
|
56
62
|
- README.md
|
57
63
|
- Rakefile
|
@@ -64,6 +70,7 @@ files:
|
|
64
70
|
- lib/oktakit/client/apps.rb
|
65
71
|
- lib/oktakit/client/events.rb
|
66
72
|
- lib/oktakit/client/factors.rb
|
73
|
+
- lib/oktakit/client/group_rules.rb
|
67
74
|
- lib/oktakit/client/groups.rb
|
68
75
|
- lib/oktakit/client/identity_providers.rb
|
69
76
|
- lib/oktakit/client/schemas.rb
|
@@ -73,11 +80,11 @@ files:
|
|
73
80
|
- lib/oktakit/response/raise_error.rb
|
74
81
|
- lib/oktakit/version.rb
|
75
82
|
- oktakit.gemspec
|
76
|
-
homepage: https://github.com/
|
83
|
+
homepage: https://github.com/Shopify/oktakit
|
77
84
|
licenses:
|
78
85
|
- MIT
|
79
86
|
metadata: {}
|
80
|
-
post_install_message:
|
87
|
+
post_install_message:
|
81
88
|
rdoc_options: []
|
82
89
|
require_paths:
|
83
90
|
- lib
|
@@ -85,16 +92,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
92
|
requirements:
|
86
93
|
- - ">="
|
87
94
|
- !ruby/object:Gem::Version
|
88
|
-
version: '2.
|
95
|
+
version: '2.6'
|
89
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
97
|
requirements:
|
91
98
|
- - ">="
|
92
99
|
- !ruby/object:Gem::Version
|
93
100
|
version: '0'
|
94
101
|
requirements: []
|
95
|
-
|
96
|
-
|
97
|
-
signing_key:
|
102
|
+
rubygems_version: 3.2.20
|
103
|
+
signing_key:
|
98
104
|
specification_version: 4
|
99
105
|
summary: Ruby toolkit for working with the Okta API
|
100
106
|
test_files: []
|