Beispiel #1
0
 internal AfdOriginData(ResourceIdentifier id, string name, Core.ResourceType resourceType, SystemData systemData, string originGroupName, WritableSubResource azureOrigin, string hostName, int?httpPort, int?httpsPort, string originHostHeader, int?priority, int?weight, SharedPrivateLinkResourceProperties sharedPrivateLinkResource, EnabledState?enabledState, bool?enforceCertificateNameCheck, AfdProvisioningState?provisioningState, DeploymentStatus?deploymentStatus) : base(id, name, resourceType, systemData)
 {
     OriginGroupName             = originGroupName;
     AzureOrigin                 = azureOrigin;
     HostName                    = hostName;
     HttpPort                    = httpPort;
     HttpsPort                   = httpsPort;
     OriginHostHeader            = originHostHeader;
     Priority                    = priority;
     Weight                      = weight;
     SharedPrivateLinkResource   = sharedPrivateLinkResource;
     EnabledState                = enabledState;
     EnforceCertificateNameCheck = enforceCertificateNameCheck;
     ProvisioningState           = provisioningState;
     DeploymentStatus            = deploymentStatus;
 }
        private SharedPrivateLinkResourceProperties CreateSharedPrivateLinkResource()
        {
            bool isPrivateLinkId             = this.MyInvocation.BoundParameters.ContainsKey("PrivateLinkId");
            bool isPrivateLinkLocation       = this.MyInvocation.BoundParameters.ContainsKey("PrivateLinkLocation");
            bool isPrivateLinkRequestMessage = this.MyInvocation.BoundParameters.ContainsKey("PrivateLinkRequestMessage");

            if (!isPrivateLinkId && !isPrivateLinkLocation && !isPrivateLinkRequestMessage)
            {
                return(null);
            }

            SharedPrivateLinkResourceProperties sharedPrivateLinkResource = new SharedPrivateLinkResourceProperties
            {
                PrivateLink         = new ResourceReference(this.PrivateLinkId),
                PrivateLinkLocation = this.PrivateLinkLocation,
                RequestMessage      = this.PrivateLinkRequestMessage
            };

            return(sharedPrivateLinkResource);
        }
Beispiel #3
0
        private AFDOriginUpdateParameters CreateAfdOriginUpdateByFields(PSAfdOrigin currentPsAfdOrigin)
        {
            bool isHostName                  = this.MyInvocation.BoundParameters.ContainsKey("HostName");
            bool isHttpPort                  = this.MyInvocation.BoundParameters.ContainsKey("HttpPort");
            bool isHttpsPort                 = this.MyInvocation.BoundParameters.ContainsKey("HttpsPort");
            bool isPriority                  = this.MyInvocation.BoundParameters.ContainsKey("Priority");
            bool isWeight                    = this.MyInvocation.BoundParameters.ContainsKey("Weight");
            bool isOriginHostHeader          = this.MyInvocation.BoundParameters.ContainsKey("OriginHostHeader");
            bool isPrivateLinkId             = this.MyInvocation.BoundParameters.ContainsKey("PrivateLinkId");
            bool isPrivateLinkLocation       = this.MyInvocation.BoundParameters.ContainsKey("PrivateLinkLocation");
            bool isPrivateLinkRequestMessage = this.MyInvocation.BoundParameters.ContainsKey("PrivateLinkRequestMessage");

            AFDOriginUpdateParameters afdOrigin = new AFDOriginUpdateParameters
            {
                HostName         = currentPsAfdOrigin.HostName,
                HttpPort         = currentPsAfdOrigin.HttpPort,
                HttpsPort        = currentPsAfdOrigin.HttpsPort,
                OriginHostHeader = currentPsAfdOrigin.OriginHostHeader,
                Priority         = currentPsAfdOrigin.Priority,
                Weight           = currentPsAfdOrigin.Weight,
            };

            if (isHostName)
            {
                afdOrigin.HostName = this.HostName;
            }
            if (isHttpPort)
            {
                afdOrigin.HttpPort = this.HttpPort;
            }
            if (isHttpsPort)
            {
                afdOrigin.HttpsPort = this.HttpsPort;
            }
            if (isPriority)
            {
                afdOrigin.Priority = this.Priority;
            }
            if (isWeight)
            {
                afdOrigin.Weight = this.Weight;
            }
            if (isOriginHostHeader)
            {
                afdOrigin.OriginHostHeader = this.OriginHostHeader;
            }

            if (isPrivateLinkId || isPrivateLinkLocation || isPrivateLinkRequestMessage)
            {
                SharedPrivateLinkResourceProperties sharedPrivateLinkResource = new SharedPrivateLinkResourceProperties
                {
                    PrivateLink         = new ResourceReference(currentPsAfdOrigin.PrivateLinkId),
                    PrivateLinkLocation = currentPsAfdOrigin.PrivateLinkLocation,
                    RequestMessage      = currentPsAfdOrigin.PrivateLinkRequestMessage
                };

                if (isPrivateLinkId)
                {
                    sharedPrivateLinkResource.PrivateLink.Id = this.PrivateLinkId;
                    afdOrigin.SharedPrivateLinkResource      = sharedPrivateLinkResource;
                }
                if (isPrivateLinkLocation)
                {
                    sharedPrivateLinkResource.PrivateLinkLocation = this.PrivateLinkLocation;
                    afdOrigin.SharedPrivateLinkResource           = sharedPrivateLinkResource;
                }
                if (isPrivateLinkRequestMessage)
                {
                    sharedPrivateLinkResource.RequestMessage = this.PrivateLinkRequestMessage;
                    afdOrigin.SharedPrivateLinkResource      = sharedPrivateLinkResource;
                }
            }

            return(afdOrigin);
        }
Beispiel #4
0
        private AFDOriginUpdateParameters CreateAfdOriginUpdateByObject(PSAfdOrigin currentPsAfdOrigin)
        {
            SharedPrivateLinkResourceProperties sharedPrivateLinkResource = new SharedPrivateLinkResourceProperties
            {
                PrivateLink         = new ResourceReference(currentPsAfdOrigin.PrivateLinkId),
                PrivateLinkLocation = currentPsAfdOrigin.PrivateLinkLocation,
                RequestMessage      = currentPsAfdOrigin.PrivateLinkRequestMessage
            };

            AFDOriginUpdateParameters afdOrigin = new AFDOriginUpdateParameters
            {
                HostName                  = currentPsAfdOrigin.HostName,
                HttpPort                  = currentPsAfdOrigin.HttpPort,
                HttpsPort                 = currentPsAfdOrigin.HttpsPort,
                OriginHostHeader          = currentPsAfdOrigin.OriginHostHeader,
                Priority                  = currentPsAfdOrigin.Priority,
                Weight                    = currentPsAfdOrigin.Weight,
                SharedPrivateLinkResource = sharedPrivateLinkResource
            };

            if (this.Origin.HostName != currentPsAfdOrigin.HostName)
            {
                afdOrigin.HostName = this.Origin.HostName;
            }
            if (this.Origin.HttpPort != currentPsAfdOrigin.HttpPort)
            {
                afdOrigin.HttpPort = this.Origin.HttpPort;
            }
            if (this.Origin.HttpsPort != currentPsAfdOrigin.HttpsPort)
            {
                afdOrigin.HttpsPort = this.Origin.HttpsPort;
            }
            if (this.Origin.OriginHostHeader != currentPsAfdOrigin.OriginHostHeader)
            {
                afdOrigin.OriginHostHeader = this.Origin.OriginHostHeader;
            }
            if (this.Origin.Priority != currentPsAfdOrigin.Priority)
            {
                afdOrigin.Priority = this.Origin.Priority;
            }
            if (this.Origin.Weight != currentPsAfdOrigin.Weight)
            {
                afdOrigin.Weight = this.Origin.Weight;
            }
            if (this.Origin.PrivateLinkId != currentPsAfdOrigin.PrivateLinkId)
            {
                sharedPrivateLinkResource.PrivateLink.Id = this.Origin.PrivateLinkId;
                afdOrigin.SharedPrivateLinkResource      = sharedPrivateLinkResource;
            }
            if (this.Origin.PrivateLinkLocation != currentPsAfdOrigin.PrivateLinkLocation)
            {
                sharedPrivateLinkResource.PrivateLinkLocation = this.Origin.PrivateLinkLocation;
                afdOrigin.SharedPrivateLinkResource           = sharedPrivateLinkResource;
            }
            if (this.Origin.PrivateLinkRequestMessage != currentPsAfdOrigin.PrivateLinkRequestMessage)
            {
                sharedPrivateLinkResource.RequestMessage = this.Origin.PrivateLinkRequestMessage;
                afdOrigin.SharedPrivateLinkResource      = sharedPrivateLinkResource;
            }

            return(afdOrigin);
        }
Beispiel #5
0
        internal static AfdOriginData DeserializeAfdOriginData(JsonElement element)
        {
            ResourceIdentifier             id               = default;
            string                         name             = default;
            ResourceType                   type             = default;
            SystemData                     systemData       = default;
            Optional <string>              originGroupName  = default;
            Optional <WritableSubResource> azureOrigin      = default;
            Optional <string>              hostName         = default;
            Optional <int>                 httpPort         = default;
            Optional <int>                 httpsPort        = default;
            Optional <string>              originHostHeader = default;
            Optional <int?>                priority         = default;
            Optional <int?>                weight           = default;
            Optional <SharedPrivateLinkResourceProperties> sharedPrivateLinkResource = default;
            Optional <EnabledState>         enabledState = default;
            Optional <bool>                 enforceCertificateNameCheck = default;
            Optional <AfdProvisioningState> provisioningState           = default;
            Optional <AfdDeploymentStatus>  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 = 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("originGroupName"))
                        {
                            originGroupName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("azureOrigin"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            azureOrigin = JsonSerializer.Deserialize <WritableSubResource>(property0.Value.ToString());
                            continue;
                        }
                        if (property0.NameEquals("hostName"))
                        {
                            hostName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("httpPort"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            httpPort = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("httpsPort"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            httpsPort = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("originHostHeader"))
                        {
                            originHostHeader = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("priority"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                priority = null;
                                continue;
                            }
                            priority = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("weight"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                weight = null;
                                continue;
                            }
                            weight = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("sharedPrivateLinkResource"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                sharedPrivateLinkResource = null;
                                continue;
                            }
                            sharedPrivateLinkResource = SharedPrivateLinkResourceProperties.DeserializeSharedPrivateLinkResourceProperties(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("enabledState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            enabledState = new EnabledState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("enforceCertificateNameCheck"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            enforceCertificateNameCheck = property0.Value.GetBoolean();
                            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 AfdDeploymentStatus(property0.Value.GetString());
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new AfdOriginData(id, name, type, systemData, originGroupName.Value, azureOrigin, hostName.Value, Optional.ToNullable(httpPort), Optional.ToNullable(httpsPort), originHostHeader.Value, Optional.ToNullable(priority), Optional.ToNullable(weight), sharedPrivateLinkResource.Value, Optional.ToNullable(enabledState), Optional.ToNullable(enforceCertificateNameCheck), Optional.ToNullable(provisioningState), Optional.ToNullable(deploymentStatus)));
        }