
com.okta.sdk.resource.api.RoleAssignmentAUserApi Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of okta-sdk-api Show documentation
Show all versions of okta-sdk-api Show documentation
The Okta Java SDK API .jar provides a Java API that your code can use to make calls to the Okta
API. This .jar is the only compile-time dependency within the Okta SDK project that your code should
depend on. Implementations of this API (implementation .jars) should be runtime dependencies only.
/*
* Okta Admin Management
* Allows customers to easily access the Okta Management APIs
*
* The version of the OpenAPI document: 2024.08.3
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package com.okta.sdk.resource.api;
import com.fasterxml.jackson.core.type.TypeReference;
import com.okta.sdk.resource.client.ApiException;
import com.okta.sdk.resource.client.ApiClient;
import com.okta.sdk.resource.client.Configuration;
import com.okta.sdk.resource.model.*;
import com.okta.sdk.resource.client.Pair;
import com.okta.sdk.resource.model.AssignRoleToUser201Response;
import com.okta.sdk.resource.model.AssignRoleToUserRequest;
import com.okta.sdk.resource.model.Error;
import com.okta.sdk.resource.model.ListGroupAssignedRoles200ResponseInner;
import com.okta.sdk.resource.model.RoleAssignedUsers;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import org.openapitools.jackson.nullable.JsonNullableModule;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-11-15T08:48:47.130589-06:00[America/Chicago]", comments = "Generator version: 7.8.0")
public class RoleAssignmentAUserApi {
private ApiClient apiClient;
public RoleAssignmentAUserApi() {
this(Configuration.getDefaultApiClient());
}
public RoleAssignmentAUserApi(ApiClient apiClient) {
this.apiClient = apiClient;
}
public ApiClient getApiClient() {
return apiClient;
}
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* Assign a User Role Assigns a [standard role](/openapi/okta-management/guides/roles/#standard-roles) to a User.
* You can also assign a custom role to a User, but the preferred method to assign a custom role to a User is to
* create a binding between the Custom Role, the Resource Set, and the User. See [Create a Role Resource Set
* Binding](/openapi/okta-management/management/tag/RoleDResourceSetBinding/#tag/RoleDResourceSetBinding/operation/createResourceSetBinding).
* > **Notes:** > * The request payload is different for standard and custom role assignments. > * For
* IAM-based standard role assignments, use the request payload for standard roles. However, the response payload
* for IAM-based role assignments is similar to the custom role's assignment response.
*
* @param userId
* ID of an existing Okta user (required)
* @param assignRoleRequest
* (required)
* @param disableNotifications
* Setting this to `true` grants the User third-party admin status (optional, default to false)
*
* @return AssignRoleToUser201Response
*
* @throws ApiException
* if fails to make API call
*/
public AssignRoleToUser201Response assignRoleToUser(String userId, AssignRoleToUserRequest assignRoleRequest,
Boolean disableNotifications) throws ApiException {
return this.assignRoleToUser(userId, assignRoleRequest, disableNotifications, Collections.emptyMap());
}
/**
* Assign a User Role Assigns a [standard role](/openapi/okta-management/guides/roles/#standard-roles) to a User.
* You can also assign a custom role to a User, but the preferred method to assign a custom role to a User is to
* create a binding between the Custom Role, the Resource Set, and the User. See [Create a Role Resource Set
* Binding](/openapi/okta-management/management/tag/RoleDResourceSetBinding/#tag/RoleDResourceSetBinding/operation/createResourceSetBinding).
* > **Notes:** > * The request payload is different for standard and custom role assignments. > * For
* IAM-based standard role assignments, use the request payload for standard roles. However, the response payload
* for IAM-based role assignments is similar to the custom role's assignment response.
*
* @param userId
* ID of an existing Okta user (required)
* @param assignRoleRequest
* (required)
* @param disableNotifications
* Setting this to `true` grants the User third-party admin status (optional, default to false)
* @param additionalHeaders
* additionalHeaders for this call
*
* @return AssignRoleToUser201Response
*
* @throws ApiException
* if fails to make API call
*/
public AssignRoleToUser201Response assignRoleToUser(String userId, AssignRoleToUserRequest assignRoleRequest,
Boolean disableNotifications, Map additionalHeaders) throws ApiException {
Object localVarPostBody = assignRoleRequest;
// verify the required parameter 'userId' is set
if (userId == null) {
throw new ApiException(400, "Missing the required parameter 'userId' when calling assignRoleToUser");
}
// verify the required parameter 'assignRoleRequest' is set
if (assignRoleRequest == null) {
throw new ApiException(400,
"Missing the required parameter 'assignRoleRequest' when calling assignRoleToUser");
}
// create path and map variables
String localVarPath = "/api/v1/users/{userId}/roles".replaceAll("\\{" + "userId" + "\\}",
apiClient.escapeString(userId.toString()));
StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
List localVarQueryParams = new ArrayList();
List localVarCollectionQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarCookieParams = new HashMap();
Map localVarFormParams = new HashMap();
localVarQueryParams.addAll(apiClient.parameterToPair("disableNotifications", disableNotifications));
localVarHeaderParams.putAll(additionalHeaders);
final String[] localVarAccepts = { "application/json" };
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = { "application/json" };
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { "apiToken", "oauth2" };
TypeReference localVarReturnType = new TypeReference() {
};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams,
localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams,
localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}
/**
* Retrieve a User Role Assignment Retrieves a Role assigned to a User (identified by `userId`). The
* `roleAssignmentId` parameter is the unique identifier for either a standard Role Assignment object or a
* custom role Resource Set Binding object.
*
* @param userId
* ID of an existing Okta user (required)
* @param roleAssignmentId
* The `id` of the Role Assignment (required)
*
* @return ListGroupAssignedRoles200ResponseInner
*
* @throws ApiException
* if fails to make API call
*/
public ListGroupAssignedRoles200ResponseInner getUserAssignedRole(String userId, String roleAssignmentId)
throws ApiException {
return this.getUserAssignedRole(userId, roleAssignmentId, Collections.emptyMap());
}
/**
* Retrieve a User Role Assignment Retrieves a Role assigned to a User (identified by `userId`). The
* `roleAssignmentId` parameter is the unique identifier for either a standard Role Assignment object or a
* custom role Resource Set Binding object.
*
* @param userId
* ID of an existing Okta user (required)
* @param roleAssignmentId
* The `id` of the Role Assignment (required)
* @param additionalHeaders
* additionalHeaders for this call
*
* @return ListGroupAssignedRoles200ResponseInner
*
* @throws ApiException
* if fails to make API call
*/
public ListGroupAssignedRoles200ResponseInner getUserAssignedRole(String userId, String roleAssignmentId,
Map additionalHeaders) throws ApiException {
Object localVarPostBody = null;
// verify the required parameter 'userId' is set
if (userId == null) {
throw new ApiException(400, "Missing the required parameter 'userId' when calling getUserAssignedRole");
}
// verify the required parameter 'roleAssignmentId' is set
if (roleAssignmentId == null) {
throw new ApiException(400,
"Missing the required parameter 'roleAssignmentId' when calling getUserAssignedRole");
}
// create path and map variables
String localVarPath = "/api/v1/users/{userId}/roles/{roleAssignmentId}"
.replaceAll("\\{" + "userId" + "\\}", apiClient.escapeString(userId.toString()))
.replaceAll("\\{" + "roleAssignmentId" + "\\}", apiClient.escapeString(roleAssignmentId.toString()));
StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
List localVarQueryParams = new ArrayList();
List localVarCollectionQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarCookieParams = new HashMap();
Map localVarFormParams = new HashMap();
localVarHeaderParams.putAll(additionalHeaders);
final String[] localVarAccepts = { "application/json" };
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { "apiToken", "oauth2" };
TypeReference localVarReturnType = new TypeReference() {
};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams,
localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams,
localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}
/**
* List all User Role Assignments Lists all roles assigned to a User (identified by `userId`)
*
* @param userId
* ID of an existing Okta user (required)
* @param expand
* An optional parameter used to return targets configured for the standard Role Assignment in the
* `embedded` property. Supported values: `targets/groups` or
* `targets/catalog/apps` (optional)
*
* @return List<ListGroupAssignedRoles200ResponseInner>
*
* @throws ApiException
* if fails to make API call
*/
public List listAssignedRolesForUser(String userId, String expand)
throws ApiException {
return this.listAssignedRolesForUser(userId, expand, Collections.emptyMap());
}
/**
* List all User Role Assignments Lists all roles assigned to a User (identified by `userId`)
*
* @param userId
* ID of an existing Okta user (required)
* @param expand
* An optional parameter used to return targets configured for the standard Role Assignment in the
* `embedded` property. Supported values: `targets/groups` or
* `targets/catalog/apps` (optional)
* @param additionalHeaders
* additionalHeaders for this call
*
* @return List<ListGroupAssignedRoles200ResponseInner>
*
* @throws ApiException
* if fails to make API call
*/
public List listAssignedRolesForUser(String userId, String expand,
Map additionalHeaders) throws ApiException {
Object localVarPostBody = null;
// verify the required parameter 'userId' is set
if (userId == null) {
throw new ApiException(400,
"Missing the required parameter 'userId' when calling listAssignedRolesForUser");
}
// create path and map variables
String localVarPath = "/api/v1/users/{userId}/roles".replaceAll("\\{" + "userId" + "\\}",
apiClient.escapeString(userId.toString()));
StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
List localVarQueryParams = new ArrayList();
List localVarCollectionQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarCookieParams = new HashMap();
Map localVarFormParams = new HashMap();
localVarQueryParams.addAll(apiClient.parameterToPair("expand", expand));
localVarHeaderParams.putAll(additionalHeaders);
final String[] localVarAccepts = { "application/json" };
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { "apiToken", "oauth2" };
TypeReference> localVarReturnType = new TypeReference>() {
};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams,
localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams,
localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}
/**
* List all Users with Role Assignments Lists all users with Role Assignments
*
* @param after
* Specifies the pagination cursor for the next page of targets (optional)
* @param limit
* Specifies the number of results returned. Defaults to `100`. (optional, default to 100)
*
* @return RoleAssignedUsers
*
* @throws ApiException
* if fails to make API call
*/
public RoleAssignedUsers listUsersWithRoleAssignments(String after, Integer limit) throws ApiException {
return this.listUsersWithRoleAssignments(after, limit, Collections.emptyMap());
}
/**
* List all Users with Role Assignments Lists all users with Role Assignments
*
* @param after
* Specifies the pagination cursor for the next page of targets (optional)
* @param limit
* Specifies the number of results returned. Defaults to `100`. (optional, default to 100)
* @param additionalHeaders
* additionalHeaders for this call
*
* @return RoleAssignedUsers
*
* @throws ApiException
* if fails to make API call
*/
public RoleAssignedUsers listUsersWithRoleAssignments(String after, Integer limit,
Map additionalHeaders) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/api/v1/iam/assignees/users";
StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
List localVarQueryParams = new ArrayList();
List localVarCollectionQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarCookieParams = new HashMap();
Map localVarFormParams = new HashMap();
localVarQueryParams.addAll(apiClient.parameterToPair("after", after));
localVarQueryParams.addAll(apiClient.parameterToPair("limit", limit));
localVarHeaderParams.putAll(additionalHeaders);
final String[] localVarAccepts = { "application/json" };
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { "apiToken", "oauth2" };
TypeReference localVarReturnType = new TypeReference() {
};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams,
localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams,
localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}
/**
* Unassign a User Role Unassigns a Role Assignment (identified by `roleAssignmentId`) from a User
* (identified by `userId`)
*
* @param userId
* ID of an existing Okta user (required)
* @param roleAssignmentId
* The `id` of the Role Assignment (required)
*
* @throws ApiException
* if fails to make API call
*/
public void unassignRoleFromUser(String userId, String roleAssignmentId) throws ApiException {
this.unassignRoleFromUser(userId, roleAssignmentId, Collections.emptyMap());
}
/**
* Unassign a User Role Unassigns a Role Assignment (identified by `roleAssignmentId`) from a User
* (identified by `userId`)
*
* @param userId
* ID of an existing Okta user (required)
* @param roleAssignmentId
* The `id` of the Role Assignment (required)
* @param additionalHeaders
* additionalHeaders for this call
*
* @throws ApiException
* if fails to make API call
*/
public void unassignRoleFromUser(String userId, String roleAssignmentId, Map additionalHeaders)
throws ApiException {
Object localVarPostBody = null;
// verify the required parameter 'userId' is set
if (userId == null) {
throw new ApiException(400, "Missing the required parameter 'userId' when calling unassignRoleFromUser");
}
// verify the required parameter 'roleAssignmentId' is set
if (roleAssignmentId == null) {
throw new ApiException(400,
"Missing the required parameter 'roleAssignmentId' when calling unassignRoleFromUser");
}
// create path and map variables
String localVarPath = "/api/v1/users/{userId}/roles/{roleAssignmentId}"
.replaceAll("\\{" + "userId" + "\\}", apiClient.escapeString(userId.toString()))
.replaceAll("\\{" + "roleAssignmentId" + "\\}", apiClient.escapeString(roleAssignmentId.toString()));
StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
String localVarQueryParameterBaseName;
List localVarQueryParams = new ArrayList();
List localVarCollectionQueryParams = new ArrayList();
Map localVarHeaderParams = new HashMap();
Map localVarCookieParams = new HashMap();
Map localVarFormParams = new HashMap();
localVarHeaderParams.putAll(additionalHeaders);
final String[] localVarAccepts = { "application/json" };
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { "apiToken", "oauth2" };
apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams,
localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams,
localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
}
protected static ObjectMapper getObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
objectMapper.registerModule(new JsonNullableModule());
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
return objectMapper;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy