示例#1
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListCachingRulesRequest request;

            try
            {
                request = new ListCachingRulesRequest
                {
                    WaasPolicyId = WaasPolicyId,
                    OpcRequestId = OpcRequestId,
                    Limit        = Limit,
                    Page         = Page
                };
                IEnumerable <ListCachingRulesResponse> 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);
            }
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListCachingRulesRequest request;

            try
            {
                request = new ListCachingRulesRequest
                {
                    WaasPolicyId = WaasPolicyId,
                    OpcRequestId = OpcRequestId,
                    Limit        = Limit,
                    Page         = Page
                };
                IEnumerable <ListCachingRulesResponse> 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 the currently configured caching rules for the Web Application Firewall configuration of a specified WAAS policy. The rules are processed in the order they are
        /// specified in and the first matching rule will be used when processing a request.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ListCachingRulesResponse ListCachingRules(ListCachingRulesRequest request)
        {
            var uri = new Uri($"{GetEndPoint(WaasServices.WaasPolicies, this.Region)}/{request.WaasPolicyId}/wafConfig/cachingRules?{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 ListCachingRulesResponse()
                        {
                            Items = this.JsonSerializer.Deserialize <List <CachingRuleSummary> >(response),
                            OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                            OpcNextPage = webResponse.Headers.Get("opc-request-id"),
                            ETag = webResponse.Headers.Get("etag")
                        });
                    }
        }