/// <summary> /// Creates a VaultApi helper object which will make HTTP API calls using the provided client application/developer credentials. /// (OAuth2 protocol Client Credentials Grant Type) /// Includes the Tokens that were created from an earlier call /// </summary> /// <param name="clientSecrets"></param> /// <param name="tokens"></param> public VaultApi(ClientSecrets clientSecrets, Tokens tokens) { if (!string.IsNullOrEmpty(tokens.AccessToken)) { this.ApiTokens = tokens; this.ClientSecrets = clientSecrets; this.REST = new RestManager(this); this.DocumentViewer = new DocumentViewerManager(this); this.Sites = new SitesManager(this); this.ScheduledProcess = new ScheduledProcessManager(this); this.CurrentUser = new CurrentUserManager(this); this.Users = new UsersManager(this); this.Groups = new GroupsManager(this); this.Folders = new FoldersManager(this); this.Files = new FilesManager(this); this.FormInstances = new FormInstancesManager(this); this.FormTemplates = new FormTemplatesManager(this); this.Documents = new DocumentsManager(this); this.IndexFields = new IndexFieldManager(this); this.Files = new FilesManager(this); this.CustomQueryManager = new CustomQueryManager(this); this.DocumentShares = new DocumentShareManager(this); this.Meta = new MetaManager(this); this.PersistedData = new PersistedData.PersistedDataManager(this); this.Customer = new CustomerManager(this); } }
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; }
internal void Populate(JToken meta, JToken data, ClientSecrets clientSecrets, Tokens apiTokens) { this.Populate(clientSecrets, apiTokens); //Now populate the meta try { this.Meta = meta.ToObject<ApiMetaData>(); } catch (Exception ex) { LogEventManager.Error("Error deserializing the Meta node.", ex); this.Meta = new ApiMetaData(); this.Meta.ErrorMessages.Add(new ApiErrorMessage { DeveloperMessage = ex.Message }); this.Meta.StatusCode = HttpStatusCode.BadRequest; } if (data != null) { this.PopulateData(data); } }
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 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 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 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); }
/// <summary> /// Creates a VaultApi helper object which will make HTTP API calls using the provided client application/developer credentials AND /// the provied UserName/Password credentials. After authenticating the client application, the Resource Owner credentials are authenticated /// and used for all subsequent HTTP API access /// (OAuth2 protocol Resource Owner Grant Type) /// </summary> /// <param name="clientSecrets"></param> /// <param name="userName"></param> /// <param name="password"></param> public VaultApi(ClientSecrets clientSecrets, string userName, string password) { this.ApiTokens = HttpHelper.GetAccessToken(clientSecrets.OAuthTokenEndPoint, clientSecrets.ApiKey, clientSecrets.ApiSecret, userName, password).Result; if (!string.IsNullOrEmpty(this.ApiTokens.AccessToken)) { this.ClientSecrets = clientSecrets; this.REST = new RestManager(this); this.DocumentViewer = new DocumentViewerManager(this); this.Sites = new SitesManager(this); this.ScheduledProcess = new ScheduledProcessManager(this); this.CurrentUser = new CurrentUserManager(this); this.Users = new UsersManager(this); this.Groups = new GroupsManager(this); this.Folders = new FoldersManager(this); this.FormInstances = new FormInstancesManager(this); this.FormTemplates = new FormTemplatesManager(this); this.Documents = new DocumentsManager(this); this.IndexFields = new IndexFieldManager(this); this.Files = new FilesManager(this); this.CustomQueryManager = new CustomQueryManager(this); this.DocumentShares = new DocumentShareManager(this); this.Meta = new MetaManager(this); this.PersistedData = new PersistedData.PersistedDataManager(this); } }
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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); //} }