// NewTeamProfileChangeNameType returns a new TeamProfileChangeNameType instance
198970
func NewTeamProfileChangeNameType(Description string) *TeamProfileChangeNameType {
	s := new(TeamProfileChangeNameType)
	s.Description = Description
	return s
}
899683
func NewDeviceChangeIpMobileType(Description string) *DeviceChangeIpMobileType {
	s := new(DeviceChangeIpMobileType)
	s.Description = Description
	return s
}
563785
func (r *GormWorkItemRepository) ChangeWorkItemType(ctx context.Context, wiStorage *WorkItemStorage, oldWIType *WorkItemType, newWIType *WorkItemType, spaceID uuid.UUID) error {
	allowedWIT, err := r.CheckTypeAndSpaceShareTemplate(ctx, newWIType, spaceID)
	if err != nil {
		return errs.Wrap(err, "failed to check workitem type")
	}
	if !allowedWIT {
		return errors.NewBadParameterError("typeID", oldWIType.ID)
	}
	var fieldDiff = Fields{}
	// Loop through old workitem type
	for oldFieldName, oldFieldDef := range oldWIType.Fields {
		// Temporary workaround to not add metastates to the field diff. We need
		// to have a special handling for fields that shouldn't be set by user
		// (or affected by type change) MetaState is a system level detail and
		// that shouldn't be affected by type change, even if it is affected, it
		// shouldn't show up in the field diff. The purpose of
		// fieldDiff is to get the list of fields that should be added to the
		// description. Metastate shouldn't show up in the description
		if oldFieldName == SystemMetaState {
			continue
		}
		// The field exists in old type and new type
		if newField, ok := newWIType.Fields[oldFieldName]; ok {
			newVal, err := oldFieldDef.Type.ConvertToModelWithType(newField.Type, wiStorage.Fields[oldFieldName])
			if err == nil {
				wiStorage.Fields[oldFieldName] = newVal
			}
			// Failed to assign the old value to the new field. Add the field to
			// the diff and remove it from the old workitem.
			if err != nil {
				fieldDiff[oldFieldName] = wiStorage.Fields[oldFieldName]
				delete(wiStorage.Fields, oldFieldName)
			}
		} else { // field doesn't exist in new type
			if wiStorage.Fields[oldFieldName] != nil {
				fieldDiff[oldFieldName] = wiStorage.Fields[oldFieldName]
				delete(wiStorage.Fields, oldFieldName)
			}
		}
	}
	// We need fieldKeys to show field diff in a defined order. Golang maps
	// aren't ordered by default.
	var fieldKeys []string
	for fieldName := range fieldDiff {
		fieldKeys = append(fieldKeys, fieldName)
	}
	// Sort the field keys to prevent random order of fields
	sort.Strings(fieldKeys)
	// Append diff (fields along with their values) between the workitem types
	// to the description
	if len(fieldDiff) > 0 {
		// If description doesn't exists, assign it empty value
		if wiStorage.Fields[SystemDescription] == nil {
			wiStorage.Fields[SystemDescription] = ""
		}
		originalDescription := rendering.NewMarkupContentFromValue(wiStorage.Fields[SystemDescription])
		// TemplateData holds the information to be added to the description
		templateData := struct {
			NewTypeName         string
			FieldNameValues     map[string]string
			OriginalDescription string
		}{
			NewTypeName:         newWIType.Name,
			FieldNameValues:     make(map[string]string),
			OriginalDescription: originalDescription.Content,
		}

		for _, fieldName := range fieldKeys {
			fieldDef := oldWIType.Fields[fieldName]
			oldKind := fieldDef.Type.GetKind()
			oldValue := fieldDiff[fieldName]

			if oldKind == KindEnum {
				enumType, ok := fieldDef.Type.(EnumType)
				if !ok {
					return errs.Errorf("failed to convert field %q to enum type: %+v", fieldName, fieldDef)
				}
				oldKind = enumType.BaseType.GetKind()
			}
			// handle all single value fields (including Enums)
			if oldKind != KindList {
				var val string
				if oldKind.IsRelational() {
					val, err = getValueOfRelationalKind(r.db, oldValue, oldKind)
					if err != nil {
						return errs.Wrapf(err, "failed to get relational value for field %s", fieldName)
					}
				} else {
					val = fmt.Sprint(oldValue)
				}
				// Add field information to the description
				templateData.FieldNameValues[oldWIType.Fields[fieldName].Label] = val
				continue
			}

			// Deal with multi value field (KindList)
			listType, ok := fieldDef.Type.(ListType)
			if !ok {
				return errs.Errorf("failed to convert field %q to list type: %+v", fieldName, fieldDef)
			}
			oldKind = listType.ComponentType.GetKind()
			valList, ok := fieldDiff[fieldName].([]interface{})
			if !ok {
				return errs.Errorf("failed to convert list value of field %q to []interface{}: %+v", fieldName, fieldDiff[fieldName])
			}

			var tempList []string
			for _, v := range valList {
				val := fmt.Sprint(v)
				if oldKind.IsRelational() {
					val, err = getValueOfRelationalKind(r.db, v, oldKind)
					if err != nil {
						return errs.Wrapf(err, "failed to get relational value for field %s", fieldName)
					}
				}
				tempList = append(tempList, val)
			}
			// Convert []string to comma seperated strings and add it to the
			// description.
			templateData.FieldNameValues[oldWIType.Fields[fieldName].Label] = strings.Join(tempList, ", ")
		}
		descriptionTemplate := template.Must(template.New("test").Parse("```" +
			`
Missing fields in workitem type: {{ .NewTypeName }}
{{range $index, $element := .FieldNameValues }}
{{$index}} : {{$element}}{{end}}
` + "```" + `
{{.OriginalDescription}}
`))
		var newDescription bytes.Buffer
		if err := descriptionTemplate.Execute(&newDescription, templateData); err != nil {
			return errs.Wrap(err, "failed to populate description template")
		}
		wiStorage.Fields[SystemDescription] = rendering.NewMarkupContent(newDescription.String(), rendering.SystemMarkupMarkdown)
	}
	// Set default values for all field in newWIType
	for fieldName, fieldDef := range newWIType.Fields {
		fieldValue := wiStorage.Fields[fieldName]
		// Do not assign default value to metastate
		if fieldName == SystemMetaState {
			continue
		}
		// Assign default only if fieldValue is nil
		wiStorage.Fields[fieldName], err = fieldDef.ConvertToModel(fieldName, fieldValue)
		if err != nil {
			return errs.Wrapf(err, "failed to convert field %q", fieldName)
		}
	}
	wiStorage.Type = newWIType.ID
	return nil
}
1201748
func NewSsoChangeSamlIdentityModeType(Description string) *SsoChangeSamlIdentityModeType {
	s := new(SsoChangeSamlIdentityModeType)
	s.Description = Description
	return s
}
503660
func NewTeamMergeToDetails(TeamName string) *TeamMergeToDetails {
	s := new(TeamMergeToDetails)
	s.TeamName = TeamName
	return s
}
173614
func NewTeamEvent(Timestamp time.Time, EventCategory *EventCategory, EventType *EventType, Details *EventDetails) *TeamEvent {
	s := new(TeamEvent)
	s.Timestamp = Timestamp
	s.EventCategory = EventCategory
	s.EventType = EventType
	s.Details = Details
	return s
}
957227
func NewTeamFolderMetadata(TeamFolderId string, Name string, Status *TeamFolderStatus, IsTeamSharedDropbox bool, SyncSetting *files.SyncSetting, ContentSyncSettings []*files.ContentSyncSetting) *TeamFolderMetadata {
	s := new(TeamFolderMetadata)
	s.TeamFolderId = TeamFolderId
	s.Name = Name
	s.Status = Status
	s.IsTeamSharedDropbox = IsTeamSharedDropbox
	s.SyncSetting = SyncSetting
	s.ContentSyncSettings = ContentSyncSettings
	return s
}
1139879
func (s *CreateChangeSetInput) SetChangeSetType(v string) *CreateChangeSetInput {
	s.ChangeSetType = &v
	return s
}
1251683
func NewTeamSelectiveSyncPolicyChangedDetails(NewValue *TeamSelectiveSyncPolicy, PreviousValue *TeamSelectiveSyncPolicy) *TeamSelectiveSyncPolicyChangedDetails {
	s := new(TeamSelectiveSyncPolicyChangedDetails)
	s.NewValue = NewValue
	s.PreviousValue = PreviousValue
	return s
}
925300
func NewTeamFolderChangeStatusDetails(NewValue *team.TeamFolderStatus) *TeamFolderChangeStatusDetails {
	s := new(TeamFolderChangeStatusDetails)
	s.NewValue = NewValue
	return s
}
83825
func NewPaperChangeMemberLinkPolicyType(Description string) *PaperChangeMemberLinkPolicyType {
	s := new(PaperChangeMemberLinkPolicyType)
	s.Description = Description
	return s
}
979204
func NewTeamGetInfoResult(Name string, TeamId string, NumLicensedUsers uint32, NumProvisionedUsers uint32, Policies *team_policies.TeamMemberPolicies) *TeamGetInfoResult {
	s := new(TeamGetInfoResult)
	s.Name = Name
	s.TeamId = TeamId
	s.NumLicensedUsers = NumLicensedUsers
	s.NumProvisionedUsers = NumProvisionedUsers
	s.Policies = Policies
	return s
}
1328673
func NewTeamFolderRenameType(Description string) *TeamFolderRenameType {
	s := new(TeamFolderRenameType)
	s.Description = Description
	return s
}
1350113
func (agent *ActionAgent) ChangeType(ctx context.Context, tabletType topodatapb.TabletType) error {
	if err := agent.lock(ctx); err != nil {
		return err
	}
	defer agent.unlock()

	// We don't want to allow multiple callers to claim a tablet as drained. There is a race that could happen during
	// horizontal resharding where two vtworkers will try to DRAIN the same tablet. This check prevents that race from
	// causing errors.
	if tabletType == topodatapb.TabletType_DRAINED && agent.Tablet().Type == topodatapb.TabletType_DRAINED {
		return fmt.Errorf("Tablet: %v, is already drained", agent.TabletAlias)
	}
	// change our type in the topology
	_, err := topotools.ChangeType(ctx, agent.TopoServer, agent.TabletAlias, tabletType)
	if err != nil {
		return err
	}

	// let's update our internal state (stop query service and other things)
	if err := agent.refreshTablet(ctx, "ChangeType"); err != nil {
		return err
	}

	// Let's see if we need to fix semi-sync acking.
	if err := agent.fixSemiSyncAndReplication(agent.Tablet().Type); err != nil {
		return vterrors.Wrap(err, "fixSemiSyncAndReplication failed, may not ack correctly")
	}

	// and re-run health check
	agent.runHealthCheckLocked()
	return nil
}
1259056
func NewTeamMergeToType(Description string) *TeamMergeToType {
	s := new(TeamMergeToType)
	s.Description = Description
	return s
}
527559
func NewTfaChangeStatusType(Description string) *TfaChangeStatusType {
	s := new(TfaChangeStatusType)
	s.Description = Description
	return s
}
256624
func NewTeamFolderPermanentlyDeleteType(Description string) *TeamFolderPermanentlyDeleteType {
	s := new(TeamFolderPermanentlyDeleteType)
	s.Description = Description
	return s
}