require 'ostruct' require 'fusionauth/rest_client' # # Copyright (c) 2018-2019, FusionAuth, All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, # either express or implied. See the License for the specific # language governing permissions and limitations under the License. # module FusionAuth # # This class is the the Ruby client library for the FusionAuth CIAM Platform {https://fusionauth.io} # # Each method on this class calls one of the APIs for FusionAuth. In most cases, the methods will take either a Hash, an # OpenStruct or any object that can be safely converted to JSON that conforms to the FusionAuth API interface. Likewise, # most methods will return an OpenStruct that contains the response JSON from FusionAuth. # # noinspection RubyInstanceMethodNamingConvention,RubyTooManyMethodsInspection,RubyParameterNamingConvention class FusionAuthClient attr_accessor :api_key, :base_url, :connect_timeout, :read_timeout def initialize(api_key, base_url) @api_key = api_key @base_url = base_url @connect_timeout = 1000 @read_timeout = 2000 end # # Takes an action on a user. The user being actioned is called the "actionee" and the user taking the action is called the # "actioner". Both user ids are required. You pass the actionee's user id into the method and the actioner's is put into the # request object. # # @param actionee_user_id [string] The actionee's user id. # @param request [OpenStruct, Hash] The action request that includes all of the information about the action being taken including # the id of the action, any options and the duration (if applicable). # @return [FusionAuth::ClientResponse] The ClientResponse object. # def action_user(actionee_user_id, request) start.uri('/api/user/action') .url_segment(actionee_user_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Cancels the user action. # # @param action_id [string] The action id of the action to cancel. # @param request [OpenStruct, Hash] The action request that contains the information about the cancellation. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def cancel_action(action_id, request) start.uri('/api/user/action') .url_segment(action_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .delete() .go() end # # Changes a user's password using the change password Id. This usually occurs after an email has been sent to the user # and they clicked on a link to reset their password. # # @param change_password_id [string] The change password Id used to find the user. This value is generated by FusionAuth once the change password workflow has been initiated. # @param request [OpenStruct, Hash] The change password request that contains all of the information used to change the password. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def change_password(change_password_id, request) start.uri('/api/user/change-password') .url_segment(change_password_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Changes a user's password using their identity (login id and password). Using a loginId instead of the changePasswordId # bypasses the email verification and allows a password to be changed directly without first calling the #forgotPassword # method. # # @param request [OpenStruct, Hash] The change password request that contains all of the information used to change the password. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def change_password_by_identity(request) start.uri('/api/user/change-password') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Adds a comment to the user's account. # # @param request [OpenStruct, Hash] The request object that contains all of the information used to create the user comment. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def comment_on_user(request) start.uri('/api/user/comment') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Creates an application. You can optionally specify an Id for the application, if not provided one will be generated. # # @param application_id [string] (Optional) The Id to use for the application. If not provided a secure random UUID will be generated. # @param request [OpenStruct, Hash] The request object that contains all of the information used to create the application. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def create_application(application_id, request) start.uri('/api/application') .url_segment(application_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Creates a new role for an application. You must specify the id of the application you are creating the role for. # You can optionally specify an Id for the role inside the ApplicationRole object itself, if not provided one will be generated. # # @param application_id [string] The Id of the application to create the role on. # @param role_id [string] (Optional) The Id of the role. If not provided a secure random UUID will be generated. # @param request [OpenStruct, Hash] The request object that contains all of the information used to create the application role. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def create_application_role(application_id, role_id, request) start.uri('/api/application') .url_segment(application_id) .url_segment("role") .url_segment(role_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Creates an audit log with the message and user name (usually an email). Audit logs should be written anytime you # make changes to the FusionAuth database. When using the FusionAuth App web interface, any changes are automatically # written to the audit log. However, if you are accessing the API, you must write the audit logs yourself. # # @param request [OpenStruct, Hash] The request object that contains all of the information used to create the audit log entry. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def create_audit_log(request) start.uri('/api/system/audit-log') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Creates an email template. You can optionally specify an Id for the template, if not provided one will be generated. # # @param email_template_id [string] (Optional) The Id for the template. If not provided a secure random UUID will be generated. # @param request [OpenStruct, Hash] The request object that contains all of the information used to create the email template. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def create_email_template(email_template_id, request) start.uri('/api/email/template') .url_segment(email_template_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Creates a group. You can optionally specify an Id for the group, if not provided one will be generated. # # @param group_id [string] (Optional) The Id for the group. If not provided a secure random UUID will be generated. # @param request [OpenStruct, Hash] The request object that contains all of the information used to create the group. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def create_group(group_id, request) start.uri('/api/group') .url_segment(group_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Creates a member in a group. # # @param request [OpenStruct, Hash] The request object that contains all of the information used to create the group member(s). # @return [FusionAuth::ClientResponse] The ClientResponse object. # def create_group_members(request) start.uri('/api/group/member') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Creates an identity provider. You can optionally specify an Id for the identity provider, if not provided one will be generated. # # @param identity_provider_id [string] (Optional) The Id of the identity provider. If not provided a secure random UUID will be generated. # @param request [OpenStruct, Hash] The request object that contains all of the information used to create the identity provider. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def create_identity_provider(identity_provider_id, request) start.uri('/api/identity-provider') .url_segment(identity_provider_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Creates a Lambda. You can optionally specify an Id for the lambda, if not provided one will be generated. # # @param lambda_id [string] (Optional) The Id for the lambda. If not provided a secure random UUID will be generated. # @param request [OpenStruct, Hash] The request object that contains all of the information used to create the lambda. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def create_lambda(lambda_id, request) start.uri('/api/lambda') .url_segment(lambda_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Creates a tenant. You can optionally specify an Id for the tenant, if not provided one will be generated. # # @param tenant_id [string] (Optional) The Id for the tenant. If not provided a secure random UUID will be generated. # @param request [OpenStruct, Hash] The request object that contains all of the information used to create the tenant. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def create_tenant(tenant_id, request) start.uri('/api/tenant') .url_segment(tenant_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Creates a user. You can optionally specify an Id for the user, if not provided one will be generated. # # @param user_id [string] (Optional) The Id for the user. If not provided a secure random UUID will be generated. # @param request [OpenStruct, Hash] The request object that contains all of the information used to create the user. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def create_user(user_id, request) start.uri('/api/user') .url_segment(user_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Creates a user action. This action cannot be taken on a user until this call successfully returns. Anytime after # that the user action can be applied to any user. # # @param user_action_id [string] (Optional) The Id for the user action. If not provided a secure random UUID will be generated. # @param request [OpenStruct, Hash] The request object that contains all of the information used to create the user action. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def create_user_action(user_action_id, request) start.uri('/api/user-action') .url_segment(user_action_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Creates a user reason. This user action reason cannot be used when actioning a user until this call completes # successfully. Anytime after that the user action reason can be used. # # @param user_action_reason_id [string] (Optional) The Id for the user action reason. If not provided a secure random UUID will be generated. # @param request [OpenStruct, Hash] The request object that contains all of the information used to create the user action reason. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def create_user_action_reason(user_action_reason_id, request) start.uri('/api/user-action-reason') .url_segment(user_action_reason_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Creates a webhook. You can optionally specify an Id for the webhook, if not provided one will be generated. # # @param webhook_id [string] (Optional) The Id for the webhook. If not provided a secure random UUID will be generated. # @param request [OpenStruct, Hash] The request object that contains all of the information used to create the webhook. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def create_webhook(webhook_id, request) start.uri('/api/webhook') .url_segment(webhook_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Deactivates the application with the given Id. # # @param application_id [string] The Id of the application to deactivate. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def deactivate_application(application_id) start.uri('/api/application') .url_segment(application_id) .delete() .go() end # # Deactivates the user with the given Id. # # @param user_id [string] The Id of the user to deactivate. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def deactivate_user(user_id) start.uri('/api/user') .url_segment(user_id) .delete() .go() end # # Deactivates the user action with the given Id. # # @param user_action_id [string] The Id of the user action to deactivate. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def deactivate_user_action(user_action_id) start.uri('/api/user-action') .url_segment(user_action_id) .delete() .go() end # # Deactivates the users with the given ids. # # @param user_ids [Array] The ids of the users to deactivate. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def deactivate_users(user_ids) start.uri('/api/user/bulk') .url_parameter('userId', user_ids) .delete() .go() end # # Hard deletes an application. This is a dangerous operation and should not be used in most circumstances. This will # delete the application, any registrations for that application, metrics and reports for the application, all the # roles for the application, and any other data associated with the application. This operation could take a very # long time, depending on the amount of data in your database. # # @param application_id [string] The Id of the application to delete. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def delete_application(application_id) start.uri('/api/application') .url_segment(application_id) .url_parameter('hardDelete', true) .delete() .go() end # # Hard deletes an application role. This is a dangerous operation and should not be used in most circumstances. This # permanently removes the given role from all users that had it. # # @param application_id [string] The Id of the application to deactivate. # @param role_id [string] The Id of the role to delete. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def delete_application_role(application_id, role_id) start.uri('/api/application') .url_segment(application_id) .url_segment("role") .url_segment(role_id) .delete() .go() end # # Deletes the email template for the given Id. # # @param email_template_id [string] The Id of the email template to delete. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def delete_email_template(email_template_id) start.uri('/api/email/template') .url_segment(email_template_id) .delete() .go() end # # Deletes the group for the given Id. # # @param group_id [string] The Id of the group to delete. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def delete_group(group_id) start.uri('/api/group') .url_segment(group_id) .delete() .go() end # # Removes users as members of a group. # # @param request [OpenStruct, Hash] The member request that contains all of the information used to remove members to the group. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def delete_group_members(request) start.uri('/api/group/member') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .delete() .go() end # # Deletes the identity provider for the given Id. # # @param identity_provider_id [string] The Id of the identity provider to delete. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def delete_identity_provider(identity_provider_id) start.uri('/api/identity-provider') .url_segment(identity_provider_id) .delete() .go() end # # Deletes the key for the given Id. # # @param key_od [string] The Id of the key to delete. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def delete_key(key_od) start.uri('/api/key') .url_segment(key_od) .delete() .go() end # # Deletes the lambda for the given Id. # # @param lambda_id [string] The Id of the lambda to delete. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def delete_lambda(lambda_id) start.uri('/api/lambda') .url_segment(lambda_id) .delete() .go() end # # Deletes the user registration for the given user and application. # # @param user_id [string] The Id of the user whose registration is being deleted. # @param application_id [string] The Id of the application to remove the registration for. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def delete_registration(user_id, application_id) start.uri('/api/user/registration') .url_segment(user_id) .url_segment(application_id) .delete() .go() end # # Deletes the tenant for the given Id. # # @param tenant_id [string] The Id of the tenant to delete. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def delete_tenant(tenant_id) start.uri('/api/tenant') .url_segment(tenant_id) .delete() .go() end # # Deletes the user for the given Id. This permanently deletes all information, metrics, reports and data associated # with the user. # # @param user_id [string] The Id of the user to delete. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def delete_user(user_id) start.uri('/api/user') .url_segment(user_id) .url_parameter('hardDelete', true) .delete() .go() end # # Deletes the user action for the given Id. This permanently deletes the user action and also any history and logs of # the action being applied to any users. # # @param user_action_id [string] The Id of the user action to delete. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def delete_user_action(user_action_id) start.uri('/api/user-action') .url_segment(user_action_id) .url_parameter('hardDelete', true) .delete() .go() end # # Deletes the user action reason for the given Id. # # @param user_action_reason_id [string] The Id of the user action reason to delete. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def delete_user_action_reason(user_action_reason_id) start.uri('/api/user-action-reason') .url_segment(user_action_reason_id) .delete() .go() end # # Deletes the users with the given ids. # # @param request [OpenStruct, Hash] The ids of the users to delete. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def delete_users(request) start.uri('/api/user/bulk') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .delete() .go() end # # Deletes the webhook for the given Id. # # @param webhook_id [string] The Id of the webhook to delete. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def delete_webhook(webhook_id) start.uri('/api/webhook') .url_segment(webhook_id) .delete() .go() end # # Disable Two Factor authentication for a user. # # @param user_id [string] The Id of the User for which you're disabling Two Factor authentication. # @param code [string] The Two Factor code used verify the the caller knows the Two Factor secret. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def disable_two_factor(user_id, code) start.uri('/api/user/two-factor') .url_parameter('userId', user_id) .url_parameter('code', code) .delete() .go() end # # Enable Two Factor authentication for a user. # # @param user_id [string] The Id of the user to enable Two Factor authentication. # @param request [OpenStruct, Hash] The two factor enable request information. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def enable_two_factor(user_id, request) start.uri('/api/user/two-factor') .url_segment(user_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Exchange a refresh token for a new JWT. # # @param request [OpenStruct, Hash] The refresh request. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def exchange_refresh_token_for_jwt(request) start.uri('/api/jwt/refresh') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Begins the forgot password sequence, which kicks off an email to the user so that they can reset their password. # # @param request [OpenStruct, Hash] The request that contains the information about the user so that they can be emailed. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def forgot_password(request) start.uri('/api/user/forgot-password') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Generate a new Email Verification Id to be used with the Verify Email API. This API will not attempt to send an # email to the User. This API may be used to collect the verificationId for use with a third party system. # # @param email [string] The email address of the user that needs a new verification email. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def generate_email_verification_id(email) start.uri('/api/user/verify-email') .url_parameter('email', email) .url_parameter('sendVerifyPasswordEmail', false) .put() .go() end # # Generate a new RSA or EC key pair or an HMAC secret. # # @param key_id [string] (Optional) The Id for the key. If not provided a secure random UUID will be generated. # @param request [OpenStruct, Hash] The request object that contains all of the information used to create the key. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def generate_key(key_id, request) start.uri('/api/key/generate') .url_segment(key_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Generate a new Application Registration Verification Id to be used with the Verify Registration API. This API will not attempt to send an # email to the User. This API may be used to collect the verificationId for use with a third party system. # # @param email [string] The email address of the user that needs a new verification email. # @param application_id [string] The Id of the application to be verified. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def generate_registration_verification_id(email, application_id) start.uri('/api/user/verify-registration') .url_parameter('email', email) .url_parameter('sendVerifyPasswordEmail', false) .url_parameter('applicationId', application_id) .put() .go() end # # Generate a Two Factor secret that can be used to enable Two Factor authentication for a User. The response will contain # both the secret and a Base32 encoded form of the secret which can be shown to a User when using a 2 Step Authentication # application such as Google Authenticator. # # @return [FusionAuth::ClientResponse] The ClientResponse object. # def generate_two_factor_secret() start.uri('/api/two-factor/secret') .get() .go() end # # Generate a Two Factor secret that can be used to enable Two Factor authentication for a User. The response will contain # both the secret and a Base32 encoded form of the secret which can be shown to a User when using a 2 Step Authentication # application such as Google Authenticator. # # @param encoded_jwt [string] The encoded JWT (access token). # @return [FusionAuth::ClientResponse] The ClientResponse object. # def generate_two_factor_secret_using_jwt(encoded_jwt) start.uri('/api/two-factor/secret') .authorization('JWT ' + encoded_jwt) .get() .go() end # # Handles login via third-parties including Social login, external OAuth and OpenID Connect, and other # login systems. # # @param request [OpenStruct, Hash] The third-party login request that contains information from the third-party login # providers that FusionAuth uses to reconcile the user's account. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def identity_provider_login(request) start.uri('/api/identity-provider/login') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Import an existing RSA or EC key pair or an HMAC secret. # # @param key_id [string] (Optional) The Id for the key. If not provided a secure random UUID will be generated. # @param request [OpenStruct, Hash] The request object that contains all of the information used to create the key. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def import_key(key_id, request) start.uri('/api/key/import') .url_segment(key_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Bulk imports multiple users. This does some validation, but then tries to run batch inserts of users. This reduces # latency when inserting lots of users. Therefore, the error response might contain some information about failures, # but it will likely be pretty generic. # # @param request [OpenStruct, Hash] The request that contains all of the information about all of the users to import. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def import_users(request) start.uri('/api/user/import') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Issue a new access token (JWT) for the requested Application after ensuring the provided JWT is valid. A valid # access token is properly signed and not expired. #
# This API may be used in an SSO configuration to issue new tokens for another application after the user has
# obtained a valid token from authentication.
#
# @param application_id [string] The Application Id for which you are requesting a new access token be issued.
# @param encoded_jwt [string] The encoded JWT (access token).
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def issue_jwt(application_id, encoded_jwt)
start.uri('/api/jwt/issue')
.authorization('JWT ' + encoded_jwt)
.url_parameter('applicationId', application_id)
.get()
.go()
end
#
# Logs a user in.
#
# @param request [OpenStruct, Hash] The login request that contains the user credentials used to log them in.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def login(request)
start.uri('/api/login')
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.post()
.go()
end
#
# Sends a ping to FusionAuth indicating that the user was automatically logged into an application. When using
# FusionAuth's SSO or your own, you should call this if the user is already logged in centrally, but accesses an
# application where they no longer have a session. This helps correctly track login counts, times and helps with
# reporting.
#
# @param user_id [string] The Id of the user that was logged in.
# @param application_id [string] The Id of the application that they logged into.
# @param caller_ip_address [string] (Optional) The IP address of the end-user that is logging in. If a null value is provided
# the IP address will be that of the client or last proxy that sent the request.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def login_ping(user_id, application_id, caller_ip_address)
start.uri('/api/login')
.url_segment(user_id)
.url_segment(application_id)
.url_parameter('ipAddress', caller_ip_address)
.put()
.go()
end
#
# The Logout API is intended to be used to remove the refresh token and access token cookies if they exist on the
# client and revoke the refresh token stored. This API does nothing if the request does not contain an access
# token or refresh token cookies.
#
# @param global [Boolean] When this value is set to true all of the refresh tokens issued to the owner of the
# provided token will be revoked.
# @param refresh_token [string] (Optional) The refresh_token as a request parameter instead of coming in via a cookie.
# If provided this takes precedence over the cookie.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def logout(global, refresh_token)
start.uri('/api/logout')
.url_parameter('global', global)
.url_parameter('refreshToken', refresh_token)
.post()
.go()
end
#
# Retrieves the identity provider for the given domain. A 200 response code indicates the domain is managed
# by a registered identity provider. A 404 indicates the domain is not managed.
#
# @param domain [string] The domain or email address to lookup.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def lookup_identity_provider(domain)
start.uri('/api/identity-provider/lookup')
.url_parameter('domain', domain)
.get()
.go()
end
#
# Modifies a temporal user action by changing the expiration of the action and optionally adding a comment to the
# action.
#
# @param action_id [string] The Id of the action to modify. This is technically the user action log id.
# @param request [OpenStruct, Hash] The request that contains all of the information about the modification.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def modify_action(action_id, request)
start.uri('/api/user/action')
.url_segment(action_id)
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.put()
.go()
end
#
# Complete a login request using a passwordless code
#
# @param request [OpenStruct, Hash] The passwordless login request that contains all of the information used to complete login.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def passwordless_login(request)
start.uri('/api/passwordless/login')
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.post()
.go()
end
#
# Reactivates the application with the given Id.
#
# @param application_id [string] The Id of the application to reactivate.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def reactivate_application(application_id)
start.uri('/api/application')
.url_segment(application_id)
.url_parameter('reactivate', true)
.put()
.go()
end
#
# Reactivates the user with the given Id.
#
# @param user_id [string] The Id of the user to reactivate.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def reactivate_user(user_id)
start.uri('/api/user')
.url_segment(user_id)
.url_parameter('reactivate', true)
.put()
.go()
end
#
# Reactivates the user action with the given Id.
#
# @param user_action_id [string] The Id of the user action to reactivate.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def reactivate_user_action(user_action_id)
start.uri('/api/user-action')
.url_segment(user_action_id)
.url_parameter('reactivate', true)
.put()
.go()
end
#
# Reconcile a User to FusionAuth using JWT issued from another Identity Provider.
#
# @param request [OpenStruct, Hash] The reconcile request that contains the data to reconcile the User.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def reconcile_jwt(request)
start.uri('/api/jwt/reconcile')
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.post()
.go()
end
#
# Registers a user for an application. If you provide the User and the UserRegistration object on this request, it
# will create the user as well as register them for the application. This is called a Full Registration. However, if
# you only provide the UserRegistration object, then the user must already exist and they will be registered for the
# application. The user id can also be provided and it will either be used to look up an existing user or it will be
# used for the newly created User.
#
# @param user_id [string] (Optional) The Id of the user being registered for the application and optionally created.
# @param request [OpenStruct, Hash] The request that optionally contains the User and must contain the UserRegistration.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def register(user_id, request)
start.uri('/api/user/registration')
.url_segment(user_id)
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.post()
.go()
end
#
# Re-sends the verification email to the user.
#
# @param email [string] The email address of the user that needs a new verification email.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def resend_email_verification(email)
start.uri('/api/user/verify-email')
.url_parameter('email', email)
.put()
.go()
end
#
# Re-sends the application registration verification email to the user.
#
# @param email [string] The email address of the user that needs a new verification email.
# @param application_id [string] The Id of the application to be verified.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def resend_registration_verification(email, application_id)
start.uri('/api/user/verify-registration')
.url_parameter('email', email)
.url_parameter('applicationId', application_id)
.put()
.go()
end
#
# Retrieves a single action log (the log of a user action that was taken on a user previously) for the given Id.
#
# @param action_id [string] The Id of the action to retrieve.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_action(action_id)
start.uri('/api/user/action')
.url_segment(action_id)
.get()
.go()
end
#
# Retrieves all of the actions for the user with the given Id. This will return all time based actions that are active,
# and inactive as well as non-time based actions.
#
# @param user_id [string] The Id of the user to fetch the actions for.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_actions(user_id)
start.uri('/api/user/action')
.url_parameter('userId', user_id)
.get()
.go()
end
#
# Retrieves all of the actions for the user with the given Id that are currently preventing the User from logging in.
#
# @param user_id [string] The Id of the user to fetch the actions for.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_actions_preventing_login(user_id)
start.uri('/api/user/action')
.url_parameter('userId', user_id)
.url_parameter('preventingLogin', true)
.get()
.go()
end
#
# Retrieves all of the actions for the user with the given Id that are currently active.
# An active action means one that is time based and has not been canceled, and has not ended.
#
# @param user_id [string] The Id of the user to fetch the actions for.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_active_actions(user_id)
start.uri('/api/user/action')
.url_parameter('userId', user_id)
.url_parameter('active', true)
.get()
.go()
end
#
# Retrieves the application for the given id or all of the applications if the id is null.
#
# @param application_id [string] (Optional) The application id.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_application(application_id)
start.uri('/api/application')
.url_segment(application_id)
.get()
.go()
end
#
# Retrieves all of the applications.
#
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_applications()
start.uri('/api/application')
.get()
.go()
end
#
# Retrieves a single audit log for the given Id.
#
# @param audit_log_id [Numeric] The Id of the audit log to retrieve.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_audit_log(audit_log_id)
start.uri('/api/system/audit-log')
.url_segment(audit_log_id)
.get()
.go()
end
#
# Retrieves the daily active user report between the two instants. If you specify an application id, it will only
# return the daily active counts for that application.
#
# @param application_id [string] (Optional) The application id.
# @param start [OpenStruct, Hash] The start instant as UTC milliseconds since Epoch.
# @param _end [OpenStruct, Hash] The end instant as UTC milliseconds since Epoch.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_daily_active_report(application_id, start, _end)
start.uri('/api/report/daily-active-user')
.url_parameter('applicationId', application_id)
.url_parameter('start', start)
.url_parameter('end', _end)
.get()
.go()
end
#
# Retrieves the email template for the given Id. If you don't specify the id, this will return all of the email templates.
#
# @param email_template_id [string] (Optional) The Id of the email template.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_email_template(email_template_id)
start.uri('/api/email/template')
.url_segment(email_template_id)
.get()
.go()
end
#
# Creates a preview of the email template provided in the request. This allows you to preview an email template that
# hasn't been saved to the database yet. The entire email template does not need to be provided on the request. This
# will create the preview based on whatever is given.
#
# @param request [OpenStruct, Hash] The request that contains the email template and optionally a locale to render it in.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_email_template_preview(request)
start.uri('/api/email/template/preview')
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.post()
.go()
end
#
# Retrieves all of the email templates.
#
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_email_templates()
start.uri('/api/email/template')
.get()
.go()
end
#
# Retrieves a single event log for the given Id.
#
# @param event_log_id [Numeric] The Id of the event log to retrieve.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_event_log(event_log_id)
start.uri('/api/system/event-log')
.url_segment(event_log_id)
.get()
.go()
end
#
# Retrieves the group for the given Id.
#
# @param group_id [string] The Id of the group.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_group(group_id)
start.uri('/api/group')
.url_segment(group_id)
.get()
.go()
end
#
# Retrieves all of the groups.
#
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_groups()
start.uri('/api/group')
.get()
.go()
end
#
# Retrieves the identity provider for the given id or all of the identity providers if the id is null.
#
# @param identity_provider_id [string] (Optional) The identity provider id.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_identity_provider(identity_provider_id)
start.uri('/api/identity-provider')
.url_segment(identity_provider_id)
.get()
.go()
end
#
# Retrieves all of the identity providers.
#
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_identity_providers()
start.uri('/api/identity-provider')
.get()
.go()
end
#
# Retrieves all of the actions for the user with the given Id that are currently inactive.
# An inactive action means one that is time based and has been canceled or has expired, or is not time based.
#
# @param user_id [string] The Id of the user to fetch the actions for.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_inactive_actions(user_id)
start.uri('/api/user/action')
.url_parameter('userId', user_id)
.url_parameter('active', false)
.get()
.go()
end
#
# Retrieves all of the applications that are currently inactive.
#
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_inactive_applications()
start.uri('/api/application')
.url_parameter('inactive', true)
.get()
.go()
end
#
# Retrieves all of the user actions that are currently inactive.
#
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_inactive_user_actions()
start.uri('/api/user-action')
.url_parameter('inactive', true)
.get()
.go()
end
#
# Retrieves the available integrations.
#
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_integration()
start.uri('/api/integration')
.get()
.go()
end
#
# Retrieves the Public Key configured for verifying JSON Web Tokens (JWT) by the key Id. If the key Id is provided a
# single public key will be returned if one is found by that id. If the optional parameter key Id is not provided all
# public keys will be returned.
#
# @param key_id [string] (Optional) The Id of the public key.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_jwt_public_key(key_id)
start.uri('/api/jwt/public-key')
.url_segment(key_id)
.get()
.go()
end
#
# Retrieves all Public Keys configured for verifying JSON Web Tokens (JWT).
#
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_jwt_public_keys()
start.uri('/api/jwt/public-key')
.get()
.go()
end
#
# Retrieves the key for the given Id.
#
# @param key_id [string] The Id of the key.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_key(key_id)
start.uri('/api/key')
.url_segment(key_id)
.get()
.go()
end
#
# Retrieves all of the keys.
#
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_keys()
start.uri('/api/key')
.get()
.go()
end
#
# Retrieves the lambda for the given Id.
#
# @param lambda_id [string] The Id of the lambda.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_lambda(lambda_id)
start.uri('/api/lambda')
.url_segment(lambda_id)
.get()
.go()
end
#
# Retrieves all of the lambdas.
#
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_lambdas()
start.uri('/api/lambda')
.get()
.go()
end
#
# Retrieves all of the lambdas for the provided type.
#
# @param type [OpenStruct, Hash] The type of the lambda to return.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_lambdas_by_type(type)
start.uri('/api/lambda')
.url_parameter('type', type)
.get()
.go()
end
#
# Retrieves the login report between the two instants. If you specify an application id, it will only return the
# login counts for that application.
#
# @param application_id [string] (Optional) The application id.
# @param start [OpenStruct, Hash] The start instant as UTC milliseconds since Epoch.
# @param _end [OpenStruct, Hash] The end instant as UTC milliseconds since Epoch.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_login_report(application_id, start, _end)
start.uri('/api/report/login')
.url_parameter('applicationId', application_id)
.url_parameter('start', start)
.url_parameter('end', _end)
.get()
.go()
end
#
# Retrieves the monthly active user report between the two instants. If you specify an application id, it will only
# return the monthly active counts for that application.
#
# @param application_id [string] (Optional) The application id.
# @param start [OpenStruct, Hash] The start instant as UTC milliseconds since Epoch.
# @param _end [OpenStruct, Hash] The end instant as UTC milliseconds since Epoch.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_monthly_active_report(application_id, start, _end)
start.uri('/api/report/monthly-active-user')
.url_parameter('applicationId', application_id)
.url_parameter('start', start)
.url_parameter('end', _end)
.get()
.go()
end
#
# Retrieves the Oauth2 configuration for the application for the given Application Id.
#
# @param application_id [string] The Id of the Application to retrieve OAuth configuration.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_oauth_configuration(application_id)
start.uri('/api/application')
.url_segment(application_id)
.url_segment("oauth-configuration")
.get()
.go()
end
#
# Retrieves the password validation rules.
#
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_password_validation_rules()
start.uri('/api/system-configuration/password-validation-rules')
.get()
.go()
end
#
# Retrieves the last number of login records.
#
# @param offset [Numeric] The initial record. e.g. 0 is the last login, 100 will be the 100th most recent login.
# @param limit [Numeric] (Optional, defaults to 10) The number of records to retrieve.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_recent_logins(offset, limit)
start.uri('/api/user/recent-login')
.url_parameter('offset', offset)
.url_parameter('limit', limit)
.get()
.go()
end
#
# Retrieves the refresh tokens that belong to the user with the given Id.
#
# @param user_id [string] The Id of the user.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_refresh_tokens(user_id)
start.uri('/api/jwt/refresh')
.url_parameter('userId', user_id)
.get()
.go()
end
#
# Retrieves the user registration for the user with the given id and the given application id.
#
# @param user_id [string] The Id of the user.
# @param application_id [string] The Id of the application.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_registration(user_id, application_id)
start.uri('/api/user/registration')
.url_segment(user_id)
.url_segment(application_id)
.get()
.go()
end
#
# Retrieves the registration report between the two instants. If you specify an application id, it will only return
# the registration counts for that application.
#
# @param application_id [string] (Optional) The application id.
# @param start [OpenStruct, Hash] The start instant as UTC milliseconds since Epoch.
# @param _end [OpenStruct, Hash] The end instant as UTC milliseconds since Epoch.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_registration_report(application_id, start, _end)
start.uri('/api/report/registration')
.url_parameter('applicationId', application_id)
.url_parameter('start', start)
.url_parameter('end', _end)
.get()
.go()
end
#
# Retrieves the system configuration.
#
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_system_configuration()
start.uri('/api/system-configuration')
.get()
.go()
end
#
# Retrieves the tenant for the given Id.
#
# @param tenant_id [string] The Id of the tenant.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_tenant(tenant_id)
start.uri('/api/tenant')
.url_segment(tenant_id)
.get()
.go()
end
#
# Retrieves all of the tenants.
#
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_tenants()
start.uri('/api/tenant')
.get()
.go()
end
#
# Retrieves the totals report. This contains all of the total counts for each application and the global registration
# count.
#
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_total_report()
start.uri('/api/report/totals')
.get()
.go()
end
#
# Retrieves the user for the given Id.
#
# @param user_id [string] The Id of the user.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_user(user_id)
start.uri('/api/user')
.url_segment(user_id)
.get()
.go()
end
#
# Retrieves the user action for the given Id. If you pass in null for the id, this will return all of the user
# actions.
#
# @param user_action_id [string] (Optional) The Id of the user action.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_user_action(user_action_id)
start.uri('/api/user-action')
.url_segment(user_action_id)
.get()
.go()
end
#
# Retrieves the user action reason for the given Id. If you pass in null for the id, this will return all of the user
# action reasons.
#
# @param user_action_reason_id [string] (Optional) The Id of the user action reason.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_user_action_reason(user_action_reason_id)
start.uri('/api/user-action-reason')
.url_segment(user_action_reason_id)
.get()
.go()
end
#
# Retrieves all the user action reasons.
#
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_user_action_reasons()
start.uri('/api/user-action-reason')
.get()
.go()
end
#
# Retrieves all of the user actions.
#
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_user_actions()
start.uri('/api/user-action')
.get()
.go()
end
#
# Retrieves the user by a change password Id. The intended use of this API is to retrieve a user after the forgot
# password workflow has been initiated and you may not know the user's email or username.
#
# @param change_password_id [string] The unique change password Id that was sent via email or returned by the Forgot Password API.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_user_by_change_password_id(change_password_id)
start.uri('/api/user')
.url_parameter('changePasswordId', change_password_id)
.get()
.go()
end
#
# Retrieves the user for the given email.
#
# @param email [string] The email of the user.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_user_by_email(email)
start.uri('/api/user')
.url_parameter('email', email)
.get()
.go()
end
#
# Retrieves the user for the loginId. The loginId can be either the username or the email.
#
# @param login_id [string] The email or username of the user.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_user_by_login_id(login_id)
start.uri('/api/user')
.url_parameter('loginId', login_id)
.get()
.go()
end
#
# Retrieves the user for the given username.
#
# @param username [string] The username of the user.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_user_by_username(username)
start.uri('/api/user')
.url_parameter('username', username)
.get()
.go()
end
#
# Retrieves the user by a verificationId. The intended use of this API is to retrieve a user after the forgot
# password workflow has been initiated and you may not know the user's email or username.
#
# @param verification_id [string] The unique verification Id that has been set on the user object.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_user_by_verification_id(verification_id)
start.uri('/api/user')
.url_parameter('verificationId', verification_id)
.get()
.go()
end
#
# Retrieves all of the comments for the user with the given Id.
#
# @param user_id [string] The Id of the user.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_user_comments(user_id)
start.uri('/api/user/comment')
.url_segment(user_id)
.get()
.go()
end
#
# Retrieves the login report between the two instants for a particular user by Id. If you specify an application id, it will only return the
# login counts for that application.
#
# @param application_id [string] (Optional) The application id.
# @param user_id [string] The userId id.
# @param start [OpenStruct, Hash] The start instant as UTC milliseconds since Epoch.
# @param _end [OpenStruct, Hash] The end instant as UTC milliseconds since Epoch.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_user_login_report(application_id, user_id, start, _end)
start.uri('/api/report/login')
.url_parameter('applicationId', application_id)
.url_parameter('userId', user_id)
.url_parameter('start', start)
.url_parameter('end', _end)
.get()
.go()
end
#
# Retrieves the login report between the two instants for a particular user by login Id. If you specify an application id, it will only return the
# login counts for that application.
#
# @param application_id [string] (Optional) The application id.
# @param login_id [string] The userId id.
# @param start [OpenStruct, Hash] The start instant as UTC milliseconds since Epoch.
# @param _end [OpenStruct, Hash] The end instant as UTC milliseconds since Epoch.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_user_login_report_by_login_id(application_id, login_id, start, _end)
start.uri('/api/report/login')
.url_parameter('applicationId', application_id)
.url_parameter('loginId', login_id)
.url_parameter('start', start)
.url_parameter('end', _end)
.get()
.go()
end
#
# Retrieves the last number of login records for a user.
#
# @param user_id [string] The Id of the user.
# @param offset [Numeric] The initial record. e.g. 0 is the last login, 100 will be the 100th most recent login.
# @param limit [Numeric] (Optional, defaults to 10) The number of records to retrieve.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_user_recent_logins(user_id, offset, limit)
start.uri('/api/user/recent-login')
.url_parameter('userId', user_id)
.url_parameter('offset', offset)
.url_parameter('limit', limit)
.get()
.go()
end
#
# Retrieves the user for the given Id. This method does not use an API key, instead it uses a JSON Web Token (JWT) for authentication.
#
# @param encoded_jwt [string] The encoded JWT (access token).
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_user_using_jwt(encoded_jwt)
start.uri('/api/user')
.authorization('JWT ' + encoded_jwt)
.get()
.go()
end
#
# Retrieves the webhook for the given Id. If you pass in null for the id, this will return all the webhooks.
#
# @param webhook_id [string] (Optional) The Id of the webhook.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_webhook(webhook_id)
start.uri('/api/webhook')
.url_segment(webhook_id)
.get()
.go()
end
#
# Retrieves all the webhooks.
#
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def retrieve_webhooks()
start.uri('/api/webhook')
.get()
.go()
end
#
# Revokes a single refresh token, all tokens for a user or all tokens for an application. If you provide a user id
# and an application id, this will delete all the refresh tokens for that user for that application.
#
# @param token [string] (Optional) The refresh token to delete.
# @param user_id [string] (Optional) The user id whose tokens to delete.
# @param application_id [string] (Optional) The application id of the tokens to delete.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def revoke_refresh_token(token, user_id, application_id)
start.uri('/api/jwt/refresh')
.url_parameter('token', token)
.url_parameter('userId', user_id)
.url_parameter('applicationId', application_id)
.delete()
.go()
end
#
# Searches the audit logs with the specified criteria and pagination.
#
# @param request [OpenStruct, Hash] The search criteria and pagination information.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def search_audit_logs(request)
start.uri('/api/system/audit-log/search')
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.post()
.go()
end
#
# Searches the event logs with the specified criteria and pagination.
#
# @param request [OpenStruct, Hash] The search criteria and pagination information.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def search_event_logs(request)
start.uri('/api/system/event-log/search')
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.post()
.go()
end
#
# Retrieves the users for the given ids. If any id is invalid, it is ignored.
#
# @param ids [Array] The user ids to search for.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def search_users(ids)
start.uri('/api/user/search')
.url_parameter('ids', ids)
.get()
.go()
end
#
# Retrieves the users for the given search criteria and pagination.
#
# @param request [OpenStruct, Hash] The search criteria and pagination constraints. Fields used: queryString, numberOfResults, startRow,
# and sort fields.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def search_users_by_query_string(request)
start.uri('/api/user/search')
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.post()
.go()
end
#
# Send an email using an email template id. You can optionally provide requestData
to access key value
# pairs in the email template.
#
# @param email_template_id [string] The id for the template.
# @param request [OpenStruct, Hash] The send email request that contains all of the information used to send the email.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def send_email(email_template_id, request)
start.uri('/api/email/send')
.url_segment(email_template_id)
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.post()
.go()
end
#
# Send a passwordless authentication code in an email to complete login.
#
# @param request [OpenStruct, Hash] The passwordless send request that contains all of the information used to send an email containing a code.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def send_passwordless_code(request)
start.uri('/api/passwordless/send')
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.post()
.go()
end
#
# Send a Two Factor authentication code to assist in setting up Two Factor authentication or disabling.
#
# @param request [OpenStruct, Hash] The request object that contains all of the information used to send the code.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def send_two_factor_code(request)
start.uri('/api/two-factor/send')
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.post()
.go()
end
#
# Send a Two Factor authentication code to allow the completion of Two Factor authentication.
#
# @param two_factor_id [string] The Id returned by the Login API necessary to complete Two Factor authentication.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def send_two_factor_code_for_login(two_factor_id)
start.uri('/api/two-factor/send')
.url_segment(two_factor_id)
.post()
.go()
end
#
# Complete login using a 2FA challenge
#
# @param request [OpenStruct, Hash] The login request that contains the user credentials used to log them in.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def two_factor_login(request)
start.uri('/api/two-factor/login')
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.post()
.go()
end
#
# Updates the application with the given Id.
#
# @param application_id [string] The Id of the application to update.
# @param request [OpenStruct, Hash] The request that contains all of the new application information.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def update_application(application_id, request)
start.uri('/api/application')
.url_segment(application_id)
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.put()
.go()
end
#
# Updates the application role with the given id for the application.
#
# @param application_id [string] The Id of the application that the role belongs to.
# @param role_id [string] The Id of the role to update.
# @param request [OpenStruct, Hash] The request that contains all of the new role information.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def update_application_role(application_id, role_id, request)
start.uri('/api/application')
.url_segment(application_id)
.url_segment("role")
.url_segment(role_id)
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.put()
.go()
end
#
# Updates the email template with the given Id.
#
# @param email_template_id [string] The Id of the email template to update.
# @param request [OpenStruct, Hash] The request that contains all of the new email template information.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def update_email_template(email_template_id, request)
start.uri('/api/email/template')
.url_segment(email_template_id)
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.put()
.go()
end
#
# Updates the group with the given Id.
#
# @param group_id [string] The Id of the group to update.
# @param request [OpenStruct, Hash] The request that contains all of the new group information.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def update_group(group_id, request)
start.uri('/api/group')
.url_segment(group_id)
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.put()
.go()
end
#
# Updates the identity provider with the given Id.
#
# @param identity_provider_id [string] The Id of the identity provider to update.
# @param request [OpenStruct, Hash] The request object that contains the updated identity provider.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def update_identity_provider(identity_provider_id, request)
start.uri('/api/identity-provider')
.url_segment(identity_provider_id)
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.put()
.go()
end
#
# Updates the available integrations.
#
# @param request [OpenStruct, Hash] The request that contains all of the new integration information.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def update_integrations(request)
start.uri('/api/integration')
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.put()
.go()
end
#
# Updates the key with the given Id.
#
# @param key_id [string] The Id of the key to update.
# @param request [OpenStruct, Hash] The request that contains all of the new key information.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def update_key(key_id, request)
start.uri('/api/key')
.url_segment(key_id)
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.put()
.go()
end
#
# Updates the lambda with the given Id.
#
# @param lambda_id [string] The Id of the lambda to update.
# @param request [OpenStruct, Hash] The request that contains all of the new lambda information.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def update_lambda(lambda_id, request)
start.uri('/api/lambda')
.url_segment(lambda_id)
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.put()
.go()
end
#
# Updates the registration for the user with the given id and the application defined in the request.
#
# @param user_id [string] The Id of the user whose registration is going to be updated.
# @param request [OpenStruct, Hash] The request that contains all of the new registration information.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def update_registration(user_id, request)
start.uri('/api/user/registration')
.url_segment(user_id)
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.put()
.go()
end
#
# Updates the system configuration.
#
# @param request [OpenStruct, Hash] The request that contains all of the new system configuration information.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def update_system_configuration(request)
start.uri('/api/system-configuration')
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.put()
.go()
end
#
# Updates the tenant with the given Id.
#
# @param tenant_id [string] The Id of the tenant to update.
# @param request [OpenStruct, Hash] The request that contains all of the new tenant information.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def update_tenant(tenant_id, request)
start.uri('/api/tenant')
.url_segment(tenant_id)
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.put()
.go()
end
#
# Updates the user with the given Id.
#
# @param user_id [string] The Id of the user to update.
# @param request [OpenStruct, Hash] The request that contains all of the new user information.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def update_user(user_id, request)
start.uri('/api/user')
.url_segment(user_id)
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.put()
.go()
end
#
# Updates the user action with the given Id.
#
# @param user_action_id [string] The Id of the user action to update.
# @param request [OpenStruct, Hash] The request that contains all of the new user action information.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def update_user_action(user_action_id, request)
start.uri('/api/user-action')
.url_segment(user_action_id)
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.put()
.go()
end
#
# Updates the user action reason with the given Id.
#
# @param user_action_reason_id [string] The Id of the user action reason to update.
# @param request [OpenStruct, Hash] The request that contains all of the new user action reason information.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def update_user_action_reason(user_action_reason_id, request)
start.uri('/api/user-action-reason')
.url_segment(user_action_reason_id)
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.put()
.go()
end
#
# Updates the webhook with the given Id.
#
# @param webhook_id [string] The Id of the webhook to update.
# @param request [OpenStruct, Hash] The request that contains all of the new webhook information.
# @return [FusionAuth::ClientResponse] The ClientResponse object.
#
def update_webhook(webhook_id, request)
start.uri('/api/webhook')
.url_segment(webhook_id)
.body_handler(FusionAuth::JSONBodyHandler.new(request))
.put()
.go()
end
#
# Validates the provided JWT (encoded JWT string) to ensure the token is valid. A valid access token is properly
# signed and not expired.
#
# This API may be used to verify the JWT as well as decode the encoded JWT into human readable identity claims. # # @param encoded_jwt [string] The encoded JWT (access token). # @return [FusionAuth::ClientResponse] The ClientResponse object. # def validate_jwt(encoded_jwt) start.uri('/api/jwt/validate') .authorization('JWT ' + encoded_jwt) .get() .go() end # # Confirms a email verification. The Id given is usually from an email sent to the user. # # @param verification_id [string] The email verification id sent to the user. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def verify_email(verification_id) start.uri('/api/user/verify-email') .url_segment(verification_id) .post() .go() end # # Confirms an application registration. The Id given is usually from an email sent to the user. # # @param verification_id [string] The registration verification Id sent to the user. # @return [FusionAuth::ClientResponse] The ClientResponse object. # def verify_registration(verification_id) start.uri('/api/user/verify-registration') .url_segment(verification_id) .post() .go() end # # Starts the HTTP call # # @return [RESTClient] The RESTClient # private def start RESTClient.new .authorization(@api_key) .success_response_handler(FusionAuth::JSONResponseHandler.new(OpenStruct)) .error_response_handler(FusionAuth::JSONResponseHandler.new(OpenStruct)) .url(@base_url) .connect_timeout(@connect_timeout) .read_timeout(@read_timeout) end end end