// Code generated by Microsoft Kiota - DO NOT EDIT.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.

package models

import (
    i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)

type AgentIdentityBlueprintPrincipal struct {
    ServicePrincipal
}
// NewAgentIdentityBlueprintPrincipal instantiates a new AgentIdentityBlueprintPrincipal and sets the default values.
func NewAgentIdentityBlueprintPrincipal()(*AgentIdentityBlueprintPrincipal) {
    m := &AgentIdentityBlueprintPrincipal{
        ServicePrincipal: *NewServicePrincipal(),
    }
    odataTypeValue := "#microsoft.graph.agentIdentityBlueprintPrincipal"
    m.SetOdataType(&odataTypeValue)
    return m
}
// CreateAgentIdentityBlueprintPrincipalFromDiscriminatorValue creates a new instance of the appropriate class based on discriminator value
// returns a Parsable when successful
func CreateAgentIdentityBlueprintPrincipalFromDiscriminatorValue(parseNode i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, error) {
    return NewAgentIdentityBlueprintPrincipal(), nil
}
// GetFieldDeserializers the deserialization information for the current model
// returns a map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(error) when successful
func (m *AgentIdentityBlueprintPrincipal) GetFieldDeserializers()(map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode)(error)) {
    res := m.ServicePrincipal.GetFieldDeserializers()
    res["sponsors"] = func (n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
        val, err := n.GetCollectionOfObjectValues(CreateDirectoryObjectFromDiscriminatorValue)
        if err != nil {
            return err
        }
        if val != nil {
            res := make([]DirectoryObjectable, len(val))
            for i, v := range val {
                if v != nil {
                    res[i] = v.(DirectoryObjectable)
                }
            }
            m.SetSponsors(res)
        }
        return nil
    }
    return res
}
// GetSponsors gets the sponsors property value. The sponsors for this agent identity blueprint principal. Sponsors are users or service principals who can authorize and manage the lifecycle of agent identity instances.
// returns a []DirectoryObjectable when successful
func (m *AgentIdentityBlueprintPrincipal) GetSponsors()([]DirectoryObjectable) {
    val, err := m.GetBackingStore().Get("sponsors")
    if err != nil {
        panic(err)
    }
    if val != nil {
        return val.([]DirectoryObjectable)
    }
    return nil
}
// Serialize serializes information the current object
func (m *AgentIdentityBlueprintPrincipal) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {
    err := m.ServicePrincipal.Serialize(writer)
    if err != nil {
        return err
    }
    if m.GetSponsors() != nil {
        cast := make([]i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, len(m.GetSponsors()))
        for i, v := range m.GetSponsors() {
            if v != nil {
                cast[i] = v.(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable)
            }
        }
        err = writer.WriteCollectionOfObjectValues("sponsors", cast)
        if err != nil {
            return err
        }
    }
    return nil
}
// SetSponsors sets the sponsors property value. The sponsors for this agent identity blueprint principal. Sponsors are users or service principals who can authorize and manage the lifecycle of agent identity instances.
func (m *AgentIdentityBlueprintPrincipal) SetSponsors(value []DirectoryObjectable)() {
    err := m.GetBackingStore().Set("sponsors", value)
    if err != nil {
        panic(err)
    }
}
type AgentIdentityBlueprintPrincipalable interface {
    i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable
    ServicePrincipalable
    GetSponsors()([]DirectoryObjectable)
    SetSponsors(value []DirectoryObjectable)()
}
