// NewDeviceApprovalsChangeDesktopPolicyType returns a new DeviceApprovalsChangeDesktopPolicyType instance
552001
func NewDeviceApprovalsChangeDesktopPolicyType(Description string) *DeviceApprovalsChangeDesktopPolicyType {
	s := new(DeviceApprovalsChangeDesktopPolicyType)
	s.Description = Description
	return s
}
1279779
func NewPaperChangePolicyType(Description string) *PaperChangePolicyType {
	s := new(PaperChangePolicyType)
	s.Description = Description
	return s
}
917717
func NewDeviceChangeIpWebDetails(UserAgent string) *DeviceChangeIpWebDetails {
	s := new(DeviceChangeIpWebDetails)
	s.UserAgent = UserAgent
	return s
}
1344237
func (s *CloneStackInput) SetDefaultRootDeviceType(v string) *CloneStackInput {
	s.DefaultRootDeviceType = &v
	return s
}
859647
func NewDeviceDeleteOnUnlinkFailType(Description string) *DeviceDeleteOnUnlinkFailType {
	s := new(DeviceDeleteOnUnlinkFailType)
	s.Description = Description
	return s
}
406992
func (e *loginProvision) deviceWithType(m libkb.MetaContext, provisionerType keybase1.DeviceType) (err error) {
	defer m.Trace("loginProvision#deviceWithType", func() error { return err })()

	// make a new device:
	deviceID, err := libkb.NewDeviceID()
	if err != nil {
		return err
	}
	device := &libkb.Device{
		ID:   deviceID,
		Type: e.arg.DeviceType,
	}

	// prompt for the device name here so there's no delay during kex:
	m.Debug("deviceWithType: prompting for device name")
	name, err := e.deviceName(m)
	if err != nil {
		m.Debug("deviceWithType: error getting device name from user: %s", err)
		return err
	}
	device.Description = &name
	m.Debug("deviceWithType: got device name: %q", name)

	// make a new secret:
	uid := m.CurrentUID()

	// Continue to generate legacy Kex2 secret types
	kex2SecretTyp := libkb.Kex2SecretTypeV1Desktop
	if e.arg.DeviceType == libkb.DeviceTypeMobile || provisionerType == keybase1.DeviceType_MOBILE {
		kex2SecretTyp = libkb.Kex2SecretTypeV1Mobile
	}
	m.Debug("Generating Kex2 secret for uid=%s, typ=%d", uid, kex2SecretTyp)
	secret, err := libkb.NewKex2SecretFromTypeAndUID(kex2SecretTyp, uid)
	if err != nil {
		return err
	}

	// create provisionee engine
	salt, err := e.arg.User.GetSalt()
	if err != nil {
		m.Debug("Failed to get salt")
		return err
	}
	provisionee := NewKex2Provisionee(m.G(), device, secret.Secret(), e.arg.User.GetUID(), salt)

	var canceler func()

	// display secret and prompt for secret from X in a goroutine:
	go func() {
		sb := secret.Secret()
		arg := keybase1.DisplayAndPromptSecretArg{
			Secret:          sb[:],
			Phrase:          secret.Phrase(),
			OtherDeviceType: provisionerType,
		}
		var contxt context.Context
		contxt, canceler = context.WithCancel(context.Background())
		for i := 0; i < 10; i++ {
			receivedSecret, err := m.UIs().ProvisionUI.DisplayAndPromptSecret(contxt, arg)
			if err != nil {
				// cancel provisionee run:
				provisionee.Cancel()
				m.Warning("DisplayAndPromptSecret error: %s", err)
				break
			} else if receivedSecret.Secret != nil && len(receivedSecret.Secret) > 0 {
				m.Debug("received secret, adding to provisionee")
				var ks kex2.Secret
				copy(ks[:], receivedSecret.Secret)
				provisionee.AddSecret(ks)
				break
			} else if len(receivedSecret.Phrase) > 0 {
				m.Debug("received secret phrase, checking validity")
				checker := libkb.MakeCheckKex2SecretPhrase(m.G())
				if !checker.F(receivedSecret.Phrase) {
					m.Debug("secret phrase failed validity check (attempt %d)", i)
					arg.PreviousErr = checker.Hint
					continue
				}
				m.Debug("received secret phrase, adding to provisionee")
				ks, err := libkb.NewKex2SecretFromUIDAndPhrase(uid, receivedSecret.Phrase)
				if err != nil {
					m.Warning("DisplayAndPromptSecret error: %s", err)
				} else {
					provisionee.AddSecret(ks.Secret())
				}
				break
			} else {
				// empty secret, so must have been a display-only case.
				// ok to stop the loop
				m.Debug("login provision DisplayAndPromptSecret returned empty secret, stopping retry loop")
				break
			}
		}
	}()

	defer func() {
		if canceler != nil {
			m.Debug("canceling DisplayAndPromptSecret call")
			canceler()
		}
	}()

	err = RunEngine2(m, provisionee)
	if err != nil {
		return err
	}

	e.saveToSecretStoreWithLKS(m, provisionee.GetLKSec())

	e.signingKey, err = provisionee.SigningKey()
	if err != nil {
		return err
	}
	e.encryptionKey, err = provisionee.EncryptionKey()
	if err != nil {
		return err
	}

	// Load me again so that keys will be up to date.
	loadArg := libkb.NewLoadUserArgWithMetaContext(m).WithSelf(true).WithUID(e.arg.User.GetUID())
	e.arg.User, err = libkb.LoadUser(loadArg)
	if err != nil {
		return err
	}

	// need username, device name for ProvisionUI.ProvisioneeSuccess()
	e.username = provisionee.GetName()
	pdevice := provisionee.Device()
	if pdevice == nil {
		m.Warning("nil provisionee device")
	} else if pdevice.Description == nil {
		m.Warning("nil provisionee device description")
	} else {
		e.devname = *pdevice.Description
	}

	return nil
}
889220
func NewSharedFolderChangeMembersInheritancePolicyType(Description string) *SharedFolderChangeMembersInheritancePolicyType {
	s := new(SharedFolderChangeMembersInheritancePolicyType)
	s.Description = Description
	return s
}
86726
func (s *DeviceTemplate) SetDeviceType(v string) *DeviceTemplate {
	s.DeviceType = &v
	return s
}
722833
func NewSharedContentChangeViewerInfoPolicyType(Description string) *SharedContentChangeViewerInfoPolicyType {
	s := new(SharedContentChangeViewerInfoPolicyType)
	s.Description = Description
	return s
}
997068
func NewGroupChangeManagementTypeType(Description string) *GroupChangeManagementTypeType {
	s := new(GroupChangeManagementTypeType)
	s.Description = Description
	return s
}
778025
func (s *VTLDevice) SetVTLDeviceType(v string) *VTLDevice {
	s.VTLDeviceType = &v
	return s
}
1102614
func (client *Client) ChangeType(ctx context.Context, tablet *topodatapb.Tablet, dbType topodatapb.TabletType) error {
	cc, c, err := client.dial(tablet)
	if err != nil {
		return err
	}
	defer cc.Close()
	_, err = c.ChangeType(ctx, &tabletmanagerdatapb.ChangeTypeRequest{
		TabletType: dbType,
	})
	return err
}
1044414
func (s *UpdateStackInput) SetDefaultRootDeviceType(v string) *UpdateStackInput {
	s.DefaultRootDeviceType = &v
	return s
}
124559
func NewGroupChangeExternalIdType(Description string) *GroupChangeExternalIdType {
	s := new(GroupChangeExternalIdType)
	s.Description = Description
	return s
}
1100180
func NewSharingChangeFolderJoinPolicyType(Description string) *SharingChangeFolderJoinPolicyType {
	s := new(SharingChangeFolderJoinPolicyType)
	s.Description = Description
	return s
}
1350537
func NewShowcaseChangeExternalSharingPolicyType(Description string) *ShowcaseChangeExternalSharingPolicyType {
	s := new(ShowcaseChangeExternalSharingPolicyType)
	s.Description = Description
	return s
}
899683
func NewDeviceChangeIpMobileType(Description string) *DeviceChangeIpMobileType {
	s := new(DeviceChangeIpMobileType)
	s.Description = Description
	return s
}