func (r *Resource) AccountID() string {
	return r.GetAttribute(AccountIDAttribute)
}
AccountID returns account ID attribute of policy resource if exists
package iampapv1
import (
	"github.com/IBM-Cloud/bluemix-go/api/iampap/iampapv2"
	"github.com/IBM-Cloud/bluemix-go/models"
)
type Policy struct {
	ID               string     `json:"id,omitempty"`
	Type             string     `json:"type"`
	Subjects         []Subject  `json:"subjects"`
	Roles            []Role     `json:"roles"`
	Resources        []Resource `json:"resources"`
	Href             string     `json:"href,omitempty"`
	CreatedAt        string     `json:"created_at,omitempty"`
	CreatedByID      string     `json:"created_by_id,omitempty"`
	LastModifiedAt   string     `json:"last_modified_at,omitempty"`
	LastModifiedByID string     `json:"last_modified_by_id,omitempty"`
	Version          string     `json:"-"`
}
type Role struct {
	RoleID      string `json:"role_id"`
	Name        string `json:"display_name,omitempty"`
	Description string `json:"description,omitempty"`
}
func fromModel(role models.PolicyRole) Role {
	return Role{
		RoleID: role.ID.String(),
	}
}
func ConvertRoleModels(roles []models.PolicyRole) []Role {
	results := make([]Role, len(roles))
	for i, r := range roles {
		results[i] = fromModel(r)
	}
	return results
}
func ConvertV2RoleModels(roles []iampapv2.Role) []Role {
	results := make([]Role, len(roles))
	for i, r := range roles {
		results[i] = Role{
			RoleID: r.Crn,
		}
	}
	return results
}
type Subject struct {
	Attributes []Attribute `json:"attributes"`
}
const (
	AccessGroupIDAttribute   = "accesGroupId"
	AccountIDAttribute       = "accountId"
	OrganizationIDAttribute  = "organizationId"
	SpaceIDAttribute         = "spaceId"
	RegionAttribute          = "region"
	ServiceTypeAttribute     = "serviceType"
	ServiceNameAttribute     = "serviceName"
	ServiceInstanceAttribute = "serviceInstance"
	ResourceTypeAttribute    = "resourceType"
	ResourceAttribute        = "resource"
	ResourceGroupIDAttribute = "resourceGroupId"
)
func (s *Subject) GetAttribute(name string) string {
	for _, a := range s.Attributes {
		if a.Name == name {
			return a.Value
		}
	}
	return ""
}
func (s *Subject) SetAttribute(name string, value string) {
	for _, a := range s.Attributes {
		if a.Name == name {
			a.Value = value
			return
		}
	}
	s.Attributes = append(s.Attributes, Attribute{
		Name:  name,
		Value: value,
	})
}
func (s *Subject) AccessGroupID() string {
	return s.GetAttribute("access_group_id")
}
func (s *Subject) AccountID() string {
	return s.GetAttribute("accountId")
}
func (s *Subject) IAMID() string {
	return s.GetAttribute("iam_id")
}
func (s *Subject) ServiceName() string {
	return s.GetAttribute("serviceName")
}
func (s *Subject) ServiceInstance() string {
	return s.GetAttribute("serviceInstance")
}
func (s *Subject) ResourceType() string {
	return s.GetAttribute("resourceType")
}
func (s *Subject) ResourceGroupID() string {
	return s.GetAttribute(ResourceGroupIDAttribute)
}
func (s *Subject) SetAccessGroupID(value string) {
	s.SetAttribute("access_group_id", value)
}
func (s *Subject) SetAccountID(value string) {
	s.SetAttribute("accountId", value)
}
func (s *Subject) SetIAMID(value string) {
	s.SetAttribute("iam_id", value)
}
func (s *Subject) SetServiceName(value string) {
	s.SetAttribute("serviceName", value)
}
func (s *Subject) SetServiceInstance(value string) {
	s.SetAttribute("serviceInstance", value)
}
func (s *Subject) SetResourceType(value string) {
	s.SetAttribute("resourceType", value)
}
func (s *Subject) SetResourceGroupID(value string) {
	s.SetAttribute(ResourceGroupIDAttribute, value)
}
type Resource struct {
	Attributes []Attribute `json:"attributes"`
}
func (r *Resource) GetAttribute(name string) string {
	for _, a := range r.Attributes {
		if a.Name == name {
			return a.Value
		}
	}
	return ""
}
func (r *Resource) SetAttribute(name string, value string) {
	for _, a := range r.Attributes {
		if a.Name == name {
			a.Value = value
			return
		}
	}
	r.Attributes = append(r.Attributes, Attribute{
		Name:  name,
		Value: value,
	})
}
func (r *Resource) AccessGroupID() string {
	return r.GetAttribute(AccessGroupIDAttribute)
}