Exemplo n.º 1
0
        public async void FindRetentionPolicies()
        {
            var md  = TestMetadata;
            var rp1 = await _hiarc.CreateRetentionPolicy(60, md);

            md["quotaCarrying"] = false;
            await _hiarc.CreateRetentionPolicy(60, md);

            await _hiarc.CreateRetentionPolicy(60);

            var query = new List <Dictionary <string, object> >
            {
                new Dictionary <string, object>
                {
                    { "prop", "department" },
                    { "op", "starts with" },
                    { "value", "sal" }
                },
                new Dictionary <string, object>
                {
                    { "bool", "and" }
                },
                new Dictionary <string, object>
                {
                    { "parens", "(" }
                },
                new Dictionary <string, object>
                {
                    { "prop", "targetRate" },
                    { "op", ">=" },
                    { "value", 4.22 }
                },
                new Dictionary <string, object>
                {
                    { "bool", "and" }
                },
                new Dictionary <string, object>
                {
                    { "prop", "quotaCarrying" },
                    { "op", "=" },
                    { "value", true }
                },
                new Dictionary <string, object>
                {
                    { "parens", ")" }
                }
            };

            var request = new FindRetentionPoliciesRequest {
                Query = query
            };
            var foundPolicies = await _hiarc.FindRetentionPolicies(request);

            Assert.Single(foundPolicies);
            Assert.Equal(rp1, foundPolicies[0], new EntityComparer());
        }
Exemplo n.º 2
0
        public async Task <List <RetentionPolicy> > FindRetentionPolicies(FindRetentionPoliciesRequest request, string asUserKey = null, string bearerToken = null, bool logToConsole = true)
        {
            var foundPolicies = await Post <FindRetentionPoliciesRequest, List <RetentionPolicy> >(request, "retentionpolicies/find", asUserKey, bearerToken);

            if (logToConsole)
            {
                Console.WriteLine($"Found {foundPolicies.Count} Policies: {ToJson(foundPolicies)}");
            }
            ;
            return(foundPolicies);
        }
Exemplo n.º 3
0
        public async Task <IActionResult> FindRetentionPolicies([FromBody] FindRetentionPoliciesRequest request)
        {
            try
            {
                var matchingPolicies = await _hiarcDatabase.FindRetentionPolicies(request);

                return(Ok(matchingPolicies));
            }
            catch (Exception ex)
            {
                return(BuildErrorResponse(ex, _logger));
            }
        }