func()

in controller/ad/ad.go [132:165]


func (c controller) DeleteDetector(ctx context.Context, id string, interactive bool, force bool) error {
	if len(id) < 1 {
		return fmt.Errorf("detector Id cannot be empty")
	}
	proceed := true
	if interactive {
		proceed = c.askForConfirmation(
			mapper.StringToStringPtr(
				fmt.Sprintf(
					"opensearch-cli will delete detector: %s . Do you want to proceed? Y/N ",
					id,
				),
			),
		)
	}
	if !proceed {
		return nil
	}
	if force {
		res, err := c.gateway.StopDetector(ctx, id)
		if err != nil {
			return err
		}
		if interactive {
			fmt.Println(*res)
		}

	}
	err := c.gateway.DeleteDetector(ctx, id)
	if err != nil {
		return err
	}
	return nil
}