internal PolicyAssignment(string id, string type, string name, PolicySku sku, string location, IdentityAutoGenerated identity, string displayName, string policyDefinitionId, string scope, IList <string> notScopes, IDictionary <string, ParameterValuesValue> parameters, string description, object metadata, EnforcementMode?enforcementMode) { Id = id; Type = type; Name = name; Sku = sku; Location = location; Identity = identity; DisplayName = displayName; PolicyDefinitionId = policyDefinitionId; Scope = scope; NotScopes = notScopes; Parameters = parameters; Description = description; Metadata = metadata; EnforcementMode = enforcementMode; }
internal static PolicyAssignment DeserializePolicyAssignment(JsonElement element) { Optional <string> id = default; Optional <string> type = default; Optional <string> name = default; Optional <PolicySku> sku = default; Optional <string> location = default; Optional <IdentityAutoGenerated> identity = default; Optional <string> displayName = default; Optional <string> policyDefinitionId = default; Optional <string> scope = default; Optional <IList <string> > notScopes = default; Optional <IDictionary <string, ParameterValuesValue> > parameters = default; Optional <string> description = default; Optional <object> metadata = default; Optional <EnforcementMode> enforcementMode = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id")) { id = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("sku")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } sku = PolicySku.DeserializePolicySku(property.Value); continue; } if (property.NameEquals("location")) { location = property.Value.GetString(); continue; } if (property.NameEquals("identity")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } identity = IdentityAutoGenerated.DeserializeIdentityAutoGenerated(property.Value); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("displayName")) { displayName = property0.Value.GetString(); continue; } if (property0.NameEquals("policyDefinitionId")) { policyDefinitionId = property0.Value.GetString(); continue; } if (property0.NameEquals("scope")) { scope = property0.Value.GetString(); continue; } if (property0.NameEquals("notScopes")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <string> array = new List <string>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(item.GetString()); } notScopes = array; continue; } if (property0.NameEquals("parameters")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } Dictionary <string, ParameterValuesValue> dictionary = new Dictionary <string, ParameterValuesValue>(); foreach (var property1 in property0.Value.EnumerateObject()) { dictionary.Add(property1.Name, ParameterValuesValue.DeserializeParameterValuesValue(property1.Value)); } parameters = dictionary; continue; } if (property0.NameEquals("description")) { description = property0.Value.GetString(); continue; } if (property0.NameEquals("metadata")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } metadata = property0.Value.GetObject(); continue; } if (property0.NameEquals("enforcementMode")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } enforcementMode = new EnforcementMode(property0.Value.GetString()); continue; } } continue; } } return(new PolicyAssignment(id.Value, type.Value, name.Value, sku.Value, location.Value, identity.Value, displayName.Value, policyDefinitionId.Value, scope.Value, Optional.ToList(notScopes), Optional.ToDictionary(parameters), description.Value, metadata.Value, Optional.ToNullable(enforcementMode))); }
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)); }