public ApiResponse GetVaultUserWebLoginToken(string userName, string apiKey, string developerSecret, string oAuthServerTokenEndPoint, string baseVaultUrl, string apiVersion, string customerAlias, string databaseAlias)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                ClientSecrets clientSecrets = new ClientSecrets
                {
                    ApiKey = apiKey,
                    ApiSecret = developerSecret,
                    OAuthTokenEndPoint = oAuthServerTokenEndPoint,
                    BaseUrl = baseVaultUrl,
                    ApiVersion = apiVersion,
                    CustomerAlias = customerAlias,
                    DatabaseAlias = databaseAlias
                };

                VaultApi vaultApi = new VaultApi(clientSecrets);

                var user = vaultApi.Users.GetUser(userName);

                if (user != null)
                {
                    response.Value = user.GetWebLoginToken();
                }
            }
            catch (Exception ex)
            {
                response.IsError = true;
                response.ErrorMessage = ex.Message;
            }

            return response;
        }
        public ApiResponse StorePersistedData(string valuesInJsonFormat, int minutesToStoreData, string apiKey, string developerSecret, string oAuthServerTokenEndPoint, string baseVaultUrl, string apiVersion, string customerAlias, string databaseAlias)
        {
            ApiResponse response = new ApiResponse();

            try
            {
                ClientSecrets clientSecrets = new ClientSecrets
                {
                    ApiKey = apiKey,
                    ApiSecret = developerSecret,
                    OAuthTokenEndPoint = oAuthServerTokenEndPoint,
                    BaseUrl = baseVaultUrl,
                    ApiVersion = apiVersion,
                    CustomerAlias = customerAlias,
                    DatabaseAlias = databaseAlias
                };

                VaultApi vaultApi = new VaultApi(clientSecrets);

                DateTime expirationDate = DateTime.UtcNow.AddMinutes(minutesToStoreData);

                var data = vaultApi.PersistedData.CreateData(Guid.NewGuid().ToString(), ScopeType.Global, valuesInJsonFormat, "text/JSON", string.Empty, LinkedObjectType.None, expirationDate);

                if (data != null)
                {
                    response.Value = data.Id.ToString();
                }
            }
            catch (Exception ex)
            {
                response.IsError = true;
                response.ErrorMessage = ex.Message;
            }

            return response;
        }
        public void AddSecurityMemberOnFolder()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var generalFolder = vaultApi.Folders.GetFolderByPath("/General");

            Assert.AreNotEqual(Guid.Empty, generalFolder.Id);

            if (generalFolder != null)
            {
                var memberId = new Guid("22BF8B4C-A961-E111-8E23-14FEB5F06078");
                var memberType = MemberType.Group;
                var role = RoleType.Editor;

                var updateCount = vaultApi.Folders.AddSecurityMember(generalFolder.Id, memberId, memberType, role);

                Assert.AreEqual(1, updateCount);
            }
        }
        public void GetCustomerDatabaseInfo()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var dbInfo = vaultApi.Customer.GetCustomerDatabaseInfo();

            Assert.IsNotNull(dbInfo);
        }
        public void GetApiObjectFieldNames()
        {
            ClientSecrets clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            VaultApi vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            List<MetaDataType> ApiObjectTypes = vaultApi.Meta.GetDataTypes();

            StringBuilder sbFieldList = new StringBuilder();

            sbFieldList.AppendLine("API Object Field List");

            foreach (MetaDataType apiObjectType in ApiObjectTypes)
            {
                sbFieldList.AppendLine("-----------------------------------------------------------------");

                sbFieldList.AppendLine(string.Format("{0} fields: {1}", apiObjectType.Name, Environment.NewLine));

                foreach (string fieldName in apiObjectType.AvailableFields)
                {
                    sbFieldList.AppendLine(string.Format("{0}", fieldName));
                }
            }

            LogEventManager.Info(sbFieldList.ToString());
        }
        public void FormTemplatesTest()
        {
            ClientSecrets clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            VaultApi vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            Page<FormTemplate> formTemplates = vaultApi.FormTemplates.GetFormTemplates();

            foreach (FormTemplate formTemplate in formTemplates.Items)
            {
                Assert.IsNotNullOrEmpty(formTemplate.Name);
                Debug.WriteLine("Form template name: " + formTemplate.Name);
            }

            Assert.IsTrue(formTemplates.Items.Count > 0);
        }
        public void FormDataTest()
        {
            ClientSecrets clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            VaultApi vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var formTemplateId = new Guid("F9CB9977-5B0E-E211-80A1-14FEB5F06078");

            //var options = new RequestOptions
            //{
            //    Fields = "dhdocid,revisionid,City,First Name,Unit"
            //};
            var options = new RequestOptions
            {
                Query = "[VVModifyDate] ge '2015-11-07T22:18:09.444Z'",
                Expand = true
            };

            var formdata = vaultApi.FormTemplates.GetFormInstanceData(formTemplateId, options);
            Assert.IsNotNull(formdata);

            //foreach (FormTemplate formTemplate in formTemplates.Items)
            //{
            //    Assert.IsNotNullOrEmpty(formTemplate.Name);
            //}

            //Assert.IsNotNull(formTemplates);
        }
        public void CreateUsersTopLevelContainerFolder()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var folderName = "Irish Marshes";
            var folderDescription = "The Green Irish Marshes";
            var allowRevisions = true;
            var namingConventionPrefix = "IrishMarshes-";
            var namingConventionSufix = " - IM";
            var datePosition = DocDatePosition.NoDateInsert;
            var docSeqType = VVRestApi.Vault.Library.DocSeqType.TypeInteger;
            var expireAction = ExpireAction.Nothing;
            var expireRequired = false;
            var expirationDays = 0;
            var reviewRequired = false;
            var reviewDays = 0;

            var folder = vaultApi.Folders.CreateUsersTopLevelContainerFolder();
            Assert.IsNotNull(folder);
        }
        public void UploadZeroByteFile()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var folder = vaultApi.Folders.GetFolderByPath("/Test");

            Assert.NotNull(folder);

            if (folder != null)
            {

                var document = vaultApi.Documents.CreateDocument(folder.Id, "12345.txt", "Zero Byte Upload", "1", DocumentState.Released);

                Assert.IsNotNull(document);

                var fileArray = new byte[0];

                var returnObject = vaultApi.Files.UploadZeroByteFile(document.DocumentId, "12345.txt", 5, fileArray);

            }
        }
        public void UploadFileStream()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            //var testFolder = vaultApi.Folders.GetFolderByPath("/Arbys");
            //if (testFolder != null)
            //{
            var document = vaultApi.Documents.CreateDocument(new Guid("C9B9DB43-5BCF-E411-8281-14FEB5F06078"), "RandomNewDocument", "Random New Document in TestFolder", "1", DocumentState.Released);
            Assert.IsNotNull(document);

            var documentId = document.DocumentId;
            //documentId = Guid.Empty;

            var fileStream = TestHelperShared.GetSearchWordTextFileStream();
            //var byteArray = TestHelperShared.GetSearchWordTextFile();
            //var fileStream = TestHelperShared.GetFileStream(@"c:\temp\video1.mp4");

            //if (fileStream == null)
            //{
            //    throw new Exception("Could not get the embedded file: SearchWordTextFile.txt");
            //}

            var indexFields = new List<KeyValuePair<string, string>>
            {
                new KeyValuePair<string, string>("Name", "Test Data")
            };

            var optParameters = new JObject(){
                new JProperty("source", "DocumentViewer"),
                new JProperty("command", "copyPriorRevisionAnnotations")
            };

            var returnObject = vaultApi.Files.UploadFile(documentId, "SearchWordTextFile.txt", "14", "14", DocumentCheckInState.Released, indexFields, fileStream, optParameters);
            var meta = returnObject.GetValue("meta") as JObject;
            if (meta != null)
            {
                var status = meta.GetValue("status").Value<string>();
                Assert.AreEqual("200", status);

                var checkinstatusString = meta.GetValue("checkInStatus").Value<string>();
                Assert.AreEqual(CheckInStatusType.CheckedIn.ToString(), checkinstatusString);
            }
            //}
        }
        public void UploadFile()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            //var arbysFolder = vaultApi.Folders.GetFolderByPath("/Arbys");
            //if (arbysFolder != null)
            //{
                var document = vaultApi.Documents.CreateDocument(new Guid("C9B9DB43-5BCF-E411-8281-14FEB5F06078"), "SeventhNewDocument", "Seventh New Document in Arbys", "1", DocumentState.Released);

                Assert.IsNotNull(document);

                var fileArray = TestHelperShared.GetSearchWordTextFile();

                //var returnObject = vaultApi.Files.UploadFile(document.DocumentId, "SearchWordTextFile", fileArray);

            //}
        }
        public void UpdateIndexFieldsForDocument()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var dlId = new Guid("85fa0e91-a64a-e511-82a3-5cf3706c36ed");
            //var dhId = new Guid("BD9DB6B5-A64A-E511-82A3-5CF3706C36ED");
            //var dataId = new Guid("5ABEAFB5-A64A-E511-82A3-5CF3706C36ED");

            var indexFields = new List<KeyValuePair<string, string>>
            {
                new KeyValuePair<string, string>("name", "Some common name"),
                new KeyValuePair<string, string>("text1", "Appropriate text goes here"),
            };

            var docIndexFields = vaultApi.Documents.UpdateIndexFieldValues(dlId, indexFields);

            Assert.IsNotEmpty(docIndexFields);
        }
        public void UpdateIndexFieldForDocument()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var dlId = new Guid("85fa0e91-a64a-e511-82a3-5cf3706c36ed");
            var dhId = new Guid("BD9DB6B5-A64A-E511-82A3-5CF3706C36ED");
            var fieldId = new Guid("3AD6D13A-2E75-E111-84E2-14FEB5F06078");
            var dataId = new Guid("5ABEAFB5-A64A-E511-82A3-5CF3706C36ED");

            var value = "Movies";

            var docIndexField = vaultApi.Documents.UpdateIndexFieldValue(dlId, fieldId, value);

            Assert.AreEqual(value, docIndexField.Value);
        }
        public void UpdateGroupDescription()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var groupId = new Guid("B0B428D4-4183-E511-82B0-5CF3706C36ED");
            var newDescription = "New Group Desciption";
            var group = vaultApi.Groups.UpdateGroupDescription(groupId, newDescription);

            Assert.IsNotNull(group);
        }
        public void ShareDocumentWithUsers()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var dlId = new Guid("6ADC119D-C6A8-E411-8278-14FEB5F06078");

            var userWopUsId = new Guid("369493C9-36AD-E211-9D53-14FEB5F06078");
            var userWpUsId = new Guid("A6DFFCC3-35AD-E211-9D53-14FEB5F06078");
            var aceAdmin = new Guid("ABD2F88A-8861-E111-8E23-14FEB5F06078");

            var userList = new List<Guid>
            {
                userWopUsId,
                userWpUsId,
                aceAdmin
            };

            //var document = vaultApi.Documents.GetDocument(dlId, new RequestOptions { Fields = "Id,DhId,FieldId,FieldType,Label,Required,Value,OrdinalPosition,CreateDate,CreateById,CreateBy,ModifyDate,ModifyBy,ModifyById" });
            var documentShare = vaultApi.DocumentShares.ShareDocument(dlId, userList);

            Assert.IsNotEmpty(documentShare);
        }
        public void CreateNewDocumentWithZeroByteFile()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var folder = vaultApi.Folders.GetFolderByPath("/Arbys");

            Assert.NotNull(folder);

            if (folder != null)
            {
                //var indexFields = new List<KeyValuePair<string, string>>();
                var indexFields = new List<KeyValuePair<string, string>>
                {
                    new KeyValuePair<string, string>("Name", "Leather Hat")
                };

                var document = vaultApi.Documents.CreateDocumentWithEmptyFile(folder.Id, "12345.txt", "Zero Byte Upload", "1", "12345.txt", 55125, DocumentState.Released, indexFields);

                Assert.IsNotNull(document);

                //var fileArray = new byte[0];

                //var returnObject = vaultApi.Files.UploadZeroByteFile(document.DocumentId, "12345.txt", 5, fileArray);

            }
        }
        public void CreateNewFormInstanceWithData()
        {
            ClientSecrets clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            VaultApi vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var template = vaultApi.FormTemplates.GetFormTemplate("API REST Form Test ");
            Assert.IsNotNull(template);

            //var formTemplateId = new Guid("F9CB9977-5B0E-E211-80A1-14FEB5F06078");

            var fields = new List<KeyValuePair<string, object>>();
            fields.Add(new KeyValuePair<string, object>("Field1", "Some Text Value"));
            fields.Add(new KeyValuePair<string, object>("Field2", "jj"));
            fields.Add(new KeyValuePair<string, object>("Field3", "Bad Date Example"));

            var formInstance = vaultApi.FormTemplates.CreateNewFormInstance(template.Id, fields);
            Assert.IsNotNull(formInstance);

            //foreach (FormTemplate formTemplate in formTemplates.Items)
            //{
            //    Assert.IsNotNullOrEmpty(formTemplate.Name);
            //}

            //Assert.IsNotNull(formTemplates);
        }
        public void CallScheduledProcessCompleteUsingQueryString()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var spToken = new Guid("C1647446-4417-4341-B1F2-D82FAAEE20EA");

            vaultApi.ScheduledProcess.CallCompleteScheduledProcessUsingQueryString(spToken, "Test Message", true);

            //Assert.IsNotNull(data);
        }
        public void FormDataLookupByInstanceNameTest()
        {
            ClientSecrets clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            VaultApi vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            //"FormTemplates/bde2c653-f735-e511-80c8-0050568dab97/forms", "q=[instancename] eq '" + masterFormId + "'"	"q=[instancename] eq 'Patient-000053'"
            //"bde2c653-f735-e511-80c8-0050568dab97"
            //Query = "[instancename] eq 'Patient-000053'",
            var requestOptions = new RequestOptions
            {
                Query = "[ModifyDate] ge '2015-11-07T22:18:09.444Z'",
                Fields = "dhdocid,revisionid"
            };

            var formdata = vaultApi.FormTemplates.GetFormInstanceData(new Guid("FDC7C07B-5ACC-E511-AB37-5CF3706C36ED"), requestOptions);

            //foreach (FormTemplate formTemplate in formTemplates.Items)
            //{
            //    Assert.IsNotNullOrEmpty(formTemplate.Name);
            //}

            Assert.IsNotNull(formdata);
        }
        public void ClientCredentialsGrantType_LoginTest()
        {
            ClientSecrets clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            VaultApi vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);
        }
        public void FormTemplateNameTest()
        {
            ClientSecrets clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            VaultApi vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var formTemplate = vaultApi.FormTemplates.GetFormTemplate("Encounters");

            Assert.IsNotNull(formTemplate);

            Debug.WriteLine("Form template name: " + formTemplate.Name);
        }
        public void CreateChildFolder()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var parentFolder = vaultApi.Folders.GetFolderByPath("/General");
            if (parentFolder != null)
            {
                var namingConventionPrefix = "ChilderFolder1-";
                var namingConventionSufix = "";
                var datePosition = DocDatePosition.NoDateInsert;
                var docSeqType = VVRestApi.Vault.Library.DocSeqType.TypeInteger;
                var expireAction = ExpireAction.Nothing;
                var expireRequired = false;
                var expirationDays = 0;
                var reviewRequired = false;
                var reviewDays = 0;

                var folder = vaultApi.Folders.CreateChildFolder(parentFolder.Id, "ChildFolder1", "ChildFolder1", false, false, true, namingConventionPrefix, namingConventionSufix, datePosition, docSeqType, expireAction, expireRequired, expirationDays, reviewRequired, reviewDays);

                Assert.IsNotNull(folder);
            }
        }
        public void GetAnnotationLayersWithPrivileges()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var annotationLayers = vaultApi.DocumentViewer.GetAnnotationLayersWithPrivileges(new Guid(RestApiTests.ResourceOwnerUsID));
        }
        public void CreateChildFolderWithNameOnly()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var parentFolder = vaultApi.Folders.GetFolderByPath("/General");
            if (parentFolder != null)
            {
                var folder = vaultApi.Folders.CreateChildFolder(parentFolder.Id, "SampleChildFolder2");

                Assert.IsNotNull(folder);
            }
        }
        public void GetChildFolders()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var arbysFolder = vaultApi.Folders.GetFolderByPath("/Arbys");
            Assert.IsNotNull(arbysFolder);
            if (arbysFolder != null)
            {
                List<Folder> childFolderListList = vaultApi.Folders.GetChildFolders(arbysFolder.Id);

                Assert.IsNotEmpty(childFolderListList);
            }
        }
        public void CreateCustomerTest()
        {
            ClientSecrets clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            VaultApi vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var newCustomer = vaultApi.Customer.CreateCustomer("Customer2", "Customer2", "Main", "Customer2.Admin", "p",
                                             "*****@*****.**", 1, 5, true);

            Assert.IsNotNull(newCustomer);
        }
        public void GetCustomQueryByQueryName()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var queryName = "Department";
            var queryId = new Guid("AEB2F858-7B96-E111-972B-14FEB5F06078");

            var results = vaultApi.CustomQueryManager.GetCustomQueryResults(queryName);

            var count = results;
        }
        public void CreateFolderByPath()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var folderPath = "/Community/Airplanes/Lockheed";

            var folderDescription = "Lockheed Folder";
            var allowRevisions = true;
            var namingConventionPrefix = "Lockheed-";
            var namingConventionSufix = "";
            var datePosition = DocDatePosition.NoDateInsert;
            var docSeqType = VVRestApi.Vault.Library.DocSeqType.TypeInteger;
            var expireAction = ExpireAction.Nothing;
            var expireRequired = false;
            var expirationDays = 0;
            var reviewRequired = false;
            var reviewDays = 0;

            var folder = vaultApi.Folders.CreateFolderByPath(folderPath, folderDescription, false, false, allowRevisions, namingConventionPrefix, namingConventionSufix, datePosition, docSeqType, expireAction, expireRequired, expirationDays, reviewRequired, reviewDays);
            Assert.IsNotNull(folder);
        }
        public void CreateGlobalIndexFieldDefinition()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var indexField = vaultApi.IndexFields.CreateIndexField("US Parks 1", "List of US Parks", FolderIndexFieldType.DatasourceDropDown, Guid.Empty, new Guid("1AC5A2D0-1F4D-E511-82A3-5CF3706C36ED"), "Name", "Id", true, "2");

            Assert.IsNotNull(indexField);
        }
        public void SetSecurityMembersOnFolder()
        {
            var clientSecrets = new ClientSecrets
            {
                ApiKey = RestApiTests.ClientId,
                ApiSecret = RestApiTests.ClientSecret,
                OAuthTokenEndPoint = RestApiTests.OAuthServerTokenEndPoint,
                BaseUrl = RestApiTests.VaultApiBaseUrl,
                ApiVersion = RestApiTests.ApiVersion,
                CustomerAlias = RestApiTests.CustomerAlias,
                DatabaseAlias = RestApiTests.DatabaseAlias,
                Scope = RestApiTests.Scope
            };

            var vaultApi = new VaultApi(clientSecrets);

            Assert.IsNotNull(vaultApi);

            var generalFolder = vaultApi.Folders.GetFolderByPath("/General");

            Assert.AreNotEqual(Guid.Empty, generalFolder.Id);

            if (generalFolder != null)
            {
                var securityActionList = new List<SecurityMemberApplyAction>();
                securityActionList.Add(new SecurityMemberApplyAction
                {
                    Action = SecurityAction.Add,
                    MemberId = new Guid("069493C9-36AD-E211-9D53-14FEB5F06078"),
                    MemberType =  MemberType.Group,
                    RoleType = RoleType.Viewer
                });
                securityActionList.Add(new SecurityMemberApplyAction
                {
                    Action = SecurityAction.Add,
                    MemberId = new Guid("B4384FBA-40AD-E211-9D53-14FEB5F06078"),
                    MemberType = MemberType.User,
                    RoleType = RoleType.Owner
                });

                var updateCount = vaultApi.Folders.UpdateSecurityMembers(generalFolder.Id, securityActionList, true);

                Assert.AreEqual(2, updateCount);
            }
        }