private HealthProbeParameters CreateHealthProbeSettingsByObject(PSAfdOriginGroup currentPsAfdOriginGroup, PSAfdOriginGroup proposedPsAfdOriginGroup)
        {
            HealthProbeParameters healthProbeSettings = new HealthProbeParameters
            {
                ProbeIntervalInSeconds = currentPsAfdOriginGroup.ProbeIntervalInSeconds,
                ProbePath        = currentPsAfdOriginGroup.ProbePath,
                ProbeProtocol    = AfdUtilities.CreateProbeProtocol(currentPsAfdOriginGroup.ProbeProtocol),
                ProbeRequestType = AfdUtilities.CreateProbeRequestType(currentPsAfdOriginGroup.ProbeRequestType)
            };

            if (proposedPsAfdOriginGroup.ProbeIntervalInSeconds != currentPsAfdOriginGroup.ProbeIntervalInSeconds)
            {
                healthProbeSettings.ProbeIntervalInSeconds = proposedPsAfdOriginGroup.ProbeIntervalInSeconds;
            }

            if (proposedPsAfdOriginGroup.ProbePath != currentPsAfdOriginGroup.ProbePath)
            {
                healthProbeSettings.ProbePath = proposedPsAfdOriginGroup.ProbePath;
            }

            if (proposedPsAfdOriginGroup.ProbeProtocol != currentPsAfdOriginGroup.ProbeProtocol)
            {
                healthProbeSettings.ProbeProtocol = AfdUtilities.CreateProbeProtocol(proposedPsAfdOriginGroup.ProbeProtocol);
            }

            if (proposedPsAfdOriginGroup.ProbeRequestType != currentPsAfdOriginGroup.ProbeRequestType)
            {
                healthProbeSettings.ProbeRequestType = AfdUtilities.CreateProbeRequestType(proposedPsAfdOriginGroup.ProbeRequestType);
            }

            return(healthProbeSettings);
        }
Exemple #2
0
 internal CdnOriginGroupData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, HealthProbeParameters healthProbeSettings, IList <WritableSubResource> origins, int?trafficRestorationTimeToHealedOrNewEndpointsInMinutes, ResponseBasedOriginErrorDetectionParameters responseBasedOriginErrorDetectionSettings, OriginGroupResourceState?resourceState, string provisioningState) : base(id, name, resourceType, systemData)
 {
     HealthProbeSettings = healthProbeSettings;
     Origins             = origins;
     TrafficRestorationTimeToHealedOrNewEndpointsInMinutes = trafficRestorationTimeToHealedOrNewEndpointsInMinutes;
     ResponseBasedOriginErrorDetectionSettings             = responseBasedOriginErrorDetectionSettings;
     ResourceState     = resourceState;
     ProvisioningState = provisioningState;
 }
Exemple #3
0
 internal AfdOriginGroupData(ResourceIdentifier id, string name, Core.ResourceType resourceType, SystemData systemData, string profileName, LoadBalancingSettingsParameters loadBalancingSettings, HealthProbeParameters healthProbeSettings, int?trafficRestorationTimeToHealedOrNewEndpointsInMinutes, EnabledState?sessionAffinityState, AfdProvisioningState?provisioningState, DeploymentStatus?deploymentStatus) : base(id, name, resourceType, systemData)
 {
     ProfileName           = profileName;
     LoadBalancingSettings = loadBalancingSettings;
     HealthProbeSettings   = healthProbeSettings;
     TrafficRestorationTimeToHealedOrNewEndpointsInMinutes = trafficRestorationTimeToHealedOrNewEndpointsInMinutes;
     SessionAffinityState = sessionAffinityState;
     ProvisioningState    = provisioningState;
     DeploymentStatus     = deploymentStatus;
 }
Exemple #4
0
 internal AfdOriginGroupData(ResourceIdentifier id, string name, ResourceType type, SystemData systemData, LoadBalancingSettingsParameters loadBalancingSettings, HealthProbeParameters healthProbeSettings, int?trafficRestorationTimeToHealedOrNewEndpointsInMinutes, ResponseBasedOriginErrorDetectionParameters responseBasedAfdOriginErrorDetectionSettings, EnabledState?sessionAffinityState, AfdProvisioningState?provisioningState, DeploymentStatus?deploymentStatus) : base(id, name, type, systemData)
 {
     LoadBalancingSettings = loadBalancingSettings;
     HealthProbeSettings   = healthProbeSettings;
     TrafficRestorationTimeToHealedOrNewEndpointsInMinutes = trafficRestorationTimeToHealedOrNewEndpointsInMinutes;
     ResponseBasedAfdOriginErrorDetectionSettings          = responseBasedAfdOriginErrorDetectionSettings;
     SessionAffinityState = sessionAffinityState;
     ProvisioningState    = provisioningState;
     DeploymentStatus     = deploymentStatus;
 }
Exemple #5
0
        private HealthProbeParameters CreateHealthProbeSettings(bool isProbePath, bool isProbeRequestType, bool isProbeProtocol, bool isProbeIntervalInSeconds)
        {
            if (!isProbePath && !isProbeRequestType && !isProbeProtocol && !isProbeIntervalInSeconds)
            {
                return(null);
            }

            HealthProbeParameters healthProbeSettings = new HealthProbeParameters
            {
                ProbePath              = isProbePath ? this.ProbePath : "/",
                ProbeRequestType       = isProbeRequestType ? AfdUtilities.CreateProbeRequestType(this.ProbeRequestType) : HealthProbeRequestType.HEAD,
                ProbeProtocol          = isProbeProtocol ? AfdUtilities.CreateProbeProtocol(this.ProbeProtocol) : Management.Cdn.Models.ProbeProtocol.Http,
                ProbeIntervalInSeconds = isProbeIntervalInSeconds ? this.ProbeIntervalInSeconds : 240
            };

            return(healthProbeSettings);
        }
        private HealthProbeParameters CreateHealthProbeSettingsByFields(PSAfdOriginGroup currentPsAfdOriginGroup, bool isProbePath, bool isProbeRequestType, bool isProbeProtocol, bool isProbeIntervalInSeconds)
        {
            if (!isProbePath && !isProbeRequestType && !isProbeProtocol && !isProbeIntervalInSeconds)
            {
                return(null);
            }

            HealthProbeParameters healthProbeSettings = new HealthProbeParameters
            {
                ProbeIntervalInSeconds = currentPsAfdOriginGroup.ProbeIntervalInSeconds,
                ProbePath        = currentPsAfdOriginGroup.ProbePath,
                ProbeProtocol    = AfdUtilities.CreateProbeProtocol(currentPsAfdOriginGroup.ProbeProtocol),
                ProbeRequestType = AfdUtilities.CreateProbeRequestType(currentPsAfdOriginGroup.ProbeRequestType)
            };

            if (isProbePath)
            {
                healthProbeSettings.ProbePath = this.ProbePath;
            }

            if (isProbeRequestType)
            {
                healthProbeSettings.ProbeRequestType = AfdUtilities.CreateProbeRequestType(this.ProbeRequestType);
            }

            if (isProbeProtocol)
            {
                healthProbeSettings.ProbeProtocol = AfdUtilities.CreateProbeProtocol(this.ProbeProtocol);
            }

            if (isProbeIntervalInSeconds)
            {
                healthProbeSettings.ProbeIntervalInSeconds = this.ProbeIntervalInSeconds;
            }

            return(healthProbeSettings);
        }
        internal static CdnOriginGroupData DeserializeCdnOriginGroupData(JsonElement element)
        {
            Optional <SystemData> systemData = default;
            ResourceIdentifier    id         = default;
            string       name = default;
            ResourceType type = default;
            Optional <HealthProbeParameters>        healthProbeSettings           = default;
            Optional <IList <WritableSubResource> > origins                       = default;
            Optional <int?> trafficRestorationTimeToHealedOrNewEndpointsInMinutes = default;
            Optional <ResponseBasedOriginErrorDetectionParameters> responseBasedOriginErrorDetectionSettings = default;
            Optional <OriginGroupResourceState> resourceState = default;
            Optional <string> provisioningState = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("systemData"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    systemData = SystemData.DeserializeSystemData(property.Value);
                    continue;
                }
                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 = property.Value.GetString();
                    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 = HealthProbeParameters.DeserializeHealthProbeParameters(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 = ResponseBasedOriginErrorDetectionParameters.DeserializeResponseBasedOriginErrorDetectionParameters(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"))
                        {
                            provisioningState = property0.Value.GetString();
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new CdnOriginGroupData(id, name, type, systemData.Value, healthProbeSettings.Value, Optional.ToList(origins), Optional.ToNullable(trafficRestorationTimeToHealedOrNewEndpointsInMinutes), responseBasedOriginErrorDetectionSettings.Value, Optional.ToNullable(resourceState), provisioningState.Value));
        }
Exemple #8
0
        internal static AfdOriginGroupData DeserializeAfdOriginGroupData(JsonElement element)
        {
            Optional <SystemData> systemData = default;
            ResourceIdentifier    id         = default;
            string       name = default;
            ResourceType type = default;
            Optional <LoadBalancingSettingsParameters> loadBalancingSettings      = default;
            Optional <HealthProbeParameters>           healthProbeSettings        = default;
            Optional <int?> trafficRestorationTimeToHealedOrNewEndpointsInMinutes = default;
            Optional <ResponseBasedOriginErrorDetectionParameters> responseBasedAfdOriginErrorDetectionSettings = default;
            Optional <EnabledState>         sessionAffinityState = default;
            Optional <AfdProvisioningState> provisioningState    = default;
            Optional <DeploymentStatus>     deploymentStatus     = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("systemData"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    systemData = SystemData.DeserializeSystemData(property.Value);
                    continue;
                }
                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 = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("loadBalancingSettings"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            loadBalancingSettings = LoadBalancingSettingsParameters.DeserializeLoadBalancingSettingsParameters(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("healthProbeSettings"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            healthProbeSettings = HealthProbeParameters.DeserializeHealthProbeParameters(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("trafficRestorationTimeToHealedOrNewEndpointsInMinutes"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                trafficRestorationTimeToHealedOrNewEndpointsInMinutes = null;
                                continue;
                            }
                            trafficRestorationTimeToHealedOrNewEndpointsInMinutes = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("responseBasedAfdOriginErrorDetectionSettings"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                responseBasedAfdOriginErrorDetectionSettings = null;
                                continue;
                            }
                            responseBasedAfdOriginErrorDetectionSettings = ResponseBasedOriginErrorDetectionParameters.DeserializeResponseBasedOriginErrorDetectionParameters(property0.Value);
                            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 AfdProvisioningState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("deploymentStatus"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            deploymentStatus = new DeploymentStatus(property0.Value.GetString());
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new AfdOriginGroupData(id, name, type, systemData.Value, loadBalancingSettings.Value, healthProbeSettings.Value, Optional.ToNullable(trafficRestorationTimeToHealedOrNewEndpointsInMinutes), responseBasedAfdOriginErrorDetectionSettings.Value, Optional.ToNullable(sessionAffinityState), Optional.ToNullable(provisioningState), Optional.ToNullable(deploymentStatus)));
        }