// This is an automatically generated code sample.
// To make this code sample work in your Oracle Cloud tenancy,
// please replace the values for any parameters whose current values do not fit
// your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
// boolean, number, and enum parameters with values not fitting your use case).
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Oci.WaasService;
using Oci.Common;
using Oci.Common.Auth;
namespace Oci.Sdk.DotNet.Example.Waas
{
public class UpdateWaasPolicyExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var updateWaasPolicyDetails = new Oci.WaasService.Models.UpdateWaasPolicyDetails
{
DisplayName = "EXAMPLE-displayName-Value",
AdditionalDomains = new List<string>
{
"EXAMPLE--Value"
},
Origins = new Dictionary<string, Oci.WaasService.Models.Origin>()
{
{
"EXAMPLE_KEY_1v9hO",
new Oci.WaasService.Models.Origin
{
Uri = "EXAMPLE-uri-Value",
HttpPort = 62022,
HttpsPort = 43370,
CustomHeaders = new List<Oci.WaasService.Models.Header>
{
new Oci.WaasService.Models.Header
{
Name = "EXAMPLE-name-Value",
Value = "EXAMPLE-value-Value"
}
}
}
}
},
OriginGroups = new Dictionary<string, Oci.WaasService.Models.OriginGroup>()
{
{
"EXAMPLE_KEY_B7Mmp",
new Oci.WaasService.Models.OriginGroup
{
Origins = new List<Oci.WaasService.Models.OriginGroup_origins>
{
new Oci.WaasService.Models.OriginGroup_origins
{
Origin = "EXAMPLE-origin-Value",
Weight = 4400
}
}
}
}
},
PolicyConfig = new Oci.WaasService.Models.PolicyConfig
{
CertificateId = "ocid1.test.oc1..<unique_ID>EXAMPLE-certificateId-Value",
IsHttpsEnabled = false,
IsHttpsForced = false,
TlsProtocols = new List<Oci.WaasService.Models.PolicyConfig.TlsProtocolsEnum>
{
Oci.WaasService.Models.PolicyConfig.TlsProtocolsEnum.TlsV12
},
IsOriginCompressionEnabled = true,
IsBehindCdn = false,
ClientAddressHeader = Oci.WaasService.Models.PolicyConfig.ClientAddressHeaderEnum.TrueClientIp,
IsCacheControlRespected = true,
IsResponseBufferingEnabled = true,
CipherGroup = Oci.WaasService.Models.PolicyConfig.CipherGroupEnum.Default,
LoadBalancingMethod = new Oci.WaasService.Models.StickyCookieLoadBalancingMethod
{
Name = "EXAMPLE-name-Value",
Domain = "EXAMPLE-domain-Value",
ExpirationTimeInSeconds = 28812571
},
WebsocketPathPrefixes = new List<string>
{
"EXAMPLE--Value"
},
IsSniEnabled = false,
HealthChecks = new Oci.WaasService.Models.HealthCheck
{
IsEnabled = false,
Method = Oci.WaasService.Models.HealthCheck.MethodEnum.Head,
Path = "EXAMPLE-path-Value",
Headers = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_ZbTHx",
"EXAMPLE_VALUE_buqltC0F071ouRegq6ar"
}
},
ExpectedResponseCodeGroup = new List<Oci.WaasService.Models.HealthCheck.ExpectedResponseCodeGroupEnum>
{
Oci.WaasService.Models.HealthCheck.ExpectedResponseCodeGroupEnum._2Xx
},
IsResponseTextCheckEnabled = true,
ExpectedResponseText = "EXAMPLE-expectedResponseText-Value",
IntervalInSeconds = 46,
TimeoutInSeconds = 20,
HealthyThreshold = 2,
UnhealthyThreshold = 8
}
},
WafConfig = new Oci.WaasService.Models.WafConfig
{
AccessRules = new List<Oci.WaasService.Models.AccessRule>
{
new Oci.WaasService.Models.AccessRule
{
Name = "EXAMPLE-name-Value",
Criteria = new List<Oci.WaasService.Models.AccessRuleCriteria>
{
new Oci.WaasService.Models.AccessRuleCriteria
{
Condition = Oci.WaasService.Models.AccessRuleCriteria.ConditionEnum.CountryIsNot,
Value = "EXAMPLE-value-Value",
IsCaseSensitive = true
}
},
Action = Oci.WaasService.Models.AccessRule.ActionEnum.Block,
BlockAction = Oci.WaasService.Models.AccessRule.BlockActionEnum.ShowErrorPage,
BlockResponseCode = 605,
BlockErrorPageMessage = "EXAMPLE-blockErrorPageMessage-Value",
BlockErrorPageCode = "EXAMPLE-blockErrorPageCode-Value",
BlockErrorPageDescription = "EXAMPLE-blockErrorPageDescription-Value",
BypassChallenges = new List<Oci.WaasService.Models.AccessRule.BypassChallengesEnum>
{
Oci.WaasService.Models.AccessRule.BypassChallengesEnum.JsChallenge
},
RedirectUrl = "EXAMPLE-redirectUrl-Value",
RedirectResponseCode = Oci.WaasService.Models.AccessRule.RedirectResponseCodeEnum.Found,
CaptchaTitle = "EXAMPLE-captchaTitle-Value",
CaptchaHeader = "EXAMPLE-captchaHeader-Value",
CaptchaFooter = "EXAMPLE-captchaFooter-Value",
CaptchaSubmitLabel = "EXAMPLE-captchaSubmitLabel-Value",
ResponseHeaderManipulation = new List<Oci.WaasService.Models.HeaderManipulationAction>
{
new Oci.WaasService.Models.AddHttpResponseHeaderAction
{
Header = "EXAMPLE-header-Value",
Value = "EXAMPLE-value-Value"
}
}
}
},
AddressRateLimiting = new Oci.WaasService.Models.AddressRateLimiting
{
IsEnabled = true,
AllowedRatePerAddress = 3820,
MaxDelayedCountPerAddress = 729,
BlockResponseCode = 270
},
Captchas = new List<Oci.WaasService.Models.Captcha>
{
new Oci.WaasService.Models.Captcha
{
Url = "EXAMPLE-url-Value",
SessionExpirationInSeconds = 399211,
Title = "EXAMPLE-title-Value",
HeaderText = "EXAMPLE-headerText-Value",
FooterText = "EXAMPLE-footerText-Value",
FailureMessage = "EXAMPLE-failureMessage-Value",
SubmitLabel = "EXAMPLE-submitLabel-Value"
}
},
DeviceFingerprintChallenge = new Oci.WaasService.Models.DeviceFingerprintChallenge
{
IsEnabled = false,
Action = Oci.WaasService.Models.DeviceFingerprintChallenge.ActionEnum.Block,
FailureThreshold = 353434,
ActionExpirationInSeconds = 317613,
FailureThresholdExpirationInSeconds = 205874,
MaxAddressCount = 152,
MaxAddressCountExpirationInSeconds = 155116,
ChallengeSettings = new Oci.WaasService.Models.BlockChallengeSettings
{
BlockAction = Oci.WaasService.Models.BlockChallengeSettings.BlockActionEnum.ShowErrorPage,
BlockResponseCode = 239,
BlockErrorPageMessage = "EXAMPLE-blockErrorPageMessage-Value",
BlockErrorPageDescription = "EXAMPLE-blockErrorPageDescription-Value",
BlockErrorPageCode = "EXAMPLE-blockErrorPageCode-Value",
CaptchaTitle = "EXAMPLE-captchaTitle-Value",
CaptchaHeader = "EXAMPLE-captchaHeader-Value",
CaptchaFooter = "EXAMPLE-captchaFooter-Value",
CaptchaSubmitLabel = "EXAMPLE-captchaSubmitLabel-Value"
}
},
GoodBots = new List<Oci.WaasService.Models.GoodBot>
{
new Oci.WaasService.Models.GoodBot
{
Key = "EXAMPLE-key-Value",
Name = "EXAMPLE-name-Value",
IsEnabled = false,
Description = "EXAMPLE-description-Value"
}
},
HumanInteractionChallenge = new Oci.WaasService.Models.HumanInteractionChallenge
{
IsEnabled = true,
Action = Oci.WaasService.Models.HumanInteractionChallenge.ActionEnum.Block,
FailureThreshold = 644611,
ActionExpirationInSeconds = 309524,
FailureThresholdExpirationInSeconds = 195337,
InteractionThreshold = 82,
RecordingPeriodInSeconds = 9028,
SetHttpHeader = new Oci.WaasService.Models.Header
{
Name = "EXAMPLE-name-Value",
Value = "EXAMPLE-value-Value"
},
ChallengeSettings = new Oci.WaasService.Models.BlockChallengeSettings
{
BlockAction = Oci.WaasService.Models.BlockChallengeSettings.BlockActionEnum.ShowCaptcha,
BlockResponseCode = 314,
BlockErrorPageMessage = "EXAMPLE-blockErrorPageMessage-Value",
BlockErrorPageDescription = "EXAMPLE-blockErrorPageDescription-Value",
BlockErrorPageCode = "EXAMPLE-blockErrorPageCode-Value",
CaptchaTitle = "EXAMPLE-captchaTitle-Value",
CaptchaHeader = "EXAMPLE-captchaHeader-Value",
CaptchaFooter = "EXAMPLE-captchaFooter-Value",
CaptchaSubmitLabel = "EXAMPLE-captchaSubmitLabel-Value"
},
IsNatEnabled = true
},
JsChallenge = new Oci.WaasService.Models.JsChallenge
{
IsEnabled = true,
Action = Oci.WaasService.Models.JsChallenge.ActionEnum.Block,
FailureThreshold = 964692,
ActionExpirationInSeconds = 98058,
SetHttpHeader = new Oci.WaasService.Models.Header
{
Name = "EXAMPLE-name-Value",
Value = "EXAMPLE-value-Value"
},
ChallengeSettings = new Oci.WaasService.Models.BlockChallengeSettings
{
BlockAction = Oci.WaasService.Models.BlockChallengeSettings.BlockActionEnum.SetResponseCode,
BlockResponseCode = 612,
BlockErrorPageMessage = "EXAMPLE-blockErrorPageMessage-Value",
BlockErrorPageDescription = "EXAMPLE-blockErrorPageDescription-Value",
BlockErrorPageCode = "EXAMPLE-blockErrorPageCode-Value",
CaptchaTitle = "EXAMPLE-captchaTitle-Value",
CaptchaHeader = "EXAMPLE-captchaHeader-Value",
CaptchaFooter = "EXAMPLE-captchaFooter-Value",
CaptchaSubmitLabel = "EXAMPLE-captchaSubmitLabel-Value"
},
AreRedirectsChallenged = false,
Criteria = new List<Oci.WaasService.Models.AccessRuleCriteria>
{
new Oci.WaasService.Models.AccessRuleCriteria
{
Condition = Oci.WaasService.Models.AccessRuleCriteria.ConditionEnum.HttpMethodIs,
Value = "EXAMPLE-value-Value",
IsCaseSensitive = false
}
},
IsNatEnabled = false
},
Origin = "EXAMPLE-origin-Value",
CachingRules = new List<Oci.WaasService.Models.CachingRule>
{
new Oci.WaasService.Models.CachingRule
{
Key = "EXAMPLE-key-Value",
Name = "EXAMPLE-name-Value",
Action = Oci.WaasService.Models.CachingRule.ActionEnum.BypassCache,
CachingDuration = "EXAMPLE-cachingDuration-Value",
IsClientCachingEnabled = true,
ClientCachingDuration = "EXAMPLE-clientCachingDuration-Value",
Criteria = new List<Oci.WaasService.Models.CachingRuleCriteria>
{
new Oci.WaasService.Models.CachingRuleCriteria
{
Condition = Oci.WaasService.Models.CachingRuleCriteria.ConditionEnum.UrlPartContains,
Value = "EXAMPLE-value-Value"
}
}
}
},
CustomProtectionRules = new List<Oci.WaasService.Models.CustomProtectionRuleSetting>
{
new Oci.WaasService.Models.CustomProtectionRuleSetting
{
Id = "ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value",
Action = Oci.WaasService.Models.CustomProtectionRuleSetting.ActionEnum.Detect,
Exclusions = new List<Oci.WaasService.Models.ProtectionRuleExclusion>
{
new Oci.WaasService.Models.ProtectionRuleExclusion
{
Target = Oci.WaasService.Models.ProtectionRuleExclusion.TargetEnum.RequestCookieNames,
Exclusions = new List<string>
{
"EXAMPLE--Value"
}
}
}
}
},
OriginGroups = new List<string>
{
"EXAMPLE--Value"
},
ProtectionRules = new List<Oci.WaasService.Models.ProtectionRule>
{
new Oci.WaasService.Models.ProtectionRule
{
Key = "EXAMPLE-key-Value",
ModSecurityRuleIds = new List<string>
{
"EXAMPLE--Value"
},
Name = "EXAMPLE-name-Value",
Description = "EXAMPLE-description-Value",
Action = Oci.WaasService.Models.ProtectionRule.ActionEnum.Off,
Labels = new List<string>
{
"EXAMPLE--Value"
},
Exclusions = new List<Oci.WaasService.Models.ProtectionRuleExclusion>
{
new Oci.WaasService.Models.ProtectionRuleExclusion
{
Target = Oci.WaasService.Models.ProtectionRuleExclusion.TargetEnum.Args,
Exclusions = new List<string>
{
"EXAMPLE--Value"
}
}
}
}
},
ProtectionSettings = new Oci.WaasService.Models.ProtectionSettings
{
BlockAction = Oci.WaasService.Models.ProtectionSettings.BlockActionEnum.SetResponseCode,
BlockResponseCode = 831,
BlockErrorPageMessage = "EXAMPLE-blockErrorPageMessage-Value",
BlockErrorPageCode = "EXAMPLE-blockErrorPageCode-Value",
BlockErrorPageDescription = "EXAMPLE-blockErrorPageDescription-Value",
MaxArgumentCount = 5576,
MaxNameLengthPerArgument = 61082,
MaxTotalNameLengthOfArguments = 322836,
RecommendationsPeriodInDays = 71,
IsResponseInspected = false,
MaxResponseSizeInKiB = 258,
AllowedHttpMethods = new List<Oci.WaasService.Models.ProtectionSettings.AllowedHttpMethodsEnum>
{
Oci.WaasService.Models.ProtectionSettings.AllowedHttpMethodsEnum.Trace
},
MediaTypes = new List<string>
{
"EXAMPLE--Value"
}
},
ThreatFeeds = new List<Oci.WaasService.Models.ThreatFeed>
{
new Oci.WaasService.Models.ThreatFeed
{
Key = "EXAMPLE-key-Value",
Name = "EXAMPLE-name-Value",
Action = Oci.WaasService.Models.ThreatFeed.ActionEnum.Off,
Description = "EXAMPLE-description-Value"
}
},
Whitelists = new List<Oci.WaasService.Models.Whitelist>
{
new Oci.WaasService.Models.Whitelist
{
Name = "EXAMPLE-name-Value",
Addresses = new List<string>
{
"EXAMPLE--Value"
},
AddressLists = new List<string>
{
"EXAMPLE--Value"
}
}
}
},
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_ynNoK",
"EXAMPLE_VALUE_bTSPHjc5h3FTgH4buCcK"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_fsQeU",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_0wlPC",
"EXAMPLE--Value"
}
}
}
}
};
var updateWaasPolicyRequest = new Oci.WaasService.Requests.UpdateWaasPolicyRequest
{
WaasPolicyId = "ocid1.test.oc1..<unique_ID>EXAMPLE-waasPolicyId-Value",
UpdateWaasPolicyDetails = updateWaasPolicyDetails,
OpcRequestId = "3PSRIBSTRMIFUCBBPQGV<unique_ID>",
OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
IfMatch = "EXAMPLE-ifMatch-Value"
};
// Create a default authentication provider that uses the DEFAULT
// profile in the configuration file.
// Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file.
var provider = new ConfigFileAuthenticationDetailsProvider("DEFAULT");
try
{
// Create a service client and send the request.
using (var client = new WaasClient(provider, new ClientConfiguration()))
{
var response = await client.UpdateWaasPolicy(updateWaasPolicyRequest);
// Retrieve value from the response.
var versionValue = response.httpResponseMessage.Version;
}
}
catch (Exception e)
{
Console.WriteLine($"UpdateWaasPolicy Failed with {e.Message}");
throw e;
}
}
}
}