protected override async Task ProcessRecordAsync() { await Task.Run(() => { AddToQueryCollection(Name, new PgQuery(Query)); var res = SavedQueries.Select(s => new { Name = s.Key, s.Value.Query }); if (!Quiet) { WriteObject(res); } }); }
protected override async Task ProcessRecordAsync() { await Task.Run(() => { var res = SavedQueries .Where(s => Name == null || Name == s.Key) .Select(s => new { Name = s.Key, s.Value.Query, Parameters = s.Value.GetQueryParameters() }); if (!Quiet) { WriteObject(res); } }); }
/// <summary> /// Save the General.Modules settings to the settings file /// </summary> /// <param name="pathsNode">XML-node for the General.Modules settings</param> public void Save(XmlNode modulesNode) { string xpath; //XmlNode node; xpath = "./showLogin"; SettingsHelper.SetSettingValue(xpath, modulesNode, ShowLogin.ToString()); xpath = "./usageLogging"; SettingsHelper.SetSettingValue(xpath, modulesNode, UsageLogging.ToString()); xpath = "./savedQueries"; SettingsHelper.SetSettingValue(xpath, modulesNode, SavedQueries.ToString()); }
new public object GetDynamicParameters() { base.GetDynamicParameters(); var queryParamAttr = new Collection <Attribute> { }; queryParamAttr.Add(new ParameterAttribute { Mandatory = false }); if (SavedQueries != null) { queryParamAttr.Add(new ValidateSetAttribute(SavedQueries.Select(query => query.Key).ToArray())); } DynamicParameters.Add( "Query", new RuntimeDefinedParameter("Query", typeof(string), queryParamAttr) ); return(DynamicParameters); }
public void CreateAccessKey_With_All_Properties_Given_As_Null_Success() { var settings = new ProjectSettingsProvider(projectId: "X", masterKey: SettingsEnv.MasterKey); // Replace X with respective value var client = new KeenClient(settings); if (UseMocks) { client.AccessKeys = new AccessKeysMock(settings, createAccessKey: new Func <AccessKey, IProjectSettings, JObject>((e, p) => { Assert.True(p == settings, "Incorrect Settings"); Assert.NotNull(e.Name, "Expected a name for the newly created Key"); Assert.NotNull(e.Permitted, "Expected a list of high level actions this key can perform"); Assert.NotNull(e.Options, "Expected an object containing more details about the key’s permitted and restricted functionality"); if ((p == settings) && (e.Name == "TestAccessKey") && (e.IsActive) && e.Permitted.First() == "queries" && e.Options.CachedQueries.Allowed.First() == "my_cached_query") { return(new JObject()); } else { throw new Exception("Unexpected value"); } })); } HashSet <string> permissions = new HashSet <string>() { "queries" }; List <QueryFilter> qFilters = new List <QueryFilter>() { new QueryFilter("customer.id", QueryFilter.FilterOperator.Equals(), "asdf12345z") }; CachedQueries cachedQueries = new CachedQueries() { Allowed = null, Blocked = null }; SavedQueries savedQuaries = new SavedQueries() { Allowed = null, Blocked = null, Filters = null }; Datasets datasets = new Datasets() { Allowed = null, Blocked = null, Operations = null }; Writes writes = new Writes() { Autofill = null }; cachedQueries.Allowed = new HashSet <string>() { "my_cached_query" }; Options options = new Options() { Queries = new Core.AccessKey.Queries { Filters = qFilters }, CachedQueries = cachedQueries, SavedQueries = savedQuaries, Datasets = datasets, Writes = writes }; Assert.DoesNotThrow(() => client.CreateAccessKey(new AccessKey { Name = "TestAccessKey", IsActive = true, Options = options, Permitted = permissions })); }