/// <summary> /// Validate the object. /// </summary> /// <exception cref="ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (Name == null) { throw new ValidationException(ValidationRules.CannotBeNull, "Name"); } if (Origins == null) { throw new ValidationException(ValidationRules.CannotBeNull, "Origins"); } if (HealthProbeSettings != null) { HealthProbeSettings.Validate(); } if (TrafficRestorationTimeToHealedOrNewEndpointsInMinutes > 50) { throw new ValidationException(ValidationRules.InclusiveMaximum, "TrafficRestorationTimeToHealedOrNewEndpointsInMinutes", 50); } if (TrafficRestorationTimeToHealedOrNewEndpointsInMinutes < 0) { throw new ValidationException(ValidationRules.InclusiveMinimum, "TrafficRestorationTimeToHealedOrNewEndpointsInMinutes", 0); } if (ResponseBasedOriginErrorDetectionSettings != null) { ResponseBasedOriginErrorDetectionSettings.Validate(); } }
internal CdnOriginGroupData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, HealthProbeSettings healthProbeSettings, IList <WritableSubResource> origins, int?trafficRestorationTimeToHealedOrNewEndpointsInMinutes, ResponseBasedOriginErrorDetectionSettings responseBasedOriginErrorDetectionSettings, OriginGroupResourceState?resourceState, string provisioningState) : base(id, name, resourceType, systemData) { HealthProbeSettings = healthProbeSettings; Origins = origins; TrafficRestorationTimeToHealedOrNewEndpointsInMinutes = trafficRestorationTimeToHealedOrNewEndpointsInMinutes; ResponseBasedOriginErrorDetectionSettings = responseBasedOriginErrorDetectionSettings; ResourceState = resourceState; ProvisioningState = provisioningState; }
internal FrontDoorOriginGroupData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string profileName, LoadBalancingSettings loadBalancingSettings, HealthProbeSettings healthProbeSettings, int?trafficRestorationTimeInMinutes, EnabledState?sessionAffinityState, FrontDoorProvisioningState?provisioningState, FrontDoorDeploymentStatus?deploymentStatus) : base(id, name, resourceType, systemData) { ProfileName = profileName; LoadBalancingSettings = loadBalancingSettings; HealthProbeSettings = healthProbeSettings; TrafficRestorationTimeInMinutes = trafficRestorationTimeInMinutes; SessionAffinityState = sessionAffinityState; ProvisioningState = provisioningState; DeploymentStatus = deploymentStatus; }
internal static FrontDoorOriginGroupData DeserializeFrontDoorOriginGroupData(JsonElement element) { ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; Optional <string> profileName = default; Optional <LoadBalancingSettings> loadBalancingSettings = default; Optional <HealthProbeSettings> healthProbeSettings = default; Optional <int?> trafficRestorationTimeToHealedOrNewEndpointsInMinutes = default; Optional <EnabledState> sessionAffinityState = default; Optional <FrontDoorProvisioningState> provisioningState = default; Optional <FrontDoorDeploymentStatus> deploymentStatus = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = new ResourceType(property.Value.GetString()); continue; } if (property.NameEquals("systemData")) { systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString()); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("profileName")) { profileName = property0.Value.GetString(); continue; } if (property0.NameEquals("loadBalancingSettings")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } loadBalancingSettings = LoadBalancingSettings.DeserializeLoadBalancingSettings(property0.Value); continue; } if (property0.NameEquals("healthProbeSettings")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } healthProbeSettings = HealthProbeSettings.DeserializeHealthProbeSettings(property0.Value); continue; } if (property0.NameEquals("trafficRestorationTimeToHealedOrNewEndpointsInMinutes")) { if (property0.Value.ValueKind == JsonValueKind.Null) { trafficRestorationTimeToHealedOrNewEndpointsInMinutes = null; continue; } trafficRestorationTimeToHealedOrNewEndpointsInMinutes = property0.Value.GetInt32(); continue; } if (property0.NameEquals("sessionAffinityState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } sessionAffinityState = new EnabledState(property0.Value.GetString()); continue; } if (property0.NameEquals("provisioningState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } provisioningState = new FrontDoorProvisioningState(property0.Value.GetString()); continue; } if (property0.NameEquals("deploymentStatus")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } deploymentStatus = new FrontDoorDeploymentStatus(property0.Value.GetString()); continue; } } continue; } } return(new FrontDoorOriginGroupData(id, name, type, systemData, profileName.Value, loadBalancingSettings.Value, healthProbeSettings.Value, Optional.ToNullable(trafficRestorationTimeToHealedOrNewEndpointsInMinutes), Optional.ToNullable(sessionAffinityState), Optional.ToNullable(provisioningState), Optional.ToNullable(deploymentStatus))); }
internal static CdnOriginGroupData DeserializeCdnOriginGroupData(JsonElement element) { ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; Optional <HealthProbeSettings> healthProbeSettings = default; Optional <IList <WritableSubResource> > origins = default; Optional <int?> trafficRestorationTimeToHealedOrNewEndpointsInMinutes = default; Optional <ResponseBasedOriginErrorDetectionSettings> responseBasedOriginErrorDetectionSettings = default; Optional <OriginGroupResourceState> resourceState = default; Optional <OriginGroupProvisioningState> provisioningState = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = new ResourceType(property.Value.GetString()); continue; } if (property.NameEquals("systemData")) { systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString()); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("healthProbeSettings")) { if (property0.Value.ValueKind == JsonValueKind.Null) { healthProbeSettings = null; continue; } healthProbeSettings = HealthProbeSettings.DeserializeHealthProbeSettings(property0.Value); continue; } if (property0.NameEquals("origins")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <WritableSubResource> array = new List <WritableSubResource>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(JsonSerializer.Deserialize <WritableSubResource>(item.ToString())); } origins = array; continue; } if (property0.NameEquals("trafficRestorationTimeToHealedOrNewEndpointsInMinutes")) { if (property0.Value.ValueKind == JsonValueKind.Null) { trafficRestorationTimeToHealedOrNewEndpointsInMinutes = null; continue; } trafficRestorationTimeToHealedOrNewEndpointsInMinutes = property0.Value.GetInt32(); continue; } if (property0.NameEquals("responseBasedOriginErrorDetectionSettings")) { if (property0.Value.ValueKind == JsonValueKind.Null) { responseBasedOriginErrorDetectionSettings = null; continue; } responseBasedOriginErrorDetectionSettings = ResponseBasedOriginErrorDetectionSettings.DeserializeResponseBasedOriginErrorDetectionSettings(property0.Value); continue; } if (property0.NameEquals("resourceState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } resourceState = new OriginGroupResourceState(property0.Value.GetString()); continue; } if (property0.NameEquals("provisioningState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } provisioningState = new OriginGroupProvisioningState(property0.Value.GetString()); continue; } } continue; } } return(new CdnOriginGroupData(id, name, type, systemData, healthProbeSettings.Value, Optional.ToList(origins), Optional.ToNullable(trafficRestorationTimeToHealedOrNewEndpointsInMinutes), responseBasedOriginErrorDetectionSettings.Value, Optional.ToNullable(resourceState), Optional.ToNullable(provisioningState))); }