Exemplo n.º 1
0
        public void CompileWriteResult_ReceivesFailedSet_ReturnsFormattedMessageWithResults()
        {
            // Arrange
            var results = new WriteResultSet <RDO>()
            {
                Message = "This is my global message",
                Success = false,
                Results = new List <Result <RDO> >()
                {
                    new Result <RDO>()
                    {
                        Artifact = new RDO(),
                        Message  = "This is a test message",
                        Success  = true
                    },
                    new Result <RDO>()
                    {
                        Artifact = new RDO(),
                        Message  = "This is another test message",
                        Success  = false
                    }
                }
            };

            // Act
            var actual = Response <Int32> .CompileWriteResults(results);

            // Assert
            Assert.IsFalse(actual.Success);
            Assert.AreEqual("This is my global messageThis is a test messageThis is another test message", actual.Message);
            Assert.Greater(actual.Results.Count(), 0);
        }
Exemplo n.º 2
0
        public static int Create_Group(IRSAPIClient client, String name)
        {
            var clientID = client.APIOptions.WorkspaceID;

            client.APIOptions.WorkspaceID = -1;
            Group newGroup = new Group();

            newGroup.Name = name;
            WriteResultSet <kCura.Relativity.Client.DTOs.Group> resultSet = new WriteResultSet <Group>();

            try
            {
                resultSet = client.Repositories.Group.Create(newGroup);
                if (!resultSet.Success || resultSet.Results.Count == 0)
                {
                    throw new Exception("Group was not found");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception occured while trying to create a new group" + e);
            }
            var groupartid = resultSet.Results[0].Artifact.ArtifactID;

            client.APIOptions.WorkspaceID = clientID;
            return(groupartid);
        }
Exemplo n.º 3
0
        public static bool Delete_Group(IRSAPIClient client, int artifactId)
        {
            var clientID = client.APIOptions.WorkspaceID;

            client.APIOptions.WorkspaceID = -1;
            Group groupToDelete = new Group(artifactId);
            WriteResultSet <Group> resultSet = new WriteResultSet <Group>();

            try
            {
                resultSet = client.Repositories.Group.Delete(groupToDelete);

                if (!resultSet.Success || resultSet.Results.Count == 0)
                {
                    throw new Exception("Group not found in Relativity");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Group deletion threw an exception" + e);
                return(false);
            }

            client.APIOptions.WorkspaceID = clientID;
            return(true);
        }
        /// <summary>
        /// Adds the user to the DynamicAPI Group for permissions
        /// </summary>
        /// <param name="groupId"></param>
        private void AddAdminUserToGroup(int groupId)
        {
            using (IRSAPIClient rsapiClient = GetServiceFactory().CreateProxy <IRSAPIClient>())
            {
                DTOs.User user = GetUser(_userName);
                user.Groups.Add(new Group(groupId));
                WriteResultSet <DTOs.User> userUpdateResults = null;

                try
                {
                    userUpdateResults = rsapiClient.Repositories.User.Update(user);

                    if (userUpdateResults.Success)
                    {
                        Console.WriteLine($"Added user to DynamicAPI Group");
                    }
                    else
                    {
                        Console.WriteLine($"Unable to add user to DynamicAPI Group: {userUpdateResults.Message}");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"An error occurred updating the user: {ex.Message}");
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a group object
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public int Create(String name)
        {
            DTOs.Group newGroup = new DTOs.Group();
            newGroup.Name = name;
            WriteResultSet <DTOs.Group> resultSet = new WriteResultSet <DTOs.Group>();

            try
            {
                using (var client = _helper.GetServicesManager().CreateProxy <IRSAPIClient>(API.ExecutionIdentity.System))
                {
                    client.APIOptions.WorkspaceID = -1;
                    resultSet = client.Repositories.Group.Create(newGroup);
                }
                if (!resultSet.Success || resultSet.Results.Count == 0)
                {
                    throw new Exception("Group was not found");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception occured while trying to create a new group" + e);
            }
            var groupartid = resultSet.Results[0].Artifact.ArtifactID;

            return(groupartid);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Deletes the group by artifact ID.
        /// </summary>
        /// <param name="artifactId"></param>
        /// <returns></returns>
        public bool Delete(int artifactId)
        {
            var groupToDelete = new DTOs.Group(artifactId);
            WriteResultSet <DTOs.Group> resultSet = new WriteResultSet <DTOs.Group>();

            try
            {
                using (var client = _helper.GetServicesManager().CreateProxy <IRSAPIClient>(API.ExecutionIdentity.System))
                {
                    resultSet = client.Repositories.Group.Delete(groupToDelete);
                }

                if (!resultSet.Success || resultSet.Results.Count == 0)
                {
                    throw new Exception("Group not found in Relativity");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Group deletion threw an exception" + e);
                return(false);
            }

            return(true);
        }
        public static bool DeleteTestWorkspace(Int32 workspaceID, IServicesMgr svcMgr, string userName, string password)
        {
            WriteResultSet <Workspace> resultSet = null;

            using (var proxy = svcMgr.GetProxy <IRSAPIClient>(userName, password))
            {
                proxy.APIOptions.WorkspaceID = -1;

                try
                {
                    //Create a Workspace Artifact and pass to the Delete method on the repository
                    var workspaceDTO = new kCura.Relativity.Client.DTOs.Workspace(workspaceID);
                    resultSet = proxy.Repositories.Workspace.Delete(workspaceDTO);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("An error occurred deleting the Workspace: {0}", ex.Message);
                    return(false);
                }


                if (!resultSet.Success)
                {
                    Console.WriteLine("An error occurred deleting the Workspace: {0}", resultSet.Message);
                    return(false);
                }

                return(true);
            }
        }
Exemplo n.º 8
0
        public void CompileWriteResult_ReceivesSuccessfulSet_ReturnsParsedResults()
        {
            // Arrange
            var results = new WriteResultSet <RDO>()
            {
                Message = "This is my global message",
                Success = true,
                Results = new List <Result <RDO> >()
                {
                    new Result <RDO>()
                    {
                        Artifact = new RDO(),
                        Message  = "This is a test message",
                        Success  = true
                    }
                }
            };

            // Act
            var actual = Response <Int32> .CompileWriteResults(results);

            // Assert
            Assert.IsTrue(actual.Success);
            Assert.AreEqual(String.Empty, actual.Message);
            Assert.Greater(actual.Results.Count(), 0);
        }
Exemplo n.º 9
0
        protected WriteResultSet <RDO> UpdateRdos(params RDO[] rdos)
        {
            WriteResultSet <RDO> resultSet = new WriteResultSet <RDO>();

            using (var proxyToWorkspace = CreateProxy())
            {
                try
                {
                    resultSet = invokeWithRetryService.InvokeWithRetry(() => proxyToWorkspace.Repositories.RDO.Update(rdos));
                }
                catch (Exception ex)
                {
                    throw new ProxyOperationFailedException("Failed in method: " + System.Reflection.MethodInfo.GetCurrentMethod(), ex);
                }
            }

            return(resultSet);
        }
Exemplo n.º 10
0
        public void WriteToTable(string requestID, string pageTitle, IRSAPIClient proxy, int workspaceID, string prefix, int count)
        {
            string requestUrl = $"https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exlimit=max&explaintext&titles={pageTitle}&redirects=";

            proxy.APIOptions.WorkspaceID = workspaceID;
            RDO wikitivityRequestRDO = new RDO(WikitivityRDOGuid);

            List <Guid> guidList = new List <Guid>();

            guidList.Add(WikitivityRDOGuid);
            wikitivityRequestRDO.ArtifactTypeGuids = guidList;
            wikitivityRequestRDO.Fields.Add(new FieldValue()
            {
                Name = "Request ID", Value = requestID
            });
            wikitivityRequestRDO.Fields.Add(new FieldValue()
            {
                Name = "Request Url", Value = requestUrl
            });

            if (prefix == String.Empty)
            {
                prefix = "WIKI";
            }
            string docID = prefix + count.ToString("D7");

            wikitivityRequestRDO.Fields.Add(new FieldValue()
            {
                Name = "Name", Value = docID
            });
            wikitivityRequestRDO.Fields.Add(new FieldValue()
            {
                Name = "Page Title", Value = pageTitle
            });

            try
            {
                WriteResultSet <RDO> writeResultSet = proxy.Repositories.RDO.Create(wikitivityRequestRDO);
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 11
0
        public static Response <IEnumerable <Error> > CompileWriteResults(WriteResultSet <Error> theseResults)
        {
            bool   success = true;
            string message = "";

            message += theseResults.Message;
            if (!theseResults.Success)
            {
                success = false;
            }

            var res = new Response <IEnumerable <Error> >
            {
                Results = theseResults.Results.Select(x => x.Artifact),
                Success = success,
                Message = MessageFormatter.FormatMessage(theseResults.Results.Select(x => x.Message).ToList(), message, success)
            };

            return(res);
        }
Exemplo n.º 12
0
        public void UpdateRequestHistory(IRSAPIClient proxy, string requestID, string requestUser, int articleCount, int workspaceID, string requestedCategories, string prefix)
        {
            proxy.APIOptions.WorkspaceID = workspaceID;
            RDO         wikitivityRequestHistoryRDO = new RDO(WikitivityRequestHistoryRDOGuid);
            List <Guid> guidList = new List <Guid>();

            guidList.Add(WikitivityRequestHistoryRDOGuid);
            wikitivityRequestHistoryRDO.ArtifactTypeGuids = guidList;
            wikitivityRequestHistoryRDO.Fields.Add(new FieldValue()
            {
                Name = "Request ID", Value = requestID
            });
            wikitivityRequestHistoryRDO.Fields.Add(new FieldValue()
            {
                Name = "Request User", Value = requestUser
            });
            wikitivityRequestHistoryRDO.Fields.Add(new FieldValue()
            {
                Name = "Request Date", Value = DateTime.Today.ToShortDateString()
            });
            wikitivityRequestHistoryRDO.Fields.Add(new FieldValue()
            {
                Name = "Article Count", Value = articleCount
            });
            wikitivityRequestHistoryRDO.Fields.Add(new FieldValue()
            {
                Name = "Requested Categories", Value = requestedCategories
            });
            wikitivityRequestHistoryRDO.Fields.Add(new FieldValue()
            {
                Name = "Prefix", Value = prefix
            });

            try
            {
                WriteResultSet <RDO> writeResultSet = proxy.Repositories.RDO.Create(wikitivityRequestHistoryRDO);
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Creates/Gets DynamicAPI Group
        /// </summary>
        /// <returns></returns>
        private int CreateDynamicApiGroup()
        {
            int groupId = 0;

            Group newGroup = new Group();

            newGroup.Name = _dynamicApiGroup;

            TextCondition condition = new TextCondition(GroupFieldNames.Name, TextConditionEnum.EqualTo, newGroup.Name);

            Query <Group> query = new Query <Group> {
                Condition = condition
            };

            // STEP 2: Create a WriteResultSet. It provide details after the create operation completes.
            WriteResultSet <Group> resultSet = new WriteResultSet <Group>();

            using (IRSAPIClient rsapiClient = GetServiceFactory().CreateProxy <IRSAPIClient>())
            {
                rsapiClient.APIOptions = new APIOptions {
                    WorkspaceID = -1
                };

                QueryResultSet <Group> queryResultSet = rsapiClient.Repositories.Group.Query(query);

                if (queryResultSet.Success && queryResultSet.TotalCount == 0)
                {
                    resultSet = rsapiClient.Repositories.Group.Create(newGroup);
                    groupId   = resultSet.Results.First().Artifact.ArtifactID;
                    Console.WriteLine($"Group created ({newGroup.Name})");
                }
                else
                {
                    Console.WriteLine($"Group ({newGroup.Name}) already exists");
                    groupId = queryResultSet.Results.First().Artifact.ArtifactID;
                }
            }

            return(groupId);
        }
Exemplo n.º 14
0
        public async Task TagDocumentsResponsiveAsync(int workspaceId, List <int> documentsToTag)
        {
            Console2.WriteDisplayStartLine("Tagging all documents as Responsive");

            RsapiClient.APIOptions.WorkspaceID = workspaceId;
            foreach (int currentDocumentArtifactId in documentsToTag)
            {
                // Read the document
                Document currentDocumentRdo = await Task.Run(() => RsapiClient.Repositories.Document.ReadSingle(currentDocumentArtifactId));

                // Code the document as Responsive
                currentDocumentRdo.Fields.Add(new FieldValue
                {
                    Name  = Constants.Workspace.ResponsiveField.Name,
                    Value = Constants.Workspace.ResponsiveField.VALUE
                });

                try
                {
                    // Perform the document update
                    WriteResultSet <Document> documentWriteResultSet = await Task.Run(() => RsapiClient.Repositories.Document.Update(currentDocumentRdo));

                    if (!documentWriteResultSet.Success)
                    {
                        Console2.WriteDebugLine($"Error: {documentWriteResultSet.Message} \r\n {documentWriteResultSet.Results[0].Message}");
                        Console2.WriteDebugLine(string.Join(";", documentWriteResultSet.Results));
                        throw new Exception("Failed to tag document as Responsive");
                    }

                    Console2.WriteDebugLine($"Tagged document as Responsive! [Name: {currentDocumentRdo.TextIdentifier}]");
                }
                catch (Exception ex)
                {
                    throw new Exception("An error occured when tagging document as Responsive", ex);
                }
            }

            Console2.WriteDisplayEndLine("Tagged all documents as Responsive!");
        }
Exemplo n.º 15
0
        public static bool Delete_User(IRSAPIClient client, int artifactId)
        {
            client.APIOptions.WorkspaceID = -1;
            User userToDelete = new User(artifactId);
            WriteResultSet <kCura.Relativity.Client.DTOs.User> resultSet = new WriteResultSet <User>();

            try
            {
                resultSet = client.Repositories.User.Delete(userToDelete);

                if (!resultSet.Success || resultSet.Results.Count == 0)
                {
                    throw new Exception("User was not found");
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("An error occurred deleting for the user: {0}", ex.Message);
                return(false);
            }

            return(true);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Deletes DynamicAPI Group
        /// </summary>
        /// <returns></returns>
        private void DeleteDynamicApiGroup(int groupId)
        {
            Group newGroup = new Group();

            newGroup.Name = _dynamicApiGroup;

            TextCondition condition = new TextCondition(GroupFieldNames.Name, TextConditionEnum.EqualTo, newGroup.Name);

            Query <Group> query = new Query <Group> {
                Condition = condition
            };

            // STEP 2: Create a WriteResultSet. It provide details after the create operation completes.
            WriteResultSet <Group> resultSet = new WriteResultSet <Group>();

            using (IRSAPIClient rsapiClient = GetServiceFactory().CreateProxy <IRSAPIClient>())
            {
                rsapiClient.APIOptions = new APIOptions {
                    WorkspaceID = -1
                };

                QueryResultSet <Group> queryResultSet = rsapiClient.Repositories.Group.Query(query);

                if (queryResultSet.Success && queryResultSet.TotalCount > 0)
                {
                    resultSet = rsapiClient.Repositories.Group.Delete(groupId);
                    if (resultSet.Success)
                    {
                        Console.WriteLine($"Group deleted ({newGroup.Name})");
                    }
                }
                else
                {
                    Console.WriteLine($"Group ({newGroup.Name}) does not exist");
                }
            }
        }
        public int CreateFixedLengthTextField(int workspaceId, IServicesMgr svcMgr, ExecutionIdentity identity)
        {
            int fieldId = 0;

            try
            {
                using (IRSAPIClient client = svcMgr.CreateProxy <IRSAPIClient>(identity))
                {
                    //Set the workspace ID
                    client.APIOptions.WorkspaceID = workspaceId;

                    //Create a Field DTO
                    kCura.Relativity.Client.DTOs.Field fieldDto = new kCura.Relativity.Client.DTOs.Field();

                    //Set primary fields
                    //The name of the sample data is being set to a random string so that sample data can be debugged
                    //and never causes collisions. You can set this to any string that you want
                    fieldDto.Name       = "Demo Document Field";
                    fieldDto.ObjectType = new kCura.Relativity.Client.DTOs.ObjectType()
                    {
                        DescriptorArtifactTypeID = (int)ArtifactType.Document
                    };
                    fieldDto.FieldTypeID = FieldType.FixedLengthText;

                    //Set secondary fields
                    fieldDto.AllowHTML          = false;
                    fieldDto.AllowGroupBy       = false;
                    fieldDto.AllowPivot         = false;
                    fieldDto.AllowSortTally     = false;
                    fieldDto.IncludeInTextIndex = true;
                    fieldDto.IsRequired         = false;
                    fieldDto.OpenToAssociations = false;
                    fieldDto.Length             = 255;
                    fieldDto.Linked             = false;
                    fieldDto.Unicode            = true;
                    fieldDto.Width        = "";
                    fieldDto.Wrapping     = true;
                    fieldDto.IsRelational = false;

                    //Create the field
                    WriteResultSet <kCura.Relativity.Client.DTOs.Field> resultSet = client.Repositories.Field.Create(fieldDto);

                    //Check for success
                    if (!resultSet.Success)
                    {
                        Console.WriteLine("Field was not created");
                        return(fieldId);
                    }

                    Result <kCura.Relativity.Client.DTOs.Field> firstOrDefault = resultSet.Results.FirstOrDefault();
                    if (firstOrDefault != null)
                    {
                        fieldId = firstOrDefault.Artifact.ArtifactID;
                    }

                    return(fieldId);
                }
            }
            catch (Exception)
            {
                throw new Exception("Failed in the create field method.");
            }
        }
Exemplo n.º 18
0
        public void Valid_Gravity_RelativityObject_Read_Field_Type <T>(string objectPropertyName, T sampleData)
        {
            void Inner()
            {
                //Arrange
                LogStart($"Arrangement for property {objectPropertyName}");

                GravityLevelOne testObject = new GravityLevelOne()
                {
                    Name = $"TestObjectRead_{objectPropertyName}{Guid.NewGuid()}"
                };

                Guid         testObjectTypeGuid = testObject.GetObjectLevelCustomAttribute <RelativityObjectAttribute>().ObjectTypeGuid;
                Guid         nameFieldGuid      = testObject.GetCustomAttribute <RelativityObjectFieldAttribute>("Name").FieldGuid;
                var          testFieldAttribute = testObject.GetCustomAttribute <RelativityObjectFieldAttribute>(objectPropertyName);
                Guid         testFieldGuid      = testFieldAttribute.FieldGuid;
                RdoFieldType fieldType          = testObject.GetCustomAttribute <RelativityObjectFieldAttribute>(objectPropertyName).FieldType;

                _client.APIOptions.WorkspaceID = _workspaceId;

                object expectedData = sampleData;

                var dto = new RDO()
                {
                    ArtifactTypeGuids = new List <Guid> {
                        testObjectTypeGuid
                    }
                };
                int newArtifactId = -1;

                dto.Fields.Add(new FieldValue(nameFieldGuid, testObject.Name));

                int objectToAttachID;

                //need this mess because when passing in tests for decimal and currency System wants to use double and causes problems
                switch (fieldType)
                {
                case RdoFieldType.SingleChoice:
                    Enum   singleChoice      = (Enum)Enum.ToObject(sampleData.GetType(), sampleData);
                    Guid   singleChoiceGuid  = singleChoice.GetRelativityObjectAttributeGuidValue();
                    Choice singleChoiceToAdd = new Choice(singleChoiceGuid);
                    dto.Fields.Add(new FieldValue(testFieldGuid, singleChoiceToAdd));
                    break;

                case RdoFieldType.SingleObject:
                    int objectToAttach =
                        _testObjectHelper.CreateTestObjectWithGravity <GravityLevel2>(sampleData as GravityLevel2);
                    dto.Fields.Add(new FieldValue(testFieldGuid, objectToAttach));
                    expectedData = (sampleData as GravityLevel2).Name;
                    break;

                case RdoFieldType.MultipleObject:
                    IList <GravityLevel2>     gravityLevel2s = (IList <GravityLevel2>)sampleData;
                    FieldValueList <Artifact> objects        = new FieldValueList <Artifact>();
                    expectedData = new Dictionary <int, string>();
                    foreach (GravityLevel2 child in gravityLevel2s)
                    {
                        objectToAttachID =
                            _testObjectHelper.CreateTestObjectWithGravity <GravityLevel2>(child);
                        objects.Add(new Artifact(objectToAttachID));
                        (expectedData as Dictionary <int, string>).Add(objectToAttachID, child.Name);
                    }
                    dto.Fields.Add(new FieldValue(testFieldGuid, objects));
                    break;

                default:
                    dto.Fields.Add(new FieldValue(testFieldGuid, sampleData));
                    break;
                }

                WriteResultSet <RDO> writeResults = _client.Repositories.RDO.Create(dto);

                if (writeResults.Success)
                {
                    newArtifactId = writeResults.Results[0].Artifact.ArtifactID;
                    Console.WriteLine($"Object was created with Artifact ID {newArtifactId}.");
                }
                else
                {
                    Console.WriteLine($"An error occurred creating object: {writeResults.Message}");
                    foreach (var result in
                             writeResults.Results
                             .Select((item, index) => new { rdoResult = item, itemNumber = index })
                             .Where(x => x.rdoResult.Success == false))
                    {
                        Console.WriteLine($"An error occurred in create request {result.itemNumber}: {result.rdoResult.Message}");
                    }
                }

                LogEnd("Arrangement");

                //Act
                LogStart("Act");

                object gravityFieldValue = null;

                if (newArtifactId > 0)
                {
                    GravityLevelOne testGravityObject = _testObjectHelper.ReturnTestObjectWithGravity <GravityLevelOne>(newArtifactId);
                    gravityFieldValue = testGravityObject.GetPropertyValue(objectPropertyName);
                    if (gravityFieldValue != null)
                    {
                        switch (fieldType)
                        {
                        case RdoFieldType.SingleObject:
                            gravityFieldValue = ((GravityLevel2)gravityFieldValue).Name;
                            break;

                        case RdoFieldType.MultipleObject:
                            gravityFieldValue = ((List <GravityLevel2>)gravityFieldValue).ToDictionary(x => x.ArtifactId, x => x.Name);
                            break;
                        }
                    }
                }

                LogEnd("Act");

                //Assert
                LogStart("Assertion");

                if (newArtifactId > 0)
                {
                    Assert.AreEqual(expectedData, gravityFieldValue);
                }
                else
                {
                    Assert.Fail("Could not create object to test with through RSAPI. This is not a Gravity failure.");
                }

                LogEnd("Assertion");
            }

            TestWrapper(Inner);
        }
Exemplo n.º 19
0
        public static int CreateUserUsingRepository(IRSAPIClient rsapiClient)
        {
            rsapiClient.APIOptions.WorkspaceID = -1;

            int       newUserArtifactId       = -1;
            const int defaultSelectedFileType = 1;
            const int userType              = 3;
            const int documentSkip          = 1000003;
            const int skipDefaultPreference = 1000004;
            const int password              = 1000005;
            const int sendNewPasswordTo     = 1000006;

            int returnPasswordCodeId = FindChoiceArtifactId(rsapiClient, sendNewPasswordTo, "Return");
            int passwordCodeId       = FindChoiceArtifactId(rsapiClient, password, "Auto-generate password");
            int documentSkipCodeId   = FindChoiceArtifactId(rsapiClient, documentSkip, "Enabled");

            int documentSkipPreferenceCodeId = FindChoiceArtifactId(rsapiClient, skipDefaultPreference, "Normal");
            int defaultFileTypeCodeId        = FindChoiceArtifactId(rsapiClient, defaultSelectedFileType, "Native");
            int userTypeCodeId = FindChoiceArtifactId(rsapiClient, userType, "Internal");

            int everyoneGroupArtifactId = FindGroupArtifactId(rsapiClient, "Everyone");
            int clientArtifactId        = FindClientArtifactId(rsapiClient, "Relativity Template");

            long ticks = DateTime.Now.Ticks;

            kCura.Relativity.Client.DTOs.User userDto = new kCura.Relativity.Client.DTOs.User
            {
                AdvancedSearchPublicByDefault = true,
                AuthenticationData            = "",
                BetaUser                = false,
                ChangePassword          = true,
                ChangePasswordNextLogin = false,
                ChangeSettings          = true,
                Client    = new Client(clientArtifactId),
                DataFocus = 1,
                DefaultSelectedFileType    = new kCura.Relativity.Client.DTOs.Choice(defaultFileTypeCodeId),
                DocumentSkip               = new kCura.Relativity.Client.DTOs.Choice(documentSkipCodeId),
                EmailAddress               = $"email.{ticks}@test.com",
                EnforceViewerCompatibility = true,
                FirstName = $"firstName_{ticks}",
                Groups    = new List <Group> {
                    new Group(everyoneGroupArtifactId)
                },
                ItemListPageLength     = 25,
                KeyboardShortcuts      = true,
                LastName               = "Test User",
                MaximumPasswordAge     = 0,
                NativeViewerCacheAhead = true,
                PasswordAction         = new kCura.Relativity.Client.DTOs.Choice(passwordCodeId),
                RelativityAccess       = true,
                SendPasswordTo         = new kCura.Relativity.Client.DTOs.Choice(returnPasswordCodeId),
                SkipDefaultPreference  = new kCura.Relativity.Client.DTOs.Choice(documentSkipPreferenceCodeId),
                TrustedIPs             = "",
                Type = new kCura.Relativity.Client.DTOs.Choice(userTypeCodeId)
            };

            WriteResultSet <kCura.Relativity.Client.DTOs.User> userWriteResultSet = new WriteResultSet <kCura.Relativity.Client.DTOs.User>();

            try
            {
                userWriteResultSet = rsapiClient.Repositories.User.Create(userDto);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"An error occurred: {ex.Message}");
            }

            // Check for success.
            if (!userWriteResultSet.Success)
            {
                Console.WriteLine($"An error occurred creating user: {userWriteResultSet.Message}");

                foreach (Result <kCura.Relativity.Client.DTOs.User> createResult in userWriteResultSet.Results)
                {
                    if (!createResult.Success)
                    {
                        Console.WriteLine($"An error occurred in create request: {createResult.Message}");
                    }
                }
            }

            if (userWriteResultSet.Results != null)
            {
                newUserArtifactId = userWriteResultSet.Results.FirstOrDefault().Artifact.ArtifactID;
            }
            return(newUserArtifactId);
        }