Example #1
0
 internal ManagedServiceIdentity(Guid?principalId, Guid?tenantId, ManagedServiceIdentityType managedServiceIdentityType, IDictionary <ResourceIdentifier, UserAssignedIdentity> userAssignedIdentities)
 {
     PrincipalId = principalId;
     TenantId    = tenantId;
     ManagedServiceIdentityType = managedServiceIdentityType;
     UserAssignedIdentities     = userAssignedIdentities;
 }
 internal ManagedServiceIdentity(Guid?principalId, Guid?tenantId, ManagedServiceIdentityType type, IDictionary <string, UserAssignedIdentity> userAssignedIdentities)
 {
     PrincipalId            = principalId;
     TenantId               = tenantId;
     Type                   = type;
     UserAssignedIdentities = userAssignedIdentities;
 }
        internal static ManagedServiceIdentity DeserializeManagedServiceIdentity(JsonElement element, JsonSerializerOptions options = default)
        {
            Optional <Guid>            principalId = default;
            Optional <Guid>            tenantId    = default;
            ManagedServiceIdentityType type        = default;
            Optional <IDictionary <string, UserAssignedIdentity> > userAssignedIdentities = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("principalId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    principalId = property.Value.GetGuid();
                    continue;
                }
                if (property.NameEquals("tenantId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    tenantId = property.Value.GetGuid();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = JsonSerializer.Deserialize <ManagedServiceIdentityType>("{" + property.ToString() + "}", options);
                    continue;
                }
                if (property.NameEquals("userAssignedIdentities"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, UserAssignedIdentity> dictionary = new Dictionary <string, UserAssignedIdentity>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, UserAssignedIdentity.DeserializeUserAssignedIdentity(property0.Value));
                    }
                    userAssignedIdentities = dictionary;
                    continue;
                }
            }
            return(new ManagedServiceIdentity(Optional.ToNullable(principalId), Optional.ToNullable(tenantId), type, Optional.ToDictionary(userAssignedIdentities)));
        }
Example #4
0
 public ManagedServiceIdentity(ManagedServiceIdentityType managedServiceIdentityType)
 {
     ManagedServiceIdentityType = managedServiceIdentityType;
     UserAssignedIdentities     = new ChangeTrackingDictionary <ResourceIdentifier, UserAssignedIdentity>();
 }
 public ManagedServiceIdentity(ManagedServiceIdentityType type)
 {
     Type = type;
     UserAssignedIdentities = new ChangeTrackingDictionary <string, UserAssignedIdentity>();
 }