// UpdateTarget updates a scraper target.
965419
func (s *Service) UpdateTarget(ctx context.Context, update *influxdb.ScraperTarget, userID influxdb.ID) (target *influxdb.ScraperTarget, err error) {
	op := OpPrefix + influxdb.OpUpdateTarget
	if !update.ID.Valid() {
		return nil, &influxdb.Error{
			Code: influxdb.EInvalid,
			Op:   op,
			Msg:  "provided scraper target ID has invalid format",
		}
	}
	oldTarget, pe := s.loadScraperTarget(update.ID)
	if pe != nil {
		return nil, &influxdb.Error{
			Op:  op,
			Err: pe,
		}
	}
	if !update.OrgID.Valid() {
		update.OrgID = oldTarget.OrgID
	}
	if !update.BucketID.Valid() {
		update.BucketID = oldTarget.BucketID
	}
	if err = s.PutTarget(ctx, update); err != nil {
		return nil, &influxdb.Error{
			Op:  op,
			Err: pe,
		}
	}

	return update, nil
}
378296
func (s *Service) RemoveTarget(ctx context.Context, id platform.ID) error {
	if _, pe := s.loadScraperTarget(id); pe != nil {
		return &platform.Error{
			Err: pe,
			Op:  OpPrefix + platform.OpRemoveTarget,
		}
	}
	s.scraperTargetKV.Delete(id.String())
	return nil
}
39902
func updateTargetIssue(raw *TargetIssueEntity, dst *issue.TargetIssue) bool {
	rebuildSummary := false
	if raw.Summary != nil {
		dst.Summary = *raw.Summary
	}
	if raw.Desc != nil {
		dst.Desc = *raw.Desc
	}
	if raw.References != nil {
		dst.References = raw.References
	}
	if raw.VulnType != nil {
		dst.VulnType = *raw.VulnType
	}
	if raw.Vector != nil {
		dst.Vector = raw.Vector.Transform()
	}
	if raw.Confirmed != nil {
		dst.Confirmed = *raw.Confirmed
	}
	if raw.False != nil {
		rebuildSummary = true
		dst.False = *raw.False
	}
	if raw.Resolved != nil {
		rebuildSummary = true
		dst.Resolved = *raw.Resolved
		if *raw.Resolved {
			dst.ResolvedAt = time.Now()
		} else {
			dst.ResolvedAt = time.Time{}
		}
	}
	if raw.Muted != nil {
		rebuildSummary = true
		dst.Muted = *raw.Muted
	}
	if raw.Severity != nil {
		if isValidSeverity(*raw.Severity) {
			rebuildSummary = true
			dst.Severity = *raw.Severity
		}
	}
	return rebuildSummary
}
691627
func (launcher *Launcher) SetTarget(target string) {
	launcher.Mutex.Lock()
	launcher.target = target
	launcher.Mutex.Unlock()
}
538192
func (s *StartSessionInput) SetTarget(v string) *StartSessionInput {
	s.Target = &v
	return s
}
571897
func (s *ListAttachedPoliciesInput) SetTarget(v string) *ListAttachedPoliciesInput {
	s.Target = &v
	return s
}
1182708
func (s *CompareFacesInput) SetTargetImage(v *Image) *CompareFacesInput {
	s.TargetImage = v
	return s
}
581787
func (s *AutomationExecutionMetadata) SetTarget(v string) *AutomationExecutionMetadata {
	s.Target = &v
	return s
}
298491
func (s *CreateRouteInput) SetTarget(v string) *CreateRouteInput {
	s.Target = &v
	return s
}
60637
func (c *Client) RemoveTarget(ctx context.Context, id influxdb.ID) error {
	err := c.db.Update(func(tx *bolt.Tx) error {
		_, pe := c.findTargetByID(ctx, tx, id)
		if pe != nil {
			return pe
		}
		encID, err := id.Encode()
		if err != nil {
			return &influxdb.Error{
				Code: influxdb.EInvalid,
				Err:  err,
			}
		}
		if err = tx.Bucket(scraperBucket).Delete(encID); err != nil {
			return nil
		}
		return c.deleteUserResourceMappings(ctx, tx, influxdb.UserResourceMappingFilter{
			ResourceID:   id,
			ResourceType: influxdb.ScraperResourceType,
		})
	})
	if err != nil {
		return &influxdb.Error{
			Err: err,
			Op:  OpPrefix + influxdb.OpRemoveTarget,
		}
	}
	return nil
}
1269816
func (i *Instance) updateTargetNetworks(set provider.Ipset, old, new []string) error {

	deleteMap := map[string]bool{}
	for _, net := range old {
		deleteMap[net] = true
	}

	for _, net := range new {
		if _, ok := deleteMap[net]; ok {
			deleteMap[net] = false
			continue
		}
		if err := i.addToIPset(set, net); err != nil {
			return fmt.Errorf("unable to update target set: %s", err)
		}
	}

	for net, delete := range deleteMap {
		if delete {
			if err := i.delFromIPset(set, net); err != nil {
				zap.L().Debug("unable to remove network from set", zap.Error(err))
			}
		}
	}
	return nil
}
1333431
func (s *Subscription) SetTarget(v string) *Subscription {
	s.Target = &v
	return s
}
307204
func (s *ScraperService) ListTargets(ctx context.Context, filter influxdb.ScraperTargetFilter) ([]influxdb.ScraperTarget, error) {
	url, err := newURL(s.Addr, targetsPath)
	if err != nil {
		return nil, err
	}

	query := url.Query()
	if filter.IDs != nil {
		for id := range filter.IDs {
			query.Add("id", id.String())
		}
	}
	if filter.Name != nil {
		query.Set("name", *filter.Name)
	}
	if filter.OrgID != nil {
		query.Set("orgID", filter.OrgID.String())
	}
	if filter.Org != nil {
		query.Set("org", *filter.Org)
	}

	req, err := http.NewRequest("GET", url.String(), nil)
	if err != nil {
		return nil, err
	}

	req.URL.RawQuery = query.Encode()
	SetToken(s.Token, req)

	hc := newClient(url.Scheme, s.InsecureSkipVerify)
	resp, err := hc.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	if err := CheckError(resp); err != nil {
		return nil, err
	}

	var targetsResp getTargetsResponse
	if err := json.NewDecoder(resp.Body).Decode(&targetsResp); err != nil {
		return nil, err
	}

	targets := make([]influxdb.ScraperTarget, len(targetsResp.Targets))
	for k, v := range targetsResp.Targets {
		targets[k] = v.ScraperTarget
	}

	return targets, nil
}
1321399
func (s *UpgradeElasticsearchDomainInput) SetTargetVersion(v string) *UpgradeElasticsearchDomainInput {
	s.TargetVersion = &v
	return s
}
446517
func (s *ScraperService) ListTargets(ctx context.Context) ([]platform.ScraperTarget, error) {
	url, err := newURL(s.Addr, targetPath)
	if err != nil {
		return nil, err
	}

	query := url.Query()

	req, err := http.NewRequest("GET", url.String(), nil)
	if err != nil {
		return nil, err
	}

	req.URL.RawQuery = query.Encode()
	SetToken(s.Token, req)

	hc := newClient(url.Scheme, s.InsecureSkipVerify)
	resp, err := hc.Do(req)
	if err != nil {
		return nil, err
	}
	if err := CheckError(resp, true); err != nil {
		return nil, err
	}

	var targetsResp getTargetsResponse
	if err := json.NewDecoder(resp.Body).Decode(&targetsResp); err != nil {
		return nil, err
	}

	targets := make([]platform.ScraperTarget, len(targetsResp.Targets))
	for k, v := range targetsResp.Targets {
		targets[k] = v.ScraperTarget
	}

	return targets, nil
}
914948
func (s *UpdateDocumentInput) SetTargetType(v string) *UpdateDocumentInput {
	s.TargetType = &v
	return s
}
293699
func (p *BlockPrefetchClient) retarget(hash string) {
	if hash == "" {
		return
	}

	if p.next.headerResult != nil && hash == p.next.headerResult.Hash {
		return
	}
	// Do not go backwards
	if p.current.headerResult != nil && hash == p.current.headerResult.Hash {
		return
	}

	h, err := chainhash.NewHashFromStr(hash)
	if err != nil {
		log.Errorf("Invalid hash %s: %v", hash, err)
		return
	}

	p.retargetChan <- h
}