Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .oagen-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@
"lib/workos/directory_sync/directory_group.rb",
"lib/workos/directory_sync/directory_metadata.rb",
"lib/workos/directory_sync/directory_metadata_user.rb",
"lib/workos/directory_sync/directory_sync_rate_limit_error.rb",
"lib/workos/directory_sync/directory_sync_response.rb",
"lib/workos/directory_sync/directory_user.rb",
"lib/workos/directory_sync/directory_user_email.rb",
"lib/workos/directory_sync/directory_user_with_groups.rb",
Expand Down Expand Up @@ -1101,6 +1103,8 @@
"rbi/workos/directory_metadata.rbi",
"rbi/workos/directory_metadata_user.rbi",
"rbi/workos/directory_sync.rbi",
"rbi/workos/directory_sync_rate_limit_error.rbi",
"rbi/workos/directory_sync_response.rbi",
"rbi/workos/directory_user.rbi",
"rbi/workos/directory_user_email.rbi",
"rbi/workos/directory_user_with_groups.rbi",
Expand Down Expand Up @@ -2589,6 +2593,10 @@
"GET /audit_logs/exports/{auditLogExportId}": {
"sdkMethod": "get_export",
"service": "audit_logs"
},
"POST /directories/{id}/sync": {
"sdkMethod": "sync_directory",
"service": "directory_sync"
}
}
}
19 changes: 19 additions & 0 deletions lib/workos/directory_sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,25 @@ def delete_directory(
nil
end

# Sync a Directory
# @param id [String] Unique identifier for the Directory.
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
# @return [WorkOS::DirectorySyncResponse]
def sync_directory(
id:,
request_options: {}
)
response = @client.request(
method: :post,
path: "/directories/#{WorkOS::Util.encode_path(id)}/sync",
auth: true,
request_options: request_options
)
result = WorkOS::DirectorySyncResponse.new(response.body)
result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
result
end

# List Directory Groups
# @param before [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `before="obj_123"` to fetch a new batch of objects before `"obj_123"`.
# @param after [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `after="obj_123"` to fetch a new batch of objects after `"obj_123"`.
Expand Down
25 changes: 25 additions & 0 deletions lib/workos/directory_sync/directory_sync_rate_limit_error.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

# This file is auto-generated by oagen. Do not edit.

module WorkOS
class DirectorySyncRateLimitError < WorkOS::Types::BaseModel
HASH_ATTRS = {
code: :code,
message: :message,
retry_after_seconds: :retry_after_seconds
}.freeze

attr_accessor \
:code,
:message,
:retry_after_seconds

def initialize(json)
hash = self.class.normalize(json)
@code = hash[:code]
@message = hash[:message]
@retry_after_seconds = hash[:retry_after_seconds]
end
end
end
18 changes: 18 additions & 0 deletions lib/workos/directory_sync/directory_sync_response.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

# This file is auto-generated by oagen. Do not edit.

module WorkOS
class DirectorySyncResponse < WorkOS::Types::BaseModel
HASH_ATTRS = {
status: :status
}.freeze

attr_accessor :status

def initialize(json)
hash = self.class.normalize(json)
@status = hash[:status]
end
end
end
8 changes: 8 additions & 0 deletions rbi/workos/directory_sync.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ module WorkOS
end
def delete_directory(id:, request_options:); end

sig do
params(
id: String,
request_options: T::Hash[Symbol, T.untyped]
).returns(WorkOS::DirectorySyncResponse)
end
def sync_directory(id:, request_options:); end

sig do
params(
before: T.nilable(String),
Expand Down
36 changes: 36 additions & 0 deletions rbi/workos/directory_sync_rate_limit_error.rbi
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true

# This file is auto-generated by oagen. Do not edit.

# typed: strong

module WorkOS
class DirectorySyncRateLimitError
sig { params(json: T.any(String, T::Hash[Symbol, T.untyped])).void }
def initialize(json); end

sig { returns(String) }
def code; end

sig { params(value: String).returns(String) }
def code=(value); end

sig { returns(String) }
def message; end

sig { params(value: String).returns(String) }
def message=(value); end

sig { returns(Integer) }
def retry_after_seconds; end

sig { params(value: Integer).returns(Integer) }
def retry_after_seconds=(value); end

sig { returns(T::Hash[Symbol, T.untyped]) }
def to_h; end

sig { params(args: T.untyped).returns(String) }
def to_json(*args); end
end
end
24 changes: 24 additions & 0 deletions rbi/workos/directory_sync_response.rbi
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

# This file is auto-generated by oagen. Do not edit.

# typed: strong

module WorkOS
class DirectorySyncResponse
sig { params(json: T.any(String, T::Hash[Symbol, T.untyped])).void }
def initialize(json); end

sig { returns(String) }
def status; end

sig { params(value: String).returns(String) }
def status=(value); end

sig { returns(T::Hash[Symbol, T.untyped]) }
def to_h; end

sig { params(args: T.untyped).returns(String) }
def to_json(*args); end
end
end
8 changes: 8 additions & 0 deletions test/workos/test_directory_sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ def test_delete_directory_returns_expected_result
assert_nil result
end

def test_sync_directory_returns_expected_result
stub_request(:post, %r{\Ahttps://api\.workos\.com/directories/stub/sync(\?|\z)})
.to_return(body: "{}", status: 200)
result = @client.directory_sync.sync_directory(id: "stub")
refute_nil result
end

def test_list_groups_returns_expected_result
stub_request(:get, %r{\Ahttps://api\.workos\.com/directory_groups(\?|\z)})
.to_return(body: '{"data": [], "list_metadata": {}}', status: 200)
Expand Down Expand Up @@ -65,6 +72,7 @@ def test_get_user_returns_expected_result
{name: :list_directories, verb: :get, url: %r{\Ahttps://api\.workos\.com/directories(\?|\z)}},
{name: :get_directory, verb: :get, url: %r{\Ahttps://api\.workos\.com/directories/stub(\?|\z)}, args: {id: "stub"}},
{name: :delete_directory, verb: :delete, url: %r{\Ahttps://api\.workos\.com/directories/stub(\?|\z)}, args: {id: "stub"}},
{name: :sync_directory, verb: :post, url: %r{\Ahttps://api\.workos\.com/directories/stub/sync(\?|\z)}, args: {id: "stub"}},
{name: :list_groups, verb: :get, url: %r{\Ahttps://api\.workos\.com/directory_groups(\?|\z)}},
{name: :get_group, verb: :get, url: %r{\Ahttps://api\.workos\.com/directory_groups/stub(\?|\z)}, args: {id: "stub"}},
{name: :list_users, verb: :get, url: %r{\Ahttps://api\.workos\.com/directory_users(\?|\z)}},
Expand Down
24 changes: 24 additions & 0 deletions test/workos/test_directory_sync_model_round_trip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,30 @@ def test_directory_round_trip
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_directory_sync_response_round_trip
fixture = {
"status" => "queued"
}
model = WorkOS::DirectorySyncResponse.new(fixture.to_json)
json = model.to_h
assert_kind_of Hash, json
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_directory_sync_rate_limit_error_round_trip
fixture = {
"code" => "directory_sync_rate_limited",
"message" => "stub",
"retry_after_seconds" => 1
}
model = WorkOS::DirectorySyncRateLimitError.new(fixture.to_json)
json = model.to_h
assert_kind_of Hash, json
assert_equal fixture["message"], json[:message]
assert_equal fixture["retry_after_seconds"], json[:retry_after_seconds]
fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
end

def test_directory_group_round_trip
fixture = {
"object" => "directory_group",
Expand Down
Loading