// CreateState creates process state if it does not exist yet.
500822
func (p *ProcessStorage) CreateState(role teleport.Role, state StateV2) error {
	if err := state.CheckAndSetDefaults(); err != nil {
		return trace.Wrap(err)
	}
	value, err := json.Marshal(state)
	if err != nil {
		return trace.Wrap(err)
	}
	item := backend.Item{
		Key:   backend.Key(statesPrefix, strings.ToLower(role.String()), stateName),
		Value: value,
	}
	_, err = p.Create(context.TODO(), item)
	if err != nil {
		return trace.Wrap(err)
	}
	return nil
}
230333
func (s *DescribeHapgOutput) SetState(v string) *DescribeHapgOutput {
	s.State = &v
	return s
}
652497
func (s *WorkGroupSummary) SetState(v string) *WorkGroupSummary {
	s.State = &v
	return s
}
409311
func (s *Member) SetState(v string) *Member {
	s.State = &v
	return s
}
887011
func (s *WorkspaceImage) SetState(v string) *WorkspaceImage {
	s.State = &v
	return s
}
892859
func (s *WorkGroup) SetState(v string) *WorkGroup {
	s.State = &v
	return s
}
99432
func (s *LifecyclePolicySummary) SetState(v string) *LifecyclePolicySummary {
	s.State = &v
	return s
}
418664
func (s *AssessmentRunStateChange) SetState(v string) *AssessmentRunStateChange {
	s.State = &v
	return s
}
1141614
func (s *InstanceGroupDetail) SetState(v string) *InstanceGroupDetail {
	s.State = &v
	return s
}
559616
func makeState(arg fastLoadArg, s *keybase1.FastTeamData) *keybase1.FastTeamData {
	if s != nil {
		tmp := s.DeepCopy()
		return &tmp
	}
	return &keybase1.FastTeamData{
		PerTeamKeySeedsUnverified: make(map[keybase1.PerTeamKeyGeneration]keybase1.PerTeamKeySeed),
		ReaderKeyMasks:            make(map[keybase1.TeamApplication](map[keybase1.PerTeamKeyGeneration]keybase1.MaskB64)),
		Chain: keybase1.FastTeamSigChainState{
			ID:                      arg.ID,
			Public:                  arg.Public,
			PerTeamKeys:             make(map[keybase1.PerTeamKeyGeneration]keybase1.PerTeamKey),
			PerTeamKeySeedsVerified: make(map[keybase1.PerTeamKeyGeneration]keybase1.PerTeamKeySeed),
			DownPointers:            make(map[keybase1.Seqno]keybase1.DownPointer),
			LinkIDs:                 make(map[keybase1.Seqno]keybase1.LinkID),
			MerkleInfo:              make(map[keybase1.Seqno]keybase1.MerkleRootV2),
		},
	}
}
241339
func (s *Trigger) SetState(v string) *Trigger {
	s.State = &v
	return s
}
902737
func (s *StopChannelOutput) SetState(v string) *StopChannelOutput {
	s.State = &v
	return s
}
755001
func (s *Input) SetState(v string) *Input {
	s.State = &v
	return s
}
788094
func CreateState(conn client.Connection, req StateRequest) error {
	logger := plog.WithFields(log.Fields{
		"hostid":     req.HostID,
		"serviceid":  req.ServiceID,
		"instanceid": req.InstanceID,
	})

	basepth := "/"
	if req.PoolID != "" {
		basepth = path.Join("/pools", req.PoolID)
	}

	t := conn.NewTransaction()

	// Prepare the host instance
	hpth := path.Join(basepth, "/hosts", req.HostID, "instances")
	err := conn.CreateIfExists(hpth, &client.Dir{})
	if err != nil && err != client.ErrNodeExists {

		logger.WithError(err).Debug("Could not initialize host path")
		return &StateError{
			Request:   req,
			Operation: "create",
			Message:   "could not initialize host path",
		}
	}

	hspth := path.Join(hpth, req.StateID())
	hsdat := &HostState{
		DesiredState: service.SVCRun,
		Scheduled:    time.Now(),
	}
	t.Create(hspth, hsdat)

	// Prepare the service instance
	sspth := path.Join(basepth, "/services", req.ServiceID, req.StateID())
	ssdat := &ServiceState{}
	t.Create(sspth, ssdat)

	cspth := path.Join(sspth, "current")
	cstate := &CurrentStateContainer{}
	cstate.Status = service.StateStopped
	t.Create(cspth, cstate)

	if err := t.Commit(); err != nil {
		logger.WithError(err).Debug("Could not commit transaction")
		return &StateError{
			Request:   req,
			Operation: "create",
			Message:   "could not commit transaction",
		}
	}

	logger.Debug("Created state")
	return nil
}
537395
func (s *GetVaultLockOutput) SetState(v string) *GetVaultLockOutput {
	s.State = &v
	return s
}
409068
func (s *CreateComputeEnvironmentInput) SetState(v string) *CreateComputeEnvironmentInput {
	s.State = &v
	return s
}
1203000
func (s *DescribeChannelOutput) SetState(v string) *DescribeChannelOutput {
	s.State = &v
	return s
}