// NewMemberSpaceLimitsChangePolicyType returns a new MemberSpaceLimitsChangePolicyType instance
772985
func NewMemberSpaceLimitsChangePolicyType(Description string) *MemberSpaceLimitsChangePolicyType {
	s := new(MemberSpaceLimitsChangePolicyType)
	s.Description = Description
	return s
}
6536
func NewMemberSpaceLimitsChangeCustomQuotaType(Description string) *MemberSpaceLimitsChangeCustomQuotaType {
	s := new(MemberSpaceLimitsChangeCustomQuotaType)
	s.Description = Description
	return s
}
259720
func NewMemberChangeStatusType(Description string) *MemberChangeStatusType {
	s := new(MemberChangeStatusType)
	s.Description = Description
	return s
}
997068
func NewGroupChangeManagementTypeType(Description string) *GroupChangeManagementTypeType {
	s := new(GroupChangeManagementTypeType)
	s.Description = Description
	return s
}
526382
func NewMemberChangeAdminRoleType(Description string) *MemberChangeAdminRoleType {
	s := new(MemberChangeAdminRoleType)
	s.Description = Description
	return s
}
1100180
func NewSharingChangeFolderJoinPolicyType(Description string) *SharingChangeFolderJoinPolicyType {
	s := new(SharingChangeFolderJoinPolicyType)
	s.Description = Description
	return s
}
785268
func NewMemberSpaceLimitsAddCustomQuotaDetails(NewValue uint64) *MemberSpaceLimitsAddCustomQuotaDetails {
	s := new(MemberSpaceLimitsAddCustomQuotaDetails)
	s.NewValue = NewValue
	return s
}
148923
func NewTeamFolderChangeStatusType(Description string) *TeamFolderChangeStatusType {
	s := new(TeamFolderChangeStatusType)
	s.Description = Description
	return s
}
174768
func NewPaperChangeMemberPolicyType(Description string) *PaperChangeMemberPolicyType {
	s := new(PaperChangeMemberPolicyType)
	s.Description = Description
	return s
}
1178863
func NewMemberSpaceLimitsChangeCustomQuotaDetails(PreviousValue uint64, NewValue uint64) *MemberSpaceLimitsChangeCustomQuotaDetails {
	s := new(MemberSpaceLimitsChangeCustomQuotaDetails)
	s.PreviousValue = PreviousValue
	s.NewValue = NewValue
	return s
}
267357
func NewMemberSpaceLimitsChangeCapsTypePolicyDetails(PreviousValue *SpaceCapsType, NewValue *SpaceCapsType) *MemberSpaceLimitsChangeCapsTypePolicyDetails {
	s := new(MemberSpaceLimitsChangeCapsTypePolicyDetails)
	s.PreviousValue = PreviousValue
	s.NewValue = NewValue
	return s
}
598536
func NewPaperContentRemoveMemberType(Description string) *PaperContentRemoveMemberType {
	s := new(PaperContentRemoveMemberType)
	s.Description = Description
	return s
}
351821
func NewMemberSpaceLimitsChangeCapsTypePolicyType(Description string) *MemberSpaceLimitsChangeCapsTypePolicyType {
	s := new(MemberSpaceLimitsChangeCapsTypePolicyType)
	s.Description = Description
	return s
}
83825
func NewPaperChangeMemberLinkPolicyType(Description string) *PaperChangeMemberLinkPolicyType {
	s := new(PaperChangeMemberLinkPolicyType)
	s.Description = Description
	return s
}
294370
func ComputeMembershipChanges(oldMetadata *etcdraft.BlockMetadata, oldConsenters map[uint64]*etcdraft.Consenter, newConsenters []*etcdraft.Consenter) (mc *MembershipChanges, err error) {
	result := &MembershipChanges{
		NewConsenters:    map[uint64]*etcdraft.Consenter{},
		NewBlockMetadata: proto.Clone(oldMetadata).(*etcdraft.BlockMetadata),
		AddedNodes:       []*etcdraft.Consenter{},
		RemovedNodes:     []*etcdraft.Consenter{},
	}

	result.NewBlockMetadata.ConsenterIds = make([]uint64, len(newConsenters))

	var addedNodeIndex int
	currentConsentersSet := MembershipByCert(oldConsenters)
	for i, c := range newConsenters {
		if nodeID, exists := currentConsentersSet[string(c.ClientTlsCert)]; exists {
			result.NewBlockMetadata.ConsenterIds[i] = nodeID
			result.NewConsenters[nodeID] = c
			continue
		}
		addedNodeIndex = i
		result.AddedNodes = append(result.AddedNodes, c)
	}

	var deletedNodeID uint64
	newConsentersSet := ConsentersToMap(newConsenters)
	for nodeID, c := range oldConsenters {
		if _, exists := newConsentersSet[string(c.ClientTlsCert)]; !exists {
			result.RemovedNodes = append(result.RemovedNodes, c)
			deletedNodeID = nodeID
		}
	}

	switch {
	case len(result.AddedNodes) == 1 && len(result.RemovedNodes) == 1:
		// cert rotation
		result.RotatedNode = deletedNodeID
		result.NewBlockMetadata.ConsenterIds[addedNodeIndex] = deletedNodeID
		result.NewConsenters[deletedNodeID] = result.AddedNodes[0]
	case len(result.AddedNodes) == 1 && len(result.RemovedNodes) == 0:
		// new node
		nodeID := result.NewBlockMetadata.NextConsenterId
		result.NewConsenters[nodeID] = result.AddedNodes[0]
		result.NewBlockMetadata.ConsenterIds[addedNodeIndex] = nodeID
		result.NewBlockMetadata.NextConsenterId++
		result.ConfChange = &raftpb.ConfChange{
			NodeID: nodeID,
			Type:   raftpb.ConfChangeAddNode,
		}
	case len(result.AddedNodes) == 0 && len(result.RemovedNodes) == 1:
		// removed node
		nodeID := deletedNodeID
		result.ConfChange = &raftpb.ConfChange{
			Type:   raftpb.ConfChangeRemoveNode,
			NodeID: nodeID,
		}
		delete(result.NewConsenters, nodeID)
	case len(result.AddedNodes) == 0 && len(result.RemovedNodes) == 0:
		// no change
	default:
		// len(result.AddedNodes) > 1 || len(result.RemovedNodes) > 1 {
		return nil, errors.Errorf("update of more than one consenter at a time is not supported, requested changes: %s", result)
	}

	return result, nil
}
341132
func NewMemberChangeEmailType(Description string) *MemberChangeEmailType {
	s := new(MemberChangeEmailType)
	s.Description = Description
	return s
}
124559
func NewGroupChangeExternalIdType(Description string) *GroupChangeExternalIdType {
	s := new(GroupChangeExternalIdType)
	s.Description = Description
	return s
}