public class ObjectRecordRequest extends VaultRequest
The following properties can be set for a variety of input/output options to the request, leveraging builder pattern setters.
Example create request with input CSV file, receiving JSON response:
ObjectRecordResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.setContentTypeCsv()
.setInputPath(inputPath)
.createObjectRecords(objectName);The following endpoints are covered in other classes for ease of use
ObjectRecordAttachmentRequestMetaDataRequestMetaDataRequest| Modifier and Type | Class and Description |
|---|---|
static class |
ObjectRecordRequest.UnchangedFieldBehaviorType |
| Modifier and Type | Field and Description |
|---|---|
static String |
HTTP_HEADER_VAULT_MIGRATION_MODE
X-VaultAPI-MigrationMode Set to true to create object records in a specific state or state type.
|
static String |
HTTP_HEADER_VAULT_UNCHANGED_FIELD_BEHAVIOR
X-VaultAPI-UnchangedFieldBehavior
When upserting, set to IgnoreSetOnCreateOnly to ignore values given for the Object Type field and parent object fields
if the record already exists and the value has not changed.
|
static String |
ID_PARAM
If you’re identifying object records in your input by a unique field, add idParam={fieldname} to the request endpoint.
|
HTTP_HEADER_AUTHORIZATION, HTTP_HEADER_VAULT_CLIENT_ID, vaultClient| Modifier and Type | Method and Description |
|---|---|
ObjectRecordRoleChangeResponse |
assignUsersAndGroupsToRolesOnObjectRecords(String objectName)
Object Roles - Assign Users and Groups to Roles on Object Records
|
JobCreateResponse |
cascadeDeleteObjectRecord(String objectName,
String id)
Cascade Delete Object Record
|
ObjectRecordBulkResponse |
changeObjectType(String objectName)
Object Types - Change Object Type
|
ObjectRecordBulkResponse |
createObjectRecords(String objectName)
Create Object Records
|
JobCreateResponse |
deepCopyObjectRecord(String objectName,
String recordId)
Deep Copy Object Record
|
ObjectRecordBulkResponse |
deleteObjectRecords(String objectName)
Delete Object Records
|
VaultResponse |
getResultsOfCascadeDeleteJob(String objectName,
String jobStatus,
int jobId)
Get Results of Cascade Delete Job
|
VaultResponse |
getResultsOfDeepCopyJob(String objectName,
boolean success,
int jobId)
Get Results of Deep Copy Job
|
ObjectRecordRoleChangeResponse |
removeUsersAndGroupsFromRolesOnObjectRecords(String objectName)
Object Roles - Remove Users and Groups from Roles on Object Records
|
ObjectRecordDeletedResponse |
retrieveDeletedObjectRecordId(String objectName)
Retrieve Deleted Object Record ID
|
ObjectRecordTypeResponse |
retrieveDetailsFromAllObjectTypes()
Object Types - Retrieve Details from All Object Types
|
ObjectRecordTypeResponse |
retrieveDetailsFromASpecificObject(String objectName,
String objectType)
Object Types - Retrieve Details from a Specific Object
|
VaultResponse |
retrieveLimitsOnObjects()
Retrieve Limits on Objects
|
ObjectRecordResponse |
retrieveObjectRecord(String objectName,
String recordId)
Retrieve Object Record
|
ObjectRecordCollectionResponse |
retrieveObjectRecordCollection(String objectName)
Retrieve Object Record Collection
|
ObjectRecordRoleResponse |
retrieveObjectRecordRole(String objectName,
String id,
String roleName)
Object Roles - Retrieve Object Record Role (Filter to a specific role)
|
ObjectRecordRoleResponse |
retrieveObjectRecordRoles(String objectName,
String id)
Object Roles - Retrieve Object Record Roles
|
ObjectRecordRequest |
setAcceptCSV()
Set the Header Accept to return CSV
|
ObjectRecordRequest |
setBinaryFile(String filename,
byte[] binaryContent)
Specify source data in an input file
|
ObjectRecordRequest |
setBodyParams(Map<String,Object> bodyParams)
Single record form ObjectRecordRequest with name/value body parameters
|
ObjectRecordRequest |
setContentTypeCsv()
Set the Header Content Type to CSV
|
ObjectRecordRequest |
setContentTypeJson()
Set the Header Content Type to JSON
|
ObjectRecordRequest |
setEndDateDeleted(ZonedDateTime endDateDeleted)
Specify the start date when calling the deleted records endpoint
|
ObjectRecordRequest |
setIdParam(String idParam)
Specify an UPSERT operation via the idParam
|
ObjectRecordRequest |
setInputPath(String inputPath)
Specify source data in an input file
|
ObjectRecordRequest |
setMigrationMode(boolean migrationMode)
Enable migration mode to set the object record state.
|
ObjectRecordRequest |
setOutputPath(String outputPath)
Specify source data in an output file
|
ObjectRecordRequest |
setRequestString(String requestString)
Specify source data in an input string, such as a JSON request
|
ObjectRecordRequest |
setStartDateDeleted(ZonedDateTime startDateDeleted)
Specify the start date when calling the deleted records endpoint
|
ObjectRecordRequest |
setUnchangedFieldBehavior(ObjectRecordRequest.UnchangedFieldBehaviorType unchangedFieldBehavior)
When upserting, set to IgnoreSetOnCreateOnly (default starting with API v21.1)
to ignore values given for the Object Type field and parent object fields
if the record already exists and the value has not changed.
|
JobCreateResponse |
updateCorporateCurrencyFields(String objectName)
Update Corporate Currency Fields
|
ObjectRecordBulkResponse |
updateObjectRecords(String objectName)
Update Object Records
|
getBaseObjectMapper, send, send, sendReturnBinary, sendReturnBinary, sendToFile, sendToFile, setVaultClientpublic static final String HTTP_HEADER_VAULT_MIGRATION_MODE
public static final String HTTP_HEADER_VAULT_UNCHANGED_FIELD_BEHAVIOR
public static final String ID_PARAM
public ObjectRecordCollectionResponse retrieveObjectRecordCollection(String objectName)
Retrieve all records for a specific Vault Object.
objectName - The object name for the operation
GET /api/{version}/vobjects/{object_name}
ObjectRecordResponse response = vaultClient.newRequest(ObjectRecordRequest.class)
.retrieveObjectRecordCollection(objectName);System.out.println(resp.getResponse()); }
public ObjectRecordResponse retrieveObjectRecord(String objectName, String recordId)
Single record transaction - Retrieve metadata (and values) configured on a single/specific object record.
Use bulk for multiple records
objectName - The object name for the operationrecordId - The record id to get
GET /api/{version}/vobjects/{object_name}/{object_record_id}
ObjectRecordResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.retrieveObjectRecord(objectName, id);
System.out.println(resp.getResponse());
ObjectRecord objectRecord = resp.getData();
System.out.println("Id = " + objectRecord.getId());
System.out.println("Name = " + objectRecord.getName());
Map<String,Object> additionalFields = objectRecord.getProperties();
for (String name : additionalFields.keySet())
System.out.println(name + " = " + additionalFields.get(name));
for (String roleName : resp.getManuallyAssignedSharingRoles().keySet()) {
System.out.println("\nRole " + roleName);
Map<String,Object> role = (Map<String, Object>) resp.getManuallyAssignedSharingRoles().get(roleName);
List<Integer> groups = (List<Integer> ) role.get("groups");
List<Integer> users = (List<Integer> ) role.get("users");
if (groups != null) {
for (Integer groupId : groups)
System.out.println("Group = " + groupId);
}
if (users != null) {
for (Integer userId : users)
System.out.println("User = " + userId);
}
}
}public ObjectRecordBulkResponse createObjectRecords(String objectName)
Create Object Records in bulk based on the set properties of the class. The maximum batch size is 500 records. Note that it is up to the calling code to batch the data.
objectName - The object name for the operation
POST /api/{version}/vobjects/{object_name}
Example 1 - Source - CSV file, Response - JSON
ObjectRecordBulkResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.setContentTypeCsv()
.setInputPath(inputPath)
.createObjectRecords(objectName);,
Example 2 - Source - CSV file, Response - CSV
ObjectRecordBulkResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.setContentTypeCsv()
.setAcceptCSV()
.setInputPath(inputPath)
.createObjectRecords(objectName);,
Example 3 - Source - CSV file, Response - JSON, Upsert operation with idParam
ObjectRecordBulkResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.setContentTypeCsv()
.setIdParam(idParam)
.setInputPath(inputPath)
.createObjectRecords(objectName);,
Example 4 - Source - CSV file, Response - JSON, Migration Mode
ObjectRecordBulkResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.setContentTypeCsv()
.setMigrationMode(true)
.setInputPath(inputPath)
.createObjectRecords(objectName);,
Example 5 - Source - JSON string, Response - JSON
ObjectRecordBulkResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.setContentTypeJson()
.setRequestString(requestString)
.createObjectRecords(objectName);
System.out.println(resp.getResponse());
if (resp.hasErrors()) {
System.out.println("Errors exist");
if (resp.getErrors() != null) {
for (VaultResponse.APIResponseError e : resp.getErrors())
System.out.println("VaultResponse Error " + e.getMessage());
}
}
if (resp.getErrors() == null) {
for (ObjectRecordResponse objectRecordResponse : resp.getData()) {
System.out.println("Record successful? " + objectRecordResponse.isSuccessful());
if (objectRecordResponse.isSuccessful())
System.out.println(objectRecordResponse.getData().getId() + " " + objectRecordResponse.getData().getUrl());
if (objectRecordResponse.getErrors() != null) {
for (VaultResponse.APIResponseError error : objectRecordResponse.getErrors()) {
System.out.println("Error " + error.getType() + " " + error.getMessage());
}
}
}
}public ObjectRecordBulkResponse updateObjectRecords(String objectName)
Update Object Records in bulk based on the set properties of the class. The maximum batch size is 500 records. Note that it is up to the calling code to batch the data.
objectName - The object name for the operation
PUT /api/{version}/vobjects/{object_name}createObjectRecords(String) for example requests (replace "createObjectRecords" with "updateObjectRecords")createObjectRecords(String) for example responses (replace "createObjectRecords" with "updateObjectRecords")public ObjectRecordBulkResponse deleteObjectRecords(String objectName)
Bulk delete object records. The maximum batch size is 500. Note that it is up to the calling code to batch the data.
objectName - The object name for the operation
DELETE /api/{version}/vobjects/{object_name}
Example 1 - Source - CSV file, Response - JSON
ObjectRecordBulkResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.setContentTypeCsv()
.setInputPath(inputPath)
.deleteObjectRecords(objectName);,
Additional Requests
See createObjectRecords(String) for additional example requests (replace "createObjectRecords" with "deleteObjectRecords")createObjectRecords(String) for example responses (replace "createObjectRecords" with "deleteObjectRecords")public JobCreateResponse cascadeDeleteObjectRecord(String objectName, String id)
Submit a job to perform a cascade delete. The corresponding job id can be retrieved from the response via the "getJobId" method.
objectName - The object name for the operationid - The record id to delete
POST /api/{version}/vobjects/{object_name}/{object_record_id}/actions/cascadedelete
JobCreateResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.cascadeDeleteObjectRecord(objectName, id);
System.out.println(resp.getResponse());
System.out.println("Job Id = " + resp.getJobId());public VaultResponse getResultsOfCascadeDeleteJob(String objectName, String jobStatus, int jobId)
After submitting a request to deep copy an object record, query vault to determine the results of the request.
objectName - The object name for the operationjobStatus - "success" or "failure"jobId - The ID of the job, retrieved from the response of the job request
GET /api/{version}/vobjects/cascadedelete/results/{object_name}/{job_status}/{job_id}
VaultResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.getResultsOfCascadeDeleteJob(objectName, "success", jobId);System.out.println(new String(resp.getBinaryContent()));
public ObjectRecordTypeResponse retrieveDetailsFromAllObjectTypes()
GET /api/{version}/configuration/Objecttype
ObjectRecordTypeResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.retrieveDetailsFromAllObjectTypes();
for (ObjectRecordType rt : resp.getData()) {
System.out.println("Object " + rt.getObject() + " - " + rt.getName() + " - "+ rt.getLabel());
for (String s : rt.getAdditionalTypeValidations())
System.out.println("Validations " + s);
List<ObjectRecordTypeAction> actions = rt.getActions();
if (actions != null) {
for (ObjectRecordTypeAction action : rt.getActions())
System.out.println("Action " + action.getAction() + " - " + action.getName());
}
for (ObjectRecordTypeField fld : rt.getFields())
System.out.println("Field " + fld.getName() + " - " + fld.getSource() + " - " + fld.getRequired());
}public ObjectRecordTypeResponse retrieveDetailsFromASpecificObject(String objectName, String objectType)
List all object types and all fields configured on each object type for the specific object. Note that an array is returned with size one.
objectName - The object nameobjectType - The object type name
GET /api/{version}/configuration/Objecttype.{object_name}.{object_type}
ObjectRecordTypeResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.retrieveDetailsFromASpecificObject(objectName, objectType);retrieveDetailsFromAllObjectTypes()public ObjectRecordBulkResponse changeObjectType(String objectName)
Change the object type for the data supplied in localfile, binarydata, or raw json
objectName - The object name
POST /api/{version}/vobjects/{object_name}/actions/changetype
VaultResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.setContentTypeCsv()
.setBinaryFile("file",mapper.writeValueAsBytes(objectRecords))
.changeObjectType(objectName);System.out.println(resp.getResponse());
public ObjectRecordRoleResponse retrieveObjectRecordRoles(String objectName, String id)
Retrieve manually assigned roles on an object record and the users and groups assigned to them.
objectName - The object nameid - The id of the object record
GET /api/{version}/vobjects/{object_name}/{id}/roles
ObjectRecordRoleResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.retrieveObjectRecordRoles(objectName, id);
for (ObjectRole role : resp.getData()) {
System.out.println("\nRole: " + role.getName() + ", Assignment Type = " + role.getAssignmentType());
for (Integer i : role.getGroups())
System.out.println("Group = " + i);
for (Integer i : role.getUsers())
System.out.println("User = " + i);
}public ObjectRecordRoleResponse retrieveObjectRecordRole(String objectName, String id, String roleName)
Retrieve manually assigned role on an object record and the users and groups assigned to them.
objectName - The object nameid - The id of the object recordroleName - Role name to filter for a specific role. For example, owner__v.
GET /api/{version}/vobjects/{object_name}/{id}/roles{/role_name}
ObjectRecordRoleResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.retrieveObjectRecordRole(objectName, id, roleName);
for (ObjectRole role : resp.getData()) {
System.out.println("\n" + role.getName() + ", Assignment Type = " + role.getAssignmentType());
for (Integer i : role.getGroups()) {
System.out.println("Group = " + i);
}
for (Integer i : role.getUsers()) {
System.out.println("User = " + i);
}
}public ObjectRecordRoleChangeResponse assignUsersAndGroupsToRolesOnObjectRecords(String objectName)
Assign users and groups to roles on an object record in bulk.
objectName - The name of the object where you want to update records.
POST /api/{version}/vobjects/{object_name}/roles
Example 1 - CSV
ObjectRecordRoleChangeResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.setInputPath(inputPath)
.setContentTypeCsv()
.assignUsersAndGroupsToRolesOnObjectRecords(objectName);,
Example 2 - JSON
ObjectRecordRoleChangeResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.setRequestString(requestString)
.setContentTypeJson()
.assignUsersAndGroupsToRolesOnObjectRecords(objectName);, for (ObjectRecordRoleChangeResponse.ObjectRoleChange roleChange : resp.getData()) System.out.println(roleChange.getResponseStatus() + " for " + roleChange.getData().getId());
public ObjectRecordRoleChangeResponse removeUsersAndGroupsFromRolesOnObjectRecords(String objectName)
objectName - The name of the object where you want to remove roles.
DELETE /api/{version}/vobjects/{object_name}/roles
Example 1 - CSV
ObjectRecordRoleChangeResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.setInputPath(inputPath)
.setContentTypeCsv()
.removeUsersAndGroupsFromRolesOnObjectRecords(objectName);,
Example 2 - JSON
ObjectRecordRoleChangeResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.setRequestString(requestString)
.setContentTypeJson()
.removeUsersAndGroupsFromRolesOnObjectRecords(objectName);for (ObjectRecordRoleChangeResponse.ObjectRoleChange roleChange : resp.getData()) System.out.println(roleChange.getResponseStatus() + " for " + roleChange.getData().getId());
public JobCreateResponse deepCopyObjectRecord(String objectName, String recordId)
Deep Copy copies an object record, including all of the record's related child and grandchild records. Each deep (hierarchical) copy can copy a maximum of 10,000 related records at a time.
Add raw JSON request string for overriding/ignoring field values in the request by calling the "setRequestString" in the builder.
objectName - The name of the parent object to copyrecordId - The ID of the specific object record to copy
POST /api/{version}/vobjects/{object_name}/{object_record_ID}/actions/deepcopy
JobCreateResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.deepCopyObjectRecord(objectName, objectRecordId);
System.out.println("Status = " + resp.getResponseStatus());
if (resp.isSuccessful()) {
Integer jobId = resp.getJobId();
System.out.println("Job id = " + jobId.toString());
boolean jobRunning = true;
while (jobRunning) {
try {
Thread.sleep(5000);
JobStatusResponse respJob = vaultClient.newRequest(JobRequest.class).retrieveJobStatus(jobId);
String status = respJob.getData().getStatus();
System.out.println("Job status = " + status);
if (status.equalsIgnoreCase("ERRORS_ENCOUNTERED")) {
jobRunning = false;
VaultResponse respJobResults = vaultClient.newRequest(ObjectRecordRequest.class).getResultsOfDeepCopyJob(objectName, false, jobId);
System.out.println(new String(respJobResults.getBinaryContent()));
}
if (status.equalsIgnoreCase("SUCCESS")) {
jobRunning = false;
VaultResponse respJobResults = vaultClient.newRequest(ObjectRecordRequest.class).getResultsOfDeepCopyJob(objectName, true, jobId);
System.out.println(new String(respJobResults.getBinaryContent()));
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}public VaultResponse getResultsOfDeepCopyJob(String objectName, boolean success, int jobId)
Query vault to determine the results of the deep copy request.
objectName - The name of the deep copied objectsuccess - True for successes, false for failuresjobId - The ID of the job, retrieved from the response of the job request.
GET /api/{version}/vobjects/deepcopy/results/{object_name}/{job_status}/{job_id}
See deepCopyObjectRecord(String, String)public ObjectRecordDeletedResponse retrieveDeletedObjectRecordId(String objectName)
Retrieve the IDs of object records that have been deleted from your vault within the past 30 days. The method automatically paginates to return all records in the response.
objectName - Object name for the recycle bin
GET /api/{version}/objects/deletions/vobjects/{object_name}
ObjectRecordDeletedResponse resp = vaultClient.newRequest(ObjectRecordRequest.class)
.setStartDateDeleted(startDate)
.setEndDateDeleted(endDate)
.retrieveDeletedObjectRecordId(objectName);
if (resp.getData() != null) {
System.out.println("Total Deleted Records = " + resp.getData().size());
System.out.println("First record deleted " + resp.getData().get(0).getId() + ", " + resp.getData().get(0).getDateDeleted());
}
else
System.out.println("No deleted records");public VaultResponse retrieveLimitsOnObjects()
GET /api/{version}/limitspublic JobCreateResponse updateCorporateCurrencyFields(String objectName)
Add raw JSON request string for overriding/ignoring field values in the request by calling the "setRequestString" in the builder.
objectName - The object name__v field value, for example, product__v
PUT /api/{version}/vobjects/{object_name}/actions/updatecorporatecurrencypublic ObjectRecordRequest setAcceptCSV()
public ObjectRecordRequest setBinaryFile(String filename, byte[] binaryContent)
filename - file name (no path)binaryContent - byte array of the file contentpublic ObjectRecordRequest setBodyParams(Map<String,Object> bodyParams)
bodyParams - map of body paramspublic ObjectRecordRequest setContentTypeCsv()
public ObjectRecordRequest setContentTypeJson()
public ObjectRecordRequest setEndDateDeleted(ZonedDateTime endDateDeleted)
Specify a date (no more than 30 days past) after which Vault will look for deleted object records. Dates and times are in UTC. If the time is not specified, it will default to midnight (T00:00:00Z) on the specified date. Date formats will automatically be formatted.
endDateDeleted - End date for the date rangepublic ObjectRecordRequest setIdParam(String idParam)
idParam - External Id field API name for the UPSERTpublic ObjectRecordRequest setInputPath(String inputPath)
inputPath - Absolute path to the file for the requestpublic ObjectRecordRequest setMigrationMode(boolean migrationMode)
migrationMode - The source request as a stringpublic ObjectRecordRequest setOutputPath(String outputPath)
outputPath - Absolute path to the file for the responsepublic ObjectRecordRequest setRequestString(String requestString)
requestString - The source request as a stringpublic ObjectRecordRequest setStartDateDeleted(ZonedDateTime startDateDeleted)
Specify a date (no more than 30 days past) after which Vault will look for deleted object records. Dates and times are in UTC. If the time is not specified, it will default to midnight (T00:00:00Z) on the specified date. Date formats will automatically be formatted.
startDateDeleted - Start date for the date rangepublic ObjectRecordRequest setUnchangedFieldBehavior(ObjectRecordRequest.UnchangedFieldBehaviorType unchangedFieldBehavior)
unchangedFieldBehavior - The source request as a stringCopyright © 2021. All rights reserved.