io.fusionauth.client.FusionAuthClient Maven / Gradle / Ivy
Show all versions of fusionauth-java-client Show documentation
/*
* Copyright (c) 2018-2023, 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.
*/
package io.fusionauth.client;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.inversoft.error.Errors;
import com.inversoft.json.JacksonModule;
import com.inversoft.rest.ClientResponse;
import com.inversoft.rest.FormDataBodyHandler;
import com.inversoft.rest.JSONBodyHandler;
import com.inversoft.rest.JSONResponseHandler;
import com.inversoft.rest.RESTClient;
import io.fusionauth.domain.LambdaType;
import io.fusionauth.domain.OpenIdConfiguration;
import io.fusionauth.domain.api.APIKeyRequest;
import io.fusionauth.domain.api.APIKeyResponse;
import io.fusionauth.domain.api.ApplicationOAuthScopeRequest;
import io.fusionauth.domain.api.ApplicationOAuthScopeResponse;
import io.fusionauth.domain.api.ApplicationRequest;
import io.fusionauth.domain.api.ApplicationResponse;
import io.fusionauth.domain.api.ApplicationSearchRequest;
import io.fusionauth.domain.api.ApplicationSearchResponse;
import io.fusionauth.domain.api.AuditLogRequest;
import io.fusionauth.domain.api.AuditLogResponse;
import io.fusionauth.domain.api.AuditLogSearchRequest;
import io.fusionauth.domain.api.AuditLogSearchResponse;
import io.fusionauth.domain.api.ConnectorRequest;
import io.fusionauth.domain.api.ConnectorResponse;
import io.fusionauth.domain.api.ConsentRequest;
import io.fusionauth.domain.api.ConsentResponse;
import io.fusionauth.domain.api.ConsentSearchRequest;
import io.fusionauth.domain.api.ConsentSearchResponse;
import io.fusionauth.domain.api.EmailTemplateRequest;
import io.fusionauth.domain.api.EmailTemplateResponse;
import io.fusionauth.domain.api.EmailTemplateSearchRequest;
import io.fusionauth.domain.api.EmailTemplateSearchResponse;
import io.fusionauth.domain.api.EntityGrantRequest;
import io.fusionauth.domain.api.EntityGrantResponse;
import io.fusionauth.domain.api.EntityGrantSearchRequest;
import io.fusionauth.domain.api.EntityGrantSearchResponse;
import io.fusionauth.domain.api.EntityRequest;
import io.fusionauth.domain.api.EntityResponse;
import io.fusionauth.domain.api.EntitySearchRequest;
import io.fusionauth.domain.api.EntitySearchResponse;
import io.fusionauth.domain.api.EntityTypeRequest;
import io.fusionauth.domain.api.EntityTypeResponse;
import io.fusionauth.domain.api.EntityTypeSearchRequest;
import io.fusionauth.domain.api.EntityTypeSearchResponse;
import io.fusionauth.domain.api.EventLogResponse;
import io.fusionauth.domain.api.EventLogSearchRequest;
import io.fusionauth.domain.api.EventLogSearchResponse;
import io.fusionauth.domain.api.FamilyEmailRequest;
import io.fusionauth.domain.api.FamilyRequest;
import io.fusionauth.domain.api.FamilyResponse;
import io.fusionauth.domain.api.FormFieldRequest;
import io.fusionauth.domain.api.FormFieldResponse;
import io.fusionauth.domain.api.FormRequest;
import io.fusionauth.domain.api.FormResponse;
import io.fusionauth.domain.api.GroupMemberSearchRequest;
import io.fusionauth.domain.api.GroupMemberSearchResponse;
import io.fusionauth.domain.api.GroupSearchRequest;
import io.fusionauth.domain.api.GroupSearchResponse;
import io.fusionauth.domain.api.GroupRequest;
import io.fusionauth.domain.api.GroupResponse;
import io.fusionauth.domain.api.IPAccessControlListRequest;
import io.fusionauth.domain.api.IPAccessControlListResponse;
import io.fusionauth.domain.api.IPAccessControlListSearchRequest;
import io.fusionauth.domain.api.IPAccessControlListSearchResponse;
import io.fusionauth.domain.api.IdentityProviderSearchRequest;
import io.fusionauth.domain.api.IdentityProviderSearchResponse;
import io.fusionauth.domain.api.IdentityProviderRequest;
import io.fusionauth.domain.api.IdentityProviderResponse;
import io.fusionauth.domain.api.IntegrationRequest;
import io.fusionauth.domain.api.IntegrationResponse;
import io.fusionauth.domain.api.KeyRequest;
import io.fusionauth.domain.api.KeyResponse;
import io.fusionauth.domain.api.KeySearchRequest;
import io.fusionauth.domain.api.KeySearchResponse;
import io.fusionauth.domain.api.LambdaRequest;
import io.fusionauth.domain.api.LambdaResponse;
import io.fusionauth.domain.api.LambdaSearchRequest;
import io.fusionauth.domain.api.LambdaSearchResponse;
import io.fusionauth.domain.api.LoginRecordSearchRequest;
import io.fusionauth.domain.api.LoginRecordSearchResponse;
import io.fusionauth.domain.api.LoginPingRequest;
import io.fusionauth.domain.api.LoginRequest;
import io.fusionauth.domain.api.LoginResponse;
import io.fusionauth.domain.api.LogoutRequest;
import io.fusionauth.domain.api.MemberDeleteRequest;
import io.fusionauth.domain.api.MemberRequest;
import io.fusionauth.domain.api.MemberResponse;
import io.fusionauth.domain.api.MessageTemplateRequest;
import io.fusionauth.domain.api.MessageTemplateResponse;
import io.fusionauth.domain.api.MessengerRequest;
import io.fusionauth.domain.api.MessengerResponse;
import io.fusionauth.domain.api.OAuthConfigurationResponse;
import io.fusionauth.domain.api.PasswordValidationRulesResponse;
import io.fusionauth.domain.api.PendingResponse;
import io.fusionauth.domain.api.PreviewMessageTemplateRequest;
import io.fusionauth.domain.api.PreviewMessageTemplateResponse;
import io.fusionauth.domain.api.PreviewRequest;
import io.fusionauth.domain.api.PreviewResponse;
import io.fusionauth.domain.api.PublicKeyResponse;
import io.fusionauth.domain.api.ReactorMetricsResponse;
import io.fusionauth.domain.api.ReactorRequest;
import io.fusionauth.domain.api.ReactorResponse;
import io.fusionauth.domain.api.ReindexRequest;
import io.fusionauth.domain.api.StatusResponse;
import io.fusionauth.domain.api.SystemConfigurationRequest;
import io.fusionauth.domain.api.SystemConfigurationResponse;
import io.fusionauth.domain.api.TenantDeleteRequest;
import io.fusionauth.domain.api.TenantRequest;
import io.fusionauth.domain.api.TenantResponse;
import io.fusionauth.domain.api.TenantSearchRequest;
import io.fusionauth.domain.api.TenantSearchResponse;
import io.fusionauth.domain.api.ThemeRequest;
import io.fusionauth.domain.api.ThemeResponse;
import io.fusionauth.domain.api.ThemeSearchRequest;
import io.fusionauth.domain.api.ThemeSearchResponse;
import io.fusionauth.domain.api.TwoFactorDisableRequest;
import io.fusionauth.domain.api.TwoFactorRecoveryCodeResponse;
import io.fusionauth.domain.api.TwoFactorRequest;
import io.fusionauth.domain.api.TwoFactorResponse;
import io.fusionauth.domain.api.UserActionReasonRequest;
import io.fusionauth.domain.api.UserActionReasonResponse;
import io.fusionauth.domain.api.UserActionRequest;
import io.fusionauth.domain.api.UserActionResponse;
import io.fusionauth.domain.api.UserCommentRequest;
import io.fusionauth.domain.api.UserCommentResponse;
import io.fusionauth.domain.api.UserCommentSearchRequest;
import io.fusionauth.domain.api.UserCommentSearchResponse;
import io.fusionauth.domain.api.UserConsentRequest;
import io.fusionauth.domain.api.UserConsentResponse;
import io.fusionauth.domain.api.UserDeleteRequest;
import io.fusionauth.domain.api.UserDeleteResponse;
import io.fusionauth.domain.api.UserDeleteSingleRequest;
import io.fusionauth.domain.api.UserRequest;
import io.fusionauth.domain.api.UserResponse;
import io.fusionauth.domain.api.VersionResponse;
import io.fusionauth.domain.api.WebAuthnAssertResponse;
import io.fusionauth.domain.api.WebAuthnCredentialImportRequest;
import io.fusionauth.domain.api.WebAuthnCredentialResponse;
import io.fusionauth.domain.api.WebAuthnLoginRequest;
import io.fusionauth.domain.api.WebAuthnRegisterCompleteRequest;
import io.fusionauth.domain.api.WebAuthnRegisterCompleteResponse;
import io.fusionauth.domain.api.WebAuthnRegisterStartRequest;
import io.fusionauth.domain.api.WebAuthnRegisterStartResponse;
import io.fusionauth.domain.api.WebAuthnStartRequest;
import io.fusionauth.domain.api.WebAuthnStartResponse;
import io.fusionauth.domain.api.WebhookRequest;
import io.fusionauth.domain.api.WebhookResponse;
import io.fusionauth.domain.api.WebhookSearchRequest;
import io.fusionauth.domain.api.WebhookSearchResponse;
import io.fusionauth.domain.api.email.SendRequest;
import io.fusionauth.domain.api.email.SendResponse;
import io.fusionauth.domain.api.identityProvider.IdentityProviderLinkRequest;
import io.fusionauth.domain.api.identityProvider.IdentityProviderLinkResponse;
import io.fusionauth.domain.api.identityProvider.IdentityProviderLoginRequest;
import io.fusionauth.domain.api.identityProvider.IdentityProviderPendingLinkResponse;
import io.fusionauth.domain.api.identityProvider.IdentityProviderStartLoginRequest;
import io.fusionauth.domain.api.identityProvider.IdentityProviderStartLoginResponse;
import io.fusionauth.domain.api.identityProvider.LookupResponse;
import io.fusionauth.domain.api.jwt.IssueResponse;
import io.fusionauth.domain.api.jwt.JWTRefreshResponse;
import io.fusionauth.domain.api.jwt.JWTVendRequest;
import io.fusionauth.domain.api.jwt.JWTVendResponse;
import io.fusionauth.domain.api.jwt.RefreshRequest;
import io.fusionauth.domain.api.jwt.RefreshTokenResponse;
import io.fusionauth.domain.api.jwt.RefreshTokenRevokeRequest;
import io.fusionauth.domain.api.jwt.ValidateResponse;
import io.fusionauth.domain.api.passwordless.PasswordlessLoginRequest;
import io.fusionauth.domain.api.passwordless.PasswordlessSendRequest;
import io.fusionauth.domain.api.passwordless.PasswordlessStartRequest;
import io.fusionauth.domain.api.passwordless.PasswordlessStartResponse;
import io.fusionauth.domain.api.report.DailyActiveUserReportResponse;
import io.fusionauth.domain.api.report.LoginReportResponse;
import io.fusionauth.domain.api.report.MonthlyActiveUserReportResponse;
import io.fusionauth.domain.api.report.RegistrationReportResponse;
import io.fusionauth.domain.api.report.TotalsReportResponse;
import io.fusionauth.domain.api.twoFactor.SecretResponse;
import io.fusionauth.domain.api.twoFactor.TwoFactorLoginRequest;
import io.fusionauth.domain.api.twoFactor.TwoFactorSendRequest;
import io.fusionauth.domain.api.twoFactor.TwoFactorStartRequest;
import io.fusionauth.domain.api.twoFactor.TwoFactorStartResponse;
import io.fusionauth.domain.api.twoFactor.TwoFactorStatusResponse;
import io.fusionauth.domain.api.user.ActionRequest;
import io.fusionauth.domain.api.user.ActionResponse;
import io.fusionauth.domain.api.user.ChangePasswordRequest;
import io.fusionauth.domain.api.user.ChangePasswordResponse;
import io.fusionauth.domain.api.user.ForgotPasswordRequest;
import io.fusionauth.domain.api.user.ForgotPasswordResponse;
import io.fusionauth.domain.api.user.ImportRequest;
import io.fusionauth.domain.api.user.RecentLoginResponse;
import io.fusionauth.domain.api.user.RefreshTokenImportRequest;
import io.fusionauth.domain.api.user.RegistrationDeleteRequest;
import io.fusionauth.domain.api.user.RegistrationRequest;
import io.fusionauth.domain.api.user.RegistrationResponse;
import io.fusionauth.domain.api.user.SearchRequest;
import io.fusionauth.domain.api.user.SearchResponse;
import io.fusionauth.domain.api.user.VerifyEmailRequest;
import io.fusionauth.domain.api.user.VerifyEmailResponse;
import io.fusionauth.domain.api.user.VerifyRegistrationRequest;
import io.fusionauth.domain.api.user.VerifyRegistrationResponse;
import io.fusionauth.domain.oauth2.AccessToken;
import io.fusionauth.domain.oauth2.DeviceApprovalResponse;
import io.fusionauth.domain.oauth2.IntrospectResponse;
import io.fusionauth.domain.oauth2.JWKSResponse;
import io.fusionauth.domain.oauth2.OAuthError;
import io.fusionauth.domain.oauth2.UserinfoResponse;
import io.fusionauth.domain.provider.IdentityProviderType;
/**
* Client that connects to a FusionAuth server and provides access to the full set of FusionAuth APIs.
*
* When any method is called the return value is always a ClientResponse object. When an API call was successful, the
* response will contain the response from the server. This might be empty or contain an success object or an error
* object. If there was a validation error or any other type of error, this will return the Errors object in the
* response. Additionally, if FusionAuth could not be contacted because it is down or experiencing a failure, the response
* will contain an Exception, which could be an IOException.
*
* @author Brian Pontarelli
*/
@SuppressWarnings("unused")
public class FusionAuthClient {
public static String TENANT_ID_HEADER = "X-FusionAuth-TenantId";
public static final ObjectMapper objectMapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL)
.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false)
.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true)
.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, true)
.configure(DeserializationFeature.USE_BIG_INTEGER_FOR_INTS, true)
.registerModule(new JacksonModule());
private final String apiKey;
private final String baseURL;
private final ObjectMapper customMapper;
private final String tenantId;
public int connectTimeout;
public int readTimeout;
public FusionAuthClient(String apiKey, String baseURL) {
this(apiKey, baseURL, null);
}
public FusionAuthClient(String apiKey, String baseURL, String tenantId) {
this(apiKey, baseURL, 2000, 2000, tenantId);
}
public FusionAuthClient(String apiKey, String baseURL, int connectTimeout, int readTimeout) {
this(apiKey, baseURL, connectTimeout, readTimeout, null);
}
public FusionAuthClient(String apiKey, String baseURL, int connectTimeout, int readTimeout, String tenantId) {
this(apiKey, baseURL, connectTimeout, readTimeout, tenantId, null);
}
public FusionAuthClient(String apiKey, String baseURL, int connectTimeout, int readTimeout, String tenantId, ObjectMapper objectMapper) {
this.apiKey = apiKey;
this.baseURL = baseURL;
this.connectTimeout = connectTimeout;
this.readTimeout = readTimeout;
this.tenantId = tenantId;
this.customMapper = objectMapper;
}
/**
* Creates a new copy of this client with the provided tenant Id. When more than one tenant is configured in FusionAuth
* use this method to set the tenant Id prior to making API calls.
*
* When only one tenant is configured, or you have not configured tenants, setting the tenant is not necessary.
*
* @param tenantId The tenant Id
* @return the new FusionAuthClient
*/
public FusionAuthClient setTenantId(UUID tenantId) {
if (tenantId == null) {
return this;
}
return new FusionAuthClient(apiKey, baseURL, connectTimeout, readTimeout, tenantId.toString());
}
/**
* Creates a new copy of this client with the object mapper. This will take the place of the default FusionAuth object mapper when serializing
* and deserializing objects to and from JSON for the request and response bodies.
*
* @param objectMapper The object mapper
* @return the new FusionAuthClient
*/
public FusionAuthClient setObjectMapper(ObjectMapper objectMapper) {
return new FusionAuthClient(apiKey, baseURL, connectTimeout, readTimeout, tenantId, objectMapper);
}
/**
* 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 The action request that includes all the information about the action being taken including
* the Id of the action, any options and the duration (if applicable).
* @return The ClientResponse object.
*/
public ClientResponse actionUser(ActionRequest request) {
return start(ActionResponse.class, Errors.class)
.uri("/api/user/action")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Activates the FusionAuth Reactor using a license Id and optionally a license text (for air-gapped deployments)
*
* @param request An optional request that contains the license text to activate Reactor (useful for air-gap deployments of FusionAuth).
* @return The ClientResponse object.
*/
public ClientResponse activateReactor(ReactorRequest request) {
return start(Void.TYPE, Errors.class)
.uri("/api/reactor")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Adds a user to an existing family. The family Id must be specified.
*
* @param familyId The Id of the family.
* @param request The request object that contains all the information used to determine which user to add to the family.
* @return The ClientResponse object.
*/
public ClientResponse addUserToFamily(UUID familyId, FamilyRequest request) {
return start(FamilyResponse.class, Errors.class)
.uri("/api/user/family")
.urlSegment(familyId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.put()
.go();
}
/**
* Approve a device grant.
*
* @param client_id (Optional) The unique client identifier. The client Id is the Id of the FusionAuth Application in which you are attempting to authenticate.
* @param client_secret (Optional) The client secret. This value will be required if client authentication is enabled.
* @param token The access token used to identify the user.
* @param user_code The end-user verification code.
* @return The ClientResponse object.
*/
public ClientResponse approveDevice(String client_id, String client_secret, String token, String user_code) {
Map> parameters = new HashMap<>();
parameters.put("client_id", Arrays.asList(client_id));
parameters.put("client_secret", Arrays.asList(client_secret));
parameters.put("token", Arrays.asList(token));
parameters.put("user_code", Arrays.asList(user_code));
return start(DeviceApprovalResponse.class, Errors.class)
.uri("/oauth2/device/approve")
.bodyHandler(new FormDataBodyHandler(parameters))
.post()
.go();
}
/**
* Cancels the user action.
*
* @param actionId The action Id of the action to cancel.
* @param request The action request that contains the information about the cancellation.
* @return The ClientResponse object.
*/
public ClientResponse cancelAction(UUID actionId, ActionRequest request) {
return start(ActionResponse.class, Errors.class)
.uri("/api/user/action")
.urlSegment(actionId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.delete()
.go();
}
/**
* 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.
*
* As of version 1.32.2, prefer sending the changePasswordId in the request body. To do this, omit the first parameter, and set
* the value in the request body.
*
* @param changePasswordId 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 The change password request that contains all the information used to change the password.
* @return The ClientResponse object.
*/
public ClientResponse changePassword(String changePasswordId, ChangePasswordRequest request) {
return startAnonymous(ChangePasswordResponse.class, Errors.class)
.uri("/api/user/change-password")
.urlSegment(changePasswordId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Changes a user's password using their identity (loginId 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 The change password request that contains all the information used to change the password.
* @return The ClientResponse object.
*/
public ClientResponse changePasswordByIdentity(ChangePasswordRequest request) {
return start(Void.TYPE, Errors.class)
.uri("/api/user/change-password")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Check to see if the user must obtain a Trust Token Id in order to complete a change password request.
* When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
* your password, you must obtain a Trust Token by completing a Two-Factor Step-Up authentication.
*
* An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API.
*
* @param changePasswordId The change password Id used to find the user. This value is generated by FusionAuth once the change password workflow has been initiated.
* @return The ClientResponse object.
*/
public ClientResponse checkChangePasswordUsingId(String changePasswordId) {
return startAnonymous(Void.TYPE, Errors.class)
.uri("/api/user/change-password")
.urlSegment(changePasswordId)
.get()
.go();
}
/**
* Check to see if the user must obtain a Trust Token Id in order to complete a change password request.
* When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
* your password, you must obtain a Trust Token by completing a Two-Factor Step-Up authentication.
*
* An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API.
*
* @param encodedJWT The encoded JWT (access token).
* @return The ClientResponse object.
*/
public ClientResponse checkChangePasswordUsingJWT(String encodedJWT) {
return startAnonymous(Void.TYPE, Errors.class)
.uri("/api/user/change-password")
.authorization("Bearer " + encodedJWT)
.get()
.go();
}
/**
* Check to see if the user must obtain a Trust Request Id in order to complete a change password request.
* When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
* your password, you must obtain a Trust Request Id by completing a Two-Factor Step-Up authentication.
*
* An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API.
*
* @param loginId The loginId of the User that you intend to change the password for.
* @return The ClientResponse object.
*/
public ClientResponse checkChangePasswordUsingLoginId(String loginId) {
return start(Void.TYPE, Errors.class)
.uri("/api/user/change-password")
.urlParameter("username", loginId)
.get()
.go();
}
/**
* Make a Client Credentials grant request to obtain an access token.
*
* @param client_id (Optional) The client identifier. The client Id is the Id of the FusionAuth Entity in which you are attempting to authenticate.
* This parameter is optional when Basic Authorization is used to authenticate this request.
* @param client_secret (Optional) The client secret used to authenticate this request.
* This parameter is optional when Basic Authorization is used to authenticate this request.
* @param scope (Optional) This parameter is used to indicate which target entity you are requesting access. To request access to an entity, use the format target-entity:<target-entity-id>:<roles>. Roles are an optional comma separated list.
* @return The ClientResponse object.
*/
public ClientResponse clientCredentialsGrant(String client_id, String client_secret, String scope) {
Map> parameters = new HashMap<>();
parameters.put("client_id", Arrays.asList(client_id));
parameters.put("client_secret", Arrays.asList(client_secret));
parameters.put("grant_type", Arrays.asList("client_credentials"));
parameters.put("scope", Arrays.asList(scope));
return startAnonymous(AccessToken.class, OAuthError.class)
.uri("/oauth2/token")
.bodyHandler(new FormDataBodyHandler(parameters))
.post()
.go();
}
/**
* Adds a comment to the user's account.
*
* @param request The request object that contains all the information used to create the user comment.
* @return The ClientResponse object.
*/
public ClientResponse commentOnUser(UserCommentRequest request) {
return start(UserCommentResponse.class, Errors.class)
.uri("/api/user/comment")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Complete a WebAuthn authentication ceremony by validating the signature against the previously generated challenge without logging the user in
*
* @param request An object containing data necessary for completing the authentication ceremony
* @return The ClientResponse object.
*/
public ClientResponse completeWebAuthnAssertion(WebAuthnLoginRequest request) {
return startAnonymous(WebAuthnAssertResponse.class, Errors.class)
.uri("/api/webauthn/assert")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Complete a WebAuthn authentication ceremony by validating the signature against the previously generated challenge and then login the user in
*
* @param request An object containing data necessary for completing the authentication ceremony
* @return The ClientResponse object.
*/
public ClientResponse completeWebAuthnLogin(WebAuthnLoginRequest request) {
return startAnonymous(LoginResponse.class, Errors.class)
.uri("/api/webauthn/login")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Complete a WebAuthn registration ceremony by validating the client request and saving the new credential
*
* @param request An object containing data necessary for completing the registration ceremony
* @return The ClientResponse object.
*/
public ClientResponse completeWebAuthnRegistration(WebAuthnRegisterCompleteRequest request) {
return start(WebAuthnRegisterCompleteResponse.class, Errors.class)
.uri("/api/webauthn/register/complete")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates an API key. You can optionally specify a unique Id for the key, if not provided one will be generated.
* an API key can only be created with equal or lesser authority. An API key cannot create another API key unless it is granted
* to that API key.
*
* If an API key is locked to a tenant, it can only create API Keys for that same tenant.
*
* @param keyId (Optional) The unique Id of the API key. If not provided a secure random Id will be generated.
* @param request The request object that contains all the information needed to create the APIKey.
* @return The ClientResponse object.
*/
public ClientResponse createAPIKey(UUID keyId, APIKeyRequest request) {
return start(APIKeyResponse.class, Errors.class)
.uri("/api/api-key")
.urlSegment(keyId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates an application. You can optionally specify an Id for the application, if not provided one will be generated.
*
* @param applicationId (Optional) The Id to use for the application. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the application.
* @return The ClientResponse object.
*/
public ClientResponse createApplication(UUID applicationId, ApplicationRequest request) {
return start(ApplicationResponse.class, Errors.class)
.uri("/api/application")
.urlSegment(applicationId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* 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 applicationId The Id of the application to create the role on.
* @param roleId (Optional) The Id of the role. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the application role.
* @return The ClientResponse object.
*/
public ClientResponse createApplicationRole(UUID applicationId, UUID roleId, ApplicationRequest request) {
return start(ApplicationResponse.class, Errors.class)
.uri("/api/application")
.urlSegment(applicationId)
.urlSegment("role")
.urlSegment(roleId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* 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 The request object that contains all the information used to create the audit log entry.
* @return The ClientResponse object.
*/
public ClientResponse createAuditLog(AuditLogRequest request) {
return start(AuditLogResponse.class, Errors.class)
.uri("/api/system/audit-log")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates a connector. You can optionally specify an Id for the connector, if not provided one will be generated.
*
* @param connectorId (Optional) The Id for the connector. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the connector.
* @return The ClientResponse object.
*/
public ClientResponse createConnector(UUID connectorId, ConnectorRequest request) {
return start(ConnectorResponse.class, Errors.class)
.uri("/api/connector")
.urlSegment(connectorId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates a user consent type. You can optionally specify an Id for the consent type, if not provided one will be generated.
*
* @param consentId (Optional) The Id for the consent. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the consent.
* @return The ClientResponse object.
*/
public ClientResponse createConsent(UUID consentId, ConsentRequest request) {
return start(ConsentResponse.class, Errors.class)
.uri("/api/consent")
.urlSegment(consentId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates an email template. You can optionally specify an Id for the template, if not provided one will be generated.
*
* @param emailTemplateId (Optional) The Id for the template. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the email template.
* @return The ClientResponse object.
*/
public ClientResponse createEmailTemplate(UUID emailTemplateId, EmailTemplateRequest request) {
return start(EmailTemplateResponse.class, Errors.class)
.uri("/api/email/template")
.urlSegment(emailTemplateId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates an Entity. You can optionally specify an Id for the Entity. If not provided one will be generated.
*
* @param entityId (Optional) The Id for the Entity. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the Entity.
* @return The ClientResponse object.
*/
public ClientResponse createEntity(UUID entityId, EntityRequest request) {
return start(EntityResponse.class, Errors.class)
.uri("/api/entity")
.urlSegment(entityId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates a Entity Type. You can optionally specify an Id for the Entity Type, if not provided one will be generated.
*
* @param entityTypeId (Optional) The Id for the Entity Type. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the Entity Type.
* @return The ClientResponse object.
*/
public ClientResponse createEntityType(UUID entityTypeId, EntityTypeRequest request) {
return start(EntityTypeResponse.class, Errors.class)
.uri("/api/entity/type")
.urlSegment(entityTypeId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates a new permission for an entity type. You must specify the Id of the entity type you are creating the permission for.
* You can optionally specify an Id for the permission inside the EntityTypePermission object itself, if not provided one will be generated.
*
* @param entityTypeId The Id of the entity type to create the permission on.
* @param permissionId (Optional) The Id of the permission. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the permission.
* @return The ClientResponse object.
*/
public ClientResponse createEntityTypePermission(UUID entityTypeId, UUID permissionId, EntityTypeRequest request) {
return start(EntityTypeResponse.class, Errors.class)
.uri("/api/entity/type")
.urlSegment(entityTypeId)
.urlSegment("permission")
.urlSegment(permissionId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* 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 familyId (Optional) The Id for the family. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the family.
* @return The ClientResponse object.
*/
public ClientResponse createFamily(UUID familyId, FamilyRequest request) {
return start(FamilyResponse.class, Errors.class)
.uri("/api/user/family")
.urlSegment(familyId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates a form. You can optionally specify an Id for the form, if not provided one will be generated.
*
* @param formId (Optional) The Id for the form. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the form.
* @return The ClientResponse object.
*/
public ClientResponse createForm(UUID formId, FormRequest request) {
return start(FormResponse.class, Errors.class)
.uri("/api/form")
.urlSegment(formId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates a form field. You can optionally specify an Id for the form, if not provided one will be generated.
*
* @param fieldId (Optional) The Id for the form field. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the form field.
* @return The ClientResponse object.
*/
public ClientResponse createFormField(UUID fieldId, FormFieldRequest request) {
return start(FormFieldResponse.class, Errors.class)
.uri("/api/form/field")
.urlSegment(fieldId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates a group. You can optionally specify an Id for the group, if not provided one will be generated.
*
* @param groupId (Optional) The Id for the group. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the group.
* @return The ClientResponse object.
*/
public ClientResponse createGroup(UUID groupId, GroupRequest request) {
return start(GroupResponse.class, Errors.class)
.uri("/api/group")
.urlSegment(groupId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates a member in a group.
*
* @param request The request object that contains all the information used to create the group member(s).
* @return The ClientResponse object.
*/
public ClientResponse createGroupMembers(MemberRequest request) {
return start(MemberResponse.class, Errors.class)
.uri("/api/group/member")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates an IP Access Control List. You can optionally specify an Id on this create request, if one is not provided one will be generated.
*
* @param accessControlListId (Optional) The Id for the IP Access Control List. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the IP Access Control List.
* @return The ClientResponse object.
*/
public ClientResponse createIPAccessControlList(UUID accessControlListId, IPAccessControlListRequest request) {
return start(IPAccessControlListResponse.class, Errors.class)
.uri("/api/ip-acl")
.urlSegment(accessControlListId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates an identity provider. You can optionally specify an Id for the identity provider, if not provided one will be generated.
*
* @param identityProviderId (Optional) The Id of the identity provider. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the identity provider.
* @return The ClientResponse object.
*/
public ClientResponse createIdentityProvider(UUID identityProviderId, IdentityProviderRequest request) {
return start(IdentityProviderResponse.class, Errors.class)
.uri("/api/identity-provider")
.urlSegment(identityProviderId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates a Lambda. You can optionally specify an Id for the lambda, if not provided one will be generated.
*
* @param lambdaId (Optional) The Id for the lambda. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the lambda.
* @return The ClientResponse object.
*/
public ClientResponse createLambda(UUID lambdaId, LambdaRequest request) {
return start(LambdaResponse.class, Errors.class)
.uri("/api/lambda")
.urlSegment(lambdaId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates an message template. You can optionally specify an Id for the template, if not provided one will be generated.
*
* @param messageTemplateId (Optional) The Id for the template. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the message template.
* @return The ClientResponse object.
*/
public ClientResponse createMessageTemplate(UUID messageTemplateId, MessageTemplateRequest request) {
return start(MessageTemplateResponse.class, Errors.class)
.uri("/api/message/template")
.urlSegment(messageTemplateId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates a messenger. You can optionally specify an Id for the messenger, if not provided one will be generated.
*
* @param messengerId (Optional) The Id for the messenger. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the messenger.
* @return The ClientResponse object.
*/
public ClientResponse createMessenger(UUID messengerId, MessengerRequest request) {
return start(MessengerResponse.class, Errors.class)
.uri("/api/messenger")
.urlSegment(messengerId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates a new custom OAuth scope for an application. You must specify the Id of the application you are creating the scope for.
* You can optionally specify an Id for the OAuth scope on the URL, if not provided one will be generated.
*
* @param applicationId The Id of the application to create the OAuth scope on.
* @param scopeId (Optional) The Id of the OAuth scope. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the OAuth OAuth scope.
* @return The ClientResponse object.
*/
public ClientResponse createOAuthScope(UUID applicationId, UUID scopeId, ApplicationOAuthScopeRequest request) {
return start(ApplicationOAuthScopeResponse.class, Errors.class)
.uri("/api/application")
.urlSegment(applicationId)
.urlSegment("scope")
.urlSegment(scopeId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates a tenant. You can optionally specify an Id for the tenant, if not provided one will be generated.
*
* @param tenantId (Optional) The Id for the tenant. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the tenant.
* @return The ClientResponse object.
*/
public ClientResponse createTenant(UUID tenantId, TenantRequest request) {
return start(TenantResponse.class, Errors.class)
.uri("/api/tenant")
.urlSegment(tenantId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates a Theme. You can optionally specify an Id for the theme, if not provided one will be generated.
*
* @param themeId (Optional) The Id for the theme. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the theme.
* @return The ClientResponse object.
*/
public ClientResponse createTheme(UUID themeId, ThemeRequest request) {
return start(ThemeResponse.class, Errors.class)
.uri("/api/theme")
.urlSegment(themeId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates a user. You can optionally specify an Id for the user, if not provided one will be generated.
*
* @param userId (Optional) The Id for the user. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the user.
* @return The ClientResponse object.
*/
public ClientResponse createUser(UUID userId, UserRequest request) {
return start(UserResponse.class, Errors.class)
.uri("/api/user")
.urlSegment(userId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* 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 userActionId (Optional) The Id for the user action. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the user action.
* @return The ClientResponse object.
*/
public ClientResponse createUserAction(UUID userActionId, UserActionRequest request) {
return start(UserActionResponse.class, Errors.class)
.uri("/api/user-action")
.urlSegment(userActionId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* 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 userActionReasonId (Optional) The Id for the user action reason. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the user action reason.
* @return The ClientResponse object.
*/
public ClientResponse createUserActionReason(UUID userActionReasonId, UserActionReasonRequest request) {
return start(UserActionReasonResponse.class, Errors.class)
.uri("/api/user-action-reason")
.urlSegment(userActionReasonId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates a single User consent.
*
* @param userConsentId (Optional) The Id for the User consent. If not provided a secure random UUID will be generated.
* @param request The request that contains the user consent information.
* @return The ClientResponse object.
*/
public ClientResponse createUserConsent(UUID userConsentId, UserConsentRequest request) {
return start(UserConsentResponse.class, Errors.class)
.uri("/api/user/consent")
.urlSegment(userConsentId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Link an external user from a 3rd party identity provider to a FusionAuth user.
*
* @param request The request object that contains all the information used to link the FusionAuth user.
* @return The ClientResponse object.
*/
public ClientResponse createUserLink(IdentityProviderLinkRequest request) {
return start(IdentityProviderLinkResponse.class, Errors.class)
.uri("/api/identity-provider/link")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Creates a webhook. You can optionally specify an Id for the webhook, if not provided one will be generated.
*
* @param webhookId (Optional) The Id for the webhook. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the webhook.
* @return The ClientResponse object.
*/
public ClientResponse createWebhook(UUID webhookId, WebhookRequest request) {
return start(WebhookResponse.class, Errors.class)
.uri("/api/webhook")
.urlSegment(webhookId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Deactivates the application with the given Id.
*
* @param applicationId The Id of the application to deactivate.
* @return The ClientResponse object.
*/
public ClientResponse deactivateApplication(UUID applicationId) {
return start(Void.TYPE, Errors.class)
.uri("/api/application")
.urlSegment(applicationId)
.delete()
.go();
}
/**
* Deactivates the FusionAuth Reactor.
*
* @return The ClientResponse object.
*/
public ClientResponse deactivateReactor() {
return start(Void.TYPE, Void.TYPE)
.uri("/api/reactor")
.delete()
.go();
}
/**
* Deactivates the user with the given Id.
*
* @param userId The Id of the user to deactivate.
* @return The ClientResponse object.
*/
public ClientResponse deactivateUser(UUID userId) {
return start(Void.TYPE, Errors.class)
.uri("/api/user")
.urlSegment(userId)
.delete()
.go();
}
/**
* Deactivates the user action with the given Id.
*
* @param userActionId The Id of the user action to deactivate.
* @return The ClientResponse object.
*/
public ClientResponse deactivateUserAction(UUID userActionId) {
return start(Void.TYPE, Errors.class)
.uri("/api/user-action")
.urlSegment(userActionId)
.delete()
.go();
}
/**
* Deactivates the users with the given ids.
*
* @param userIds The ids of the users to deactivate.
* @return The ClientResponse object.
* @deprecated This method has been renamed to deactivateUsersByIds, use that method instead.
*/
@Deprecated
public ClientResponse deactivateUsers(Collection userIds) {
return start(UserDeleteResponse.class, Errors.class)
.uri("/api/user/bulk")
.urlParameter("userId", userIds)
.urlParameter("dryRun", false)
.urlParameter("hardDelete", false)
.delete()
.go();
}
/**
* Deactivates the users with the given ids.
*
* @param userIds The ids of the users to deactivate.
* @return The ClientResponse object.
*/
public ClientResponse deactivateUsersByIds(Collection userIds) {
return start(UserDeleteResponse.class, Errors.class)
.uri("/api/user/bulk")
.urlParameter("userId", userIds)
.urlParameter("dryRun", false)
.urlParameter("hardDelete", false)
.delete()
.go();
}
/**
* Deletes the API key for the given Id.
*
* @param keyId The Id of the authentication API key to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteAPIKey(UUID keyId) {
return start(Void.TYPE, Errors.class)
.uri("/api/api-key")
.urlSegment(keyId)
.delete()
.go();
}
/**
* 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 applicationId The Id of the application to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteApplication(UUID applicationId) {
return start(Void.TYPE, Errors.class)
.uri("/api/application")
.urlSegment(applicationId)
.urlParameter("hardDelete", true)
.delete()
.go();
}
/**
* 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 applicationId The Id of the application that the role belongs to.
* @param roleId The Id of the role to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteApplicationRole(UUID applicationId, UUID roleId) {
return start(Void.TYPE, Errors.class)
.uri("/api/application")
.urlSegment(applicationId)
.urlSegment("role")
.urlSegment(roleId)
.delete()
.go();
}
/**
* Deletes the connector for the given Id.
*
* @param connectorId The Id of the connector to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteConnector(UUID connectorId) {
return start(Void.TYPE, Errors.class)
.uri("/api/connector")
.urlSegment(connectorId)
.delete()
.go();
}
/**
* Deletes the consent for the given Id.
*
* @param consentId The Id of the consent to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteConsent(UUID consentId) {
return start(Void.TYPE, Errors.class)
.uri("/api/consent")
.urlSegment(consentId)
.delete()
.go();
}
/**
* Deletes the email template for the given Id.
*
* @param emailTemplateId The Id of the email template to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteEmailTemplate(UUID emailTemplateId) {
return start(Void.TYPE, Errors.class)
.uri("/api/email/template")
.urlSegment(emailTemplateId)
.delete()
.go();
}
/**
* Deletes the Entity for the given Id.
*
* @param entityId The Id of the Entity to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteEntity(UUID entityId) {
return start(Void.TYPE, Errors.class)
.uri("/api/entity")
.urlSegment(entityId)
.delete()
.go();
}
/**
* Deletes an Entity Grant for the given User or Entity.
*
* @param entityId The Id of the Entity that the Entity Grant is being deleted for.
* @param recipientEntityId (Optional) The Id of the Entity that the Entity Grant is for.
* @param userId (Optional) The Id of the User that the Entity Grant is for.
* @return The ClientResponse object.
*/
public ClientResponse deleteEntityGrant(UUID entityId, UUID recipientEntityId, UUID userId) {
return start(Void.TYPE, Errors.class)
.uri("/api/entity")
.urlSegment(entityId)
.urlSegment("grant")
.urlParameter("recipientEntityId", recipientEntityId)
.urlParameter("userId", userId)
.delete()
.go();
}
/**
* Deletes the Entity Type for the given Id.
*
* @param entityTypeId The Id of the Entity Type to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteEntityType(UUID entityTypeId) {
return start(Void.TYPE, Errors.class)
.uri("/api/entity/type")
.urlSegment(entityTypeId)
.delete()
.go();
}
/**
* Hard deletes a permission. This is a dangerous operation and should not be used in most circumstances. This
* permanently removes the given permission from all grants that had it.
*
* @param entityTypeId The Id of the entityType the the permission belongs to.
* @param permissionId The Id of the permission to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteEntityTypePermission(UUID entityTypeId, UUID permissionId) {
return start(Void.TYPE, Errors.class)
.uri("/api/entity/type")
.urlSegment(entityTypeId)
.urlSegment("permission")
.urlSegment(permissionId)
.delete()
.go();
}
/**
* Deletes the form for the given Id.
*
* @param formId The Id of the form to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteForm(UUID formId) {
return start(Void.TYPE, Errors.class)
.uri("/api/form")
.urlSegment(formId)
.delete()
.go();
}
/**
* Deletes the form field for the given Id.
*
* @param fieldId The Id of the form field to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteFormField(UUID fieldId) {
return start(Void.TYPE, Errors.class)
.uri("/api/form/field")
.urlSegment(fieldId)
.delete()
.go();
}
/**
* Deletes the group for the given Id.
*
* @param groupId The Id of the group to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteGroup(UUID groupId) {
return start(Void.TYPE, Errors.class)
.uri("/api/group")
.urlSegment(groupId)
.delete()
.go();
}
/**
* Removes users as members of a group.
*
* @param request The member request that contains all the information used to remove members to the group.
* @return The ClientResponse object.
*/
public ClientResponse deleteGroupMembers(MemberDeleteRequest request) {
return start(Void.TYPE, Errors.class)
.uri("/api/group/member")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.delete()
.go();
}
/**
* Deletes the IP Access Control List for the given Id.
*
* @param ipAccessControlListId The Id of the IP Access Control List to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteIPAccessControlList(UUID ipAccessControlListId) {
return start(Void.TYPE, Errors.class)
.uri("/api/ip-acl")
.urlSegment(ipAccessControlListId)
.delete()
.go();
}
/**
* Deletes the identity provider for the given Id.
*
* @param identityProviderId The Id of the identity provider to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteIdentityProvider(UUID identityProviderId) {
return start(Void.TYPE, Errors.class)
.uri("/api/identity-provider")
.urlSegment(identityProviderId)
.delete()
.go();
}
/**
* Deletes the key for the given Id.
*
* @param keyId The Id of the key to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteKey(UUID keyId) {
return start(Void.TYPE, Errors.class)
.uri("/api/key")
.urlSegment(keyId)
.delete()
.go();
}
/**
* Deletes the lambda for the given Id.
*
* @param lambdaId The Id of the lambda to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteLambda(UUID lambdaId) {
return start(Void.TYPE, Errors.class)
.uri("/api/lambda")
.urlSegment(lambdaId)
.delete()
.go();
}
/**
* Deletes the message template for the given Id.
*
* @param messageTemplateId The Id of the message template to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteMessageTemplate(UUID messageTemplateId) {
return start(Void.TYPE, Errors.class)
.uri("/api/message/template")
.urlSegment(messageTemplateId)
.delete()
.go();
}
/**
* Deletes the messenger for the given Id.
*
* @param messengerId The Id of the messenger to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteMessenger(UUID messengerId) {
return start(Void.TYPE, Errors.class)
.uri("/api/messenger")
.urlSegment(messengerId)
.delete()
.go();
}
/**
* Hard deletes a custom OAuth scope.
* OAuth workflows that are still requesting the deleted OAuth scope may fail depending on the application's unknown scope policy.
*
* @param applicationId The Id of the application that the OAuth scope belongs to.
* @param scopeId The Id of the OAuth scope to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteOAuthScope(UUID applicationId, UUID scopeId) {
return start(Void.TYPE, Errors.class)
.uri("/api/application")
.urlSegment(applicationId)
.urlSegment("scope")
.urlSegment(scopeId)
.delete()
.go();
}
/**
* Deletes the user registration for the given user and application.
*
* @param userId The Id of the user whose registration is being deleted.
* @param applicationId The Id of the application to remove the registration for.
* @return The ClientResponse object.
*/
public ClientResponse deleteRegistration(UUID userId, UUID applicationId) {
return start(Void.TYPE, Errors.class)
.uri("/api/user/registration")
.urlSegment(userId)
.urlSegment(applicationId)
.delete()
.go();
}
/**
* Deletes the user registration for the given user and application along with the given JSON body that contains the event information.
*
* @param userId The Id of the user whose registration is being deleted.
* @param applicationId The Id of the application to remove the registration for.
* @param request The request body that contains the event information.
* @return The ClientResponse object.
*/
public ClientResponse deleteRegistrationWithRequest(UUID userId, UUID applicationId, RegistrationDeleteRequest request) {
return start(Void.TYPE, Errors.class)
.uri("/api/user/registration")
.urlSegment(userId)
.urlSegment(applicationId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.delete()
.go();
}
/**
* Deletes the tenant based on the given Id on the URL. This permanently deletes all information, metrics, reports and data associated
* with the tenant and everything under the tenant (applications, users, etc).
*
* @param tenantId The Id of the tenant to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteTenant(UUID tenantId) {
return start(Void.TYPE, Errors.class)
.uri("/api/tenant")
.urlSegment(tenantId)
.delete()
.go();
}
/**
* Deletes the tenant for the given Id asynchronously.
* This method is helpful if you do not want to wait for the delete operation to complete.
*
* @param tenantId The Id of the tenant to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteTenantAsync(UUID tenantId) {
return start(Void.TYPE, Errors.class)
.uri("/api/tenant")
.urlSegment(tenantId)
.urlParameter("async", true)
.delete()
.go();
}
/**
* Deletes the tenant based on the given request (sent to the API as JSON). This permanently deletes all information, metrics, reports and data associated
* with the tenant and everything under the tenant (applications, users, etc).
*
* @param tenantId The Id of the tenant to delete.
* @param request The request object that contains all the information used to delete the user.
* @return The ClientResponse object.
*/
public ClientResponse deleteTenantWithRequest(UUID tenantId, TenantDeleteRequest request) {
return start(Void.TYPE, Errors.class)
.uri("/api/tenant")
.urlSegment(tenantId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.delete()
.go();
}
/**
* Deletes the theme for the given Id.
*
* @param themeId The Id of the theme to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteTheme(UUID themeId) {
return start(Void.TYPE, Errors.class)
.uri("/api/theme")
.urlSegment(themeId)
.delete()
.go();
}
/**
* Deletes the user for the given Id. This permanently deletes all information, metrics, reports and data associated
* with the user.
*
* @param userId The Id of the user to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteUser(UUID userId) {
return start(Void.TYPE, Errors.class)
.uri("/api/user")
.urlSegment(userId)
.urlParameter("hardDelete", true)
.delete()
.go();
}
/**
* 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 userActionId The Id of the user action to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteUserAction(UUID userActionId) {
return start(Void.TYPE, Errors.class)
.uri("/api/user-action")
.urlSegment(userActionId)
.urlParameter("hardDelete", true)
.delete()
.go();
}
/**
* Deletes the user action reason for the given Id.
*
* @param userActionReasonId The Id of the user action reason to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteUserActionReason(UUID userActionReasonId) {
return start(Void.TYPE, Errors.class)
.uri("/api/user-action-reason")
.urlSegment(userActionReasonId)
.delete()
.go();
}
/**
* Remove an existing link that has been made from a 3rd party identity provider to a FusionAuth user.
*
* @param identityProviderId The unique Id of the identity provider.
* @param identityProviderUserId The unique Id of the user in the 3rd party identity provider to unlink.
* @param userId The unique Id of the FusionAuth user to unlink.
* @return The ClientResponse object.
*/
public ClientResponse deleteUserLink(UUID identityProviderId, String identityProviderUserId, UUID userId) {
return start(IdentityProviderLinkResponse.class, Errors.class)
.uri("/api/identity-provider/link")
.urlParameter("identityProviderId", identityProviderId)
.urlParameter("identityProviderUserId", identityProviderUserId)
.urlParameter("userId", userId)
.delete()
.go();
}
/**
* Deletes the user based on the given request (sent to the API as JSON). This permanently deletes all information, metrics, reports and data associated
* with the user.
*
* @param userId The Id of the user to delete (required).
* @param request The request object that contains all the information used to delete the user.
* @return The ClientResponse object.
*/
public ClientResponse deleteUserWithRequest(UUID userId, UserDeleteSingleRequest request) {
return start(Void.TYPE, Errors.class)
.uri("/api/user")
.urlSegment(userId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.delete()
.go();
}
/**
* 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 The UserDeleteRequest.
* @return The ClientResponse object.
* @deprecated This method has been renamed to deleteUsersByQuery, use that method instead.
*/
@Deprecated
public ClientResponse deleteUsers(UserDeleteRequest request) {
return start(UserDeleteResponse.class, Errors.class)
.uri("/api/user/bulk")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.delete()
.go();
}
/**
* 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 The UserDeleteRequest.
* @return The ClientResponse object.
*/
public ClientResponse deleteUsersByQuery(UserDeleteRequest request) {
return start(UserDeleteResponse.class, Errors.class)
.uri("/api/user/bulk")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.delete()
.go();
}
/**
* Deletes the WebAuthn credential for the given Id.
*
* @param id The Id of the WebAuthn credential to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteWebAuthnCredential(UUID id) {
return start(Void.TYPE, Errors.class)
.uri("/api/webauthn")
.urlSegment(id)
.delete()
.go();
}
/**
* Deletes the webhook for the given Id.
*
* @param webhookId The Id of the webhook to delete.
* @return The ClientResponse object.
*/
public ClientResponse deleteWebhook(UUID webhookId) {
return start(Void.TYPE, Errors.class)
.uri("/api/webhook")
.urlSegment(webhookId)
.delete()
.go();
}
/**
* Disable two-factor authentication for a user.
*
* @param userId The Id of the User for which you're disabling two-factor authentication.
* @param methodId The two-factor method identifier you wish to disable
* @param code The two-factor code used verify the the caller knows the two-factor secret.
* @return The ClientResponse object.
*/
public ClientResponse disableTwoFactor(UUID userId, String methodId, String code) {
return start(Void.TYPE, Errors.class)
.uri("/api/user/two-factor")
.urlSegment(userId)
.urlParameter("methodId", methodId)
.urlParameter("code", code)
.delete()
.go();
}
/**
* Disable two-factor authentication for a user using a JSON body rather than URL parameters.
*
* @param userId The Id of the User for which you're disabling two-factor authentication.
* @param request The request information that contains the code and methodId along with any event information.
* @return The ClientResponse object.
*/
public ClientResponse disableTwoFactorWithRequest(UUID userId, TwoFactorDisableRequest request) {
return start(Void.TYPE, Errors.class)
.uri("/api/user/two-factor")
.urlSegment(userId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.delete()
.go();
}
/**
* Enable two-factor authentication for a user.
*
* @param userId The Id of the user to enable two-factor authentication.
* @param request The two-factor enable request information.
* @return The ClientResponse object.
*/
public ClientResponse enableTwoFactor(UUID userId, TwoFactorRequest request) {
return start(TwoFactorResponse.class, Errors.class)
.uri("/api/user/two-factor")
.urlSegment(userId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Exchanges an OAuth authorization code for an access token.
* Makes a request to the Token endpoint to exchange the authorization code returned from the Authorize endpoint for an access token.
*
* @param code The authorization code returned on the /oauth2/authorize response.
* @param client_id (Optional) The unique client identifier. The client Id is the Id of the FusionAuth Application in which you are attempting to authenticate.
* This parameter is optional when Basic Authorization is used to authenticate this request.
* @param client_secret (Optional) The client secret. This value will be required if client authentication is enabled.
* @param redirect_uri The URI to redirect to upon a successful request.
* @return The ClientResponse object.
*/
public ClientResponse exchangeOAuthCodeForAccessToken(String code, String client_id, String client_secret, String redirect_uri) {
Map> parameters = new HashMap<>();
parameters.put("code", Arrays.asList(code));
parameters.put("client_id", Arrays.asList(client_id));
parameters.put("client_secret", Arrays.asList(client_secret));
parameters.put("grant_type", Arrays.asList("authorization_code"));
parameters.put("redirect_uri", Arrays.asList(redirect_uri));
return startAnonymous(AccessToken.class, OAuthError.class)
.uri("/oauth2/token")
.bodyHandler(new FormDataBodyHandler(parameters))
.post()
.go();
}
/**
* Exchanges an OAuth authorization code and code_verifier for an access token.
* Makes a request to the Token endpoint to exchange the authorization code returned from the Authorize endpoint and a code_verifier for an access token.
*
* @param code The authorization code returned on the /oauth2/authorize response.
* @param client_id (Optional) The unique client identifier. The client Id is the Id of the FusionAuth Application in which you are attempting to authenticate. This parameter is optional when the Authorization header is provided.
* This parameter is optional when Basic Authorization is used to authenticate this request.
* @param client_secret (Optional) The client secret. This value may optionally be provided in the request body instead of the Authorization header.
* @param redirect_uri The URI to redirect to upon a successful request.
* @param code_verifier The random string generated previously. Will be compared with the code_challenge sent previously, which allows the OAuth provider to authenticate your app.
* @return The ClientResponse object.
*/
public ClientResponse exchangeOAuthCodeForAccessTokenUsingPKCE(String code, String client_id, String client_secret, String redirect_uri, String code_verifier) {
Map> parameters = new HashMap<>();
parameters.put("code", Arrays.asList(code));
parameters.put("client_id", Arrays.asList(client_id));
parameters.put("client_secret", Arrays.asList(client_secret));
parameters.put("grant_type", Arrays.asList("authorization_code"));
parameters.put("redirect_uri", Arrays.asList(redirect_uri));
parameters.put("code_verifier", Arrays.asList(code_verifier));
return startAnonymous(AccessToken.class, OAuthError.class)
.uri("/oauth2/token")
.bodyHandler(new FormDataBodyHandler(parameters))
.post()
.go();
}
/**
* 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 The refresh token that you would like to use to exchange for an access token.
* @param client_id (Optional) The unique client identifier. The client Id is the Id of the FusionAuth Application in which you are attempting to authenticate. This parameter is optional when the Authorization header is provided.
* This parameter is optional when Basic Authorization is used to authenticate this request.
* @param client_secret (Optional) The client secret. This value may optionally be provided in the request body instead of the Authorization header.
* @param scope (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 (Optional) The end-user verification code. This code is required if using this endpoint to approve the Device Authorization.
* @return The ClientResponse object.
*/
public ClientResponse exchangeRefreshTokenForAccessToken(String refresh_token, String client_id, String client_secret, String scope, String user_code) {
Map> parameters = new HashMap<>();
parameters.put("refresh_token", Arrays.asList(refresh_token));
parameters.put("client_id", Arrays.asList(client_id));
parameters.put("client_secret", Arrays.asList(client_secret));
parameters.put("grant_type", Arrays.asList("refresh_token"));
parameters.put("scope", Arrays.asList(scope));
parameters.put("user_code", Arrays.asList(user_code));
return startAnonymous(AccessToken.class, OAuthError.class)
.uri("/oauth2/token")
.bodyHandler(new FormDataBodyHandler(parameters))
.post()
.go();
}
/**
* Exchange a refresh token for a new JWT.
*
* @param request The refresh request.
* @return The ClientResponse object.
*/
public ClientResponse exchangeRefreshTokenForJWT(RefreshRequest request) {
return startAnonymous(JWTRefreshResponse.class, Errors.class)
.uri("/api/jwt/refresh")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* 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 The login identifier of the user. The login identifier can be either the email or the username.
* @param password The user’s password.
* @param client_id (Optional) The unique client identifier. The client Id is the Id of the FusionAuth Application in which you are attempting to authenticate. This parameter is optional when the Authorization header is provided.
* This parameter is optional when Basic Authorization is used to authenticate this request.
* @param client_secret (Optional) The client secret. This value may optionally be provided in the request body instead of the Authorization header.
* @param scope (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 (Optional) The end-user verification code. This code is required if using this endpoint to approve the Device Authorization.
* @return The ClientResponse object.
*/
public ClientResponse exchangeUserCredentialsForAccessToken(String username, String password, String client_id, String client_secret, String scope, String user_code) {
Map> parameters = new HashMap<>();
parameters.put("username", Arrays.asList(username));
parameters.put("password", Arrays.asList(password));
parameters.put("client_id", Arrays.asList(client_id));
parameters.put("client_secret", Arrays.asList(client_secret));
parameters.put("grant_type", Arrays.asList("password"));
parameters.put("scope", Arrays.asList(scope));
parameters.put("user_code", Arrays.asList(user_code));
return startAnonymous(AccessToken.class, OAuthError.class)
.uri("/oauth2/token")
.bodyHandler(new FormDataBodyHandler(parameters))
.post()
.go();
}
/**
* Begins the forgot password sequence, which kicks off an email to the user so that they can reset their password.
*
* @param request The request that contains the information about the user so that they can be emailed.
* @return The ClientResponse object.
*/
public ClientResponse forgotPassword(ForgotPasswordRequest request) {
return start(ForgotPasswordResponse.class, Errors.class)
.uri("/api/user/forgot-password")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* 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 The email address of the user that needs a new verification email.
* @return The ClientResponse object.
*/
public ClientResponse generateEmailVerificationId(String email) {
return start(VerifyEmailResponse.class, Void.TYPE)
.uri("/api/user/verify-email")
.urlParameter("email", email)
.urlParameter("sendVerifyEmail", false)
.put()
.go();
}
/**
* Generate a new RSA or EC key pair or an HMAC secret.
*
* @param keyId (Optional) The Id for the key. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the key.
* @return The ClientResponse object.
*/
public ClientResponse generateKey(UUID keyId, KeyRequest request) {
return start(KeyResponse.class, Errors.class)
.uri("/api/key/generate")
.urlSegment(keyId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* 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 The email address of the user that needs a new verification email.
* @param applicationId The Id of the application to be verified.
* @return The ClientResponse object.
*/
public ClientResponse generateRegistrationVerificationId(String email, UUID applicationId) {
return start(VerifyRegistrationResponse.class, Void.TYPE)
.uri("/api/user/verify-registration")
.urlParameter("email", email)
.urlParameter("sendVerifyPasswordEmail", false)
.urlParameter("applicationId", applicationId)
.put()
.go();
}
/**
* Generate two-factor recovery codes for a user. Generating two-factor recovery codes will invalidate any existing recovery codes.
*
* @param userId The Id of the user to generate new Two Factor recovery codes.
* @return The ClientResponse object.
*/
public ClientResponse generateTwoFactorRecoveryCodes(UUID userId) {
return start(TwoFactorRecoveryCodeResponse.class, Errors.class)
.uri("/api/user/two-factor/recovery-code")
.urlSegment(userId)
.post()
.go();
}
/**
* 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 The ClientResponse object.
*/
public ClientResponse generateTwoFactorSecret() {
return start(SecretResponse.class, Void.TYPE)
.uri("/api/two-factor/secret")
.get()
.go();
}
/**
* 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 encodedJWT The encoded JWT (access token).
* @return The ClientResponse object.
*/
public ClientResponse generateTwoFactorSecretUsingJWT(String encodedJWT) {
return startAnonymous(SecretResponse.class, Void.TYPE)
.uri("/api/two-factor/secret")
.authorization("Bearer " + encodedJWT)
.get()
.go();
}
/**
* Handles login via third-parties including Social login, external OAuth and OpenID Connect, and other
* login systems.
*
* @param request The third-party login request that contains information from the third-party login
* providers that FusionAuth uses to reconcile the user's account.
* @return The ClientResponse object.
*/
public ClientResponse identityProviderLogin(IdentityProviderLoginRequest request) {
return startAnonymous(LoginResponse.class, Errors.class)
.uri("/api/identity-provider/login")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Import an existing RSA or EC key pair or an HMAC secret.
*
* @param keyId (Optional) The Id for the key. If not provided a secure random UUID will be generated.
* @param request The request object that contains all the information used to create the key.
* @return The ClientResponse object.
*/
public ClientResponse importKey(UUID keyId, KeyRequest request) {
return start(KeyResponse.class, Errors.class)
.uri("/api/key/import")
.urlSegment(keyId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* 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 The request that contains all the information about all the refresh tokens to import.
* @return The ClientResponse object.
*/
public ClientResponse importRefreshTokens(RefreshTokenImportRequest request) {
return start(Void.TYPE, Errors.class)
.uri("/api/user/refresh-token/import")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* 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 The request that contains all the information about all the users to import.
* @return The ClientResponse object.
*/
public ClientResponse importUsers(ImportRequest request) {
return start(Void.TYPE, Errors.class)
.uri("/api/user/import")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Import a WebAuthn credential
*
* @param request An object containing data necessary for importing the credential
* @return The ClientResponse object.
*/
public ClientResponse importWebAuthnCredential(WebAuthnCredentialImportRequest request) {
return start(Void.TYPE, Errors.class)
.uri("/api/webauthn/import")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Inspect an access token issued as the result of the User based grant such as the Authorization Code Grant, Implicit Grant, the User Credentials Grant or the Refresh Grant.
*
* @param client_id The unique client identifier. The client Id is the Id of the FusionAuth Application for which this token was generated.
* @param token The access token returned by this OAuth provider as the result of a successful client credentials grant.
* @return The ClientResponse object.
*/
public ClientResponse introspectAccessToken(String client_id, String token) {
Map> parameters = new HashMap<>();
parameters.put("client_id", Arrays.asList(client_id));
parameters.put("token", Arrays.asList(token));
return startAnonymous(IntrospectResponse.class, OAuthError.class)
.uri("/oauth2/introspect")
.bodyHandler(new FormDataBodyHandler(parameters))
.post()
.go();
}
/**
* Inspect an access token issued as the result of the Client Credentials Grant.
*
* @param token The access token returned by this OAuth provider as the result of a successful client credentials grant.
* @return The ClientResponse object.
*/
public ClientResponse introspectClientCredentialsAccessToken(String token) {
Map> parameters = new HashMap<>();
parameters.put("token", Arrays.asList(token));
return startAnonymous(IntrospectResponse.class, OAuthError.class)
.uri("/oauth2/introspect")
.bodyHandler(new FormDataBodyHandler(parameters))
.post()
.go();
}
/**
* 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 applicationId The Application Id for which you are requesting a new access token be issued.
* @param encodedJWT The encoded JWT (access token).
* @param refreshToken (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 The ClientResponse object.
*/
public ClientResponse issueJWT(UUID applicationId, String encodedJWT, String refreshToken) {
return startAnonymous(IssueResponse.class, Errors.class)
.uri("/api/jwt/issue")
.authorization("Bearer " + encodedJWT)
.urlParameter("applicationId", applicationId)
.urlParameter("refreshToken", refreshToken)
.get()
.go();
}
/**
* Authenticates a user to FusionAuth.
*
* This API optionally requires an API key. See Application.loginConfiguration.requireAuthentication
.
*
* @param request The login request that contains the user credentials used to log them in.
* @return The ClientResponse object.
*/
public ClientResponse login(LoginRequest request) {
return start(LoginResponse.class, Errors.class)
.uri("/api/login")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* 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 userId The Id of the user that was logged in.
* @param applicationId The Id of the application that they logged into.
* @param callerIPAddress (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 The ClientResponse object.
*/
public ClientResponse loginPing(UUID userId, UUID applicationId, String callerIPAddress) {
return start(LoginResponse.class, Errors.class)
.uri("/api/login")
.urlSegment(userId)
.urlSegment(applicationId)
.urlParameter("ipAddress", callerIPAddress)
.put()
.go();
}
/**
* 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 request The login request that contains the user credentials used to log them in.
* @return The ClientResponse object.
*/
public ClientResponse loginPingWithRequest(LoginPingRequest request) {
return start(LoginResponse.class, Errors.class)
.uri("/api/login")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.put()
.go();
}
/**
* 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 When this value is set to true all the refresh tokens issued to the owner of the
* provided token will be revoked.
* @param refreshToken (Optional) The refresh_token as a request parameter instead of coming in via a cookie.
* If provided this takes precedence over the cookie.
* @return The ClientResponse object.
*/
public ClientResponse logout(boolean global, String refreshToken) {
return startAnonymous(Void.TYPE, Void.TYPE)
.uri("/api/logout")
.urlParameter("global", global)
.urlParameter("refreshToken", refreshToken)
.post()
.go();
}
/**
* 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 takes the refresh token in the JSON body.
*
* @param request The request object that contains all the information used to logout the user.
* @return The ClientResponse object.
*/
public ClientResponse logoutWithRequest(LogoutRequest request) {
return startAnonymous(Void.TYPE, Void.TYPE)
.uri("/api/logout")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* 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 The domain or email address to lookup.
* @return The ClientResponse object.
*/
public ClientResponse lookupIdentityProvider(String domain) {
return start(LookupResponse.class, Void.TYPE)
.uri("/api/identity-provider/lookup")
.urlParameter("domain", domain)
.get()
.go();
}
/**
* Modifies a temporal user action by changing the expiration of the action and optionally adding a comment to the
* action.
*
* @param actionId The Id of the action to modify. This is technically the user action log id.
* @param request The request that contains all the information about the modification.
* @return The ClientResponse object.
*/
public ClientResponse modifyAction(UUID actionId, ActionRequest request) {
return start(ActionResponse.class, Errors.class)
.uri("/api/user/action")
.urlSegment(actionId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.put()
.go();
}
/**
* Complete a login request using a passwordless code
*
* @param request The passwordless login request that contains all the information used to complete login.
* @return The ClientResponse object.
*/
public ClientResponse passwordlessLogin(PasswordlessLoginRequest request) {
return startAnonymous(LoginResponse.class, Errors.class)
.uri("/api/passwordless/login")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Updates an authentication API key by given id
*
* @param keyId The Id of the authentication key. If not provided a secure random api key will be generated.
* @param request The request object that contains all the information needed to create the APIKey.
* @return The ClientResponse object.
*/
public ClientResponse patchAPIKey(UUID keyId, APIKeyRequest request) {
return start(APIKeyResponse.class, Errors.class)
.uri("/api/api-key")
.urlSegment(keyId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Updates, via PATCH, the application with the given Id.
*
* @param applicationId The Id of the application to update.
* @param request The request that contains just the new application information.
* @return The ClientResponse object.
*/
public ClientResponse patchApplication(UUID applicationId, Map request) {
return start(ApplicationResponse.class, Errors.class)
.uri("/api/application")
.urlSegment(applicationId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, the application role with the given Id for the application.
*
* @param applicationId The Id of the application that the role belongs to.
* @param roleId The Id of the role to update.
* @param request The request that contains just the new role information.
* @return The ClientResponse object.
*/
public ClientResponse patchApplicationRole(UUID applicationId, UUID roleId, Map request) {
return start(ApplicationResponse.class, Errors.class)
.uri("/api/application")
.urlSegment(applicationId)
.urlSegment("role")
.urlSegment(roleId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, the connector with the given Id.
*
* @param connectorId The Id of the connector to update.
* @param request The request that contains just the new connector information.
* @return The ClientResponse object.
*/
public ClientResponse patchConnector(UUID connectorId, Map request) {
return start(ConnectorResponse.class, Errors.class)
.uri("/api/connector")
.urlSegment(connectorId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, the consent with the given Id.
*
* @param consentId The Id of the consent to update.
* @param request The request that contains just the new consent information.
* @return The ClientResponse object.
*/
public ClientResponse patchConsent(UUID consentId, Map request) {
return start(ConsentResponse.class, Errors.class)
.uri("/api/consent")
.urlSegment(consentId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, the email template with the given Id.
*
* @param emailTemplateId The Id of the email template to update.
* @param request The request that contains just the new email template information.
* @return The ClientResponse object.
*/
public ClientResponse patchEmailTemplate(UUID emailTemplateId, Map request) {
return start(EmailTemplateResponse.class, Errors.class)
.uri("/api/email/template")
.urlSegment(emailTemplateId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, the Entity Type with the given Id.
*
* @param entityTypeId The Id of the Entity Type to update.
* @param request The request that contains just the new Entity Type information.
* @return The ClientResponse object.
*/
public ClientResponse patchEntityType(UUID entityTypeId, Map request) {
return start(EntityTypeResponse.class, Errors.class)
.uri("/api/entity/type")
.urlSegment(entityTypeId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, the group with the given Id.
*
* @param groupId The Id of the group to update.
* @param request The request that contains just the new group information.
* @return The ClientResponse object.
*/
public ClientResponse patchGroup(UUID groupId, Map request) {
return start(GroupResponse.class, Errors.class)
.uri("/api/group")
.urlSegment(groupId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, the identity provider with the given Id.
*
* @param identityProviderId The Id of the identity provider to update.
* @param request The request object that contains just the updated identity provider information.
* @return The ClientResponse object.
*/
public ClientResponse patchIdentityProvider(UUID identityProviderId, Map request) {
return start(IdentityProviderResponse.class, Errors.class)
.uri("/api/identity-provider")
.urlSegment(identityProviderId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, the available integrations.
*
* @param request The request that contains just the new integration information.
* @return The ClientResponse object.
*/
public ClientResponse patchIntegrations(Map request) {
return start(IntegrationResponse.class, Errors.class)
.uri("/api/integration")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, the lambda with the given Id.
*
* @param lambdaId The Id of the lambda to update.
* @param request The request that contains just the new lambda information.
* @return The ClientResponse object.
*/
public ClientResponse patchLambda(UUID lambdaId, Map request) {
return start(LambdaResponse.class, Errors.class)
.uri("/api/lambda")
.urlSegment(lambdaId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, the message template with the given Id.
*
* @param messageTemplateId The Id of the message template to update.
* @param request The request that contains just the new message template information.
* @return The ClientResponse object.
*/
public ClientResponse patchMessageTemplate(UUID messageTemplateId, Map request) {
return start(MessageTemplateResponse.class, Errors.class)
.uri("/api/message/template")
.urlSegment(messageTemplateId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, the messenger with the given Id.
*
* @param messengerId The Id of the messenger to update.
* @param request The request that contains just the new messenger information.
* @return The ClientResponse object.
*/
public ClientResponse patchMessenger(UUID messengerId, Map request) {
return start(MessengerResponse.class, Errors.class)
.uri("/api/messenger")
.urlSegment(messengerId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, the custom OAuth scope with the given Id for the application.
*
* @param applicationId The Id of the application that the OAuth scope belongs to.
* @param scopeId The Id of the OAuth scope to update.
* @param request The request that contains just the new OAuth scope information.
* @return The ClientResponse object.
*/
public ClientResponse patchOAuthScope(UUID applicationId, UUID scopeId, Map request) {
return start(ApplicationOAuthScopeResponse.class, Errors.class)
.uri("/api/application")
.urlSegment(applicationId)
.urlSegment("scope")
.urlSegment(scopeId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, the registration for the user with the given Id and the application defined in the request.
*
* @param userId The Id of the user whose registration is going to be updated.
* @param request The request that contains just the new registration information.
* @return The ClientResponse object.
*/
public ClientResponse patchRegistration(UUID userId, Map request) {
return start(RegistrationResponse.class, Errors.class)
.uri("/api/user/registration")
.urlSegment(userId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, the system configuration.
*
* @param request The request that contains just the new system configuration information.
* @return The ClientResponse object.
*/
public ClientResponse patchSystemConfiguration(Map request) {
return start(SystemConfigurationResponse.class, Errors.class)
.uri("/api/system-configuration")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, the tenant with the given Id.
*
* @param tenantId The Id of the tenant to update.
* @param request The request that contains just the new tenant information.
* @return The ClientResponse object.
*/
public ClientResponse patchTenant(UUID tenantId, Map request) {
return start(TenantResponse.class, Errors.class)
.uri("/api/tenant")
.urlSegment(tenantId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, the theme with the given Id.
*
* @param themeId The Id of the theme to update.
* @param request The request that contains just the new theme information.
* @return The ClientResponse object.
*/
public ClientResponse patchTheme(UUID themeId, Map request) {
return start(ThemeResponse.class, Errors.class)
.uri("/api/theme")
.urlSegment(themeId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, the user with the given Id.
*
* @param userId The Id of the user to update.
* @param request The request that contains just the new user information.
* @return The ClientResponse object.
*/
public ClientResponse patchUser(UUID userId, Map request) {
return start(UserResponse.class, Errors.class)
.uri("/api/user")
.urlSegment(userId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, the user action with the given Id.
*
* @param userActionId The Id of the user action to update.
* @param request The request that contains just the new user action information.
* @return The ClientResponse object.
*/
public ClientResponse patchUserAction(UUID userActionId, Map request) {
return start(UserActionResponse.class, Errors.class)
.uri("/api/user-action")
.urlSegment(userActionId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, the user action reason with the given Id.
*
* @param userActionReasonId The Id of the user action reason to update.
* @param request The request that contains just the new user action reason information.
* @return The ClientResponse object.
*/
public ClientResponse patchUserActionReason(UUID userActionReasonId, Map request) {
return start(UserActionReasonResponse.class, Errors.class)
.uri("/api/user-action-reason")
.urlSegment(userActionReasonId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Updates, via PATCH, a single User consent by Id.
*
* @param userConsentId The User Consent Id
* @param request The request that contains just the new user consent information.
* @return The ClientResponse object.
*/
public ClientResponse patchUserConsent(UUID userConsentId, Map request) {
return start(UserConsentResponse.class, Errors.class)
.uri("/api/user/consent")
.urlSegment(userConsentId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.patch()
.go();
}
/**
* Reactivates the application with the given Id.
*
* @param applicationId The Id of the application to reactivate.
* @return The ClientResponse object.
*/
public ClientResponse reactivateApplication(UUID applicationId) {
return start(ApplicationResponse.class, Errors.class)
.uri("/api/application")
.urlSegment(applicationId)
.urlParameter("reactivate", true)
.put()
.go();
}
/**
* Reactivates the user with the given Id.
*
* @param userId The Id of the user to reactivate.
* @return The ClientResponse object.
*/
public ClientResponse reactivateUser(UUID userId) {
return start(UserResponse.class, Errors.class)
.uri("/api/user")
.urlSegment(userId)
.urlParameter("reactivate", true)
.put()
.go();
}
/**
* Reactivates the user action with the given Id.
*
* @param userActionId The Id of the user action to reactivate.
* @return The ClientResponse object.
*/
public ClientResponse reactivateUserAction(UUID userActionId) {
return start(UserActionResponse.class, Errors.class)
.uri("/api/user-action")
.urlSegment(userActionId)
.urlParameter("reactivate", true)
.put()
.go();
}
/**
* Reconcile a User to FusionAuth using JWT issued from another Identity Provider.
*
* @param request The reconcile request that contains the data to reconcile the User.
* @return The ClientResponse object.
*/
public ClientResponse reconcileJWT(IdentityProviderLoginRequest request) {
return startAnonymous(LoginResponse.class, Errors.class)
.uri("/api/jwt/reconcile")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Request a refresh of the Entity 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 Entity 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 The ClientResponse object.
*/
public ClientResponse refreshEntitySearchIndex() {
return start(Void.TYPE, Void.TYPE)
.uri("/api/entity/search")
.put()
.go();
}
/**
* 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 The ClientResponse object.
*/
public ClientResponse refreshUserSearchIndex() {
return start(Void.TYPE, Void.TYPE)
.uri("/api/user/search")
.put()
.go();
}
/**
* Regenerates any keys that are used by the FusionAuth Reactor.
*
* @return The ClientResponse object.
*/
public ClientResponse regenerateReactorKeys() {
return start(Void.TYPE, Void.TYPE)
.uri("/api/reactor")
.put()
.go();
}
/**
* 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 userId (Optional) The Id of the user being registered for the application and optionally created.
* @param request The request that optionally contains the User and must contain the UserRegistration.
* @return The ClientResponse object.
*/
public ClientResponse register(UUID userId, RegistrationRequest request) {
return start(RegistrationResponse.class, Errors.class)
.uri("/api/user/registration")
.urlSegment(userId)
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Requests Elasticsearch to delete and rebuild the index for FusionAuth users or entities. Be very careful when running this request as it will
* increase the CPU and I/O load on your database until the operation completes. Generally speaking you do not ever need to run this operation unless
* instructed by FusionAuth support, or if you are migrating a database another system and you are not brining along the Elasticsearch index.
*
* You have been warned.
*
* @param request The request that contains the index name.
* @return The ClientResponse object.
*/
public ClientResponse reindex(ReindexRequest request) {
return start(Void.TYPE, Errors.class)
.uri("/api/system/reindex")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Removes a user from the family with the given id.
*
* @param familyId The Id of the family to remove the user from.
* @param userId The Id of the user to remove from the family.
* @return The ClientResponse object.
*/
public ClientResponse removeUserFromFamily(UUID familyId, UUID userId) {
return start(Void.TYPE, Errors.class)
.uri("/api/user/family")
.urlSegment(familyId)
.urlSegment(userId)
.delete()
.go();
}
/**
* Re-sends the verification email to the user.
*
* @param email The email address of the user that needs a new verification email.
* @return The ClientResponse object.
*/
public ClientResponse resendEmailVerification(String email) {
return start(VerifyEmailResponse.class, Errors.class)
.uri("/api/user/verify-email")
.urlParameter("email", email)
.put()
.go();
}
/**
* 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 applicationId The unique Application Id to used to resolve an application specific email template.
* @param email The email address of the user that needs a new verification email.
* @return The ClientResponse object.
*/
public ClientResponse resendEmailVerificationWithApplicationTemplate(UUID applicationId, String email) {
return start(VerifyEmailResponse.class, Errors.class)
.uri("/api/user/verify-email")
.urlParameter("applicationId", applicationId)
.urlParameter("email", email)
.put()
.go();
}
/**
* Re-sends the application registration verification email to the user.
*
* @param email The email address of the user that needs a new verification email.
* @param applicationId The Id of the application to be verified.
* @return The ClientResponse object.
*/
public ClientResponse resendRegistrationVerification(String email, UUID applicationId) {
return start(VerifyRegistrationResponse.class, Errors.class)
.uri("/api/user/verify-registration")
.urlParameter("email", email)
.urlParameter("applicationId", applicationId)
.put()
.go();
}
/**
* Retrieves an authentication API key for the given id
*
* @param keyId The Id of the API key to retrieve.
* @return The ClientResponse object.
*/
public ClientResponse retrieveAPIKey(UUID keyId) {
return start(APIKeyResponse.class, Errors.class)
.uri("/api/api-key")
.urlSegment(keyId)
.get()
.go();
}
/**
* Retrieves a single action log (the log of a user action that was taken on a user previously) for the given Id.
*
* @param actionId The Id of the action to retrieve.
* @return The ClientResponse object.
*/
public ClientResponse retrieveAction(UUID actionId) {
return start(ActionResponse.class, Errors.class)
.uri("/api/user/action")
.urlSegment(actionId)
.get()
.go();
}
/**
* Retrieves all 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 userId The Id of the user to fetch the actions for.
* @return The ClientResponse object.
*/
public ClientResponse retrieveActions(UUID userId) {
return start(ActionResponse.class, Errors.class)
.uri("/api/user/action")
.urlParameter("userId", userId)
.get()
.go();
}
/**
* Retrieves all the actions for the user with the given Id that are currently preventing the User from logging in.
*
* @param userId The Id of the user to fetch the actions for.
* @return The ClientResponse object.
*/
public ClientResponse retrieveActionsPreventingLogin(UUID userId) {
return start(ActionResponse.class, Errors.class)
.uri("/api/user/action")
.urlParameter("userId", userId)
.urlParameter("preventingLogin", true)
.get()
.go();
}
/**
* Retrieves all 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 userId The Id of the user to fetch the actions for.
* @return The ClientResponse object.
*/
public ClientResponse retrieveActiveActions(UUID userId) {
return start(ActionResponse.class, Errors.class)
.uri("/api/user/action")
.urlParameter("userId", userId)
.urlParameter("active", true)
.get()
.go();
}
/**
* Retrieves the application for the given Id or all the applications if the Id is null.
*
* @param applicationId (Optional) The application id.
* @return The ClientResponse object.
*/
public ClientResponse retrieveApplication(UUID applicationId) {
return start(ApplicationResponse.class, Void.TYPE)
.uri("/api/application")
.urlSegment(applicationId)
.get()
.go();
}
/**
* Retrieves all the applications.
*
* @return The ClientResponse object.
*/
public ClientResponse retrieveApplications() {
return start(ApplicationResponse.class, Void.TYPE)
.uri("/api/application")
.get()
.go();
}
/**
* Retrieves a single audit log for the given Id.
*
* @param auditLogId The Id of the audit log to retrieve.
* @return The ClientResponse object.
*/
public ClientResponse retrieveAuditLog(Integer auditLogId) {
return start(AuditLogResponse.class, Errors.class)
.uri("/api/system/audit-log")
.urlSegment(auditLogId)
.get()
.go();
}
/**
* Retrieves the connector with the given Id.
*
* @param connectorId The Id of the connector.
* @return The ClientResponse object.
*/
public ClientResponse retrieveConnector(UUID connectorId) {
return start(ConnectorResponse.class, Void.TYPE)
.uri("/api/connector")
.urlSegment(connectorId)
.get()
.go();
}
/**
* Retrieves all the connectors.
*
* @return The ClientResponse object.
*/
public ClientResponse retrieveConnectors() {
return start(ConnectorResponse.class, Void.TYPE)
.uri("/api/connector")
.get()
.go();
}
/**
* Retrieves the Consent for the given Id.
*
* @param consentId The Id of the consent.
* @return The ClientResponse object.
*/
public ClientResponse retrieveConsent(UUID consentId) {
return start(ConsentResponse.class, Void.TYPE)
.uri("/api/consent")
.urlSegment(consentId)
.get()
.go();
}
/**
* Retrieves all the consent.
*
* @return The ClientResponse object.
*/
public ClientResponse retrieveConsents() {
return start(ConsentResponse.class, Void.TYPE)
.uri("/api/consent")
.get()
.go();
}
/**
* 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 applicationId (Optional) The application id.
* @param start The start instant as UTC milliseconds since Epoch.
* @param end The end instant as UTC milliseconds since Epoch.
* @return The ClientResponse object.
*/
public ClientResponse retrieveDailyActiveReport(UUID applicationId, long start, long end) {
return start(DailyActiveUserReportResponse.class, Errors.class)
.uri("/api/report/daily-active-user")
.urlParameter("applicationId", applicationId)
.urlParameter("start", start)
.urlParameter("end", end)
.get()
.go();
}
/**
* Retrieves the email template for the given Id. If you don't specify the id, this will return all the email templates.
*
* @param emailTemplateId (Optional) The Id of the email template.
* @return The ClientResponse object.
*/
public ClientResponse retrieveEmailTemplate(UUID emailTemplateId) {
return start(EmailTemplateResponse.class, Void.TYPE)
.uri("/api/email/template")
.urlSegment(emailTemplateId)
.get()
.go();
}
/**
* 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 The request that contains the email template and optionally a locale to render it in.
* @return The ClientResponse object.
*/
public ClientResponse retrieveEmailTemplatePreview(PreviewRequest request) {
return start(PreviewResponse.class, Errors.class)
.uri("/api/email/template/preview")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Retrieves all the email templates.
*
* @return The ClientResponse object.
*/
public ClientResponse retrieveEmailTemplates() {
return start(EmailTemplateResponse.class, Void.TYPE)
.uri("/api/email/template")
.get()
.go();
}
/**
* Retrieves the Entity for the given Id.
*
* @param entityId The Id of the Entity.
* @return The ClientResponse object.
*/
public ClientResponse retrieveEntity(UUID entityId) {
return start(EntityResponse.class, Errors.class)
.uri("/api/entity")
.urlSegment(entityId)
.get()
.go();
}
/**
* Retrieves an Entity Grant for the given Entity and User/Entity.
*
* @param entityId The Id of the Entity.
* @param recipientEntityId (Optional) The Id of the Entity that the Entity Grant is for.
* @param userId (Optional) The Id of the User that the Entity Grant is for.
* @return The ClientResponse object.
*/
public ClientResponse retrieveEntityGrant(UUID entityId, UUID recipientEntityId, UUID userId) {
return start(EntityGrantResponse.class, Errors.class)
.uri("/api/entity")
.urlSegment(entityId)
.urlSegment("grant")
.urlParameter("recipientEntityId", recipientEntityId)
.urlParameter("userId", userId)
.get()
.go();
}
/**
* Retrieves the Entity Type for the given Id.
*
* @param entityTypeId The Id of the Entity Type.
* @return The ClientResponse object.
*/
public ClientResponse retrieveEntityType(UUID entityTypeId) {
return start(EntityTypeResponse.class, Errors.class)
.uri("/api/entity/type")
.urlSegment(entityTypeId)
.get()
.go();
}
/**
* Retrieves all the Entity Types.
*
* @return The ClientResponse object.
*/
public ClientResponse retrieveEntityTypes() {
return start(EntityTypeResponse.class, Errors.class)
.uri("/api/entity/type")
.get()
.go();
}
/**
* Retrieves a single event log for the given Id.
*
* @param eventLogId The Id of the event log to retrieve.
* @return The ClientResponse object.
*/
public ClientResponse retrieveEventLog(Integer eventLogId) {
return start(EventLogResponse.class, Errors.class)
.uri("/api/system/event-log")
.urlSegment(eventLogId)
.get()
.go();
}
/**
* Retrieves all the families that a user belongs to.
*
* @param userId The User's id
* @return The ClientResponse object.
*/
public ClientResponse retrieveFamilies(UUID userId) {
return start(FamilyResponse.class, Void.TYPE)
.uri("/api/user/family")
.urlParameter("userId", userId)
.get()
.go();
}
/**
* Retrieves all the members of a family by the unique Family Id.
*
* @param familyId The unique Id of the Family.
* @return The ClientResponse object.
*/
public ClientResponse retrieveFamilyMembersByFamilyId(UUID familyId) {
return start(FamilyResponse.class, Void.TYPE)
.uri("/api/user/family")
.urlSegment(familyId)
.get()
.go();
}
/**
* Retrieves the form with the given Id.
*
* @param formId The Id of the form.
* @return The ClientResponse object.
*/
public ClientResponse retrieveForm(UUID formId) {
return start(FormResponse.class, Void.TYPE)
.uri("/api/form")
.urlSegment(formId)
.get()
.go();
}
/**
* Retrieves the form field with the given Id.
*
* @param fieldId The Id of the form field.
* @return The ClientResponse object.
*/
public ClientResponse retrieveFormField(UUID fieldId) {
return start(FormFieldResponse.class, Void.TYPE)
.uri("/api/form/field")
.urlSegment(fieldId)
.get()
.go();
}
/**
* Retrieves all the forms fields
*
* @return The ClientResponse object.
*/
public ClientResponse retrieveFormFields() {
return start(FormFieldResponse.class, Void.TYPE)
.uri("/api/form/field")
.get()
.go();
}
/**
* Retrieves all the forms.
*
* @return The ClientResponse object.
*/
public ClientResponse retrieveForms() {
return start(FormResponse.class, Void.TYPE)
.uri("/api/form")
.get()
.go();
}
/**
* Retrieves the group for the given Id.
*
* @param groupId The Id of the group.
* @return The ClientResponse object.
*/
public ClientResponse retrieveGroup(UUID groupId) {
return start(GroupResponse.class, Errors.class)
.uri("/api/group")
.urlSegment(groupId)
.get()
.go();
}
/**
* Retrieves all the groups.
*
* @return The ClientResponse object.
*/
public ClientResponse retrieveGroups() {
return start(GroupResponse.class, Void.TYPE)
.uri("/api/group")
.get()
.go();
}
/**
* Retrieves the IP Access Control List with the given Id.
*
* @param ipAccessControlListId The Id of the IP Access Control List.
* @return The ClientResponse object.
*/
public ClientResponse retrieveIPAccessControlList(UUID ipAccessControlListId) {
return start(IPAccessControlListResponse.class, Void.TYPE)
.uri("/api/ip-acl")
.urlSegment(ipAccessControlListId)
.get()
.go();
}
/**
* Retrieves the identity provider for the given Id or all the identity providers if the Id is null.
*
* @param identityProviderId The identity provider Id.
* @return The ClientResponse object.
*/
public ClientResponse retrieveIdentityProvider(UUID identityProviderId) {
return start(IdentityProviderResponse.class, Errors.class)
.uri("/api/identity-provider")
.urlSegment(identityProviderId)
.get()
.go();
}
/**
* Retrieves one or more identity provider for the given type. For types such as Google, Facebook, Twitter and LinkedIn, only a single
* identity provider can exist. For types such as OpenID Connect and SAMLv2 more than one identity provider can be configured so this request
* may return multiple identity providers.
*
* @param type The type of the identity provider.
* @return The ClientResponse object.
*/
public ClientResponse retrieveIdentityProviderByType(IdentityProviderType type) {
return start(IdentityProviderResponse.class, Errors.class)
.uri("/api/identity-provider")
.urlParameter("type", type)
.get()
.go();
}
/**
* Retrieves all the identity providers.
*
* @return The ClientResponse object.
*/
public ClientResponse retrieveIdentityProviders() {
return start(IdentityProviderResponse.class, Void.TYPE)
.uri("/api/identity-provider")
.get()
.go();
}
/**
* Retrieves all 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 userId The Id of the user to fetch the actions for.
* @return The ClientResponse object.
*/
public ClientResponse retrieveInactiveActions(UUID userId) {
return start(ActionResponse.class, Errors.class)
.uri("/api/user/action")
.urlParameter("userId", userId)
.urlParameter("active", false)
.get()
.go();
}
/**
* Retrieves all the applications that are currently inactive.
*
* @return The ClientResponse object.
*/
public ClientResponse retrieveInactiveApplications() {
return start(ApplicationResponse.class, Void.TYPE)
.uri("/api/application")
.urlParameter("inactive", true)
.get()
.go();
}
/**
* Retrieves all the user actions that are currently inactive.
*
* @return The ClientResponse object.
*/
public ClientResponse retrieveInactiveUserActions() {
return start(UserActionResponse.class, Void.TYPE)
.uri("/api/user-action")
.urlParameter("inactive", true)
.get()
.go();
}
/**
* Retrieves the available integrations.
*
* @return The ClientResponse object.
*/
public ClientResponse retrieveIntegration() {
return start(IntegrationResponse.class, Void.TYPE)
.uri("/api/integration")
.get()
.go();
}
/**
* Retrieves the Public Key configured for verifying JSON Web Tokens (JWT) by the key Id (kid).
*
* @param keyId The Id of the public key (kid).
* @return The ClientResponse object.
*/
public ClientResponse retrieveJWTPublicKey(String keyId) {
return startAnonymous(PublicKeyResponse.class, Void.TYPE)
.uri("/api/jwt/public-key")
.urlParameter("kid", keyId)
.get()
.go();
}
/**
* Retrieves the Public Key configured for verifying the JSON Web Tokens (JWT) issued by the Login API by the Application Id.
*
* @param applicationId The Id of the Application for which this key is used.
* @return The ClientResponse object.
*/
public ClientResponse retrieveJWTPublicKeyByApplicationId(String applicationId) {
return startAnonymous(PublicKeyResponse.class, Void.TYPE)
.uri("/api/jwt/public-key")
.urlParameter("applicationId", applicationId)
.get()
.go();
}
/**
* Retrieves all Public Keys configured for verifying JSON Web Tokens (JWT).
*
* @return The ClientResponse object.
*/
public ClientResponse retrieveJWTPublicKeys() {
return startAnonymous(PublicKeyResponse.class, Void.TYPE)
.uri("/api/jwt/public-key")
.get()
.go();
}
/**
* Returns public keys used by FusionAuth to cryptographically verify JWTs using the JSON Web Key format.
*
* @return The ClientResponse object.
*/
public ClientResponse retrieveJsonWebKeySet() {
return startAnonymous(JWKSResponse.class, Void.TYPE)
.uri("/.well-known/jwks.json")
.get()
.go();
}
/**
* Retrieves the key for the given Id.
*
* @param keyId The Id of the key.
* @return The ClientResponse object.
*/
public ClientResponse retrieveKey(UUID keyId) {
return start(KeyResponse.class, Errors.class)
.uri("/api/key")
.urlSegment(keyId)
.get()
.go();
}
/**
* Retrieves all the keys.
*
* @return The ClientResponse object.
*/
public ClientResponse retrieveKeys() {
return start(KeyResponse.class, Void.TYPE)
.uri("/api/key")
.get()
.go();
}
/**
* Retrieves the lambda for the given Id.
*
* @param lambdaId The Id of the lambda.
* @return The ClientResponse object.
*/
public ClientResponse retrieveLambda(UUID lambdaId) {
return start(LambdaResponse.class, Errors.class)
.uri("/api/lambda")
.urlSegment(lambdaId)
.get()
.go();
}
/**
* Retrieves all the lambdas.
*
* @return The ClientResponse object.
*/
public ClientResponse retrieveLambdas() {
return start(LambdaResponse.class, Void.TYPE)
.uri("/api/lambda")
.get()
.go();
}
/**
* Retrieves all the lambdas for the provided type.
*
* @param type The type of the lambda to return.
* @return The ClientResponse object.
*/
public ClientResponse retrieveLambdasByType(LambdaType type) {
return start(LambdaResponse.class, Void.TYPE)
.uri("/api/lambda")
.urlParameter("type", type)
.get()
.go();
}
/**
* 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 applicationId (Optional) The application id.
* @param start The start instant as UTC milliseconds since Epoch.
* @param end The end instant as UTC milliseconds since Epoch.
* @return The ClientResponse object.
*/
public ClientResponse retrieveLoginReport(UUID applicationId, long start, long end) {
return start(LoginReportResponse.class, Errors.class)
.uri("/api/report/login")
.urlParameter("applicationId", applicationId)
.urlParameter("start", start)
.urlParameter("end", end)
.get()
.go();
}
/**
* Retrieves the message template for the given Id. If you don't specify the id, this will return all the message templates.
*
* @param messageTemplateId (Optional) The Id of the message template.
* @return The ClientResponse object.
*/
public ClientResponse retrieveMessageTemplate(UUID messageTemplateId) {
return start(MessageTemplateResponse.class, Void.TYPE)
.uri("/api/message/template")
.urlSegment(messageTemplateId)
.get()
.go();
}
/**
* Creates a preview of the message template provided in the request, normalized to a given locale.
*
* @param request The request that contains the email template and optionally a locale to render it in.
* @return The ClientResponse object.
*/
public ClientResponse retrieveMessageTemplatePreview(PreviewMessageTemplateRequest request) {
return start(PreviewMessageTemplateResponse.class, Errors.class)
.uri("/api/message/template/preview")
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
.post()
.go();
}
/**
* Retrieves all the message templates.
*
* @return The ClientResponse object.
*/
public ClientResponse retrieveMessageTemplates() {
return start(MessageTemplateResponse.class, Void.TYPE)
.uri("/api/message/template")
.get()
.go();
}
/**
* Retrieves the messenger with the given Id.
*
* @param messengerId The Id of the messenger.
* @return The ClientResponse object.
*/
public ClientResponse retrieveMessenger(UUID messengerId) {
return start(MessengerResponse.class, Void.TYPE)
.uri("/api/messenger")
.urlSegment(messengerId)
.get()
.go();
}
/**
* Retrieves all the messengers.
*
* @return The ClientResponse object.
*/
public ClientResponse retrieveMessengers() {
return start(MessengerResponse.class, Void.TYPE)
.uri("/api/messenger")
.get()
.go();
}
/**
* 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 applicationId (Optional) The application id.
* @param start The start instant as UTC milliseconds since Epoch.
* @param end The end instant as UTC milliseconds since Epoch.
* @return The ClientResponse object.
*/
public ClientResponse retrieveMonthlyActiveReport(UUID applicationId, long start, long end) {
return start(MonthlyActiveUserReportResponse.class, Errors.class)
.uri("/api/report/monthly-active-user")
.urlParameter("applicationId", applicationId)
.urlParameter("start", start)
.urlParameter("end", end)
.get()
.go();
}
/**
* Retrieves a custom OAuth scope.
*
* @param applicationId The Id of the application that the OAuth scope belongs to.
* @param scopeId The Id of the OAuth scope to retrieve.
* @return The ClientResponse object.
*/
public ClientResponse retrieveOAuthScope(UUID applicationId, UUID scopeId) {
return start(ApplicationOAuthScopeResponse.class, Errors.class)
.uri("/api/application")
.urlSegment(applicationId)
.urlSegment("scope")
.urlSegment(scopeId)
.get()
.go();
}
/**
* Retrieves the Oauth2 configuration for the application for the given Application Id.
*
* @param applicationId The Id of the Application to retrieve OAuth configuration.
* @return The ClientResponse object.
*/
public ClientResponse retrieveOauthConfiguration(UUID applicationId) {
return start(OAuthConfigurationResponse.class, Errors.class)
.uri("/api/application")
.urlSegment(applicationId)
.urlSegment("oauth-configuration")
.get()
.go();
}
/**
* Returns the well known OpenID Configuration JSON document
*
* @return The ClientResponse object.
*/
public ClientResponse retrieveOpenIdConfiguration() {
return startAnonymous(OpenIdConfiguration.class, Void.TYPE)
.uri("/.well-known/openid-configuration")
.get()
.go();
}
/**
* 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.
*