func NewAffiliationListRequest(serviceId, nodeID string) (*IQ, error) {
	iq, err := NewIQ(Attrs{Type: IQTypeGet, To: serviceId})
	if err != nil {
		return nil, err
	}
	iq.Payload = &PubSubOwner{
		OwnerUseCase: &AffiliationsOwner{
			Node: nodeID,
		},
	}
	return iq, nil
}
NewAffiliationListRequest creates a request to list all affiliated entities
See 8.9.1 Retrieve List List
package stanza
import (
	"encoding/xml"
	"errors"
	"strings"
)
type PubSubOwner struct {
	XMLName      xml.Name `xml:"http://jabber.org/protocol/pubsub#owner pubsub"`
	OwnerUseCase OwnerUseCase
	ResultSet *ResultSet `xml:"set,omitempty"`
}
func (pso *PubSubOwner) Namespace() string {
	return pso.XMLName.Space
}
func (pso *PubSubOwner) GetSet() *ResultSet {
	return pso.ResultSet
}
type OwnerUseCase interface {
	UseCase() string
}
type AffiliationsOwner struct {
	XMLName      xml.Name           `xml:"affiliations"`
	Affiliations []AffiliationOwner `xml:"affiliation,omitempty"`
	Node         string             `xml:"node,attr"`
}
func (AffiliationsOwner) UseCase() string {
	return "affiliations"
}
type AffiliationOwner struct {
	XMLName           xml.Name `xml:"affiliation"`
	AffiliationStatus string   `xml:"affiliation,attr"`
	Jid               string   `xml:"jid,attr"`
}
const (
	AffiliationStatusMember      = "member"
	AffiliationStatusNone        = "none"
	AffiliationStatusOutcast     = "outcast"
	AffiliationStatusOwner       = "owner"
	AffiliationStatusPublisher   = "publisher"
	AffiliationStatusPublishOnly = "publish-only"
)
type ConfigureOwner struct {
	XMLName xml.Name `xml:"configure"`
	Node    string   `xml:"node,attr,omitempty"`
	Form    *Form    `xml:"x,omitempty"`
}
func (*ConfigureOwner) UseCase() string {
	return "configure"
}
type DefaultOwner struct {
	XMLName xml.Name `xml:"default"`
	Form    *Form    `xml:"x,omitempty"`
}
func (*DefaultOwner) UseCase() string {
	return "default"
}
type DeleteOwner struct {
	XMLName       xml.Name       `xml:"delete"`
	RedirectOwner *RedirectOwner `xml:"redirect,omitempty"`
	Node          string         `xml:"node,attr,omitempty"`
}
func (*DeleteOwner) UseCase() string {
	return "delete"
}
type RedirectOwner struct {
	XMLName xml.Name `xml:"redirect"`
	URI     string   `xml:"uri,attr"`
}
type PurgeOwner struct {
	XMLName xml.Name `xml:"purge"`
	Node    string   `xml:"node,attr"`
}
func (*PurgeOwner) UseCase() string {
	return "purge"
}
type SubscriptionsOwner struct {
	XMLName       xml.Name            `xml:"subscriptions"`
	Subscriptions []SubscriptionOwner `xml:"subscription"`
	Node          string              `xml:"node,attr"`
}
func (*SubscriptionsOwner) UseCase() string {
	return "subscriptions"
}
type SubscriptionOwner struct {
	SubscriptionStatus string `xml:"subscription"`
	Jid                string `xml:"jid,attr"`
}
const (
	SubscriptionStatusNone         = "none"
	SubscriptionStatusPending      = "pending"
	SubscriptionStatusSubscribed   = "subscribed"
	SubscriptionStatusUnconfigured = "unconfigured"
)
func NewConfigureNode(serviceId, nodeName string) (*IQ, error) {
	iq, err := NewIQ(Attrs{Type: IQTypeGet, To: serviceId})
	if err != nil {
		return nil, err
	}
	iq.Payload = &PubSubOwner{
		OwnerUseCase: &ConfigureOwner{Node: nodeName},
	}
	return iq, nil
}
func NewDelNode(serviceId, nodeID string) (*IQ, error) {
	if strings.TrimSpace(nodeID) == "" {
		return nil, errors.New("cannot delete a node without a target node ID")
	}
	iq, err := NewIQ(Attrs{Type: IQTypeSet, To: serviceId})
	if err != nil {
		return nil, err
	}
	iq.Payload = &PubSubOwner{
		OwnerUseCase: &DeleteOwner{Node: nodeID},
	}
	return iq, nil
}
func NewPurgeAllItems(serviceId, nodeId string) (*IQ, error) {
	iq, err := NewIQ(Attrs{Type: IQTypeSet, To: serviceId})
	if err != nil {
		return nil, err
	}
	iq.Payload = &PubSubOwner{
		OwnerUseCase: &PurgeOwner{Node: nodeId},
	}
	return iq, nil
}
func NewRequestDefaultConfig(serviceId string) (*IQ, error) {
	iq, err := NewIQ(Attrs{Type: IQTypeGet, To: serviceId})
	if err != nil {
		return nil, err
	}
	iq.Payload = &PubSubOwner{
		OwnerUseCase: &DefaultOwner{},
	}
	return iq, nil
}
func NewApproveSubRequest(serviceId, reqID string, apprForm *Form) (Message, error) {
	if serviceId == "" {
		return Message{}, errors.New("need a target service serviceId send approval serviceId")
	}
	if reqID == "" {
		return Message{}, errors.New("the request ID is empty but must be used for the approval")
	}
	if apprForm == nil {
		return Message{}, errors.New("approval form is nil")
	}
	apprMess := NewMessage(Attrs{To: serviceId})
	apprMess.Extensions = []MsgExtension{apprForm}
	apprMess.Id = reqID
	return apprMess, nil
}
func NewGetPendingSubRequests(serviceId string) (*IQ, error) {
	iq, err := NewIQ(Attrs{Type: IQTypeSet, To: serviceId})
	if err != nil {
		return nil, err
	}
	iq.Payload = &Command{
		Node:   "http://jabber.org/protocol/pubsub#get-pending",
		Action: CommandActionExecute,
	}
	return iq, nil
}
func NewApprovePendingSubRequest(serviceId, sessionId, nodeId string) (*IQ, error) {
	if sessionId == "" {
		return nil, errors.New("the sessionId must be maintained for the command")
	}
	form := &Form{
		Type:   FormTypeSubmit,
		Fields: []*Field{{Var: "pubsub#node", ValuesList: []string{nodeId}}},
	}
	data, err := xml.Marshal(form)
	if err != nil {
		return nil, err
	}
	var n Node
	err = xml.Unmarshal(data, &n)
	if err != nil {
		return nil, err
	}
	iq, err := NewIQ(Attrs{Type: IQTypeSet, To: serviceId})
	if err != nil {
		return nil, err
	}
	iq.Payload = &Command{
		Node:           "http://jabber.org/protocol/pubsub#get-pending",
		Action:         CommandActionExecute,
		SessionId:      sessionId,
		CommandElement: &n,
	}
	return iq, nil
}
func NewSubListRqPl(serviceId, nodeID string) (*IQ, error) {
	iq, err := NewIQ(Attrs{Type: IQTypeGet, To: serviceId})
	if err != nil {
		return nil, err
	}
	iq.Payload = &PubSubOwner{
		OwnerUseCase: &SubscriptionsOwner{Node: nodeID},
	}
	return iq, nil
}
func NewSubsForEntitiesRequest(serviceId, nodeID string, subs []SubscriptionOwner) (*IQ, error) {
	iq, err := NewIQ(Attrs{Type: IQTypeSet, To: serviceId})
	if err != nil {
		return nil, err
	}
	iq.Payload = &PubSubOwner{
		OwnerUseCase: &SubscriptionsOwner{Node: nodeID, Subscriptions: subs},
	}
	return iq, nil
}
func NewModifAffiliationRequest(serviceId, nodeID string, newAffils []AffiliationOwner) (*IQ, error) {
	iq, err := NewIQ(Attrs{Type: IQTypeSet, To: serviceId})
	if err != nil {
		return nil, err
	}
	iq.Payload = &PubSubOwner{
		OwnerUseCase: &AffiliationsOwner{
			Node:         nodeID,
			Affiliations: newAffils,
		},
	}
	return iq, nil
}