예제 #1
0
        internal static DeploymentExtendedData DeserializeDeploymentExtendedData(JsonElement element)
        {
            Optional <string> location = default;
            Optional <DeploymentPropertiesExtended>          properties = default;
            Optional <IReadOnlyDictionary <string, string> > tags       = default;
            ResourceIdentifier id   = default;
            string             name = default;
            ResourceType       type = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("location"))
                {
                    location = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    properties = DeploymentPropertiesExtended.DeserializeDeploymentPropertiesExtended(property.Value);
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
            }
            return(new DeploymentExtendedData(id, name, type, location.Value, properties.Value, Optional.ToDictionary(tags)));
        }
        private static PSResourceGroupDeployment CreatePSResourceGroupDeployment(
            string name,
            string resourceGroup,
            DeploymentPropertiesExtended properties)
        {
            PSResourceGroupDeployment deploymentObject = new PSResourceGroupDeployment();

            deploymentObject.DeploymentName    = name;
            deploymentObject.ResourceGroupName = resourceGroup;

            SetDeploymentProperties(deploymentObject, properties);

            return(deploymentObject);
        }
        private static PSDeployment CreatePSDeployment(
            string name,
            string location,
            DeploymentPropertiesExtended properties)
        {
            PSDeployment deploymentObject = new PSDeployment();

            deploymentObject.DeploymentName = name;
            deploymentObject.Location       = location;

            SetDeploymentProperties(deploymentObject, properties);

            return(deploymentObject);
        }
        private static PSResourceGroupDeployment CreatePSResourceGroupDeployment(
            string name,
            string resourceGroup,
            DeploymentPropertiesExtended properties)
        {
            var deploymentObject = new PSResourceGroupDeployment
            {
                DeploymentName = name, ResourceGroupName = resourceGroup
            };

            if (properties == null)
            {
                return(deploymentObject);
            }

            deploymentObject.Mode              = properties.Mode();
            deploymentObject.Timestamp         = properties.Timestamp();
            deploymentObject.ProvisioningState = properties.ProvisioningState;
            deploymentObject.TemplateLink      = properties.TemplateLink;
            deploymentObject.CorrelationId     = properties.CorrelationId;
            deploymentObject.OnErrorDeployment = properties.OnErrorDeployment;

            if (properties.DebugSetting() != null && !string.IsNullOrEmpty(properties.DebugSetting().DetailLevel()))
            {
                deploymentObject.DeploymentDebugLogLevel = properties.DebugSetting().DetailLevel();
            }

            if (properties.Outputs != null && !string.IsNullOrEmpty(properties.Outputs.ToString()))
            {
                var outputs = JsonConvert.DeserializeObject <Dictionary <string, DeploymentVariable> >(properties.Outputs.ToString());
                deploymentObject.Outputs = outputs;
            }

            if (properties.Parameters != null && !string.IsNullOrEmpty(properties.Parameters.ToString()))
            {
                var parameters = JsonConvert.DeserializeObject <Dictionary <string, DeploymentVariable> >(properties.Parameters.ToString());
                deploymentObject.Parameters = parameters;
            }

            if (properties.TemplateLink != null)
            {
                deploymentObject.TemplateLinkString = ConstructTemplateLinkView(properties.TemplateLink);
            }

            return(deploymentObject);
        }
        private static PSResourceGroupDeployment CreatePSResourceGroupDeployment(
            string name,
            string gesourceGroup,
            DeploymentPropertiesExtended properties)
        {
            PSResourceGroupDeployment deploymentObject = new PSResourceGroupDeployment();

            deploymentObject.DeploymentName    = name;
            deploymentObject.ResourceGroupName = gesourceGroup;

            if (properties != null)
            {
                deploymentObject.Mode = properties.Mode.Value;
                deploymentObject.ProvisioningState = properties.ProvisioningState;
                deploymentObject.TemplateLink      = properties.TemplateLink;
                deploymentObject.Timestamp         = properties.Timestamp == null ? default(DateTime) : properties.Timestamp.Value;
                deploymentObject.CorrelationId     = properties.CorrelationId;

                if (properties.DebugSetting != null && !string.IsNullOrEmpty(properties.DebugSetting.DetailLevel))
                {
                    deploymentObject.DeploymentDebugLogLevel = properties.DebugSetting.DetailLevel;
                }

                if (properties.Outputs != null)
                {
                    Dictionary <string, DeploymentVariable> outputs = JsonConvert.DeserializeObject <Dictionary <string, DeploymentVariable> >(properties.Outputs.ToString());
                    deploymentObject.Outputs = outputs;
                }

                if (properties.Parameters != null)
                {
                    Dictionary <string, DeploymentVariable> parameters = JsonConvert.DeserializeObject <Dictionary <string, DeploymentVariable> >(properties.Parameters.ToString());
                    deploymentObject.Parameters = parameters;
                }

                if (properties.TemplateLink != null)
                {
                    deploymentObject.TemplateLinkString = ConstructTemplateLinkView(properties.TemplateLink);
                }
            }

            return(deploymentObject);
        }
        private static PSResourceGroupDeployment CreatePSResourceGroupDeployment(
            string name,
            string gesourceGroup,
            DeploymentPropertiesExtended properties)
        {
            PSResourceGroupDeployment deploymentObject = new PSResourceGroupDeployment();

            deploymentObject.DeploymentName    = name;
            deploymentObject.ResourceGroupName = gesourceGroup;

            if (properties != null)
            {
                deploymentObject.Mode = properties.Mode;
                deploymentObject.ProvisioningState = properties.ProvisioningState;
                deploymentObject.TemplateLink      = properties.TemplateLink;
                deploymentObject.Timestamp         = properties.Timestamp;
                deploymentObject.CorrelationId     = properties.CorrelationId;

                if (!string.IsNullOrEmpty(properties.Outputs))
                {
                    Dictionary <string, DeploymentVariable> outputs = JsonConvert.DeserializeObject <Dictionary <string, DeploymentVariable> >(properties.Outputs);
                    deploymentObject.Outputs = outputs;
                }

                if (!string.IsNullOrEmpty(properties.Parameters))
                {
                    Dictionary <string, DeploymentVariable> parameters = JsonConvert.DeserializeObject <Dictionary <string, DeploymentVariable> >(properties.Parameters);
                    deploymentObject.Parameters = parameters;
                }

                if (properties.TemplateLink != null)
                {
                    deploymentObject.TemplateLinkString = ConstructTemplateLinkView(properties.TemplateLink);
                }
            }

            return(deploymentObject);
        }
        private static void SetDeploymentProperties(PSDeploymentObject deploymentObject, DeploymentPropertiesExtended properties)
        {
            if (properties != null)
            {
                deploymentObject.Mode = properties.Mode.Value;
                deploymentObject.ProvisioningState = properties.ProvisioningState;
                deploymentObject.TemplateLink      = properties.TemplateLink;
                deploymentObject.Timestamp         = properties.Timestamp == null ? default(DateTime) : properties.Timestamp.Value;
                deploymentObject.CorrelationId     = properties.CorrelationId;

                if (properties.DebugSetting != null && !string.IsNullOrEmpty(properties.DebugSetting.DetailLevel))
                {
                    deploymentObject.DeploymentDebugLogLevel = properties.DebugSetting.DetailLevel;
                }

                if (properties.Outputs != null)
                {
                    Dictionary <string, DeploymentVariable> outputs = JsonConvert.DeserializeObject <Dictionary <string, DeploymentVariable> >(properties.Outputs.ToString());
                    deploymentObject.Outputs = outputs;
                }

                if (properties.Parameters != null)
                {
                    Dictionary <string, DeploymentVariable> parameters = JsonConvert.DeserializeObject <Dictionary <string, DeploymentVariable> >(properties.Parameters.ToString());
                    deploymentObject.Parameters = parameters;
                }

                if (properties.TemplateLink != null)
                {
                    deploymentObject.TemplateLinkString = ConstructTemplateLinkView(properties.TemplateLink);
                }
            }
        }
예제 #8
0
        private static PSResourceGroupDeployment CreatePSResourceGroupDeployment(
            string name,
            string gesourceGroup,
            DeploymentPropertiesExtended properties)
        {
            PSResourceGroupDeployment deploymentObject = new PSResourceGroupDeployment();

            deploymentObject.DeploymentName = name;
            deploymentObject.ResourceGroupName = gesourceGroup;

            if (properties != null)
            {
                deploymentObject.Mode = properties.Mode.Value;
                deploymentObject.ProvisioningState = properties.ProvisioningState;
                deploymentObject.TemplateLink = properties.TemplateLink;
                deploymentObject.Timestamp = properties.Timestamp == null ? default(DateTime) : properties.Timestamp.Value;
                deploymentObject.CorrelationId = properties.CorrelationId;

                if(properties.DebugSetting != null && !string.IsNullOrEmpty(properties.DebugSetting.DetailLevel))
                {
                    deploymentObject.DeploymentDebugLogLevel = properties.DebugSetting.DetailLevel;
                }

                if (properties.Outputs != null)
                {
                    Dictionary<string, DeploymentVariable> outputs = JsonConvert.DeserializeObject<Dictionary<string, DeploymentVariable>>(properties.Outputs.ToString());
                    deploymentObject.Outputs = outputs;
                }

                if (properties.Parameters != null)
                {
                    Dictionary<string, DeploymentVariable> parameters = JsonConvert.DeserializeObject<Dictionary<string, DeploymentVariable>>(properties.Parameters.ToString());
                    deploymentObject.Parameters = parameters;
                }

                if (properties.TemplateLink != null)
                {
                    deploymentObject.TemplateLinkString = ConstructTemplateLinkView(properties.TemplateLink);
                }
            }

            return deploymentObject;
        }
예제 #9
0
 internal DeploymentData(ResourceIdentifier id, string name, ResourceType type, SystemData systemData, string location, DeploymentPropertiesExtended properties, IReadOnlyDictionary <string, string> tags) : base(id, name, type, systemData)
 {
     Location   = location;
     Properties = properties;
     Tags       = tags;
 }
 internal DeploymentValidateResult(ResourceManagementErrorWithDetails error, DeploymentPropertiesExtended properties)
 {
     Error      = error;
     Properties = properties;
 }
예제 #11
0
 internal DeploymentValidateResult(ErrorResponse error, DeploymentPropertiesExtended properties)
 {
     Error      = error;
     Properties = properties;
 }
예제 #12
0
 public static DebugSetting DebugSetting(this DeploymentPropertiesExtended deploymentProperties)
 {
     return(deploymentProperties.DebugSetting);
 }
예제 #13
0
 public static DateTime Timestamp(this DeploymentPropertiesExtended deploymentProperties)
 {
     return(deploymentProperties.Timestamp.Value);
 }
예제 #14
0
 public static DeploymentMode Mode(this DeploymentPropertiesExtended deploymentProperties)
 {
     return(deploymentProperties.Mode.Value);
 }
예제 #15
0
        private static void SetDeploymentProperties(PSDeploymentObject deploymentObject, DeploymentPropertiesExtended properties)
        {
            if (properties != null)
            {
                deploymentObject.Mode = properties.Mode.Value;
                deploymentObject.ProvisioningState = properties.ProvisioningState;
                deploymentObject.TemplateLink      = properties.TemplateLink;
                deploymentObject.Timestamp         = properties.Timestamp == null ? default(DateTime) : properties.Timestamp.Value;
                deploymentObject.CorrelationId     = properties.CorrelationId;

                if (properties.DebugSetting != null && !string.IsNullOrEmpty(properties.DebugSetting.DetailLevel))
                {
                    deploymentObject.DeploymentDebugLogLevel = properties.DebugSetting.DetailLevel;
                }

                if (properties.Outputs != null)
                {
                    Dictionary <string, DeploymentVariable> outputs = JsonConvert.DeserializeObject <Dictionary <string, DeploymentVariable> >(properties.Outputs.ToString());
                    // Continue deserialize if the type of Value in DeploymentVariable is array
                    outputs?.Values.ForEach(dv => {
                        if ("Array".Equals(dv?.Type))
                        {
                            dv.Value = JsonConvert.DeserializeObject <object[]>(dv.Value.ToString());
                        }
                    });
                    deploymentObject.Outputs = outputs;
                }

                if (properties.Parameters != null)
                {
                    Dictionary <string, DeploymentVariable> parameters = JsonConvert.DeserializeObject <Dictionary <string, DeploymentVariable> >(properties.Parameters.ToString());
                    // Continue deserialize if the type of Value in DeploymentVariable is array
                    parameters?.Values.ForEach(dv => {
                        if ("Array".Equals(dv?.Type))
                        {
                            dv.Value = JsonConvert.DeserializeObject <object[]>(dv.Value.ToString());
                        }
                    });
                    deploymentObject.Parameters = parameters;
                }

                if (properties.TemplateLink != null)
                {
                    deploymentObject.TemplateLinkString = ConstructTemplateLinkView(properties.TemplateLink);
                }
            }
        }