// UpdateTarget updates a scraper target.
10980
func (s *Service) UpdateTarget(ctx context.Context, update *influxdb.ScraperTarget, userID influxdb.ID) (*influxdb.ScraperTarget, error) {
	var target *influxdb.ScraperTarget
	err := s.kv.Update(ctx, func(tx Tx) error {
		var err error
		target, err = s.updateTarget(ctx, tx, update, userID)
		return err
	})

	return target, err
}
302226
func (s *Service) AddTarget(ctx context.Context, target *influxdb.ScraperTarget, userID influxdb.ID) (err error) {
	return s.kv.Update(ctx, func(tx Tx) error {
		return s.addTarget(ctx, tx, target, userID)
	})
}
973092
func (c *Client) PutTarget(ctx context.Context, target *platform.ScraperTarget) error {
	return c.db.Update(func(tx *bolt.Tx) error {
		return c.putTarget(ctx, tx, target)
	})
}
364851
func (s *DetachPolicyInput) SetTarget(v string) *DetachPolicyInput {
	s.Target = &v
	return s
}
190213
func (s *ScraperService) AddTarget(ctx context.Context, target *platform.ScraperTarget) error {
	url, err := newURL(s.Addr, targetPath)
	if err != nil {
		return err
	}

	octets, err := json.Marshal(target)
	if err != nil {
		return err
	}

	req, err := http.NewRequest("POST", url.String(), bytes.NewReader(octets))
	if err != nil {
		return err
	}

	req.Header.Set("Content-Type", "application/json")
	SetToken(s.Token, req)

	hc := newClient(url.Scheme, s.InsecureSkipVerify)

	resp, err := hc.Do(req)
	if err != nil {
		return err
	}

	// TODO(jsternberg): Should this check for a 201 explicitly?
	if err := CheckError(resp, true); err != nil {
		return err
	}

	targetResp := new(targetResponse)
	if err := json.NewDecoder(resp.Body).Decode(targetResp); err != nil {
		return err
	}

	return nil
}
1263097
func (s *PresetWatermark) SetTarget(v string) *PresetWatermark {
	s.Target = &v
	return s
}
761501
func (c *Client) ListTargets(ctx context.Context, filter influxdb.ScraperTargetFilter) (list []influxdb.ScraperTarget, err error) {
	list = make([]influxdb.ScraperTarget, 0)
	err = c.db.View(func(tx *bolt.Tx) (err error) {
		cur := tx.Bucket(scraperBucket).Cursor()
		for k, v := cur.First(); k != nil; k, v = cur.Next() {
			target := new(influxdb.ScraperTarget)
			if err = json.Unmarshal(v, target); err != nil {
				return err
			}
			if err != nil {
				return err
			}
			if filter.IDs != nil {
				if _, ok := filter.IDs[target.ID]; !ok {
					continue
				}
			}
			if filter.Name != nil && target.Name != *filter.Name {
				continue
			}
			if filter.Org != nil {
				o, err := c.findOrganizationByName(ctx, tx, *filter.Org)
				if err != nil {
					return err
				}
				if target.OrgID != o.ID {
					continue
				}
			}
			if filter.OrgID != nil {
				o, err := c.findOrganizationByID(ctx, tx, *filter.OrgID)
				if err != nil {
					return err
				}
				if target.OrgID != o.ID {
					continue
				}
			}
			list = append(list, *target)
		}
		return err
	})
	if err != nil {
		return nil, &influxdb.Error{
			Op:  getOp(influxdb.OpListTargets),
			Err: err,
		}
	}
	return list, err
}
739972
func (s *AutoScalingTargetTrackingScalingPolicyConfigurationUpdate) SetTargetValue(v float64) *AutoScalingTargetTrackingScalingPolicyConfigurationUpdate {
	s.TargetValue = &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
}
589119
func (s *CodeGenEdge) SetTargetParameter(v string) *CodeGenEdge {
	s.TargetParameter = &v
	return s
}
339333
func (s *SimpleMonitor) SetTarget(target string) {
	s.Name = target
	s.Status.Target = target
}
298491
func (s *CreateRouteInput) SetTarget(v string) *CreateRouteInput {
	s.Target = &v
	return s
}
195295
func (s *Session) SetTarget(v string) *Session {
	s.Target = &v
	return s
}
760503
func (s *RemediationConfiguration) SetTargetVersion(v string) *RemediationConfiguration {
	s.TargetVersion = &v
	return s
}
552582
func (s *ScraperTargetStoreService) RemoveTarget(ctx context.Context, id platform.ID) error {
	return s.RemoveTargetF(ctx, id)
}
663729
func (s *GetRouteOutput) SetTarget(v string) *GetRouteOutput {
	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
}