protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListWafLogsRequest request;

            try
            {
                request = new ListWafLogsRequest
                {
                    WaasPolicyId = WaasPolicyId,
                    OpcRequestId = OpcRequestId,
                    Limit        = Limit,
                    Page         = Page,
                    TimeObservedGreaterThanOrEqualTo = TimeObservedGreaterThanOrEqualTo,
                    TimeObservedLessThan             = TimeObservedLessThan,
                    TextContains      = TextContains,
                    AccessRuleKey     = AccessRuleKey,
                    Action            = Action,
                    ClientAddress     = ClientAddress,
                    CountryCode       = CountryCode,
                    CountryName       = CountryName,
                    Fingerprint       = Fingerprint,
                    HttpMethod        = HttpMethod,
                    IncidentKey       = IncidentKey,
                    LogType           = LogType,
                    OriginAddress     = OriginAddress,
                    Referrer          = Referrer,
                    RequestUrl        = RequestUrl,
                    ResponseCode      = ResponseCode,
                    ThreatFeedKey     = ThreatFeedKey,
                    UserAgent         = UserAgent,
                    ProtectionRuleKey = ProtectionRuleKey
                };
                IEnumerable <ListWafLogsResponse> responses = GetRequestDelegate().Invoke(request);
                foreach (var item in responses)
                {
                    response = item;
                    WriteOutput(response, response.Items, true);
                }
                if (!ParameterSetName.Equals(AllPageSet) && !ParameterSetName.Equals(LimitSet) && response.OpcNextPage != null)
                {
                    WriteWarning("This operation supports pagination and not all resources were returned. Re-run using the -All option to auto paginate and list all resources.");
                }
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
示例#2
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListWafLogsRequest request;

            try
            {
                request = new ListWafLogsRequest
                {
                    WaasPolicyId = WaasPolicyId,
                    OpcRequestId = OpcRequestId,
                    Limit        = Limit,
                    Page         = Page,
                    TimeObservedGreaterThanOrEqualTo = TimeObservedGreaterThanOrEqualTo,
                    TimeObservedLessThan             = TimeObservedLessThan,
                    TextContains      = TextContains,
                    AccessRuleKey     = AccessRuleKey,
                    Action            = Action,
                    ClientAddress     = ClientAddress,
                    CountryCode       = CountryCode,
                    CountryName       = CountryName,
                    Fingerprint       = Fingerprint,
                    HttpMethod        = HttpMethod,
                    IncidentKey       = IncidentKey,
                    LogType           = LogType,
                    OriginAddress     = OriginAddress,
                    Referrer          = Referrer,
                    RequestUrl        = RequestUrl,
                    ResponseCode      = ResponseCode,
                    ThreatFeedKey     = ThreatFeedKey,
                    UserAgent         = UserAgent,
                    ProtectionRuleKey = ProtectionRuleKey
                };
                IEnumerable <ListWafLogsResponse> responses = GetRequestDelegate().Invoke(request);
                foreach (var item in responses)
                {
                    response = item;
                    WriteOutput(response, response.Items, true);
                }
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
示例#3
0
        /// <summary>
        /// Gets structured Web Application Firewall event logs for a WAAS policy. Sorted by the timeObserved in ascending order (starting from the oldest recorded event).
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ListWafLogsResponse ListWafLogs(ListWafLogsRequest request)
        {
            var uri = new Uri($"{GetEndPoint(WaasServices.WaasPolicies, this.Region)}/{request.WaasPolicyId}/wafLogs?{request.GetOptionQuery()}");

            var httpRequestHeaderParam = new HttpRequestHeaderParam()
            {
                OpcRequestId = request.OpcRequestId
            };

            using (var webResponse = this.RestClient.Get(uri, httpRequestHeaderParam))
                using (var stream = webResponse.GetResponseStream())
                    using (var reader = new StreamReader(stream))
                    {
                        var response = reader.ReadToEnd();

                        return(new ListWafLogsResponse()
                        {
                            Items = this.JsonSerializer.Deserialize <List <WafLogDetails> >(response),
                            OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                            OpcNextPage = webResponse.Headers.Get("opc-request-id")
                        });
                    }
        }