// RemoveTarget removes a scraper target from the bucket.
330321
func (c *Client) RemoveTarget(ctx context.Context, id platform.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 &platform.Error{
				Code: platform.EInvalid,
				Err:  err,
			}
		}
		return tx.Bucket(scraperBucket).Delete(encID)
	})
	if err != nil {
		return &platform.Error{
			Err: err,
			Op:  OpPrefix + platform.OpRemoveTarget,
		}
	}
	return nil
}
799068
func (s *AutomationExecution) SetTarget(v string) *AutomationExecution {
	s.Target = &v
	return s
}
1333431
func (s *Subscription) SetTarget(v string) *Subscription {
	s.Target = &v
	return s
}
855359
func (s *ResourceChangeDetail) SetTarget(v *ResourceTargetDefinition) *ResourceChangeDetail {
	s.Target = v
	return s
}
854554
func (s *ListSigningPlatformsInput) SetTarget(v string) *ListSigningPlatformsInput {
	s.Target = &v
	return s
}
256759
func (s *DeleteChapCredentialsInput) SetTargetARN(v string) *DeleteChapCredentialsInput {
	s.TargetARN = &v
	return s
}
1178727
func (g *Cloud) RemoveInstancesFromTargetPool(name, region string, instanceRefs []*compute.InstanceReference) error {
	ctx, cancel := cloud.ContextWithCallTimeout()
	defer cancel()

	req := &compute.TargetPoolsRemoveInstanceRequest{
		Instances: instanceRefs,
	}
	mc := newTargetPoolMetricContext("remove_instances", region)
	return mc.Observe(g.c.TargetPools().RemoveInstance(ctx, meta.RegionalKey(name, region), req))
}
571897
func (s *ListAttachedPoliciesInput) SetTarget(v string) *ListAttachedPoliciesInput {
	s.Target = &v
	return s
}
1263097
func (s *PresetWatermark) SetTarget(v string) *PresetWatermark {
	s.Target = &v
	return s
}
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
}
267078
func (actor Actor) ClearTarget() {
	actor.Config.SetTargetInformation("", "", "", "", "", "", false)
	actor.Config.SetTokenInformation("", "", "")
}
1315754
func (s *UpdateRouteOutput) SetTarget(v string) *UpdateRouteOutput {
	s.Target = &v
	return s
}
321481
func (g *Cloud) DeleteTargetHTTPProxy(name string) error {
	ctx, cancel := cloud.ContextWithCallTimeout()
	defer cancel()

	mc := newTargetProxyMetricContext("delete")
	return mc.Observe(g.c.TargetHttpProxies().Delete(ctx, meta.GlobalKey(name)))
}
456238
func (s *S3CopyObjectOperation) SetTargetResource(v string) *S3CopyObjectOperation {
	s.TargetResource = &v
	return s
}
194094
func (s *ScraperTargetStoreService) UpdateTarget(ctx context.Context, upd *influxdb.ScraperTarget, userID influxdb.ID) (*influxdb.ScraperTarget, error) {
	st, err := s.s.GetTargetByID(ctx, upd.ID)
	if err != nil {
		return nil, err
	}

	if err := authorizeWriteScraper(ctx, st.OrgID, upd.ID); err != nil {
		return nil, err
	}

	return s.s.UpdateTarget(ctx, upd, userID)
}
505498
func (s *OTAUpdateInfo) SetTargetSelection(v string) *OTAUpdateInfo {
	s.TargetSelection = &v
	return s
}
43549
func (c *Client) AddTarget(ctx context.Context, target *influxdb.ScraperTarget, userID influxdb.ID) (err error) {
	if !target.OrgID.Valid() {
		return &influxdb.Error{
			Code: influxdb.EInvalid,
			Msg:  "provided organization ID has invalid format",
			Op:   OpPrefix + influxdb.OpAddTarget,
		}
	}
	if !target.BucketID.Valid() {
		return &influxdb.Error{
			Code: influxdb.EInvalid,
			Msg:  "provided bucket ID has invalid format",
			Op:   OpPrefix + influxdb.OpAddTarget,
		}
	}
	err = c.db.Update(func(tx *bolt.Tx) error {
		target.ID = c.IDGenerator.ID()
		if err := c.putTarget(ctx, tx, target); err != nil {
			return err
		}
		urm := &influxdb.UserResourceMapping{
			ResourceID:   target.ID,
			UserID:       userID,
			UserType:     influxdb.Owner,
			ResourceType: influxdb.ScraperResourceType,
		}
		return c.createUserResourceMapping(ctx, tx, urm)
	})
	if err != nil {
		return &influxdb.Error{
			Err: err,
			Op:  OpPrefix + influxdb.OpAddTarget,
		}
	}
	return nil
}