Esempio n. 1
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            UpdateWhitelistsRequest request;

            try
            {
                request = new UpdateWhitelistsRequest
                {
                    WaasPolicyId  = WaasPolicyId,
                    Whitelists    = Whitelists,
                    OpcRequestId  = OpcRequestId,
                    OpcRetryToken = OpcRetryToken,
                    IfMatch       = IfMatch
                };

                response = client.UpdateWhitelists(request).GetAwaiter().GetResult();
                WriteOutput(response, CreateWorkRequestObject(response.OpcWorkRequestId));
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Updates the list of IP addresses that bypass the Web Application Firewall for a WAAS policy. Supports both single IP addresses or subnet masks (CIDR notation).
        ///
        /// This operation can create, delete, update, and/or reorder whitelists depending on the structure of the request body.
        ///
        /// Whitelists can be updated by changing the properties of the whitelist object with the rule's key specified in the key field. Whitelists can be reordered by changing the order of
        /// the whitelists in the list of objects when updating.
        ///
        /// Whitelists can be created by adding a new whitelist object to the list without a key property specified. A key will be generated for the new whitelist upon update.
        ///
        /// Whitelists can be deleted by removing the existing whitelist object from the list. Any existing whitelists that are not specified with a key in the list of access rules will be
        /// deleted upon update.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public UpdateWhitelistsResponse UpdateWhitelists(UpdateWhitelistsRequest request)
        {
            var uri = new Uri($"{GetEndPoint(WaasServices.WaasPolicies, this.Region)}/{request.WaasPolicyId}/wafConfig/whitelists");

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

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

                        return(new UpdateWhitelistsResponse()
                        {
                            OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                            OpcWorkRequestId = webResponse.Headers.Get("opc-work-request-id")
                        });
                    }
        }