예제 #1
0
        public async Task <Rule> UpdateRuleAsync(string key, string markdownDescription = null, string markdownNote = null, string name = null, IDictionary <string, string> parameters = null,
                                                 string remediationFnBaseEffort         = null, RemediationFunctionTypes?remediationFnType = null, string remediationFyGapMultiplier = null, Severities?severity = null,
                                                 RuleStatuses?status = null, string[] tags = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                [nameof(key)]            = key,
                ["markdown_description"] = markdownDescription,
                ["markdown_note"]        = markdownNote,
                [nameof(name)]           = name,
                ["params"] = parameters?.Select(x => $"{x.Key}={x.Value}"),
                ["remediation_fn_base_effort"]     = remediationFnBaseEffort,
                ["remediation_fn_type"]            = RemediationFunctionTypesConverter.ToString(remediationFnType),
                ["remediation_fy_gap_multiplier_"] = remediationFyGapMultiplier,
                [nameof(severity)] = SeveritiesConverter.ToString(severity),
                [nameof(status)]   = RuleStatusesConverter.ToString(status),
                [nameof(tags)]     = tags == null ? null : string.Join(",", tags)
            };

            var response = await GetRulesUrl("create")
                           .SetQueryParams(queryParamValues)
                           .PostAsync(s_emptyHttpContent)
                           .ConfigureAwait(false);

            return(await HandleResponseFirstNodeAsync <Rule>(response).ConfigureAwait(false));
        }
예제 #2
0
        public async Task <Rule> CreateRuleAsync(string customKey, string markdownDescription, string name, IDictionary <string, string> parameters = null, bool?preventReactivation = null,
                                                 Severities?severity = null, RuleStatuses?status = null, string templateKey = null, IssueTypes?type = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                ["custom_key"]           = customKey,
                ["markdown_description"] = markdownDescription,
                [nameof(name)]           = name,
                ["params"] = parameters?.Select(x => $"{x.Key}={x.Value}"),
                ["prevent_reactivation"] = BooleanConverter.ToString(preventReactivation),
                [nameof(severity)]       = SeveritiesConverter.ToString(severity),
                [nameof(status)]         = RuleStatusesConverter.ToString(status),
                ["template_key"]         = templateKey,
                [nameof(type)]           = IssueTypesConverter.ToString(type)
            };

            var response = await GetRulesUrl("create")
                           .SetQueryParams(queryParamValues)
                           .PostAsync(s_emptyHttpContent)
                           .ConfigureAwait(false);

            return(await HandleResponseFirstNodeAsync <Rule>(response).ConfigureAwait(false));
        }