Skip to content

Commit

Permalink
Merge pull request Shopify#44 from Shopify/ltk/add-group-rules
Browse files Browse the repository at this point in the history
Add support for group rule operations
  • Loading branch information
ltk authored Oct 18, 2021
2 parents e1990d4 + b55d4b0 commit 197230d
Show file tree
Hide file tree
Showing 12 changed files with 529 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Changelog

## [v0.2.1] - 2021-10-14
- Adds support for [Group Rule operations](https://developer.okta.com/docs/reference/api/groups/#group-rule-operations)
2 changes: 2 additions & 0 deletions lib/oktakit/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require 'oktakit/client/events'
require 'oktakit/client/factors'
require 'oktakit/client/groups'
require 'oktakit/client/group_rules'
require 'oktakit/client/identity_providers'
require 'oktakit/client/schemas'
require 'oktakit/client/templates'
Expand All @@ -17,6 +18,7 @@ class Client
include Events
include Factors
include Groups
include GroupRules
include IdentityProviders
include Schemas
include Templates
Expand Down
115 changes: 115 additions & 0 deletions lib/oktakit/client/group_rules.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
module Oktakit
class Client
module GroupRules
# Add Group Rule
#
# @param options[:query] [Hash] Optional. Query params for request
# @param options[:headers] [Hash] Optional. Header params for the request.
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
# @param options [Hash] Optional. Body params for request.
# @return [Hash<Sawyer::Resource>] The created Group Rule.
# @see https://developer.okta.com/docs/reference/api/groups/#create-group-rule
# @example
# Oktakit.add_group_rule
def add_group_rule(options = {})
post('/groups/rules', options)
end

# Get Group Rule
#
# @params id [string] Group Rule ID
# @param options[:query] [Hash] Optional. Query params for request
# @param options[:headers] [Hash] Optional. Header params for the request.
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
# @param options [Hash] Optional. Body params for request.
# @return [Hash<Sawyer::Resource>] Fetched Group Rule
# @see https://developer.okta.com/docs/reference/api/groups/#get-group-rule
# @example
# Oktakit.get_group_rule('id')
def get_group_rule(id, options = {})
get("/groups/rules/#{id}", options)
end

# List Group Rules
#
# @param options[:query] [Hash] Optional. Query params for request
# @param options[:headers] [Hash] Optional. Header params for the request.
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
# @param options [Hash] Optional. Body params for request.
# @return [Array<Sawyer::Resource>] Array of Group Rules
# @see https://developer.okta.com/docs/reference/api/groups/#list-group-rules
# @example
# Oktakit.list_group_rules
def list_group_rules(options = {})
get('/groups/rules', options)
end

# Update Group Rule
#
# @params id [string] Group Rule ID
# @param options[:query] [Hash] Optional. Query params for request
# @param options[:headers] [Hash] Optional. Header params for the request.
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
# @param options [Hash] Optional. Body params for request.
# @return [Hash<Sawyer::Resource>] Updated Group Rule
# @see https://developer.okta.com/docs/reference/api/groups/#update-group-rule
# @example
# Oktakit.update_group_rule('id')
def update_group_rule(id, options = {})
put("/groups/rules/#{id}", options)
end

# Remove Group Rule
#
# @params id [string] Group ID
# @param options[:query] [Hash] Optional. Query params for request
# @param options[:headers] [Hash] Optional. Header params for the request.
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
# @param options [Hash] Optional. Body params for request.
# @return HTTP 202 Accepted
# @see https://developer.okta.com/docs/reference/api/groups/#delete-a-group-rule
# @example
# Oktakit.remove_group_rule('id')
def remove_group_rule(id, options = {})
delete("/groups/rules/#{id}", options)
end

# Activate Group Rule
#
# @params id [string] Group ID
# @param options[:query] [Hash] Optional. Query params for request
# @param options[:headers] [Hash] Optional. Header params for the request.
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
# @param options [Hash] Optional. Body params for request.
# @return HTTP 204 No Content
# @see https://developer.okta.com/docs/reference/api/groups/#activate-a-group-rule
# @example
# Oktakit.activate_group_rule('id')
def activate_group_rule(id, options = {})
post("/groups/rules/#{id}/lifecycle/activate", options)
end

# Deactivate Group Rule
#
# @params id [string] Group ID
# @param options[:query] [Hash] Optional. Query params for request
# @param options[:headers] [Hash] Optional. Header params for the request.
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
# @param options [Hash] Optional. Body params for request.
# @return HTTP 204 No Content
# @see https://developer.okta.com/docs/reference/api/groups/#deactivate-a-group-rule
# @example
# Oktakit.deactivate_group_rule('id')
def deactivate_group_rule(id, options = {})
post("/groups/rules/#{id}/lifecycle/deactivate", options)
end
end
end
end
2 changes: 1 addition & 1 deletion lib/oktakit/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Oktakit
VERSION = '0.2.0'.freeze
VERSION = '0.2.1'.freeze
end
40 changes: 40 additions & 0 deletions spec/cassettes/activate_group_rule.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions spec/cassettes/add_group_rule.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions spec/cassettes/deactivate_group_rule.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions spec/cassettes/get_group_rule.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions spec/cassettes/list_group_rules.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 197230d

Please sign in to comment.