internal static PsAzureCliScript ToPsAzureCliScript(AzureCliScript script) { return(new PsAzureCliScript { Name = script.Name, Type = script.Type, Id = script.Id, Identity = script.Identity, Location = script.Location, Tags = script.Tags, CleanupPreference = script.CleanupPreference, ProvisioningState = script.ProvisioningState, Status = DeploymentScriptsAutoMapperProfile.Mapper.Map <PsScriptStatus>(script.Status), Outputs = script.Outputs, PrimaryScriptUri = script.PrimaryScriptUri, SupportingScriptUris = script.SupportingScriptUris, ScriptContent = script.ScriptContent, Arguments = script.Arguments, EnvironmentVariables = script.EnvironmentVariables, ForceUpdateTag = script.ForceUpdateTag, RetentionInterval = XmlConvert.ToString(script.RetentionInterval), Timeout = script.Timeout.HasValue ? XmlConvert.ToString(script.Timeout.Value) : null, AzCliVersion = script.AzCliVersion, ScriptKind = "AzureCLI" }); }
internal static DeploymentScriptData DeserializeDeploymentScriptData(JsonElement element) { if (element.TryGetProperty("kind", out JsonElement discriminator)) { switch (discriminator.GetString()) { case "AzureCLI": return(AzureCliScript.DeserializeAzureCliScript(element)); case "AzurePowerShell": return(AzurePowerShellScript.DeserializeAzurePowerShellScript(element)); } } Optional <ManagedServiceIdentity> identity = default; string location = default; Optional <IDictionary <string, string> > tags = default; ScriptType kind = default; Optional <SystemData> systemData = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("identity")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } identity = ManagedServiceIdentity.DeserializeManagedServiceIdentity(property.Value); continue; } if (property.NameEquals("location")) { location = property.Value.GetString(); 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("kind")) { kind = new ScriptType(property.Value.GetString()); continue; } if (property.NameEquals("systemData")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString()); 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; } } return(new DeploymentScriptData(id, name, type, identity.Value, location, Optional.ToDictionary(tags), kind, systemData)); }