internal static PolicyAssignment DeserializePolicyAssignment(JsonElement element) { string id = default; string type = default; string name = default; PolicySku sku = default; string location = default; IdentityAutoGenerated identity = default; string displayName = default; string policyDefinitionId = default; string scope = default; IList <string> notScopes = default; IDictionary <string, ParameterValuesValue> parameters = default; string description = default; object metadata = default; EnforcementMode?enforcementMode = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } id = property.Value.GetString(); continue; } if (property.NameEquals("type")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } type = property.Value.GetString(); continue; } if (property.NameEquals("name")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } name = property.Value.GetString(); continue; } if (property.NameEquals("sku")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } sku = PolicySku.DeserializePolicySku(property.Value); continue; } if (property.NameEquals("location")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } location = property.Value.GetString(); continue; } if (property.NameEquals("identity")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } identity = IdentityAutoGenerated.DeserializeIdentityAutoGenerated(property.Value); continue; } if (property.NameEquals("properties")) { foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("displayName")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } displayName = property0.Value.GetString(); continue; } if (property0.NameEquals("policyDefinitionId")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } policyDefinitionId = property0.Value.GetString(); continue; } if (property0.NameEquals("scope")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } scope = property0.Value.GetString(); continue; } if (property0.NameEquals("notScopes")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property0.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } notScopes = array; continue; } if (property0.NameEquals("parameters")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary <string, ParameterValuesValue> dictionary = new Dictionary <string, ParameterValuesValue>(); foreach (var property1 in property0.Value.EnumerateObject()) { if (property1.Value.ValueKind == JsonValueKind.Null) { dictionary.Add(property1.Name, null); } else { dictionary.Add(property1.Name, ParameterValuesValue.DeserializeParameterValuesValue(property1.Value)); } } parameters = dictionary; continue; } if (property0.NameEquals("description")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } description = property0.Value.GetString(); continue; } if (property0.NameEquals("metadata")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } metadata = property0.Value.GetObject(); continue; } if (property0.NameEquals("enforcementMode")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } enforcementMode = new EnforcementMode(property0.Value.GetString()); continue; } } continue; } } return(new PolicyAssignment(id, type, name, sku, location, identity, displayName, policyDefinitionId, scope, notScopes, parameters, description, metadata, enforcementMode)); }
internal static PolicyDefinitionReference DeserializePolicyDefinitionReference(JsonElement element) { string policyDefinitionId = default; IDictionary <string, ParameterValuesValue> parameters = default; string policyDefinitionReferenceId = default; IList <string> groupNames = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("policyDefinitionId")) { policyDefinitionId = property.Value.GetString(); continue; } if (property.NameEquals("parameters")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary <string, ParameterValuesValue> dictionary = new Dictionary <string, ParameterValuesValue>(); foreach (var property0 in property.Value.EnumerateObject()) { if (property0.Value.ValueKind == JsonValueKind.Null) { dictionary.Add(property0.Name, null); } else { dictionary.Add(property0.Name, ParameterValuesValue.DeserializeParameterValuesValue(property0.Value)); } } parameters = dictionary; continue; } if (property.NameEquals("policyDefinitionReferenceId")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } policyDefinitionReferenceId = property.Value.GetString(); continue; } if (property.NameEquals("groupNames")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } groupNames = array; continue; } } return(new PolicyDefinitionReference(policyDefinitionId, parameters, policyDefinitionReferenceId, groupNames)); }