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, :tenant_id def initialize(api_key, base_url) @api_key = api_key @base_url = base_url @connect_timeout = 1000 @read_timeout = 2000 @tenant_id = nil end def set_tenant_id(tenant_id) @tenant_id = tenant_id 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 in the request object. # # @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(request) start.uri('/api/user/action') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Adds a user to an existing family. The family id must be specified. # # @param family_id [string] The id of the family. # @param request [OpenStruct, Hash] The request object that contains all of the information used to determine which user to add to the family. # @return [FusionAuth::ClientResponse] The ClientResponse object. def add_user_to_family(family_id, request) start.uri('/api/user/family') .url_segment(family_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .put() .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 a connector. You can optionally specify an Id for the connector, if not provided one will be generated. # # @param connector_id [string] (Optional) The Id for the connector. 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 connector. # @return [FusionAuth::ClientResponse] The ClientResponse object. def create_connector(connector_id, request) start.uri('/api/connector') .url_segment(connector_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Creates a user consent type. You can optionally specify an Id for the consent type, if not provided one will be generated. # # @param consent_id [string] (Optional) The Id for the consent. 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 consent. # @return [FusionAuth::ClientResponse] The ClientResponse object. def create_consent(consent_id, request) start.uri('/api/consent') .url_segment(consent_id) .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 family with the user id in the request as the owner and sole member of the family. You can optionally specify an id for the # family, if not provided one will be generated. # # @param family_id [string] (Optional) The id for the family. 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 family. # @return [FusionAuth::ClientResponse] The ClientResponse object. def create_family(family_id, request) start.uri('/api/user/family') .url_segment(family_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Creates a form. You can optionally specify an Id for the form, if not provided one will be generated. # # @param form_id [string] (Optional) The Id for the form. 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 form. # @return [FusionAuth::ClientResponse] The ClientResponse object. def create_form(form_id, request) start.uri('/api/form') .url_segment(form_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Creates a form field. You can optionally specify an Id for the form, if not provided one will be generated. # # @param field_id [string] (Optional) The Id for the form field. 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 form field. # @return [FusionAuth::ClientResponse] The ClientResponse object. def create_form_field(field_id, request) start.uri('/api/form/field') .url_segment(field_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 Theme. You can optionally specify an Id for the theme, if not provided one will be generated. # # @param theme_id [string] (Optional) The Id for the theme. 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 theme. # @return [FusionAuth::ClientResponse] The ClientResponse object. def create_theme(theme_id, request) start.uri('/api/theme') .url_segment(theme_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 single User consent. # # @param user_consent_id [string] (Optional) The Id for the User consent. If not provided a secure random UUID will be generated. # @param request [OpenStruct, Hash] The request that contains the user consent information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def create_user_consent(user_consent_id, request) start.uri('/api/user/consent') .url_segment(user_consent_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. # @deprecated This method has been renamed to deactivate_users_by_ids, use that method instead. def deactivate_users(user_ids) start.uri('/api/user/bulk') .url_parameter('userId', user_ids) .url_parameter('dryRun', false) .url_parameter('hardDelete', false) .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_by_ids(user_ids) start.uri('/api/user/bulk') .url_parameter('userId', user_ids) .url_parameter('dryRun', false) .url_parameter('hardDelete', false) .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 connector for the given Id. # # @param connector_id [string] The Id of the connector to delete. # @return [FusionAuth::ClientResponse] The ClientResponse object. def delete_connector(connector_id) start.uri('/api/connector') .url_segment(connector_id) .delete() .go() end # # Deletes the consent for the given Id. # # @param consent_id [string] The Id of the consent to delete. # @return [FusionAuth::ClientResponse] The ClientResponse object. def delete_consent(consent_id) start.uri('/api/consent') .url_segment(consent_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 form for the given Id. # # @param form_id [string] The Id of the form to delete. # @return [FusionAuth::ClientResponse] The ClientResponse object. def delete_form(form_id) start.uri('/api/form') .url_segment(form_id) .delete() .go() end # # Deletes the form field for the given Id. # # @param field_id [string] The Id of the form field to delete. # @return [FusionAuth::ClientResponse] The ClientResponse object. def delete_form_field(field_id) start.uri('/api/form/field') .url_segment(field_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_id [string] The Id of the key to delete. # @return [FusionAuth::ClientResponse] The ClientResponse object. def delete_key(key_id) start.uri('/api/key') .url_segment(key_id) .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 theme for the given Id. # # @param theme_id [string] The Id of the theme to delete. # @return [FusionAuth::ClientResponse] The ClientResponse object. def delete_theme(theme_id) start.uri('/api/theme') .url_segment(theme_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, or users matching the provided JSON query or queryString. # The order of preference is ids, query and then queryString, it is recommended to only provide one of the three for the request. # # This method can be used to deactivate or permanently delete (hard-delete) users based upon the hardDelete boolean in the request body. # Using the dryRun parameter you may also request the result of the action without actually deleting or deactivating any users. # # @param request [OpenStruct, Hash] The UserDeleteRequest. # @return [FusionAuth::ClientResponse] The ClientResponse object. # @deprecated This method has been renamed to delete_users_by_query, use that method instead. def delete_users(request) start.uri('/api/user/bulk') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .delete() .go() end # # Deletes the users with the given ids, or users matching the provided JSON query or queryString. # The order of preference is ids, query and then queryString, it is recommended to only provide one of the three for the request. # # This method can be used to deactivate or permanently delete (hard-delete) users based upon the hardDelete boolean in the request body. # Using the dryRun parameter you may also request the result of the action without actually deleting or deactivating any users. # # @param request [OpenStruct, Hash] The UserDeleteRequest. # @return [FusionAuth::ClientResponse] The ClientResponse object. def delete_users_by_query(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 # # Exchanges an OAuth authorization code for an access token. # If you will be using the Authorization Code grant, you will make a request to the Token endpoint to exchange the authorization code returned from the Authorize endpoint for an access token. # # @param code [string] The authorization code returned on the /oauth2/authorize response. # @param client_id [string] The unique client identifier. The client Id is the Id of the FusionAuth Application in which you you are attempting to authenticate. # @param client_secret [string] (Optional) The client secret. This value will be required if client authentication is enabled. # @param redirect_uri [string] The URI to redirect to upon a successful request. # @return [FusionAuth::ClientResponse] The ClientResponse object. def exchange_o_auth_code_for_access_token(code, client_id, client_secret, redirect_uri) body = { "code" => code, "client_id" => client_id, "client_secret" => client_secret, "grant_type" => "authorization_code", "redirect_uri" => redirect_uri } startAnonymous.uri('/oauth2/token') .body_handler(FusionAuth::FormDataBodyHandler.new(body)) .post() .go() end # # Exchange a Refresh Token for an Access Token. # If you will be using the Refresh Token Grant, you will make a request to the Token endpoint to exchange the user’s refresh token for an access token. # # @param refresh_token [string] The refresh token that you would like to use to exchange for an access token. # @param client_id [string] (Optional) The unique client identifier. The client Id is the Id of the FusionAuth Application in which you you are attempting to authenticate. This parameter is optional when the Authorization header is provided. # @param client_secret [string] (Optional) The client secret. This value may optionally be provided in the request body instead of the Authorization header. # @param scope [string] (Optional) This parameter is optional and if omitted, the same scope requested during the authorization request will be used. If provided the scopes must match those requested during the initial authorization request. # @param user_code [string] (Optional) The end-user verification code. This code is required if using this endpoint to approve the Device Authorization. # @return [FusionAuth::ClientResponse] The ClientResponse object. def exchange_refresh_token_for_access_token(refresh_token, client_id, client_secret, scope, user_code) body = { "refresh_token" => refresh_token, "client_id" => client_id, "client_secret" => client_secret, "grant_type" => "refresh_token", "scope" => scope, "user_code" => user_code } startAnonymous.uri('/oauth2/token') .body_handler(FusionAuth::FormDataBodyHandler.new(body)) .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) startAnonymous.uri('/api/jwt/refresh') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Exchange User Credentials for a Token. # If you will be using the Resource Owner Password Credential Grant, you will make a request to the Token endpoint to exchange the user’s email and password for an access token. # # @param username [string] The login identifier of the user. The login identifier can be either the email or the username. # @param password [string] The user’s password. # @param client_id [string] (Optional) The unique client identifier. The client Id is the Id of the FusionAuth Application in which you you are attempting to authenticate. This parameter is optional when the Authorization header is provided. # @param client_secret [string] (Optional) The client secret. This value may optionally be provided in the request body instead of the Authorization header. # @param scope [string] (Optional) This parameter is optional and if omitted, the same scope requested during the authorization request will be used. If provided the scopes must match those requested during the initial authorization request. # @param user_code [string] (Optional) The end-user verification code. This code is required if using this endpoint to approve the Device Authorization. # @return [FusionAuth::ClientResponse] The ClientResponse object. def exchange_user_credentials_for_access_token(username, password, client_id, client_secret, scope, user_code) body = { "username" => username, "password" => password, "client_id" => client_id, "client_secret" => client_secret, "grant_type" => "password", "scope" => scope, "user_code" => user_code } startAnonymous.uri('/oauth2/token') .body_handler(FusionAuth::FormDataBodyHandler.new(body)) .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('sendVerifyEmail', 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) startAnonymous.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 refresh tokens. This request performs minimal validation and runs batch inserts of refresh tokens with the # expectation that each token represents a user that already exists and is registered for the corresponding FusionAuth # Application. This is done to increases the insert performance. # # Therefore, if you encounter an error due to a database key violation, the response will likely offer a generic # explanation. If you encounter an error, you may optionally enable additional validation to receive a JSON response # body with specific validation errors. This will slow the request down but will allow you to identify the cause of # the failure. See the validateDbConstraints request parameter. # # @param request [OpenStruct, Hash] The request that contains all of the information about all of the refresh tokens to import. # @return [FusionAuth::ClientResponse] The ClientResponse object. def import_refresh_tokens(request) start.uri('/api/user/refresh-token/import') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Bulk imports users. This request performs minimal validation and runs batch inserts of users with the expectation # that each user does not yet exist and each registration corresponds to an existing FusionAuth Application. This is done to # increases the insert performance. # # Therefore, if you encounter an error due to a database key violation, the response will likely offer # a generic explanation. If you encounter an error, you may optionally enable additional validation to receive a JSON response # body with specific validation errors. This will slow the request down but will allow you to identify the cause of the failure. See # the validateDbConstraints request parameter. # # @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). # @param refresh_token [string] (Optional) An existing refresh token used to request a refresh token in addition to a JWT in the response. #

The target application represented by the applicationId request parameter must have refresh # tokens enabled in order to receive a refresh token in the response.

# @return [FusionAuth::ClientResponse] The ClientResponse object. def issue_jwt(application_id, encoded_jwt, refresh_token) start.uri('/api/jwt/issue') .authorization('JWT ' + encoded_jwt) .url_parameter('applicationId', application_id) .url_parameter('refreshToken', refresh_token) .get() .go() end # # Authenticates a user to FusionAuth. # # This API optionally requires an API key. See Application.loginConfiguration.requireAuthentication. # # @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) startAnonymous.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) startAnonymous.uri('/api/passwordless/login') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Updates, via PATCH, 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 just the new application information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def patch_application(application_id, request) start.uri('/api/application') .url_segment(application_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .patch() .go() end # # Updates, via PATCH, 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 just the new role information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def patch_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)) .patch() .go() end # # Updates, via PATCH, the connector with the given Id. # # @param connector_id [string] The Id of the connector to update. # @param request [OpenStruct, Hash] The request that contains just the new connector information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def patch_connector(connector_id, request) start.uri('/api/connector') .url_segment(connector_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .patch() .go() end # # Updates, via PATCH, the consent with the given Id. # # @param consent_id [string] The Id of the consent to update. # @param request [OpenStruct, Hash] The request that contains just the new consent information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def patch_consent(consent_id, request) start.uri('/api/consent') .url_segment(consent_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .patch() .go() end # # Updates, via PATCH, 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 just the new email template information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def patch_email_template(email_template_id, request) start.uri('/api/email/template') .url_segment(email_template_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .patch() .go() end # # Updates, via PATCH, 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 just the new group information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def patch_group(group_id, request) start.uri('/api/group') .url_segment(group_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .patch() .go() end # # Updates, via PATCH, 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 just the updated identity provider information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def patch_identity_provider(identity_provider_id, request) start.uri('/api/identity-provider') .url_segment(identity_provider_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .patch() .go() end # # Updates, via PATCH, the available integrations. # # @param request [OpenStruct, Hash] The request that contains just the new integration information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def patch_integrations(request) start.uri('/api/integration') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .patch() .go() end # # Updates, via PATCH, 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 just the new lambda information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def patch_lambda(lambda_id, request) start.uri('/api/lambda') .url_segment(lambda_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .patch() .go() end # # Updates, via PATCH, 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 just the new registration information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def patch_registration(user_id, request) start.uri('/api/user/registration') .url_segment(user_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .patch() .go() end # # Updates, via PATCH, the system configuration. # # @param request [OpenStruct, Hash] The request that contains just the new system configuration information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def patch_system_configuration(request) start.uri('/api/system-configuration') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .patch() .go() end # # Updates, via PATCH, 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 just the new tenant information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def patch_tenant(tenant_id, request) start.uri('/api/tenant') .url_segment(tenant_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .patch() .go() end # # Updates, via PATCH, the theme with the given Id. # # @param theme_id [string] The Id of the theme to update. # @param request [OpenStruct, Hash] The request that contains just the new theme information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def patch_theme(theme_id, request) start.uri('/api/theme') .url_segment(theme_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .patch() .go() end # # Updates, via PATCH, 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 just the new user information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def patch_user(user_id, request) start.uri('/api/user') .url_segment(user_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .patch() .go() end # # Updates, via PATCH, 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 just the new user action information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def patch_user_action(user_action_id, request) start.uri('/api/user-action') .url_segment(user_action_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .patch() .go() end # # Updates, via PATCH, 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 just the new user action reason information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def patch_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)) .patch() .go() end # # Updates, via PATCH, a single User consent by Id. # # @param user_consent_id [string] The User Consent Id # @param request [OpenStruct, Hash] The request that contains just the new user consent information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def patch_user_consent(user_consent_id, request) start.uri('/api/user/consent') .url_segment(user_consent_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .patch() .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) startAnonymous.uri('/api/jwt/reconcile') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Request a refresh of the User search index. This API is not generally necessary and the search index will become consistent in a # reasonable amount of time. There may be scenarios where you may wish to manually request an index refresh. One example may be # if you are using the Search API or Delete Tenant API immediately following a User Create etc, you may wish to request a refresh to # ensure the index immediately current before making a query request to the search index. # # @return [FusionAuth::ClientResponse] The ClientResponse object. def refresh_user_search_index() start.uri('/api/user/search') .put() .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 # # Removes a user from the family with the given id. # # @param family_id [string] The id of the family to remove the user from. # @param user_id [string] The id of the user to remove from the family. # @return [FusionAuth::ClientResponse] The ClientResponse object. def remove_user_from_family(family_id, user_id) start.uri('/api/user/family') .url_segment(family_id) .url_segment(user_id) .delete() .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 verification email to the user. If the Application has configured a specific email template this will be used # instead of the tenant configuration. # # @param application_id [string] The unique Application Id to used to resolve an application specific email template. # @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_with_application_template(application_id, email) start.uri('/api/user/verify-email') .url_parameter('applicationId', application_id) .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 connector with the given Id. # # @param connector_id [string] The Id of the connector. # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_connector(connector_id) start.uri('/api/connector') .url_segment(connector_id) .get() .go() end # # Retrieves all of the connectors. # # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_connectors() start.uri('/api/connector') .get() .go() end # # Retrieves the Consent for the given Id. # # @param consent_id [string] The Id of the consent. # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_consent(consent_id) start.uri('/api/consent') .url_segment(consent_id) .get() .go() end # # Retrieves all of the consent. # # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_consents() start.uri('/api/consent') .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 all of the families that a user belongs to. # # @param user_id [string] The User's id # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_families(user_id) start.uri('/api/user/family') .url_parameter('userId', user_id) .get() .go() end # # Retrieves all of the members of a family by the unique Family Id. # # @param family_id [string] The unique Id of the Family. # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_family_members_by_family_id(family_id) start.uri('/api/user/family') .url_segment(family_id) .get() .go() end # # Retrieves the form with the given Id. # # @param form_id [string] The Id of the form. # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_form(form_id) start.uri('/api/form') .url_segment(form_id) .get() .go() end # # Retrieves the form field with the given Id. # # @param field_id [string] The Id of the form field. # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_form_field(field_id) start.uri('/api/form/field') .url_segment(field_id) .get() .go() end # # Retrieves all of the forms fields # # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_form_fields() start.uri('/api/form/field') .get() .go() end # # Retrieves all of the forms. # # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_forms() start.uri('/api/form') .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 (kid). # # @param key_id [string] The Id of the public key (kid). # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_jwt_public_key(key_id) startAnonymous.uri('/api/jwt/public-key') .url_parameter('kid', key_id) .get() .go() end # # Retrieves the Public Key configured for verifying the JSON Web Tokens (JWT) issued by the Login API by the Application Id. # # @param application_id [string] The Id of the Application for which this key is used. # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_jwt_public_key_by_application_id(application_id) startAnonymous.uri('/api/jwt/public-key') .url_parameter('applicationId', application_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() startAnonymous.uri('/api/jwt/public-key') .get() .go() end # # Returns public keys used by FusionAuth to cryptographically verify JWTs using the JSON Web Key format. # # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_json_web_key_set() startAnonymous.uri('/.well-known/jwks.json') .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 # # Returns the well known OpenID Configuration JSON document # # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_open_id_configuration() startAnonymous.uri('/.well-known/openid-configuration') .get() .go() end # # Retrieves the password validation rules for a specific tenant. This method requires a tenantId to be provided # through the use of a Tenant scoped API key or an HTTP header X-FusionAuth-TenantId to specify the Tenant Id. # # This API does not require an API key. # # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_password_validation_rules() startAnonymous.uri('/api/tenant/password-validation-rules') .get() .go() end # # Retrieves the password validation rules for a specific tenant. # # This API does not require an API key. # # @param tenant_id [string] The Id of the tenant. # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_password_validation_rules_with_tenant_id(tenant_id) startAnonymous.uri('/api/tenant/password-validation-rules') .url_segment(tenant_id) .get() .go() end # # Retrieves all of the children for the given parent email address. # # @param parent_email [string] The email of the parent. # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_pending_children(parent_email) start.uri('/api/user/family/pending') .url_parameter('parentEmail', parent_email) .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 theme for the given Id. # # @param theme_id [string] The Id of the theme. # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_theme(theme_id) start.uri('/api/theme') .url_segment(theme_id) .get() .go() end # # Retrieves all of the themes. # # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_themes() start.uri('/api/theme') .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 # # Retrieve a single User consent by Id. # # @param user_consent_id [string] The User consent Id # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_user_consent(user_consent_id) start.uri('/api/user/consent') .url_segment(user_consent_id) .get() .go() end # # Retrieves all of the consents for a User. # # @param user_id [string] The User's Id # @return [FusionAuth::ClientResponse] The ClientResponse object. def retrieve_user_consents(user_id) start.uri('/api/user/consent') .url_parameter('userId', 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) startAnonymous.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 # # Revokes a single User consent by Id. # # @param user_consent_id [string] The User Consent Id # @return [FusionAuth::ClientResponse] The ClientResponse object. def revoke_user_consent(user_consent_id) start.uri('/api/user/consent') .url_segment(user_consent_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 # # Searches the login records with the specified criteria and pagination. # # @param request [OpenStruct, Hash] The search criteria and pagination information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def search_login_records(request) start.uri('/api/system/login-record/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. # @deprecated This method has been renamed to search_users_by_ids, use that method instead. def search_users(ids) start.uri('/api/user/search') .url_parameter('ids', ids) .get() .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_by_ids(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: ids, query, queryString, numberOfResults, orderBy, startRow, # and sortFields. # @return [FusionAuth::ClientResponse] The ClientResponse object. def search_users_by_query(request) start.uri('/api/user/search') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Retrieves the users for the given search criteria and pagination. # # @param request [OpenStruct, Hash] The search criteria and pagination constraints. Fields used: ids, query, queryString, numberOfResults, orderBy, startRow, # and sortFields. # @return [FusionAuth::ClientResponse] The ClientResponse object. # @deprecated This method has been renamed to search_users_by_query, use that method instead. 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 # # Sends out an email to a parent that they need to register and create a family or need to log in and add a child to their existing family. # # @param request [OpenStruct, Hash] The request object that contains the parent email. # @return [FusionAuth::ClientResponse] The ClientResponse object. def send_family_request_email(request) start.uri('/api/user/family/request') .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) startAnonymous.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) startAnonymous.uri('/api/two-factor/send') .url_segment(two_factor_id) .post() .go() end # # Begins a login request for a 3rd party login that requires user interaction such as HYPR. # # @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 start_identity_provider_login(request) start.uri('/api/identity-provider/start') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .post() .go() end # # Start a passwordless login request by generating a passwordless code. This code can be sent to the User using the Send # Passwordless Code API or using a mechanism outside of FusionAuth. The passwordless login is completed by using the Passwordless Login API with this code. # # @param request [OpenStruct, Hash] The passwordless start request that contains all of the information used to begin the passwordless login request. # @return [FusionAuth::ClientResponse] The ClientResponse object. def start_passwordless_login(request) start.uri('/api/passwordless/start') .body_handler(FusionAuth::JSONBodyHandler.new(request)) .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) startAnonymous.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 connector with the given Id. # # @param connector_id [string] The Id of the connector to update. # @param request [OpenStruct, Hash] The request object that contains all of the new connector information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def update_connector(connector_id, request) start.uri('/api/connector') .url_segment(connector_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .put() .go() end # # Updates the consent with the given Id. # # @param consent_id [string] The Id of the consent to update. # @param request [OpenStruct, Hash] The request that contains all of the new consent information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def update_consent(consent_id, request) start.uri('/api/consent') .url_segment(consent_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 form with the given Id. # # @param form_id [string] The Id of the form to update. # @param request [OpenStruct, Hash] The request object that contains all of the new form information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def update_form(form_id, request) start.uri('/api/form') .url_segment(form_id) .body_handler(FusionAuth::JSONBodyHandler.new(request)) .put() .go() end # # Updates the form field with the given Id. # # @param field_id [string] The Id of the form field to update. # @param request [OpenStruct, Hash] The request object that contains all of the new form field information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def update_form_field(field_id, request) start.uri('/api/form/field') .url_segment(field_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 theme with the given Id. # # @param theme_id [string] The Id of the theme to update. # @param request [OpenStruct, Hash] The request that contains all of the new theme information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def update_theme(theme_id, request) start.uri('/api/theme') .url_segment(theme_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 a single User consent by Id. # # @param user_consent_id [string] The User Consent Id # @param request [OpenStruct, Hash] The request that contains the user consent information. # @return [FusionAuth::ClientResponse] The ClientResponse object. def update_user_consent(user_consent_id, request) start.uri('/api/user/consent') .url_segment(user_consent_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 end-user provided user_code from the user-interaction of the Device Authorization Grant. # If you build your own activation form you should validate the user provided code prior to beginning the Authorization grant. # # @param user_code [string] The end-user verification code. # @param client_id [string] The client id. # @return [FusionAuth::ClientResponse] The ClientResponse object. def validate_device(user_code, client_id) startAnonymous.uri('/oauth2/device/validate') .url_parameter('user_code', user_code) .url_parameter('client_id', client_id) .get() .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) startAnonymous.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) startAnonymous.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) startAnonymous.uri('/api/user/verify-registration') .url_segment(verification_id) .post() .go() end # # Starts the HTTP call # # @return [RESTClient] The RESTClient # private def start client = startAnonymous.authorization(@api_key) client end private def startAnonymous client = RESTClient.new .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) if @tenant_id != nil client.header("X-FusionAuth-TenantId", @tenant_id) end client end end end